From 36d22d82aa202bb199967e9512281e9a53db42c9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 21:33:14 +0200 Subject: Adding upstream version 115.7.0esr. Signed-off-by: Daniel Baumann --- .../accessor-name-inst-computed-yield-expr.js | 45 ++++ .../statements/class/accessor-name-inst/browser.js | 0 .../accessor-name-inst/computed-err-evaluation.js | 41 +++ .../accessor-name-inst/computed-err-to-prop-key.js | 57 +++++ .../computed-err-unresolvable.js | 39 +++ .../class/accessor-name-inst/computed.js | 42 +++ .../accessor-name-inst/literal-numeric-binary.js | 40 +++ .../accessor-name-inst/literal-numeric-exponent.js | 40 +++ .../accessor-name-inst/literal-numeric-hex.js | 40 +++ .../literal-numeric-leading-decimal.js | 40 +++ .../literal-numeric-non-canonical.js | 40 +++ .../accessor-name-inst/literal-numeric-octal.js | 40 +++ .../accessor-name-inst/literal-numeric-zero.js | 40 +++ .../literal-string-char-escape.js | 40 +++ .../literal-string-default-escaped-ext.js | 40 +++ .../literal-string-default-escaped.js | 40 +++ .../accessor-name-inst/literal-string-default.js | 40 +++ .../literal-string-double-quote.js | 40 +++ .../accessor-name-inst/literal-string-empty.js | 40 +++ .../literal-string-hex-escape.js | 40 +++ .../literal-string-line-continuation.js | 42 +++ .../literal-string-single-quote.js | 40 +++ .../literal-string-unicode-escape.js | 40 +++ .../statements/class/accessor-name-inst/shell.js | 0 .../accessor-name-static-computed-yield-expr.js | 47 ++++ .../class/accessor-name-static/browser.js | 0 .../computed-err-evaluation.js | 43 ++++ .../computed-err-to-prop-key.js | 59 +++++ .../computed-err-unresolvable.js | 41 +++ .../class/accessor-name-static/computed.js | 44 ++++ .../accessor-name-static/literal-numeric-binary.js | 42 +++ .../literal-numeric-exponent.js | 42 +++ .../accessor-name-static/literal-numeric-hex.js | 42 +++ .../literal-numeric-leading-decimal.js | 42 +++ .../literal-numeric-non-canonical.js | 42 +++ .../accessor-name-static/literal-numeric-octal.js | 42 +++ .../accessor-name-static/literal-numeric-zero.js | 42 +++ .../literal-string-char-escape.js | 42 +++ .../literal-string-default-escaped-ext.js | 42 +++ .../literal-string-default-escaped.js | 42 +++ .../accessor-name-static/literal-string-default.js | 42 +++ .../literal-string-double-quote.js | 42 +++ .../accessor-name-static/literal-string-empty.js | 42 +++ .../literal-string-hex-escape.js | 42 +++ .../literal-string-line-continuation.js | 44 ++++ .../literal-string-single-quote.js | 42 +++ .../literal-string-unicode-escape.js | 42 +++ .../statements/class/accessor-name-static/shell.js | 0 .../language/statements/class/arguments/access.js | 56 ++++ .../language/statements/class/arguments/browser.js | 0 .../class/arguments/default-constructor.js | 32 +++ .../language/statements/class/arguments/shell.js | 0 .../class/async-gen-meth-escaped-async.js | 27 ++ .../array-destructuring-param-strict-body.js | 138 ++++++++++ .../await-as-binding-identifier-escaped.js | 37 +++ .../await-as-binding-identifier.js | 37 +++ .../await-as-identifier-reference-escaped.js | 37 +++ .../await-as-identifier-reference.js | 37 +++ .../await-as-label-identifier-escaped.js | 37 +++ .../await-as-label-identifier.js | 37 +++ .../class/async-gen-method-static/browser.js | 0 .../async-gen-method-static/dflt-params-abrupt.js | 69 +++++ .../dflt-params-arg-val-not-undefined.js | 92 +++++++ .../dflt-params-arg-val-undefined.js | 75 ++++++ .../dflt-params-duplicates.js | 67 +++++ .../dflt-params-ref-later.js | 70 +++++ .../dflt-params-ref-prior.js | 72 ++++++ .../dflt-params-ref-self.js | 70 +++++ .../async-gen-method-static/dflt-params-rest.js | 71 ++++++ .../dflt-params-trailing-comma.js | 67 +++++ .../forbidden-ext/b1/browser.js | 0 ...c-forbidden-ext-direct-access-prop-arguments.js | 39 +++ ...atic-forbidden-ext-direct-access-prop-caller.js | 39 +++ .../forbidden-ext/b1/shell.js | 0 .../forbidden-ext/b2/browser.js | 0 ...dden-ext-indirect-access-own-prop-caller-get.js | 65 +++++ ...en-ext-indirect-access-own-prop-caller-value.js | 65 +++++ ...ic-forbidden-ext-indirect-access-prop-caller.js | 65 +++++ .../forbidden-ext/b2/shell.js | 0 .../forbidden-ext/browser.js | 0 .../async-gen-method-static/forbidden-ext/shell.js | 0 .../object-destructuring-param-strict-body.js | 138 ++++++++++ .../params-trailing-comma-multiple.js | 67 +++++ .../params-trailing-comma-single.js | 66 +++++ .../rest-param-strict-body.js | 138 ++++++++++ .../rest-params-trailing-comma-early-error.js | 64 +++++ .../class/async-gen-method-static/shell.js | 0 .../yield-as-binding-identifier-escaped.js | 37 +++ .../yield-as-binding-identifier.js | 37 +++ .../yield-as-identifier-reference-escaped.js | 37 +++ .../yield-as-identifier-reference.js | 37 +++ .../yield-as-label-identifier-escaped.js | 37 +++ .../yield-as-label-identifier.js | 37 +++ .../yield-identifier-spread-strict-strict.js | 55 ++++ .../yield-identifier-strict-strict.js | 46 ++++ .../yield-promise-reject-next-catch.js | 51 ++++ ...mise-reject-next-for-await-of-async-iterator.js | 57 +++++ ...omise-reject-next-for-await-of-sync-iterator.js | 56 ++++ ...romise-reject-next-yield-star-async-iterator.js | 55 ++++ ...promise-reject-next-yield-star-sync-iterator.js | 54 ++++ .../yield-promise-reject-next.js | 51 ++++ .../yield-spread-arr-multiple.js | 57 +++++ .../yield-spread-arr-single.js | 56 ++++ .../async-gen-method-static/yield-spread-obj.js | 59 +++++ .../yield-star-async-next.js | 226 +++++++++++++++++ .../yield-star-async-return.js | 242 ++++++++++++++++++ .../yield-star-async-throw.js | 250 ++++++++++++++++++ .../yield-star-expr-abrupt.js | 61 +++++ .../yield-star-getiter-async-get-abrupt.js | 81 ++++++ ...tar-getiter-async-not-callable-boolean-throw.js | 80 ++++++ ...star-getiter-async-not-callable-number-throw.js | 80 ++++++ ...star-getiter-async-not-callable-object-throw.js | 80 ++++++ ...star-getiter-async-not-callable-string-throw.js | 80 ++++++ ...star-getiter-async-not-callable-symbol-throw.js | 80 ++++++ ...ield-star-getiter-async-null-sync-get-abrupt.js | 86 +++++++ .../yield-star-getiter-async-returns-abrupt.js | 77 ++++++ ...eld-star-getiter-async-returns-boolean-throw.js | 77 ++++++ .../yield-star-getiter-async-returns-null-throw.js | 77 ++++++ ...ield-star-getiter-async-returns-number-throw.js | 77 ++++++ ...ield-star-getiter-async-returns-string-throw.js | 77 ++++++ ...ield-star-getiter-async-returns-symbol-throw.js | 77 ++++++ ...d-star-getiter-async-returns-undefined-throw.js | 77 ++++++ ...star-getiter-async-undefined-sync-get-abrupt.js | 86 +++++++ .../yield-star-getiter-sync-get-abrupt.js | 80 ++++++ ...star-getiter-sync-not-callable-boolean-throw.js | 79 ++++++ ...-star-getiter-sync-not-callable-number-throw.js | 79 ++++++ ...-star-getiter-sync-not-callable-object-throw.js | 79 ++++++ ...-star-getiter-sync-not-callable-string-throw.js | 79 ++++++ ...-star-getiter-sync-not-callable-symbol-throw.js | 79 ++++++ .../yield-star-getiter-sync-returns-abrupt.js | 74 ++++++ ...ield-star-getiter-sync-returns-boolean-throw.js | 79 ++++++ .../yield-star-getiter-sync-returns-null-throw.js | 79 ++++++ ...yield-star-getiter-sync-returns-number-throw.js | 79 ++++++ ...yield-star-getiter-sync-returns-string-throw.js | 79 ++++++ ...yield-star-getiter-sync-returns-symbol-throw.js | 79 ++++++ ...ld-star-getiter-sync-returns-undefined-throw.js | 79 ++++++ .../yield-star-next-call-done-get-abrupt.js | 80 ++++++ .../yield-star-next-call-returns-abrupt.js | 72 ++++++ .../yield-star-next-call-value-get-abrupt.js | 82 ++++++ .../yield-star-next-get-abrupt.js | 72 ++++++ .../yield-star-next-non-object-ignores-then.js | 92 +++++++ .../yield-star-next-not-callable-boolean-throw.js | 69 +++++ .../yield-star-next-not-callable-null-throw.js | 69 +++++ .../yield-star-next-not-callable-number-throw.js | 69 +++++ .../yield-star-next-not-callable-object-throw.js | 69 +++++ .../yield-star-next-not-callable-string-throw.js | 69 +++++ .../yield-star-next-not-callable-symbol-throw.js | 69 +++++ ...yield-star-next-not-callable-undefined-throw.js | 69 +++++ .../yield-star-next-then-get-abrupt.js | 96 +++++++ ...ext-then-non-callable-boolean-fulfillpromise.js | 90 +++++++ ...r-next-then-non-callable-null-fulfillpromise.js | 90 +++++++ ...next-then-non-callable-number-fulfillpromise.js | 90 +++++++ ...next-then-non-callable-object-fulfillpromise.js | 90 +++++++ ...next-then-non-callable-string-fulfillpromise.js | 90 +++++++ ...next-then-non-callable-symbol-fulfillpromise.js | 90 +++++++ ...t-then-non-callable-undefined-fulfillpromise.js | 90 +++++++ .../yield-star-next-then-returns-abrupt.js | 96 +++++++ .../yield-star-sync-next.js | 229 +++++++++++++++++ .../yield-star-sync-return.js | 204 +++++++++++++++ .../yield-star-sync-throw.js | 210 +++++++++++++++ .../array-destructuring-param-strict-body.js | 137 ++++++++++ .../await-as-binding-identifier-escaped.js | 37 +++ .../await-as-binding-identifier.js | 37 +++ .../await-as-identifier-reference-escaped.js | 37 +++ .../await-as-identifier-reference.js | 37 +++ .../await-as-label-identifier-escaped.js | 37 +++ .../async-gen-method/await-as-label-identifier.js | 37 +++ .../statements/class/async-gen-method/browser.js | 0 .../class/async-gen-method/dflt-params-abrupt.js | 67 +++++ .../dflt-params-arg-val-not-undefined.js | 91 +++++++ .../dflt-params-arg-val-undefined.js | 74 ++++++ .../async-gen-method/dflt-params-duplicates.js | 66 +++++ .../async-gen-method/dflt-params-ref-later.js | 68 +++++ .../async-gen-method/dflt-params-ref-prior.js | 71 ++++++ .../class/async-gen-method/dflt-params-ref-self.js | 68 +++++ .../class/async-gen-method/dflt-params-rest.js | 70 +++++ .../async-gen-method/dflt-params-trailing-comma.js | 66 +++++ .../async-gen-method/forbidden-ext/b1/browser.js | 0 ...h-forbidden-ext-direct-access-prop-arguments.js | 38 +++ ...meth-forbidden-ext-direct-access-prop-caller.js | 38 +++ .../async-gen-method/forbidden-ext/b1/shell.js | 0 .../async-gen-method/forbidden-ext/b2/browser.js | 0 ...dden-ext-indirect-access-own-prop-caller-get.js | 64 +++++ ...en-ext-indirect-access-own-prop-caller-value.js | 64 +++++ ...th-forbidden-ext-indirect-access-prop-caller.js | 64 +++++ .../async-gen-method/forbidden-ext/b2/shell.js | 0 .../async-gen-method/forbidden-ext/browser.js | 0 .../class/async-gen-method/forbidden-ext/shell.js | 0 .../object-destructuring-param-strict-body.js | 137 ++++++++++ .../params-trailing-comma-multiple.js | 66 +++++ .../params-trailing-comma-single.js | 65 +++++ .../async-gen-method/rest-param-strict-body.js | 137 ++++++++++ .../rest-params-trailing-comma-early-error.js | 63 +++++ .../statements/class/async-gen-method/shell.js | 0 .../yield-as-binding-identifier-escaped.js | 37 +++ .../yield-as-binding-identifier.js | 37 +++ .../yield-as-identifier-reference-escaped.js | 37 +++ .../yield-as-identifier-reference.js | 37 +++ .../yield-as-label-identifier-escaped.js | 37 +++ .../async-gen-method/yield-as-label-identifier.js | 37 +++ .../yield-identifier-spread-strict-strict.js | 55 ++++ .../yield-identifier-strict-strict.js | 46 ++++ .../yield-promise-reject-next-catch.js | 51 ++++ ...mise-reject-next-for-await-of-async-iterator.js | 57 +++++ ...omise-reject-next-for-await-of-sync-iterator.js | 56 ++++ ...romise-reject-next-yield-star-async-iterator.js | 55 ++++ ...promise-reject-next-yield-star-sync-iterator.js | 54 ++++ .../async-gen-method/yield-promise-reject-next.js | 51 ++++ .../async-gen-method/yield-spread-arr-multiple.js | 57 +++++ .../async-gen-method/yield-spread-arr-single.js | 56 ++++ .../class/async-gen-method/yield-spread-obj.js | 59 +++++ .../async-gen-method/yield-star-async-next.js | 226 +++++++++++++++++ .../async-gen-method/yield-star-async-return.js | 242 ++++++++++++++++++ .../async-gen-method/yield-star-async-throw.js | 250 ++++++++++++++++++ .../async-gen-method/yield-star-expr-abrupt.js | 61 +++++ .../yield-star-getiter-async-get-abrupt.js | 81 ++++++ ...tar-getiter-async-not-callable-boolean-throw.js | 80 ++++++ ...star-getiter-async-not-callable-number-throw.js | 80 ++++++ ...star-getiter-async-not-callable-object-throw.js | 80 ++++++ ...star-getiter-async-not-callable-string-throw.js | 80 ++++++ ...star-getiter-async-not-callable-symbol-throw.js | 80 ++++++ ...ield-star-getiter-async-null-sync-get-abrupt.js | 86 +++++++ .../yield-star-getiter-async-returns-abrupt.js | 77 ++++++ ...eld-star-getiter-async-returns-boolean-throw.js | 77 ++++++ .../yield-star-getiter-async-returns-null-throw.js | 77 ++++++ ...ield-star-getiter-async-returns-number-throw.js | 77 ++++++ ...ield-star-getiter-async-returns-string-throw.js | 77 ++++++ ...ield-star-getiter-async-returns-symbol-throw.js | 77 ++++++ ...d-star-getiter-async-returns-undefined-throw.js | 77 ++++++ ...star-getiter-async-undefined-sync-get-abrupt.js | 86 +++++++ .../yield-star-getiter-sync-get-abrupt.js | 80 ++++++ ...star-getiter-sync-not-callable-boolean-throw.js | 79 ++++++ ...-star-getiter-sync-not-callable-number-throw.js | 79 ++++++ ...-star-getiter-sync-not-callable-object-throw.js | 79 ++++++ ...-star-getiter-sync-not-callable-string-throw.js | 79 ++++++ ...-star-getiter-sync-not-callable-symbol-throw.js | 79 ++++++ .../yield-star-getiter-sync-returns-abrupt.js | 74 ++++++ ...ield-star-getiter-sync-returns-boolean-throw.js | 79 ++++++ .../yield-star-getiter-sync-returns-null-throw.js | 79 ++++++ ...yield-star-getiter-sync-returns-number-throw.js | 79 ++++++ ...yield-star-getiter-sync-returns-string-throw.js | 79 ++++++ ...yield-star-getiter-sync-returns-symbol-throw.js | 79 ++++++ ...ld-star-getiter-sync-returns-undefined-throw.js | 79 ++++++ .../yield-star-next-call-done-get-abrupt.js | 80 ++++++ .../yield-star-next-call-returns-abrupt.js | 72 ++++++ .../yield-star-next-call-value-get-abrupt.js | 82 ++++++ .../async-gen-method/yield-star-next-get-abrupt.js | 72 ++++++ .../yield-star-next-non-object-ignores-then.js | 92 +++++++ .../yield-star-next-not-callable-boolean-throw.js | 69 +++++ .../yield-star-next-not-callable-null-throw.js | 69 +++++ .../yield-star-next-not-callable-number-throw.js | 69 +++++ .../yield-star-next-not-callable-object-throw.js | 69 +++++ .../yield-star-next-not-callable-string-throw.js | 69 +++++ .../yield-star-next-not-callable-symbol-throw.js | 69 +++++ ...yield-star-next-not-callable-undefined-throw.js | 69 +++++ .../yield-star-next-then-get-abrupt.js | 96 +++++++ ...ext-then-non-callable-boolean-fulfillpromise.js | 90 +++++++ ...r-next-then-non-callable-null-fulfillpromise.js | 90 +++++++ ...next-then-non-callable-number-fulfillpromise.js | 90 +++++++ ...next-then-non-callable-object-fulfillpromise.js | 90 +++++++ ...next-then-non-callable-string-fulfillpromise.js | 90 +++++++ ...next-then-non-callable-symbol-fulfillpromise.js | 90 +++++++ ...t-then-non-callable-undefined-fulfillpromise.js | 90 +++++++ .../yield-star-next-then-returns-abrupt.js | 96 +++++++ .../class/async-gen-method/yield-star-sync-next.js | 229 +++++++++++++++++ .../async-gen-method/yield-star-sync-return.js | 204 +++++++++++++++ .../async-gen-method/yield-star-sync-throw.js | 210 +++++++++++++++ .../statements/class/async-meth-escaped-async.js | 27 ++ .../array-destructuring-param-strict-body.js | 135 ++++++++++ .../await-as-binding-identifier-escaped.js | 40 +++ .../await-as-binding-identifier.js | 40 +++ .../await-as-identifier-reference-escaped.js | 40 +++ .../await-as-identifier-reference.js | 40 +++ .../await-as-label-identifier-escaped.js | 40 +++ .../await-as-label-identifier.js | 40 +++ .../class/async-method-static/browser.js | 0 .../async-method-static/dflt-params-abrupt.js | 69 +++++ .../dflt-params-arg-val-not-undefined.js | 90 +++++++ .../dflt-params-arg-val-undefined.js | 73 ++++++ .../async-method-static/dflt-params-duplicates.js | 64 +++++ .../async-method-static/dflt-params-ref-later.js | 70 +++++ .../async-method-static/dflt-params-ref-prior.js | 70 +++++ .../async-method-static/dflt-params-ref-self.js | 70 +++++ .../class/async-method-static/dflt-params-rest.js | 68 +++++ .../dflt-params-trailing-comma.js | 65 +++++ .../forbidden-ext/b1/browser.js | 0 ...c-forbidden-ext-direct-access-prop-arguments.js | 39 +++ ...atic-forbidden-ext-direct-access-prop-caller.js | 39 +++ .../async-method-static/forbidden-ext/b1/shell.js | 0 .../forbidden-ext/b2/browser.js | 0 ...dden-ext-indirect-access-own-prop-caller-get.js | 65 +++++ ...en-ext-indirect-access-own-prop-caller-value.js | 65 +++++ ...ic-forbidden-ext-indirect-access-prop-caller.js | 65 +++++ .../async-method-static/forbidden-ext/b2/shell.js | 0 .../async-method-static/forbidden-ext/browser.js | 0 .../async-method-static/forbidden-ext/shell.js | 0 .../object-destructuring-param-strict-body.js | 135 ++++++++++ .../params-trailing-comma-multiple.js | 65 +++++ .../params-trailing-comma-single.js | 64 +++++ .../async-method-static/rest-param-strict-body.js | 135 ++++++++++ .../rest-params-trailing-comma-early-error.js | 60 +++++ ...arrow-returns-arguments-from-parent-function.js | 41 +++ .../returns-async-arrow-returns-newtarget.js | 40 +++ .../async-method-static/returns-async-arrow.js | 40 +++ ...function-returns-arguments-from-own-function.js | 41 +++ .../returns-async-function-returns-newtarget.js | 40 +++ .../async-method-static/returns-async-function.js | 40 +++ .../statements/class/async-method-static/shell.js | 0 .../array-destructuring-param-strict-body.js | 136 ++++++++++ .../await-as-binding-identifier-escaped.js | 39 +++ .../async-method/await-as-binding-identifier.js | 39 +++ .../await-as-identifier-reference-escaped.js | 39 +++ .../async-method/await-as-identifier-reference.js | 39 +++ .../await-as-label-identifier-escaped.js | 39 +++ .../async-method/await-as-label-identifier.js | 39 +++ .../statements/class/async-method/browser.js | 0 .../class/async-method/dflt-params-abrupt.js | 69 +++++ .../dflt-params-arg-val-not-undefined.js | 90 +++++++ .../async-method/dflt-params-arg-val-undefined.js | 73 ++++++ .../class/async-method/dflt-params-duplicates.js | 65 +++++ .../class/async-method/dflt-params-ref-later.js | 70 +++++ .../class/async-method/dflt-params-ref-prior.js | 70 +++++ .../class/async-method/dflt-params-ref-self.js | 70 +++++ .../class/async-method/dflt-params-rest.js | 69 +++++ .../async-method/dflt-params-trailing-comma.js | 65 +++++ .../class/async-method/forbidden-ext/b1/browser.js | 0 ...h-forbidden-ext-direct-access-prop-arguments.js | 39 +++ ...meth-forbidden-ext-direct-access-prop-caller.js | 39 +++ .../class/async-method/forbidden-ext/b1/shell.js | 0 .../class/async-method/forbidden-ext/b2/browser.js | 0 ...dden-ext-indirect-access-own-prop-caller-get.js | 65 +++++ ...en-ext-indirect-access-own-prop-caller-value.js | 65 +++++ ...th-forbidden-ext-indirect-access-prop-caller.js | 65 +++++ .../class/async-method/forbidden-ext/b2/shell.js | 0 .../class/async-method/forbidden-ext/browser.js | 0 .../class/async-method/forbidden-ext/shell.js | 0 .../object-destructuring-param-strict-body.js | 136 ++++++++++ .../async-method/params-trailing-comma-multiple.js | 65 +++++ .../async-method/params-trailing-comma-single.js | 64 +++++ .../class/async-method/rest-param-strict-body.js | 136 ++++++++++ .../rest-params-trailing-comma-early-error.js | 61 +++++ ...arrow-returns-arguments-from-parent-function.js | 42 +++ .../returns-async-arrow-returns-newtarget.js | 41 +++ .../class/async-method/returns-async-arrow.js | 41 +++ ...function-returns-arguments-from-own-function.js | 42 +++ .../returns-async-function-returns-newtarget.js | 41 +++ .../class/async-method/returns-async-function.js | 41 +++ .../statements/class/async-method/shell.js | 0 .../test262/language/statements/class/browser.js | 0 .../class/class-name-ident-await-escaped-module.js | 24 ++ .../class/class-name-ident-await-escaped.js | 19 ++ .../class/class-name-ident-await-module.js | 23 ++ .../statements/class/class-name-ident-await.js | 18 ++ .../class/class-name-ident-let-escaped.js | 28 ++ .../statements/class/class-name-ident-let.js | 28 ++ .../class/class-name-ident-static-escaped.js | 28 ++ .../statements/class/class-name-ident-static.js | 28 ++ .../class/class-name-ident-yield-escaped.js | 28 ++ .../statements/class/class-name-ident-yield.js | 26 ++ .../class/classelementname-abrupt-completion.js | 44 ++++ ...d-property-name-from-additive-expression-add.js | 93 +++++++ ...perty-name-from-additive-expression-subtract.js | 93 +++++++ ...property-name-from-arrow-function-expression.js | 93 +++++++ ...y-name-from-assignment-expression-assignment.js | 96 +++++++ ...y-name-from-assignment-expression-bitwise-or.js | 96 +++++++ ...rty-name-from-assignment-expression-coalesce.js | 96 +++++++ ...-name-from-assignment-expression-logical-and.js | 96 +++++++ ...y-name-from-assignment-expression-logical-or.js | 96 +++++++ ...ty-name-from-async-arrow-function-expression.js | 93 +++++++ ...computed-property-name-from-await-expression.js | 98 +++++++ ...roperty-name-from-condition-expression-false.js | 93 +++++++ ...property-name-from-condition-expression-true.js | 93 +++++++ ...perty-name-from-decimal-e-notational-literal.js | 93 +++++++ ...-computed-property-name-from-decimal-literal.js | 93 +++++++ ...-property-name-from-exponetiation-expression.js | 93 +++++++ ...puted-property-name-from-expression-coalesce.js | 96 +++++++ ...ed-property-name-from-expression-logical-and.js | 96 +++++++ ...ted-property-name-from-expression-logical-or.js | 96 +++++++ ...uted-property-name-from-function-declaration.js | 94 +++++++ ...puted-property-name-from-function-expression.js | 93 +++++++ ...rty-name-from-generator-function-declaration.js | 94 +++++++ ...ssors-computed-property-name-from-identifier.js | 95 +++++++ ...perty-name-from-integer-e-notational-literal.js | 93 +++++++ ...mputed-property-name-from-integer-separators.js | 93 +++++++ ...l-accessors-computed-property-name-from-math.js | 93 +++++++ ...erty-name-from-multiplicative-expression-div.js | 93 +++++++ ...rty-name-from-multiplicative-expression-mult.js | 93 +++++++ ...l-accessors-computed-property-name-from-null.js | 93 +++++++ ...-computed-property-name-from-numeric-literal.js | 93 +++++++ ...s-computed-property-name-from-string-literal.js | 93 +++++++ ...computed-property-name-from-yield-expression.js | 98 +++++++ ...d-property-name-from-additive-expression-add.js | 66 +++++ ...perty-name-from-additive-expression-subtract.js | 66 +++++ ...property-name-from-arrow-function-expression.js | 66 +++++ ...y-name-from-assignment-expression-assignment.js | 69 +++++ ...y-name-from-assignment-expression-bitwise-or.js | 69 +++++ ...rty-name-from-assignment-expression-coalesce.js | 69 +++++ ...-name-from-assignment-expression-logical-and.js | 69 +++++ ...y-name-from-assignment-expression-logical-or.js | 69 +++++ ...ty-name-from-async-arrow-function-expression.js | 66 +++++ ...computed-property-name-from-await-expression.js | 71 ++++++ ...roperty-name-from-condition-expression-false.js | 66 +++++ ...property-name-from-condition-expression-true.js | 66 +++++ ...perty-name-from-decimal-e-notational-literal.js | 66 +++++ ...-computed-property-name-from-decimal-literal.js | 66 +++++ ...-property-name-from-exponetiation-expression.js | 66 +++++ ...puted-property-name-from-expression-coalesce.js | 69 +++++ ...ed-property-name-from-expression-logical-and.js | 69 +++++ ...ted-property-name-from-expression-logical-or.js | 69 +++++ ...uted-property-name-from-function-declaration.js | 67 +++++ ...puted-property-name-from-function-expression.js | 66 +++++ ...rty-name-from-generator-function-declaration.js | 67 +++++ ...-decl-computed-property-name-from-identifier.js | 68 +++++ ...perty-name-from-integer-e-notational-literal.js | 66 +++++ ...mputed-property-name-from-integer-separators.js | 66 +++++ ...-class-decl-computed-property-name-from-math.js | 66 +++++ ...erty-name-from-multiplicative-expression-div.js | 66 +++++ ...rty-name-from-multiplicative-expression-mult.js | 66 +++++ ...-class-decl-computed-property-name-from-null.js | 66 +++++ ...-computed-property-name-from-numeric-literal.js | 66 +++++ ...l-computed-property-name-from-string-literal.js | 66 +++++ ...computed-property-name-from-yield-expression.js | 71 ++++++ ...d-property-name-from-additive-expression-add.js | 63 +++++ ...perty-name-from-additive-expression-subtract.js | 63 +++++ ...property-name-from-arrow-function-expression.js | 63 +++++ ...y-name-from-assignment-expression-assignment.js | 66 +++++ ...y-name-from-assignment-expression-bitwise-or.js | 66 +++++ ...rty-name-from-assignment-expression-coalesce.js | 66 +++++ ...-name-from-assignment-expression-logical-and.js | 66 +++++ ...y-name-from-assignment-expression-logical-or.js | 66 +++++ ...ty-name-from-async-arrow-function-expression.js | 63 +++++ ...computed-property-name-from-await-expression.js | 68 +++++ ...roperty-name-from-condition-expression-false.js | 63 +++++ ...property-name-from-condition-expression-true.js | 63 +++++ ...perty-name-from-decimal-e-notational-literal.js | 63 +++++ ...-computed-property-name-from-decimal-literal.js | 63 +++++ ...-property-name-from-exponetiation-expression.js | 63 +++++ ...puted-property-name-from-expression-coalesce.js | 66 +++++ ...ed-property-name-from-expression-logical-and.js | 66 +++++ ...ted-property-name-from-expression-logical-or.js | 66 +++++ ...uted-property-name-from-function-declaration.js | 64 +++++ ...puted-property-name-from-function-expression.js | 63 +++++ ...rty-name-from-generator-function-declaration.js | 64 +++++ ...ields-computed-property-name-from-identifier.js | 65 +++++ ...perty-name-from-integer-e-notational-literal.js | 63 +++++ ...mputed-property-name-from-integer-separators.js | 63 +++++ ...decl-fields-computed-property-name-from-math.js | 63 +++++ ...erty-name-from-multiplicative-expression-div.js | 63 +++++ ...rty-name-from-multiplicative-expression-mult.js | 63 +++++ ...decl-fields-computed-property-name-from-null.js | 63 +++++ ...-computed-property-name-from-numeric-literal.js | 63 +++++ ...s-computed-property-name-from-string-literal.js | 63 +++++ ...computed-property-name-from-yield-expression.js | 68 +++++ ...d-property-name-from-additive-expression-add.js | 67 +++++ ...perty-name-from-additive-expression-subtract.js | 67 +++++ ...property-name-from-arrow-function-expression.js | 67 +++++ ...y-name-from-assignment-expression-assignment.js | 70 +++++ ...y-name-from-assignment-expression-bitwise-or.js | 70 +++++ ...rty-name-from-assignment-expression-coalesce.js | 70 +++++ ...-name-from-assignment-expression-logical-and.js | 70 +++++ ...y-name-from-assignment-expression-logical-or.js | 70 +++++ ...ty-name-from-async-arrow-function-expression.js | 67 +++++ ...computed-property-name-from-await-expression.js | 72 ++++++ ...roperty-name-from-condition-expression-false.js | 67 +++++ ...property-name-from-condition-expression-true.js | 67 +++++ ...perty-name-from-decimal-e-notational-literal.js | 67 +++++ ...-computed-property-name-from-decimal-literal.js | 67 +++++ ...-property-name-from-exponetiation-expression.js | 67 +++++ ...puted-property-name-from-expression-coalesce.js | 70 +++++ ...ed-property-name-from-expression-logical-and.js | 70 +++++ ...ted-property-name-from-expression-logical-or.js | 70 +++++ ...uted-property-name-from-function-declaration.js | 68 +++++ ...puted-property-name-from-function-expression.js | 67 +++++ ...rty-name-from-generator-function-declaration.js | 68 +++++ ...thods-computed-property-name-from-identifier.js | 69 +++++ ...perty-name-from-integer-e-notational-literal.js | 67 +++++ ...mputed-property-name-from-integer-separators.js | 67 +++++ ...lds-methods-computed-property-name-from-math.js | 67 +++++ ...erty-name-from-multiplicative-expression-div.js | 67 +++++ ...rty-name-from-multiplicative-expression-mult.js | 67 +++++ ...lds-methods-computed-property-name-from-null.js | 67 +++++ ...-computed-property-name-from-numeric-literal.js | 67 +++++ ...s-computed-property-name-from-string-literal.js | 67 +++++ ...computed-property-name-from-yield-expression.js | 72 ++++++ .../test262/language/statements/class/cptn-decl.js | 16 ++ .../language/statements/class/decorator/browser.js | 0 .../language/statements/class/decorator/shell.js | 0 .../statements/class/decorator/syntax/browser.js | 0 .../class/decorator/syntax/class-valid/browser.js | 0 .../decorator-member-expr-private-identifier.js | 57 +++++ .../class/decorator/syntax/class-valid/shell.js | 0 .../statements/class/decorator/syntax/shell.js | 0 .../class/decorator/syntax/valid/browser.js | 0 ...ent-decorator-call-expr-identifier-reference.js | 88 +++++++ ...-decorator-member-expr-decorator-member-expr.js | 84 ++++++ ...t-decorator-member-expr-identifier-reference.js | 77 ++++++ ...ator-parenthesized-expr-identifier-reference.js | 90 +++++++ ...corator-call-expr-identifier-reference-yield.js | 48 ++++ .../decorator-call-expr-identifier-reference.js | 61 +++++ .../decorator-member-expr-decorator-member-expr.js | 54 ++++ ...rator-member-expr-identifier-reference-yield.js | 37 +++ .../decorator-member-expr-identifier-reference.js | 50 ++++ ...arenthesized-expr-identifier-reference-yield.js | 55 ++++ ...ator-parenthesized-expr-identifier-reference.js | 63 +++++ .../class/decorator/syntax/valid/shell.js | 0 .../statements/class/definition/accessors.js | 54 ++++ .../language/statements/class/definition/basics.js | 45 ++++ .../statements/class/definition/browser.js | 0 .../definition/class-method-returns-promise.js | 17 ++ .../definition/constructable-but-no-prototype.js | 13 + .../class/definition/constructor-property.js | 19 ++ .../definition/constructor-strict-by-default.js | 17 ++ .../statements/class/definition/constructor.js | 37 +++ ...rors-class-async-method-duplicate-parameters.js | 30 +++ .../early-errors-class-method-NSPL-with-USD.js | 18 ++ ...-class-method-arguments-in-formal-parameters.js | 17 ++ ...errors-class-method-await-in-formals-default.js | 18 ++ .../early-errors-class-method-await-in-formals.js | 17 ++ ...errors-class-method-body-contains-super-call.js | 17 ++ ...rly-errors-class-method-duplicate-parameters.js | 29 +++ ...rrors-class-method-eval-in-formal-parameters.js | 17 ++ ...y-errors-class-method-formals-body-duplicate.js | 19 ++ ...ors-class-method-formals-contains-super-call.js | 17 ++ .../fn-length-static-precedence-order.js | 74 ++++++ .../definition/fn-length-static-precedence.js | 78 ++++++ .../class/definition/fn-name-accessor-get.js | 65 +++++ .../class/definition/fn-name-accessor-set.js | 66 +++++ .../class/definition/fn-name-gen-method.js | 60 +++++ .../statements/class/definition/fn-name-method.js | 59 +++++ .../definition/fn-name-static-precedence-order.js | 71 ++++++ .../class/definition/fn-name-static-precedence.js | 75 ++++++ .../definition/getters-non-configurable-err.js | 19 ++ .../class/definition/getters-prop-desc.js | 36 +++ .../class/definition/getters-restricted-ids.js | 28 ++ .../class/definition/implicit-constructor.js | 16 ++ .../statements/class/definition/invalid-extends.js | 23 ++ .../definition/methods-async-super-call-body.js | 27 ++ .../definition/methods-async-super-call-param.js | 26 ++ .../class/definition/methods-gen-no-yield.js | 22 ++ .../class/definition/methods-gen-return.js | 25 ++ .../methods-gen-yield-as-expression-with-rhs.js | 120 +++++++++ .../methods-gen-yield-as-expression-without-rhs.js | 130 ++++++++++ ...ld-as-function-expression-binding-identifier.js | 22 ++ ...yield-as-generator-method-binding-identifier.js | 31 +++ ...s-gen-yield-as-identifier-in-nested-function.js | 24 ++ .../methods-gen-yield-as-literal-property-name.js | 23 ++ .../methods-gen-yield-as-logical-or-expression.js | 21 ++ .../definition/methods-gen-yield-as-parameter.js | 20 ++ .../methods-gen-yield-as-property-name.js | 23 ++ .../definition/methods-gen-yield-as-statement.js | 49 ++++ .../methods-gen-yield-as-yield-operand.js | 33 +++ .../class/definition/methods-gen-yield-newline.js | 29 +++ .../methods-gen-yield-star-after-newline.js | 22 ++ .../methods-gen-yield-star-before-newline.js | 24 ++ .../definition/methods-gen-yield-weak-binding.js | 19 ++ .../definition/methods-named-eval-arguments.js | 28 ++ .../definition/methods-restricted-properties.js | 106 ++++++++ .../statements/class/definition/methods.js | 34 +++ .../class/definition/numeric-property-names.js | 65 +++++ .../class/definition/prototype-getter.js | 33 +++ .../class/definition/prototype-property.js | 14 + .../class/definition/prototype-setter.js | 18 ++ .../class/definition/prototype-wiring.js | 75 ++++++ .../definition/setters-non-configurable-err.js | 19 ++ .../class/definition/setters-prop-desc.js | 41 +++ .../class/definition/setters-restricted-ids.js | 33 +++ .../language/statements/class/definition/shell.js | 0 .../class/definition/side-effects-in-extends.js | 20 ++ .../definition/side-effects-in-property-define.js | 22 ++ .../class/definition/this-access-restriction-2.js | 90 +++++++ .../class/definition/this-access-restriction.js | 100 ++++++++ .../class/definition/this-check-ordering.js | 72 ++++++ .../dstr/async-gen-meth-ary-init-iter-close.js | 78 ++++++ ...n-meth-ary-init-iter-get-err-array-prototype.js | 73 ++++++ .../dstr/async-gen-meth-ary-init-iter-get-err.js | 67 +++++ .../dstr/async-gen-meth-ary-init-iter-no-close.js | 78 ++++++ .../class/dstr/async-gen-meth-ary-name-iter-val.js | 77 ++++++ .../async-gen-meth-ary-ptrn-elem-ary-elem-init.js | 69 +++++ .../async-gen-meth-ary-ptrn-elem-ary-elem-iter.js | 70 +++++ ...sync-gen-meth-ary-ptrn-elem-ary-elision-init.js | 76 ++++++ ...sync-gen-meth-ary-ptrn-elem-ary-elision-iter.js | 73 ++++++ .../async-gen-meth-ary-ptrn-elem-ary-empty-init.js | 72 ++++++ .../async-gen-meth-ary-ptrn-elem-ary-empty-iter.js | 69 +++++ .../async-gen-meth-ary-ptrn-elem-ary-rest-init.js | 73 ++++++ .../async-gen-meth-ary-ptrn-elem-ary-rest-iter.js | 76 ++++++ .../async-gen-meth-ary-ptrn-elem-ary-val-null.js | 74 ++++++ ...ync-gen-meth-ary-ptrn-elem-id-init-exhausted.js | 68 +++++ ...gen-meth-ary-ptrn-elem-id-init-fn-name-arrow.js | 69 +++++ ...gen-meth-ary-ptrn-elem-id-init-fn-name-class.js | 71 ++++++ ...gen-meth-ary-ptrn-elem-id-init-fn-name-cover.js | 70 +++++ ...nc-gen-meth-ary-ptrn-elem-id-init-fn-name-fn.js | 70 +++++ ...c-gen-meth-ary-ptrn-elem-id-init-fn-name-gen.js | 71 ++++++ .../async-gen-meth-ary-ptrn-elem-id-init-hole.js | 64 +++++ ...async-gen-meth-ary-ptrn-elem-id-init-skipped.js | 73 ++++++ .../async-gen-meth-ary-ptrn-elem-id-init-throws.js | 65 +++++ .../async-gen-meth-ary-ptrn-elem-id-init-undef.js | 67 +++++ ...-gen-meth-ary-ptrn-elem-id-init-unresolvable.js | 72 ++++++ ...sync-gen-meth-ary-ptrn-elem-id-iter-complete.js | 71 ++++++ .../async-gen-meth-ary-ptrn-elem-id-iter-done.js | 66 +++++ ...sync-gen-meth-ary-ptrn-elem-id-iter-step-err.js | 74 ++++++ ...th-ary-ptrn-elem-id-iter-val-array-prototype.js | 87 +++++++ ...async-gen-meth-ary-ptrn-elem-id-iter-val-err.js | 85 +++++++ .../async-gen-meth-ary-ptrn-elem-id-iter-val.js | 77 ++++++ .../async-gen-meth-ary-ptrn-elem-obj-id-init.js | 69 +++++ .../dstr/async-gen-meth-ary-ptrn-elem-obj-id.js | 69 +++++ ...sync-gen-meth-ary-ptrn-elem-obj-prop-id-init.js | 79 ++++++ .../async-gen-meth-ary-ptrn-elem-obj-prop-id.js | 79 ++++++ .../async-gen-meth-ary-ptrn-elem-obj-val-null.js | 74 ++++++ .../async-gen-meth-ary-ptrn-elem-obj-val-undef.js | 74 ++++++ .../async-gen-meth-ary-ptrn-elision-exhausted.js | 74 ++++++ .../async-gen-meth-ary-ptrn-elision-step-err.js | 81 ++++++ .../class/dstr/async-gen-meth-ary-ptrn-elision.js | 83 ++++++ .../class/dstr/async-gen-meth-ary-ptrn-empty.js | 66 +++++ .../dstr/async-gen-meth-ary-ptrn-rest-ary-elem.js | 90 +++++++ .../async-gen-meth-ary-ptrn-rest-ary-elision.js | 96 +++++++ .../dstr/async-gen-meth-ary-ptrn-rest-ary-empty.js | 79 ++++++ .../dstr/async-gen-meth-ary-ptrn-rest-ary-rest.js | 75 ++++++ .../dstr/async-gen-meth-ary-ptrn-rest-id-direct.js | 70 +++++ ...c-gen-meth-ary-ptrn-rest-id-elision-next-err.js | 67 +++++ .../async-gen-meth-ary-ptrn-rest-id-elision.js | 71 ++++++ .../async-gen-meth-ary-ptrn-rest-id-exhausted.js | 67 +++++ ...sync-gen-meth-ary-ptrn-rest-id-iter-step-err.js | 78 ++++++ ...async-gen-meth-ary-ptrn-rest-id-iter-val-err.js | 80 ++++++ .../class/dstr/async-gen-meth-ary-ptrn-rest-id.js | 68 +++++ .../dstr/async-gen-meth-ary-ptrn-rest-init-ary.js | 65 +++++ .../dstr/async-gen-meth-ary-ptrn-rest-init-id.js | 65 +++++ .../dstr/async-gen-meth-ary-ptrn-rest-init-obj.js | 65 +++++ .../async-gen-meth-ary-ptrn-rest-not-final-ary.js | 65 +++++ .../async-gen-meth-ary-ptrn-rest-not-final-id.js | 65 +++++ .../async-gen-meth-ary-ptrn-rest-not-final-obj.js | 65 +++++ .../dstr/async-gen-meth-ary-ptrn-rest-obj-id.js | 68 +++++ .../async-gen-meth-ary-ptrn-rest-obj-prop-id.js | 75 ++++++ .../async-gen-meth-dflt-ary-init-iter-close.js | 78 ++++++ ...h-dflt-ary-init-iter-get-err-array-prototype.js | 73 ++++++ .../async-gen-meth-dflt-ary-init-iter-get-err.js | 67 +++++ .../async-gen-meth-dflt-ary-init-iter-no-close.js | 78 ++++++ .../dstr/async-gen-meth-dflt-ary-name-iter-val.js | 77 ++++++ ...nc-gen-meth-dflt-ary-ptrn-elem-ary-elem-init.js | 69 +++++ ...nc-gen-meth-dflt-ary-ptrn-elem-ary-elem-iter.js | 70 +++++ ...gen-meth-dflt-ary-ptrn-elem-ary-elision-init.js | 76 ++++++ ...gen-meth-dflt-ary-ptrn-elem-ary-elision-iter.js | 73 ++++++ ...c-gen-meth-dflt-ary-ptrn-elem-ary-empty-init.js | 72 ++++++ ...c-gen-meth-dflt-ary-ptrn-elem-ary-empty-iter.js | 69 +++++ ...nc-gen-meth-dflt-ary-ptrn-elem-ary-rest-init.js | 73 ++++++ ...nc-gen-meth-dflt-ary-ptrn-elem-ary-rest-iter.js | 76 ++++++ ...ync-gen-meth-dflt-ary-ptrn-elem-ary-val-null.js | 74 ++++++ ...en-meth-dflt-ary-ptrn-elem-id-init-exhausted.js | 68 +++++ ...eth-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js | 69 +++++ ...eth-dflt-ary-ptrn-elem-id-init-fn-name-class.js | 71 ++++++ ...eth-dflt-ary-ptrn-elem-id-init-fn-name-cover.js | 70 +++++ ...n-meth-dflt-ary-ptrn-elem-id-init-fn-name-fn.js | 70 +++++ ...-meth-dflt-ary-ptrn-elem-id-init-fn-name-gen.js | 71 ++++++ ...ync-gen-meth-dflt-ary-ptrn-elem-id-init-hole.js | 64 +++++ ...-gen-meth-dflt-ary-ptrn-elem-id-init-skipped.js | 73 ++++++ ...c-gen-meth-dflt-ary-ptrn-elem-id-init-throws.js | 65 +++++ ...nc-gen-meth-dflt-ary-ptrn-elem-id-init-undef.js | 67 +++++ ...meth-dflt-ary-ptrn-elem-id-init-unresolvable.js | 72 ++++++ ...gen-meth-dflt-ary-ptrn-elem-id-iter-complete.js | 71 ++++++ ...ync-gen-meth-dflt-ary-ptrn-elem-id-iter-done.js | 66 +++++ ...gen-meth-dflt-ary-ptrn-elem-id-iter-step-err.js | 74 ++++++ ...lt-ary-ptrn-elem-id-iter-val-array-prototype.js | 87 +++++++ ...-gen-meth-dflt-ary-ptrn-elem-id-iter-val-err.js | 85 +++++++ ...sync-gen-meth-dflt-ary-ptrn-elem-id-iter-val.js | 77 ++++++ ...sync-gen-meth-dflt-ary-ptrn-elem-obj-id-init.js | 69 +++++ .../async-gen-meth-dflt-ary-ptrn-elem-obj-id.js | 69 +++++ ...gen-meth-dflt-ary-ptrn-elem-obj-prop-id-init.js | 79 ++++++ ...sync-gen-meth-dflt-ary-ptrn-elem-obj-prop-id.js | 79 ++++++ ...ync-gen-meth-dflt-ary-ptrn-elem-obj-val-null.js | 74 ++++++ ...nc-gen-meth-dflt-ary-ptrn-elem-obj-val-undef.js | 74 ++++++ ...ync-gen-meth-dflt-ary-ptrn-elision-exhausted.js | 74 ++++++ ...sync-gen-meth-dflt-ary-ptrn-elision-step-err.js | 81 ++++++ .../dstr/async-gen-meth-dflt-ary-ptrn-elision.js | 83 ++++++ .../dstr/async-gen-meth-dflt-ary-ptrn-empty.js | 66 +++++ .../async-gen-meth-dflt-ary-ptrn-rest-ary-elem.js | 90 +++++++ ...sync-gen-meth-dflt-ary-ptrn-rest-ary-elision.js | 96 +++++++ .../async-gen-meth-dflt-ary-ptrn-rest-ary-empty.js | 79 ++++++ .../async-gen-meth-dflt-ary-ptrn-rest-ary-rest.js | 75 ++++++ .../async-gen-meth-dflt-ary-ptrn-rest-id-direct.js | 70 +++++ ...-meth-dflt-ary-ptrn-rest-id-elision-next-err.js | 67 +++++ ...async-gen-meth-dflt-ary-ptrn-rest-id-elision.js | 71 ++++++ ...ync-gen-meth-dflt-ary-ptrn-rest-id-exhausted.js | 67 +++++ ...gen-meth-dflt-ary-ptrn-rest-id-iter-step-err.js | 78 ++++++ ...-gen-meth-dflt-ary-ptrn-rest-id-iter-val-err.js | 80 ++++++ .../dstr/async-gen-meth-dflt-ary-ptrn-rest-id.js | 68 +++++ .../async-gen-meth-dflt-ary-ptrn-rest-init-ary.js | 65 +++++ .../async-gen-meth-dflt-ary-ptrn-rest-init-id.js | 65 +++++ .../async-gen-meth-dflt-ary-ptrn-rest-init-obj.js | 65 +++++ ...nc-gen-meth-dflt-ary-ptrn-rest-not-final-ary.js | 65 +++++ ...ync-gen-meth-dflt-ary-ptrn-rest-not-final-id.js | 65 +++++ ...nc-gen-meth-dflt-ary-ptrn-rest-not-final-obj.js | 65 +++++ .../async-gen-meth-dflt-ary-ptrn-rest-obj-id.js | 68 +++++ ...sync-gen-meth-dflt-ary-ptrn-rest-obj-prop-id.js | 75 ++++++ .../dstr/async-gen-meth-dflt-obj-init-null.js | 61 +++++ .../dstr/async-gen-meth-dflt-obj-init-undefined.js | 61 +++++ .../dstr/async-gen-meth-dflt-obj-ptrn-empty.js | 67 +++++ ...sync-gen-meth-dflt-obj-ptrn-id-get-value-err.js | 68 +++++ ...gen-meth-dflt-obj-ptrn-id-init-fn-name-arrow.js | 68 +++++ ...gen-meth-dflt-obj-ptrn-id-init-fn-name-class.js | 70 +++++ ...gen-meth-dflt-obj-ptrn-id-init-fn-name-cover.js | 69 +++++ ...nc-gen-meth-dflt-obj-ptrn-id-init-fn-name-fn.js | 69 +++++ ...c-gen-meth-dflt-obj-ptrn-id-init-fn-name-gen.js | 70 +++++ ...async-gen-meth-dflt-obj-ptrn-id-init-skipped.js | 72 ++++++ .../async-gen-meth-dflt-obj-ptrn-id-init-throws.js | 68 +++++ ...-gen-meth-dflt-obj-ptrn-id-init-unresolvable.js | 72 ++++++ ...ync-gen-meth-dflt-obj-ptrn-id-trailing-comma.js | 62 +++++ .../dstr/async-gen-meth-dflt-obj-ptrn-list-err.js | 69 +++++ .../async-gen-meth-dflt-obj-ptrn-prop-ary-init.js | 71 ++++++ ...n-meth-dflt-obj-ptrn-prop-ary-trailing-comma.js | 62 +++++ ...c-gen-meth-dflt-obj-ptrn-prop-ary-value-null.js | 63 +++++ .../dstr/async-gen-meth-dflt-obj-ptrn-prop-ary.js | 69 +++++ .../async-gen-meth-dflt-obj-ptrn-prop-eval-err.js | 65 +++++ ...gen-meth-dflt-obj-ptrn-prop-id-get-value-err.js | 70 +++++ ...-gen-meth-dflt-obj-ptrn-prop-id-init-skipped.js | 84 ++++++ ...c-gen-meth-dflt-obj-ptrn-prop-id-init-throws.js | 68 +++++ ...meth-dflt-obj-ptrn-prop-id-init-unresolvable.js | 72 ++++++ .../async-gen-meth-dflt-obj-ptrn-prop-id-init.js | 65 +++++ ...en-meth-dflt-obj-ptrn-prop-id-trailing-comma.js | 66 +++++ .../dstr/async-gen-meth-dflt-obj-ptrn-prop-id.js | 65 +++++ .../async-gen-meth-dflt-obj-ptrn-prop-obj-init.js | 71 ++++++ ...c-gen-meth-dflt-obj-ptrn-prop-obj-value-null.js | 63 +++++ ...-gen-meth-dflt-obj-ptrn-prop-obj-value-undef.js | 63 +++++ .../dstr/async-gen-meth-dflt-obj-ptrn-prop-obj.js | 69 +++++ .../async-gen-meth-dflt-obj-ptrn-rest-getter.js | 64 +++++ ...-meth-dflt-obj-ptrn-rest-skip-non-enumerable.js | 72 ++++++ .../async-gen-meth-dflt-obj-ptrn-rest-val-obj.js | 71 ++++++ .../class/dstr/async-gen-meth-obj-init-null.js | 61 +++++ .../dstr/async-gen-meth-obj-init-undefined.js | 61 +++++ .../class/dstr/async-gen-meth-obj-ptrn-empty.js | 67 +++++ .../async-gen-meth-obj-ptrn-id-get-value-err.js | 68 +++++ ...sync-gen-meth-obj-ptrn-id-init-fn-name-arrow.js | 68 +++++ ...sync-gen-meth-obj-ptrn-id-init-fn-name-class.js | 70 +++++ ...sync-gen-meth-obj-ptrn-id-init-fn-name-cover.js | 69 +++++ .../async-gen-meth-obj-ptrn-id-init-fn-name-fn.js | 69 +++++ .../async-gen-meth-obj-ptrn-id-init-fn-name-gen.js | 70 +++++ .../async-gen-meth-obj-ptrn-id-init-skipped.js | 72 ++++++ .../dstr/async-gen-meth-obj-ptrn-id-init-throws.js | 68 +++++ ...async-gen-meth-obj-ptrn-id-init-unresolvable.js | 72 ++++++ .../async-gen-meth-obj-ptrn-id-trailing-comma.js | 62 +++++ .../class/dstr/async-gen-meth-obj-ptrn-list-err.js | 69 +++++ .../dstr/async-gen-meth-obj-ptrn-prop-ary-init.js | 71 ++++++ ...nc-gen-meth-obj-ptrn-prop-ary-trailing-comma.js | 62 +++++ .../async-gen-meth-obj-ptrn-prop-ary-value-null.js | 63 +++++ .../class/dstr/async-gen-meth-obj-ptrn-prop-ary.js | 69 +++++ .../dstr/async-gen-meth-obj-ptrn-prop-eval-err.js | 65 +++++ ...sync-gen-meth-obj-ptrn-prop-id-get-value-err.js | 70 +++++ ...async-gen-meth-obj-ptrn-prop-id-init-skipped.js | 84 ++++++ .../async-gen-meth-obj-ptrn-prop-id-init-throws.js | 68 +++++ ...-gen-meth-obj-ptrn-prop-id-init-unresolvable.js | 72 ++++++ .../dstr/async-gen-meth-obj-ptrn-prop-id-init.js | 65 +++++ ...ync-gen-meth-obj-ptrn-prop-id-trailing-comma.js | 66 +++++ .../class/dstr/async-gen-meth-obj-ptrn-prop-id.js | 65 +++++ .../dstr/async-gen-meth-obj-ptrn-prop-obj-init.js | 71 ++++++ .../async-gen-meth-obj-ptrn-prop-obj-value-null.js | 63 +++++ ...async-gen-meth-obj-ptrn-prop-obj-value-undef.js | 63 +++++ .../class/dstr/async-gen-meth-obj-ptrn-prop-obj.js | 69 +++++ .../dstr/async-gen-meth-obj-ptrn-rest-getter.js | 64 +++++ ...c-gen-meth-obj-ptrn-rest-skip-non-enumerable.js | 72 ++++++ .../dstr/async-gen-meth-obj-ptrn-rest-val-obj.js | 71 ++++++ .../async-gen-meth-static-ary-init-iter-close.js | 78 ++++++ ...static-ary-init-iter-get-err-array-prototype.js | 73 ++++++ .../async-gen-meth-static-ary-init-iter-get-err.js | 67 +++++ ...async-gen-meth-static-ary-init-iter-no-close.js | 78 ++++++ .../async-gen-meth-static-ary-name-iter-val.js | 77 ++++++ ...-gen-meth-static-ary-ptrn-elem-ary-elem-init.js | 69 +++++ ...-gen-meth-static-ary-ptrn-elem-ary-elem-iter.js | 70 +++++ ...n-meth-static-ary-ptrn-elem-ary-elision-init.js | 76 ++++++ ...n-meth-static-ary-ptrn-elem-ary-elision-iter.js | 73 ++++++ ...gen-meth-static-ary-ptrn-elem-ary-empty-init.js | 72 ++++++ ...gen-meth-static-ary-ptrn-elem-ary-empty-iter.js | 69 +++++ ...-gen-meth-static-ary-ptrn-elem-ary-rest-init.js | 73 ++++++ ...-gen-meth-static-ary-ptrn-elem-ary-rest-iter.js | 76 ++++++ ...c-gen-meth-static-ary-ptrn-elem-ary-val-null.js | 74 ++++++ ...-meth-static-ary-ptrn-elem-id-init-exhausted.js | 68 +++++ ...h-static-ary-ptrn-elem-id-init-fn-name-arrow.js | 69 +++++ ...h-static-ary-ptrn-elem-id-init-fn-name-class.js | 71 ++++++ ...h-static-ary-ptrn-elem-id-init-fn-name-cover.js | 70 +++++ ...meth-static-ary-ptrn-elem-id-init-fn-name-fn.js | 70 +++++ ...eth-static-ary-ptrn-elem-id-init-fn-name-gen.js | 71 ++++++ ...c-gen-meth-static-ary-ptrn-elem-id-init-hole.js | 64 +++++ ...en-meth-static-ary-ptrn-elem-id-init-skipped.js | 73 ++++++ ...gen-meth-static-ary-ptrn-elem-id-init-throws.js | 65 +++++ ...-gen-meth-static-ary-ptrn-elem-id-init-undef.js | 67 +++++ ...th-static-ary-ptrn-elem-id-init-unresolvable.js | 72 ++++++ ...n-meth-static-ary-ptrn-elem-id-iter-complete.js | 71 ++++++ ...c-gen-meth-static-ary-ptrn-elem-id-iter-done.js | 66 +++++ ...n-meth-static-ary-ptrn-elem-id-iter-step-err.js | 74 ++++++ ...ic-ary-ptrn-elem-id-iter-val-array-prototype.js | 87 +++++++ ...en-meth-static-ary-ptrn-elem-id-iter-val-err.js | 85 +++++++ ...nc-gen-meth-static-ary-ptrn-elem-id-iter-val.js | 77 ++++++ ...nc-gen-meth-static-ary-ptrn-elem-obj-id-init.js | 69 +++++ .../async-gen-meth-static-ary-ptrn-elem-obj-id.js | 69 +++++ ...n-meth-static-ary-ptrn-elem-obj-prop-id-init.js | 79 ++++++ ...nc-gen-meth-static-ary-ptrn-elem-obj-prop-id.js | 79 ++++++ ...c-gen-meth-static-ary-ptrn-elem-obj-val-null.js | 74 ++++++ ...-gen-meth-static-ary-ptrn-elem-obj-val-undef.js | 74 ++++++ ...c-gen-meth-static-ary-ptrn-elision-exhausted.js | 74 ++++++ ...nc-gen-meth-static-ary-ptrn-elision-step-err.js | 81 ++++++ .../dstr/async-gen-meth-static-ary-ptrn-elision.js | 83 ++++++ .../dstr/async-gen-meth-static-ary-ptrn-empty.js | 66 +++++ ...async-gen-meth-static-ary-ptrn-rest-ary-elem.js | 90 +++++++ ...nc-gen-meth-static-ary-ptrn-rest-ary-elision.js | 96 +++++++ ...sync-gen-meth-static-ary-ptrn-rest-ary-empty.js | 79 ++++++ ...async-gen-meth-static-ary-ptrn-rest-ary-rest.js | 75 ++++++ ...sync-gen-meth-static-ary-ptrn-rest-id-direct.js | 70 +++++ ...eth-static-ary-ptrn-rest-id-elision-next-err.js | 67 +++++ ...ync-gen-meth-static-ary-ptrn-rest-id-elision.js | 71 ++++++ ...c-gen-meth-static-ary-ptrn-rest-id-exhausted.js | 67 +++++ ...n-meth-static-ary-ptrn-rest-id-iter-step-err.js | 78 ++++++ ...en-meth-static-ary-ptrn-rest-id-iter-val-err.js | 80 ++++++ .../dstr/async-gen-meth-static-ary-ptrn-rest-id.js | 68 +++++ ...async-gen-meth-static-ary-ptrn-rest-init-ary.js | 65 +++++ .../async-gen-meth-static-ary-ptrn-rest-init-id.js | 65 +++++ ...async-gen-meth-static-ary-ptrn-rest-init-obj.js | 65 +++++ ...-gen-meth-static-ary-ptrn-rest-not-final-ary.js | 65 +++++ ...c-gen-meth-static-ary-ptrn-rest-not-final-id.js | 65 +++++ ...-gen-meth-static-ary-ptrn-rest-not-final-obj.js | 65 +++++ .../async-gen-meth-static-ary-ptrn-rest-obj-id.js | 68 +++++ ...nc-gen-meth-static-ary-ptrn-rest-obj-prop-id.js | 75 ++++++ ...ync-gen-meth-static-dflt-ary-init-iter-close.js | 78 ++++++ ...c-dflt-ary-init-iter-get-err-array-prototype.js | 73 ++++++ ...c-gen-meth-static-dflt-ary-init-iter-get-err.js | 67 +++++ ...-gen-meth-static-dflt-ary-init-iter-no-close.js | 78 ++++++ ...async-gen-meth-static-dflt-ary-name-iter-val.js | 77 ++++++ ...meth-static-dflt-ary-ptrn-elem-ary-elem-init.js | 69 +++++ ...meth-static-dflt-ary-ptrn-elem-ary-elem-iter.js | 70 +++++ ...h-static-dflt-ary-ptrn-elem-ary-elision-init.js | 76 ++++++ ...h-static-dflt-ary-ptrn-elem-ary-elision-iter.js | 73 ++++++ ...eth-static-dflt-ary-ptrn-elem-ary-empty-init.js | 72 ++++++ ...eth-static-dflt-ary-ptrn-elem-ary-empty-iter.js | 69 +++++ ...meth-static-dflt-ary-ptrn-elem-ary-rest-init.js | 73 ++++++ ...meth-static-dflt-ary-ptrn-elem-ary-rest-iter.js | 76 ++++++ ...-meth-static-dflt-ary-ptrn-elem-ary-val-null.js | 74 ++++++ ...-static-dflt-ary-ptrn-elem-id-init-exhausted.js | 68 +++++ ...tic-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js | 69 +++++ ...tic-dflt-ary-ptrn-elem-id-init-fn-name-class.js | 71 ++++++ ...tic-dflt-ary-ptrn-elem-id-init-fn-name-cover.js | 70 +++++ ...static-dflt-ary-ptrn-elem-id-init-fn-name-fn.js | 70 +++++ ...tatic-dflt-ary-ptrn-elem-id-init-fn-name-gen.js | 71 ++++++ ...-meth-static-dflt-ary-ptrn-elem-id-init-hole.js | 64 +++++ ...th-static-dflt-ary-ptrn-elem-id-init-skipped.js | 73 ++++++ ...eth-static-dflt-ary-ptrn-elem-id-init-throws.js | 65 +++++ ...meth-static-dflt-ary-ptrn-elem-id-init-undef.js | 67 +++++ ...atic-dflt-ary-ptrn-elem-id-init-unresolvable.js | 72 ++++++ ...h-static-dflt-ary-ptrn-elem-id-iter-complete.js | 71 ++++++ ...-meth-static-dflt-ary-ptrn-elem-id-iter-done.js | 66 +++++ ...h-static-dflt-ary-ptrn-elem-id-iter-step-err.js | 74 ++++++ ...lt-ary-ptrn-elem-id-iter-val-array-prototype.js | 87 +++++++ ...th-static-dflt-ary-ptrn-elem-id-iter-val-err.js | 85 +++++++ ...n-meth-static-dflt-ary-ptrn-elem-id-iter-val.js | 77 ++++++ ...n-meth-static-dflt-ary-ptrn-elem-obj-id-init.js | 69 +++++ ...nc-gen-meth-static-dflt-ary-ptrn-elem-obj-id.js | 69 +++++ ...h-static-dflt-ary-ptrn-elem-obj-prop-id-init.js | 79 ++++++ ...n-meth-static-dflt-ary-ptrn-elem-obj-prop-id.js | 79 ++++++ ...-meth-static-dflt-ary-ptrn-elem-obj-val-null.js | 74 ++++++ ...meth-static-dflt-ary-ptrn-elem-obj-val-undef.js | 74 ++++++ ...-meth-static-dflt-ary-ptrn-elision-exhausted.js | 74 ++++++ ...n-meth-static-dflt-ary-ptrn-elision-step-err.js | 81 ++++++ .../async-gen-meth-static-dflt-ary-ptrn-elision.js | 83 ++++++ .../async-gen-meth-static-dflt-ary-ptrn-empty.js | 66 +++++ ...-gen-meth-static-dflt-ary-ptrn-rest-ary-elem.js | 90 +++++++ ...n-meth-static-dflt-ary-ptrn-rest-ary-elision.js | 96 +++++++ ...gen-meth-static-dflt-ary-ptrn-rest-ary-empty.js | 79 ++++++ ...-gen-meth-static-dflt-ary-ptrn-rest-ary-rest.js | 75 ++++++ ...gen-meth-static-dflt-ary-ptrn-rest-id-direct.js | 70 +++++ ...tatic-dflt-ary-ptrn-rest-id-elision-next-err.js | 67 +++++ ...en-meth-static-dflt-ary-ptrn-rest-id-elision.js | 71 ++++++ ...-meth-static-dflt-ary-ptrn-rest-id-exhausted.js | 67 +++++ ...h-static-dflt-ary-ptrn-rest-id-iter-step-err.js | 78 ++++++ ...th-static-dflt-ary-ptrn-rest-id-iter-val-err.js | 80 ++++++ .../async-gen-meth-static-dflt-ary-ptrn-rest-id.js | 68 +++++ ...-gen-meth-static-dflt-ary-ptrn-rest-init-ary.js | 65 +++++ ...c-gen-meth-static-dflt-ary-ptrn-rest-init-id.js | 65 +++++ ...-gen-meth-static-dflt-ary-ptrn-rest-init-obj.js | 65 +++++ ...meth-static-dflt-ary-ptrn-rest-not-final-ary.js | 65 +++++ ...-meth-static-dflt-ary-ptrn-rest-not-final-id.js | 65 +++++ ...meth-static-dflt-ary-ptrn-rest-not-final-obj.js | 65 +++++ ...nc-gen-meth-static-dflt-ary-ptrn-rest-obj-id.js | 68 +++++ ...n-meth-static-dflt-ary-ptrn-rest-obj-prop-id.js | 75 ++++++ .../async-gen-meth-static-dflt-obj-init-null.js | 61 +++++ ...sync-gen-meth-static-dflt-obj-init-undefined.js | 61 +++++ .../async-gen-meth-static-dflt-obj-ptrn-empty.js | 67 +++++ ...n-meth-static-dflt-obj-ptrn-id-get-value-err.js | 68 +++++ ...h-static-dflt-obj-ptrn-id-init-fn-name-arrow.js | 68 +++++ ...h-static-dflt-obj-ptrn-id-init-fn-name-class.js | 70 +++++ ...h-static-dflt-obj-ptrn-id-init-fn-name-cover.js | 69 +++++ ...meth-static-dflt-obj-ptrn-id-init-fn-name-fn.js | 69 +++++ ...eth-static-dflt-obj-ptrn-id-init-fn-name-gen.js | 70 +++++ ...en-meth-static-dflt-obj-ptrn-id-init-skipped.js | 72 ++++++ ...gen-meth-static-dflt-obj-ptrn-id-init-throws.js | 68 +++++ ...th-static-dflt-obj-ptrn-id-init-unresolvable.js | 72 ++++++ ...-meth-static-dflt-obj-ptrn-id-trailing-comma.js | 62 +++++ ...async-gen-meth-static-dflt-obj-ptrn-list-err.js | 69 +++++ ...-gen-meth-static-dflt-obj-ptrn-prop-ary-init.js | 71 ++++++ ...static-dflt-obj-ptrn-prop-ary-trailing-comma.js | 62 +++++ ...eth-static-dflt-obj-ptrn-prop-ary-value-null.js | 63 +++++ ...async-gen-meth-static-dflt-obj-ptrn-prop-ary.js | 69 +++++ ...-gen-meth-static-dflt-obj-ptrn-prop-eval-err.js | 65 +++++ ...h-static-dflt-obj-ptrn-prop-id-get-value-err.js | 70 +++++ ...th-static-dflt-obj-ptrn-prop-id-init-skipped.js | 84 ++++++ ...eth-static-dflt-obj-ptrn-prop-id-init-throws.js | 68 +++++ ...atic-dflt-obj-ptrn-prop-id-init-unresolvable.js | 72 ++++++ ...c-gen-meth-static-dflt-obj-ptrn-prop-id-init.js | 65 +++++ ...-static-dflt-obj-ptrn-prop-id-trailing-comma.js | 66 +++++ .../async-gen-meth-static-dflt-obj-ptrn-prop-id.js | 65 +++++ ...-gen-meth-static-dflt-obj-ptrn-prop-obj-init.js | 71 ++++++ ...eth-static-dflt-obj-ptrn-prop-obj-value-null.js | 63 +++++ ...th-static-dflt-obj-ptrn-prop-obj-value-undef.js | 63 +++++ ...async-gen-meth-static-dflt-obj-ptrn-prop-obj.js | 69 +++++ ...nc-gen-meth-static-dflt-obj-ptrn-rest-getter.js | 64 +++++ ...tatic-dflt-obj-ptrn-rest-skip-non-enumerable.js | 72 ++++++ ...c-gen-meth-static-dflt-obj-ptrn-rest-val-obj.js | 71 ++++++ .../dstr/async-gen-meth-static-obj-init-null.js | 61 +++++ .../async-gen-meth-static-obj-init-undefined.js | 61 +++++ .../dstr/async-gen-meth-static-obj-ptrn-empty.js | 67 +++++ ...nc-gen-meth-static-obj-ptrn-id-get-value-err.js | 68 +++++ ...n-meth-static-obj-ptrn-id-init-fn-name-arrow.js | 68 +++++ ...n-meth-static-obj-ptrn-id-init-fn-name-class.js | 70 +++++ ...n-meth-static-obj-ptrn-id-init-fn-name-cover.js | 69 +++++ ...-gen-meth-static-obj-ptrn-id-init-fn-name-fn.js | 69 +++++ ...gen-meth-static-obj-ptrn-id-init-fn-name-gen.js | 70 +++++ ...ync-gen-meth-static-obj-ptrn-id-init-skipped.js | 72 ++++++ ...sync-gen-meth-static-obj-ptrn-id-init-throws.js | 68 +++++ ...en-meth-static-obj-ptrn-id-init-unresolvable.js | 72 ++++++ ...c-gen-meth-static-obj-ptrn-id-trailing-comma.js | 62 +++++ .../async-gen-meth-static-obj-ptrn-list-err.js | 69 +++++ ...async-gen-meth-static-obj-ptrn-prop-ary-init.js | 71 ++++++ ...meth-static-obj-ptrn-prop-ary-trailing-comma.js | 62 +++++ ...gen-meth-static-obj-ptrn-prop-ary-value-null.js | 63 +++++ .../async-gen-meth-static-obj-ptrn-prop-ary.js | 69 +++++ ...async-gen-meth-static-obj-ptrn-prop-eval-err.js | 65 +++++ ...n-meth-static-obj-ptrn-prop-id-get-value-err.js | 70 +++++ ...en-meth-static-obj-ptrn-prop-id-init-skipped.js | 84 ++++++ ...gen-meth-static-obj-ptrn-prop-id-init-throws.js | 68 +++++ ...th-static-obj-ptrn-prop-id-init-unresolvable.js | 72 ++++++ .../async-gen-meth-static-obj-ptrn-prop-id-init.js | 65 +++++ ...-meth-static-obj-ptrn-prop-id-trailing-comma.js | 66 +++++ .../dstr/async-gen-meth-static-obj-ptrn-prop-id.js | 65 +++++ ...async-gen-meth-static-obj-ptrn-prop-obj-init.js | 71 ++++++ ...gen-meth-static-obj-ptrn-prop-obj-value-null.js | 63 +++++ ...en-meth-static-obj-ptrn-prop-obj-value-undef.js | 63 +++++ .../async-gen-meth-static-obj-ptrn-prop-obj.js | 69 +++++ .../async-gen-meth-static-obj-ptrn-rest-getter.js | 64 +++++ ...eth-static-obj-ptrn-rest-skip-non-enumerable.js | 72 ++++++ .../async-gen-meth-static-obj-ptrn-rest-val-obj.js | 71 ++++++ .../async-private-gen-meth-ary-init-iter-close.js | 82 ++++++ ...sync-private-gen-meth-ary-init-iter-no-close.js | 82 ++++++ .../async-private-gen-meth-ary-name-iter-val.js | 81 ++++++ ...private-gen-meth-ary-ptrn-elem-ary-elem-init.js | 73 ++++++ ...private-gen-meth-ary-ptrn-elem-ary-elem-iter.js | 74 ++++++ ...vate-gen-meth-ary-ptrn-elem-ary-elision-init.js | 80 ++++++ ...vate-gen-meth-ary-ptrn-elem-ary-elision-iter.js | 77 ++++++ ...rivate-gen-meth-ary-ptrn-elem-ary-empty-init.js | 76 ++++++ ...rivate-gen-meth-ary-ptrn-elem-ary-empty-iter.js | 73 ++++++ ...private-gen-meth-ary-ptrn-elem-ary-rest-init.js | 77 ++++++ ...private-gen-meth-ary-ptrn-elem-ary-rest-iter.js | 80 ++++++ ...ate-gen-meth-ary-ptrn-elem-id-init-exhausted.js | 72 ++++++ ...gen-meth-ary-ptrn-elem-id-init-fn-name-arrow.js | 73 ++++++ ...gen-meth-ary-ptrn-elem-id-init-fn-name-class.js | 75 ++++++ ...gen-meth-ary-ptrn-elem-id-init-fn-name-cover.js | 74 ++++++ ...te-gen-meth-ary-ptrn-elem-id-init-fn-name-fn.js | 74 ++++++ ...e-gen-meth-ary-ptrn-elem-id-init-fn-name-gen.js | 75 ++++++ ...-private-gen-meth-ary-ptrn-elem-id-init-hole.js | 68 +++++ ...ivate-gen-meth-ary-ptrn-elem-id-init-skipped.js | 77 ++++++ ...private-gen-meth-ary-ptrn-elem-id-init-undef.js | 71 ++++++ ...vate-gen-meth-ary-ptrn-elem-id-iter-complete.js | 75 ++++++ ...-private-gen-meth-ary-ptrn-elem-id-iter-done.js | 70 +++++ ...th-ary-ptrn-elem-id-iter-val-array-prototype.js | 91 +++++++ ...c-private-gen-meth-ary-ptrn-elem-id-iter-val.js | 81 ++++++ ...c-private-gen-meth-ary-ptrn-elem-obj-id-init.js | 73 ++++++ .../async-private-gen-meth-ary-ptrn-elem-obj-id.js | 73 ++++++ ...vate-gen-meth-ary-ptrn-elem-obj-prop-id-init.js | 83 ++++++ ...c-private-gen-meth-ary-ptrn-elem-obj-prop-id.js | 83 ++++++ ...-private-gen-meth-ary-ptrn-elision-exhausted.js | 78 ++++++ .../async-private-gen-meth-ary-ptrn-elision.js | 87 +++++++ .../dstr/async-private-gen-meth-ary-ptrn-empty.js | 70 +++++ ...sync-private-gen-meth-ary-ptrn-rest-ary-elem.js | 94 +++++++ ...c-private-gen-meth-ary-ptrn-rest-ary-elision.js | 100 ++++++++ ...ync-private-gen-meth-ary-ptrn-rest-ary-empty.js | 83 ++++++ ...sync-private-gen-meth-ary-ptrn-rest-ary-rest.js | 79 ++++++ ...ync-private-gen-meth-ary-ptrn-rest-id-direct.js | 74 ++++++ ...nc-private-gen-meth-ary-ptrn-rest-id-elision.js | 75 ++++++ ...-private-gen-meth-ary-ptrn-rest-id-exhausted.js | 71 ++++++ .../async-private-gen-meth-ary-ptrn-rest-id.js | 72 ++++++ ...sync-private-gen-meth-ary-ptrn-rest-init-ary.js | 69 +++++ ...async-private-gen-meth-ary-ptrn-rest-init-id.js | 69 +++++ ...sync-private-gen-meth-ary-ptrn-rest-init-obj.js | 69 +++++ ...private-gen-meth-ary-ptrn-rest-not-final-ary.js | 69 +++++ ...-private-gen-meth-ary-ptrn-rest-not-final-id.js | 69 +++++ ...private-gen-meth-ary-ptrn-rest-not-final-obj.js | 69 +++++ .../async-private-gen-meth-ary-ptrn-rest-obj-id.js | 72 ++++++ ...c-private-gen-meth-ary-ptrn-rest-obj-prop-id.js | 79 ++++++ ...nc-private-gen-meth-dflt-ary-init-iter-close.js | 82 ++++++ ...private-gen-meth-dflt-ary-init-iter-no-close.js | 82 ++++++ ...sync-private-gen-meth-dflt-ary-name-iter-val.js | 81 ++++++ ...te-gen-meth-dflt-ary-ptrn-elem-ary-elem-init.js | 73 ++++++ ...te-gen-meth-dflt-ary-ptrn-elem-ary-elem-iter.js | 74 ++++++ ...gen-meth-dflt-ary-ptrn-elem-ary-elision-init.js | 80 ++++++ ...gen-meth-dflt-ary-ptrn-elem-ary-elision-iter.js | 77 ++++++ ...e-gen-meth-dflt-ary-ptrn-elem-ary-empty-init.js | 76 ++++++ ...e-gen-meth-dflt-ary-ptrn-elem-ary-empty-iter.js | 73 ++++++ ...te-gen-meth-dflt-ary-ptrn-elem-ary-rest-init.js | 77 ++++++ ...te-gen-meth-dflt-ary-ptrn-elem-ary-rest-iter.js | 80 ++++++ ...en-meth-dflt-ary-ptrn-elem-id-init-exhausted.js | 72 ++++++ ...eth-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js | 73 ++++++ ...eth-dflt-ary-ptrn-elem-id-init-fn-name-class.js | 75 ++++++ ...eth-dflt-ary-ptrn-elem-id-init-fn-name-cover.js | 74 ++++++ ...n-meth-dflt-ary-ptrn-elem-id-init-fn-name-fn.js | 74 ++++++ ...-meth-dflt-ary-ptrn-elem-id-init-fn-name-gen.js | 75 ++++++ ...ate-gen-meth-dflt-ary-ptrn-elem-id-init-hole.js | 68 +++++ ...-gen-meth-dflt-ary-ptrn-elem-id-init-skipped.js | 77 ++++++ ...te-gen-meth-dflt-ary-ptrn-elem-id-init-undef.js | 71 ++++++ ...gen-meth-dflt-ary-ptrn-elem-id-iter-complete.js | 75 ++++++ ...ate-gen-meth-dflt-ary-ptrn-elem-id-iter-done.js | 70 +++++ ...lt-ary-ptrn-elem-id-iter-val-array-prototype.js | 91 +++++++ ...vate-gen-meth-dflt-ary-ptrn-elem-id-iter-val.js | 81 ++++++ ...vate-gen-meth-dflt-ary-ptrn-elem-obj-id-init.js | 73 ++++++ ...c-private-gen-meth-dflt-ary-ptrn-elem-obj-id.js | 73 ++++++ ...gen-meth-dflt-ary-ptrn-elem-obj-prop-id-init.js | 83 ++++++ ...vate-gen-meth-dflt-ary-ptrn-elem-obj-prop-id.js | 83 ++++++ ...ate-gen-meth-dflt-ary-ptrn-elision-exhausted.js | 78 ++++++ ...async-private-gen-meth-dflt-ary-ptrn-elision.js | 87 +++++++ .../async-private-gen-meth-dflt-ary-ptrn-empty.js | 70 +++++ ...private-gen-meth-dflt-ary-ptrn-rest-ary-elem.js | 94 +++++++ ...vate-gen-meth-dflt-ary-ptrn-rest-ary-elision.js | 100 ++++++++ ...rivate-gen-meth-dflt-ary-ptrn-rest-ary-empty.js | 83 ++++++ ...private-gen-meth-dflt-ary-ptrn-rest-ary-rest.js | 79 ++++++ ...rivate-gen-meth-dflt-ary-ptrn-rest-id-direct.js | 74 ++++++ ...ivate-gen-meth-dflt-ary-ptrn-rest-id-elision.js | 75 ++++++ ...ate-gen-meth-dflt-ary-ptrn-rest-id-exhausted.js | 71 ++++++ ...async-private-gen-meth-dflt-ary-ptrn-rest-id.js | 72 ++++++ ...private-gen-meth-dflt-ary-ptrn-rest-init-ary.js | 69 +++++ ...-private-gen-meth-dflt-ary-ptrn-rest-init-id.js | 69 +++++ ...private-gen-meth-dflt-ary-ptrn-rest-init-obj.js | 69 +++++ ...te-gen-meth-dflt-ary-ptrn-rest-not-final-ary.js | 69 +++++ ...ate-gen-meth-dflt-ary-ptrn-rest-not-final-id.js | 69 +++++ ...te-gen-meth-dflt-ary-ptrn-rest-not-final-obj.js | 69 +++++ ...c-private-gen-meth-dflt-ary-ptrn-rest-obj-id.js | 72 ++++++ ...vate-gen-meth-dflt-ary-ptrn-rest-obj-prop-id.js | 79 ++++++ .../async-private-gen-meth-dflt-obj-ptrn-empty.js | 71 ++++++ ...gen-meth-dflt-obj-ptrn-id-init-fn-name-arrow.js | 72 ++++++ ...gen-meth-dflt-obj-ptrn-id-init-fn-name-class.js | 74 ++++++ ...gen-meth-dflt-obj-ptrn-id-init-fn-name-cover.js | 73 ++++++ ...te-gen-meth-dflt-obj-ptrn-id-init-fn-name-fn.js | 73 ++++++ ...e-gen-meth-dflt-obj-ptrn-id-init-fn-name-gen.js | 74 ++++++ ...ivate-gen-meth-dflt-obj-ptrn-id-init-skipped.js | 76 ++++++ ...ate-gen-meth-dflt-obj-ptrn-id-trailing-comma.js | 66 +++++ ...private-gen-meth-dflt-obj-ptrn-prop-ary-init.js | 75 ++++++ ...n-meth-dflt-obj-ptrn-prop-ary-trailing-comma.js | 66 +++++ ...sync-private-gen-meth-dflt-obj-ptrn-prop-ary.js | 73 ++++++ ...-gen-meth-dflt-obj-ptrn-prop-id-init-skipped.js | 88 +++++++ ...-private-gen-meth-dflt-obj-ptrn-prop-id-init.js | 69 +++++ ...en-meth-dflt-obj-ptrn-prop-id-trailing-comma.js | 70 +++++ ...async-private-gen-meth-dflt-obj-ptrn-prop-id.js | 69 +++++ ...private-gen-meth-dflt-obj-ptrn-prop-obj-init.js | 75 ++++++ ...sync-private-gen-meth-dflt-obj-ptrn-prop-obj.js | 73 ++++++ ...c-private-gen-meth-dflt-obj-ptrn-rest-getter.js | 68 +++++ ...-meth-dflt-obj-ptrn-rest-skip-non-enumerable.js | 76 ++++++ ...-private-gen-meth-dflt-obj-ptrn-rest-val-obj.js | 75 ++++++ .../dstr/async-private-gen-meth-obj-ptrn-empty.js | 71 ++++++ ...vate-gen-meth-obj-ptrn-id-init-fn-name-arrow.js | 72 ++++++ ...vate-gen-meth-obj-ptrn-id-init-fn-name-class.js | 74 ++++++ ...vate-gen-meth-obj-ptrn-id-init-fn-name-cover.js | 73 ++++++ ...private-gen-meth-obj-ptrn-id-init-fn-name-fn.js | 73 ++++++ ...rivate-gen-meth-obj-ptrn-id-init-fn-name-gen.js | 74 ++++++ ...nc-private-gen-meth-obj-ptrn-id-init-skipped.js | 76 ++++++ ...-private-gen-meth-obj-ptrn-id-trailing-comma.js | 66 +++++ ...sync-private-gen-meth-obj-ptrn-prop-ary-init.js | 75 ++++++ ...te-gen-meth-obj-ptrn-prop-ary-trailing-comma.js | 66 +++++ .../async-private-gen-meth-obj-ptrn-prop-ary.js | 73 ++++++ ...ivate-gen-meth-obj-ptrn-prop-id-init-skipped.js | 88 +++++++ ...async-private-gen-meth-obj-ptrn-prop-id-init.js | 69 +++++ ...ate-gen-meth-obj-ptrn-prop-id-trailing-comma.js | 70 +++++ .../async-private-gen-meth-obj-ptrn-prop-id.js | 69 +++++ ...sync-private-gen-meth-obj-ptrn-prop-obj-init.js | 75 ++++++ .../async-private-gen-meth-obj-ptrn-prop-obj.js | 73 ++++++ .../async-private-gen-meth-obj-ptrn-rest-getter.js | 68 +++++ ...e-gen-meth-obj-ptrn-rest-skip-non-enumerable.js | 76 ++++++ ...async-private-gen-meth-obj-ptrn-rest-val-obj.js | 75 ++++++ ...-private-gen-meth-static-ary-init-iter-close.js | 82 ++++++ ...ivate-gen-meth-static-ary-init-iter-no-close.js | 82 ++++++ ...nc-private-gen-meth-static-ary-name-iter-val.js | 81 ++++++ ...-gen-meth-static-ary-ptrn-elem-ary-elem-init.js | 73 ++++++ ...-gen-meth-static-ary-ptrn-elem-ary-elem-iter.js | 74 ++++++ ...n-meth-static-ary-ptrn-elem-ary-elision-init.js | 80 ++++++ ...n-meth-static-ary-ptrn-elem-ary-elision-iter.js | 77 ++++++ ...gen-meth-static-ary-ptrn-elem-ary-empty-init.js | 76 ++++++ ...gen-meth-static-ary-ptrn-elem-ary-empty-iter.js | 73 ++++++ ...-gen-meth-static-ary-ptrn-elem-ary-rest-init.js | 77 ++++++ ...-gen-meth-static-ary-ptrn-elem-ary-rest-iter.js | 80 ++++++ ...-meth-static-ary-ptrn-elem-id-init-exhausted.js | 72 ++++++ ...h-static-ary-ptrn-elem-id-init-fn-name-arrow.js | 73 ++++++ ...h-static-ary-ptrn-elem-id-init-fn-name-class.js | 75 ++++++ ...h-static-ary-ptrn-elem-id-init-fn-name-cover.js | 74 ++++++ ...meth-static-ary-ptrn-elem-id-init-fn-name-fn.js | 74 ++++++ ...eth-static-ary-ptrn-elem-id-init-fn-name-gen.js | 75 ++++++ ...e-gen-meth-static-ary-ptrn-elem-id-init-hole.js | 68 +++++ ...en-meth-static-ary-ptrn-elem-id-init-skipped.js | 77 ++++++ ...-gen-meth-static-ary-ptrn-elem-id-init-undef.js | 71 ++++++ ...n-meth-static-ary-ptrn-elem-id-iter-complete.js | 75 ++++++ ...e-gen-meth-static-ary-ptrn-elem-id-iter-done.js | 70 +++++ ...ic-ary-ptrn-elem-id-iter-val-array-prototype.js | 91 +++++++ ...te-gen-meth-static-ary-ptrn-elem-id-iter-val.js | 81 ++++++ ...te-gen-meth-static-ary-ptrn-elem-obj-id-init.js | 73 ++++++ ...private-gen-meth-static-ary-ptrn-elem-obj-id.js | 73 ++++++ ...n-meth-static-ary-ptrn-elem-obj-prop-id-init.js | 83 ++++++ ...te-gen-meth-static-ary-ptrn-elem-obj-prop-id.js | 83 ++++++ ...e-gen-meth-static-ary-ptrn-elision-exhausted.js | 78 ++++++ ...ync-private-gen-meth-static-ary-ptrn-elision.js | 87 +++++++ ...async-private-gen-meth-static-ary-ptrn-empty.js | 70 +++++ ...ivate-gen-meth-static-ary-ptrn-rest-ary-elem.js | 94 +++++++ ...te-gen-meth-static-ary-ptrn-rest-ary-elision.js | 100 ++++++++ ...vate-gen-meth-static-ary-ptrn-rest-ary-empty.js | 83 ++++++ ...ivate-gen-meth-static-ary-ptrn-rest-ary-rest.js | 79 ++++++ ...vate-gen-meth-static-ary-ptrn-rest-id-direct.js | 74 ++++++ ...ate-gen-meth-static-ary-ptrn-rest-id-elision.js | 75 ++++++ ...e-gen-meth-static-ary-ptrn-rest-id-exhausted.js | 71 ++++++ ...ync-private-gen-meth-static-ary-ptrn-rest-id.js | 72 ++++++ ...ivate-gen-meth-static-ary-ptrn-rest-init-ary.js | 69 +++++ ...rivate-gen-meth-static-ary-ptrn-rest-init-id.js | 69 +++++ ...ivate-gen-meth-static-ary-ptrn-rest-init-obj.js | 69 +++++ ...-gen-meth-static-ary-ptrn-rest-not-final-ary.js | 69 +++++ ...e-gen-meth-static-ary-ptrn-rest-not-final-id.js | 69 +++++ ...-gen-meth-static-ary-ptrn-rest-not-final-obj.js | 69 +++++ ...private-gen-meth-static-ary-ptrn-rest-obj-id.js | 72 ++++++ ...te-gen-meth-static-ary-ptrn-rest-obj-prop-id.js | 79 ++++++ ...ate-gen-meth-static-dflt-ary-init-iter-close.js | 82 ++++++ ...-gen-meth-static-dflt-ary-init-iter-no-close.js | 82 ++++++ ...ivate-gen-meth-static-dflt-ary-name-iter-val.js | 81 ++++++ ...meth-static-dflt-ary-ptrn-elem-ary-elem-init.js | 73 ++++++ ...meth-static-dflt-ary-ptrn-elem-ary-elem-iter.js | 74 ++++++ ...h-static-dflt-ary-ptrn-elem-ary-elision-init.js | 80 ++++++ ...h-static-dflt-ary-ptrn-elem-ary-elision-iter.js | 77 ++++++ ...eth-static-dflt-ary-ptrn-elem-ary-empty-init.js | 76 ++++++ ...eth-static-dflt-ary-ptrn-elem-ary-empty-iter.js | 73 ++++++ ...meth-static-dflt-ary-ptrn-elem-ary-rest-init.js | 77 ++++++ ...meth-static-dflt-ary-ptrn-elem-ary-rest-iter.js | 80 ++++++ ...-static-dflt-ary-ptrn-elem-id-init-exhausted.js | 72 ++++++ ...tic-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js | 73 ++++++ ...tic-dflt-ary-ptrn-elem-id-init-fn-name-class.js | 75 ++++++ ...tic-dflt-ary-ptrn-elem-id-init-fn-name-cover.js | 74 ++++++ ...static-dflt-ary-ptrn-elem-id-init-fn-name-fn.js | 74 ++++++ ...tatic-dflt-ary-ptrn-elem-id-init-fn-name-gen.js | 75 ++++++ ...-meth-static-dflt-ary-ptrn-elem-id-init-hole.js | 68 +++++ ...th-static-dflt-ary-ptrn-elem-id-init-skipped.js | 77 ++++++ ...meth-static-dflt-ary-ptrn-elem-id-init-undef.js | 71 ++++++ ...h-static-dflt-ary-ptrn-elem-id-iter-complete.js | 75 ++++++ ...-meth-static-dflt-ary-ptrn-elem-id-iter-done.js | 70 +++++ ...lt-ary-ptrn-elem-id-iter-val-array-prototype.js | 91 +++++++ ...n-meth-static-dflt-ary-ptrn-elem-id-iter-val.js | 81 ++++++ ...n-meth-static-dflt-ary-ptrn-elem-obj-id-init.js | 73 ++++++ ...te-gen-meth-static-dflt-ary-ptrn-elem-obj-id.js | 73 ++++++ ...h-static-dflt-ary-ptrn-elem-obj-prop-id-init.js | 83 ++++++ ...n-meth-static-dflt-ary-ptrn-elem-obj-prop-id.js | 83 ++++++ ...-meth-static-dflt-ary-ptrn-elision-exhausted.js | 78 ++++++ ...rivate-gen-meth-static-dflt-ary-ptrn-elision.js | 87 +++++++ ...-private-gen-meth-static-dflt-ary-ptrn-empty.js | 70 +++++ ...-gen-meth-static-dflt-ary-ptrn-rest-ary-elem.js | 94 +++++++ ...n-meth-static-dflt-ary-ptrn-rest-ary-elision.js | 100 ++++++++ ...gen-meth-static-dflt-ary-ptrn-rest-ary-empty.js | 83 ++++++ ...-gen-meth-static-dflt-ary-ptrn-rest-ary-rest.js | 79 ++++++ ...gen-meth-static-dflt-ary-ptrn-rest-id-direct.js | 74 ++++++ ...en-meth-static-dflt-ary-ptrn-rest-id-elision.js | 75 ++++++ ...-meth-static-dflt-ary-ptrn-rest-id-exhausted.js | 71 ++++++ ...rivate-gen-meth-static-dflt-ary-ptrn-rest-id.js | 72 ++++++ ...-gen-meth-static-dflt-ary-ptrn-rest-init-ary.js | 69 +++++ ...e-gen-meth-static-dflt-ary-ptrn-rest-init-id.js | 69 +++++ ...-gen-meth-static-dflt-ary-ptrn-rest-init-obj.js | 69 +++++ ...meth-static-dflt-ary-ptrn-rest-not-final-ary.js | 69 +++++ ...-meth-static-dflt-ary-ptrn-rest-not-final-id.js | 69 +++++ ...meth-static-dflt-ary-ptrn-rest-not-final-obj.js | 69 +++++ ...te-gen-meth-static-dflt-ary-ptrn-rest-obj-id.js | 72 ++++++ ...n-meth-static-dflt-ary-ptrn-rest-obj-prop-id.js | 79 ++++++ ...-private-gen-meth-static-dflt-obj-ptrn-empty.js | 71 ++++++ ...h-static-dflt-obj-ptrn-id-init-fn-name-arrow.js | 72 ++++++ ...h-static-dflt-obj-ptrn-id-init-fn-name-class.js | 74 ++++++ ...h-static-dflt-obj-ptrn-id-init-fn-name-cover.js | 73 ++++++ ...meth-static-dflt-obj-ptrn-id-init-fn-name-fn.js | 73 ++++++ ...eth-static-dflt-obj-ptrn-id-init-fn-name-gen.js | 74 ++++++ ...en-meth-static-dflt-obj-ptrn-id-init-skipped.js | 76 ++++++ ...-meth-static-dflt-obj-ptrn-id-trailing-comma.js | 66 +++++ ...-gen-meth-static-dflt-obj-ptrn-prop-ary-init.js | 75 ++++++ ...static-dflt-obj-ptrn-prop-ary-trailing-comma.js | 66 +++++ ...ivate-gen-meth-static-dflt-obj-ptrn-prop-ary.js | 73 ++++++ ...th-static-dflt-obj-ptrn-prop-id-init-skipped.js | 88 +++++++ ...e-gen-meth-static-dflt-obj-ptrn-prop-id-init.js | 69 +++++ ...-static-dflt-obj-ptrn-prop-id-trailing-comma.js | 70 +++++ ...rivate-gen-meth-static-dflt-obj-ptrn-prop-id.js | 69 +++++ ...-gen-meth-static-dflt-obj-ptrn-prop-obj-init.js | 75 ++++++ ...ivate-gen-meth-static-dflt-obj-ptrn-prop-obj.js | 73 ++++++ ...te-gen-meth-static-dflt-obj-ptrn-rest-getter.js | 68 +++++ ...tatic-dflt-obj-ptrn-rest-skip-non-enumerable.js | 76 ++++++ ...e-gen-meth-static-dflt-obj-ptrn-rest-val-obj.js | 75 ++++++ ...async-private-gen-meth-static-obj-ptrn-empty.js | 71 ++++++ ...n-meth-static-obj-ptrn-id-init-fn-name-arrow.js | 72 ++++++ ...n-meth-static-obj-ptrn-id-init-fn-name-class.js | 74 ++++++ ...n-meth-static-obj-ptrn-id-init-fn-name-cover.js | 73 ++++++ ...-gen-meth-static-obj-ptrn-id-init-fn-name-fn.js | 73 ++++++ ...gen-meth-static-obj-ptrn-id-init-fn-name-gen.js | 74 ++++++ ...ate-gen-meth-static-obj-ptrn-id-init-skipped.js | 76 ++++++ ...e-gen-meth-static-obj-ptrn-id-trailing-comma.js | 66 +++++ ...ivate-gen-meth-static-obj-ptrn-prop-ary-init.js | 75 ++++++ ...meth-static-obj-ptrn-prop-ary-trailing-comma.js | 66 +++++ ...nc-private-gen-meth-static-obj-ptrn-prop-ary.js | 73 ++++++ ...en-meth-static-obj-ptrn-prop-id-init-skipped.js | 88 +++++++ ...rivate-gen-meth-static-obj-ptrn-prop-id-init.js | 69 +++++ ...-meth-static-obj-ptrn-prop-id-trailing-comma.js | 70 +++++ ...ync-private-gen-meth-static-obj-ptrn-prop-id.js | 69 +++++ ...ivate-gen-meth-static-obj-ptrn-prop-obj-init.js | 75 ++++++ ...nc-private-gen-meth-static-obj-ptrn-prop-obj.js | 73 ++++++ ...private-gen-meth-static-obj-ptrn-rest-getter.js | 68 +++++ ...eth-static-obj-ptrn-rest-skip-non-enumerable.js | 76 ++++++ ...rivate-gen-meth-static-obj-ptrn-rest-val-obj.js | 75 ++++++ .../language/statements/class/dstr/browser.js | 0 .../class/dstr/gen-meth-ary-init-iter-close.js | 96 +++++++ ...n-meth-ary-init-iter-get-err-array-prototype.js | 89 +++++++ .../class/dstr/gen-meth-ary-init-iter-get-err.js | 83 ++++++ .../class/dstr/gen-meth-ary-init-iter-no-close.js | 96 +++++++ .../class/dstr/gen-meth-ary-name-iter-val.js | 95 +++++++ .../dstr/gen-meth-ary-ptrn-elem-ary-elem-init.js | 87 +++++++ .../dstr/gen-meth-ary-ptrn-elem-ary-elem-iter.js | 88 +++++++ .../gen-meth-ary-ptrn-elem-ary-elision-init.js | 94 +++++++ .../gen-meth-ary-ptrn-elem-ary-elision-iter.js | 91 +++++++ .../dstr/gen-meth-ary-ptrn-elem-ary-empty-init.js | 90 +++++++ .../dstr/gen-meth-ary-ptrn-elem-ary-empty-iter.js | 87 +++++++ .../dstr/gen-meth-ary-ptrn-elem-ary-rest-init.js | 91 +++++++ .../dstr/gen-meth-ary-ptrn-elem-ary-rest-iter.js | 94 +++++++ .../dstr/gen-meth-ary-ptrn-elem-ary-val-null.js | 90 +++++++ .../gen-meth-ary-ptrn-elem-id-init-exhausted.js | 86 +++++++ ...gen-meth-ary-ptrn-elem-id-init-fn-name-arrow.js | 87 +++++++ ...gen-meth-ary-ptrn-elem-id-init-fn-name-class.js | 89 +++++++ ...gen-meth-ary-ptrn-elem-id-init-fn-name-cover.js | 88 +++++++ .../gen-meth-ary-ptrn-elem-id-init-fn-name-fn.js | 88 +++++++ .../gen-meth-ary-ptrn-elem-id-init-fn-name-gen.js | 89 +++++++ .../dstr/gen-meth-ary-ptrn-elem-id-init-hole.js | 82 ++++++ .../dstr/gen-meth-ary-ptrn-elem-id-init-skipped.js | 91 +++++++ .../dstr/gen-meth-ary-ptrn-elem-id-init-throws.js | 81 ++++++ .../dstr/gen-meth-ary-ptrn-elem-id-init-undef.js | 85 +++++++ .../gen-meth-ary-ptrn-elem-id-init-unresolvable.js | 88 +++++++ .../gen-meth-ary-ptrn-elem-id-iter-complete.js | 89 +++++++ .../dstr/gen-meth-ary-ptrn-elem-id-iter-done.js | 84 ++++++ .../gen-meth-ary-ptrn-elem-id-iter-step-err.js | 90 +++++++ ...th-ary-ptrn-elem-id-iter-val-array-prototype.js | 105 ++++++++ .../dstr/gen-meth-ary-ptrn-elem-id-iter-val-err.js | 101 ++++++++ .../dstr/gen-meth-ary-ptrn-elem-id-iter-val.js | 95 +++++++ .../dstr/gen-meth-ary-ptrn-elem-obj-id-init.js | 87 +++++++ .../class/dstr/gen-meth-ary-ptrn-elem-obj-id.js | 87 +++++++ .../gen-meth-ary-ptrn-elem-obj-prop-id-init.js | 97 +++++++ .../dstr/gen-meth-ary-ptrn-elem-obj-prop-id.js | 97 +++++++ .../dstr/gen-meth-ary-ptrn-elem-obj-val-null.js | 90 +++++++ .../dstr/gen-meth-ary-ptrn-elem-obj-val-undef.js | 90 +++++++ .../dstr/gen-meth-ary-ptrn-elision-exhausted.js | 92 +++++++ .../dstr/gen-meth-ary-ptrn-elision-step-err.js | 97 +++++++ .../class/dstr/gen-meth-ary-ptrn-elision.js | 101 ++++++++ .../class/dstr/gen-meth-ary-ptrn-empty.js | 84 ++++++ .../class/dstr/gen-meth-ary-ptrn-rest-ary-elem.js | 108 ++++++++ .../dstr/gen-meth-ary-ptrn-rest-ary-elision.js | 114 +++++++++ .../class/dstr/gen-meth-ary-ptrn-rest-ary-empty.js | 97 +++++++ .../class/dstr/gen-meth-ary-ptrn-rest-ary-rest.js | 93 +++++++ .../class/dstr/gen-meth-ary-ptrn-rest-id-direct.js | 88 +++++++ .../gen-meth-ary-ptrn-rest-id-elision-next-err.js | 83 ++++++ .../dstr/gen-meth-ary-ptrn-rest-id-elision.js | 89 +++++++ .../dstr/gen-meth-ary-ptrn-rest-id-exhausted.js | 85 +++++++ .../gen-meth-ary-ptrn-rest-id-iter-step-err.js | 94 +++++++ .../dstr/gen-meth-ary-ptrn-rest-id-iter-val-err.js | 96 +++++++ .../class/dstr/gen-meth-ary-ptrn-rest-id.js | 86 +++++++ .../class/dstr/gen-meth-ary-ptrn-rest-init-ary.js | 82 ++++++ .../class/dstr/gen-meth-ary-ptrn-rest-init-id.js | 82 ++++++ .../class/dstr/gen-meth-ary-ptrn-rest-init-obj.js | 82 ++++++ .../dstr/gen-meth-ary-ptrn-rest-not-final-ary.js | 82 ++++++ .../dstr/gen-meth-ary-ptrn-rest-not-final-id.js | 82 ++++++ .../dstr/gen-meth-ary-ptrn-rest-not-final-obj.js | 82 ++++++ .../class/dstr/gen-meth-ary-ptrn-rest-obj-id.js | 86 +++++++ .../dstr/gen-meth-ary-ptrn-rest-obj-prop-id.js | 93 +++++++ .../dstr/gen-meth-dflt-ary-init-iter-close.js | 96 +++++++ ...h-dflt-ary-init-iter-get-err-array-prototype.js | 89 +++++++ .../dstr/gen-meth-dflt-ary-init-iter-get-err.js | 83 ++++++ .../dstr/gen-meth-dflt-ary-init-iter-no-close.js | 96 +++++++ .../class/dstr/gen-meth-dflt-ary-name-iter-val.js | 95 +++++++ .../gen-meth-dflt-ary-ptrn-elem-ary-elem-init.js | 87 +++++++ .../gen-meth-dflt-ary-ptrn-elem-ary-elem-iter.js | 88 +++++++ ...gen-meth-dflt-ary-ptrn-elem-ary-elision-init.js | 94 +++++++ ...gen-meth-dflt-ary-ptrn-elem-ary-elision-iter.js | 91 +++++++ .../gen-meth-dflt-ary-ptrn-elem-ary-empty-init.js | 90 +++++++ .../gen-meth-dflt-ary-ptrn-elem-ary-empty-iter.js | 87 +++++++ .../gen-meth-dflt-ary-ptrn-elem-ary-rest-init.js | 91 +++++++ .../gen-meth-dflt-ary-ptrn-elem-ary-rest-iter.js | 94 +++++++ .../gen-meth-dflt-ary-ptrn-elem-ary-val-null.js | 90 +++++++ ...en-meth-dflt-ary-ptrn-elem-id-init-exhausted.js | 86 +++++++ ...eth-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js | 87 +++++++ ...eth-dflt-ary-ptrn-elem-id-init-fn-name-class.js | 89 +++++++ ...eth-dflt-ary-ptrn-elem-id-init-fn-name-cover.js | 88 +++++++ ...n-meth-dflt-ary-ptrn-elem-id-init-fn-name-fn.js | 88 +++++++ ...-meth-dflt-ary-ptrn-elem-id-init-fn-name-gen.js | 89 +++++++ .../gen-meth-dflt-ary-ptrn-elem-id-init-hole.js | 82 ++++++ .../gen-meth-dflt-ary-ptrn-elem-id-init-skipped.js | 91 +++++++ .../gen-meth-dflt-ary-ptrn-elem-id-init-throws.js | 81 ++++++ .../gen-meth-dflt-ary-ptrn-elem-id-init-undef.js | 85 +++++++ ...meth-dflt-ary-ptrn-elem-id-init-unresolvable.js | 88 +++++++ ...gen-meth-dflt-ary-ptrn-elem-id-iter-complete.js | 89 +++++++ .../gen-meth-dflt-ary-ptrn-elem-id-iter-done.js | 84 ++++++ ...gen-meth-dflt-ary-ptrn-elem-id-iter-step-err.js | 90 +++++++ ...lt-ary-ptrn-elem-id-iter-val-array-prototype.js | 105 ++++++++ .../gen-meth-dflt-ary-ptrn-elem-id-iter-val-err.js | 101 ++++++++ .../gen-meth-dflt-ary-ptrn-elem-id-iter-val.js | 95 +++++++ .../gen-meth-dflt-ary-ptrn-elem-obj-id-init.js | 87 +++++++ .../dstr/gen-meth-dflt-ary-ptrn-elem-obj-id.js | 87 +++++++ ...gen-meth-dflt-ary-ptrn-elem-obj-prop-id-init.js | 97 +++++++ .../gen-meth-dflt-ary-ptrn-elem-obj-prop-id.js | 97 +++++++ .../gen-meth-dflt-ary-ptrn-elem-obj-val-null.js | 90 +++++++ .../gen-meth-dflt-ary-ptrn-elem-obj-val-undef.js | 90 +++++++ .../gen-meth-dflt-ary-ptrn-elision-exhausted.js | 92 +++++++ .../gen-meth-dflt-ary-ptrn-elision-step-err.js | 97 +++++++ .../class/dstr/gen-meth-dflt-ary-ptrn-elision.js | 101 ++++++++ .../class/dstr/gen-meth-dflt-ary-ptrn-empty.js | 84 ++++++ .../dstr/gen-meth-dflt-ary-ptrn-rest-ary-elem.js | 108 ++++++++ .../gen-meth-dflt-ary-ptrn-rest-ary-elision.js | 114 +++++++++ .../dstr/gen-meth-dflt-ary-ptrn-rest-ary-empty.js | 97 +++++++ .../dstr/gen-meth-dflt-ary-ptrn-rest-ary-rest.js | 93 +++++++ .../dstr/gen-meth-dflt-ary-ptrn-rest-id-direct.js | 88 +++++++ ...-meth-dflt-ary-ptrn-rest-id-elision-next-err.js | 83 ++++++ .../dstr/gen-meth-dflt-ary-ptrn-rest-id-elision.js | 89 +++++++ .../gen-meth-dflt-ary-ptrn-rest-id-exhausted.js | 85 +++++++ ...gen-meth-dflt-ary-ptrn-rest-id-iter-step-err.js | 94 +++++++ .../gen-meth-dflt-ary-ptrn-rest-id-iter-val-err.js | 96 +++++++ .../class/dstr/gen-meth-dflt-ary-ptrn-rest-id.js | 86 +++++++ .../dstr/gen-meth-dflt-ary-ptrn-rest-init-ary.js | 82 ++++++ .../dstr/gen-meth-dflt-ary-ptrn-rest-init-id.js | 82 ++++++ .../dstr/gen-meth-dflt-ary-ptrn-rest-init-obj.js | 82 ++++++ .../gen-meth-dflt-ary-ptrn-rest-not-final-ary.js | 82 ++++++ .../gen-meth-dflt-ary-ptrn-rest-not-final-id.js | 82 ++++++ .../gen-meth-dflt-ary-ptrn-rest-not-final-obj.js | 82 ++++++ .../dstr/gen-meth-dflt-ary-ptrn-rest-obj-id.js | 86 +++++++ .../gen-meth-dflt-ary-ptrn-rest-obj-prop-id.js | 93 +++++++ .../class/dstr/gen-meth-dflt-obj-init-null.js | 77 ++++++ .../class/dstr/gen-meth-dflt-obj-init-undefined.js | 77 ++++++ .../class/dstr/gen-meth-dflt-obj-ptrn-empty.js | 85 +++++++ .../gen-meth-dflt-obj-ptrn-id-get-value-err.js | 84 ++++++ ...gen-meth-dflt-obj-ptrn-id-init-fn-name-arrow.js | 86 +++++++ ...gen-meth-dflt-obj-ptrn-id-init-fn-name-class.js | 88 +++++++ ...gen-meth-dflt-obj-ptrn-id-init-fn-name-cover.js | 87 +++++++ .../gen-meth-dflt-obj-ptrn-id-init-fn-name-fn.js | 87 +++++++ .../gen-meth-dflt-obj-ptrn-id-init-fn-name-gen.js | 88 +++++++ .../dstr/gen-meth-dflt-obj-ptrn-id-init-skipped.js | 90 +++++++ .../dstr/gen-meth-dflt-obj-ptrn-id-init-throws.js | 84 ++++++ .../gen-meth-dflt-obj-ptrn-id-init-unresolvable.js | 88 +++++++ .../gen-meth-dflt-obj-ptrn-id-trailing-comma.js | 80 ++++++ .../class/dstr/gen-meth-dflt-obj-ptrn-list-err.js | 85 +++++++ .../dstr/gen-meth-dflt-obj-ptrn-prop-ary-init.js | 89 +++++++ ...n-meth-dflt-obj-ptrn-prop-ary-trailing-comma.js | 80 ++++++ .../gen-meth-dflt-obj-ptrn-prop-ary-value-null.js | 79 ++++++ .../class/dstr/gen-meth-dflt-obj-ptrn-prop-ary.js | 87 +++++++ .../dstr/gen-meth-dflt-obj-ptrn-prop-eval-err.js | 81 ++++++ ...gen-meth-dflt-obj-ptrn-prop-id-get-value-err.js | 86 +++++++ .../gen-meth-dflt-obj-ptrn-prop-id-init-skipped.js | 102 ++++++++ .../gen-meth-dflt-obj-ptrn-prop-id-init-throws.js | 84 ++++++ ...meth-dflt-obj-ptrn-prop-id-init-unresolvable.js | 88 +++++++ .../dstr/gen-meth-dflt-obj-ptrn-prop-id-init.js | 83 ++++++ ...en-meth-dflt-obj-ptrn-prop-id-trailing-comma.js | 84 ++++++ .../class/dstr/gen-meth-dflt-obj-ptrn-prop-id.js | 83 ++++++ .../dstr/gen-meth-dflt-obj-ptrn-prop-obj-init.js | 89 +++++++ .../gen-meth-dflt-obj-ptrn-prop-obj-value-null.js | 79 ++++++ .../gen-meth-dflt-obj-ptrn-prop-obj-value-undef.js | 79 ++++++ .../class/dstr/gen-meth-dflt-obj-ptrn-prop-obj.js | 87 +++++++ .../dstr/gen-meth-dflt-obj-ptrn-rest-getter.js | 82 ++++++ ...-meth-dflt-obj-ptrn-rest-skip-non-enumerable.js | 90 +++++++ .../dstr/gen-meth-dflt-obj-ptrn-rest-val-obj.js | 89 +++++++ .../class/dstr/gen-meth-obj-init-null.js | 77 ++++++ .../class/dstr/gen-meth-obj-init-undefined.js | 77 ++++++ .../class/dstr/gen-meth-obj-ptrn-empty.js | 85 +++++++ .../dstr/gen-meth-obj-ptrn-id-get-value-err.js | 84 ++++++ .../gen-meth-obj-ptrn-id-init-fn-name-arrow.js | 86 +++++++ .../gen-meth-obj-ptrn-id-init-fn-name-class.js | 88 +++++++ .../gen-meth-obj-ptrn-id-init-fn-name-cover.js | 87 +++++++ .../dstr/gen-meth-obj-ptrn-id-init-fn-name-fn.js | 87 +++++++ .../dstr/gen-meth-obj-ptrn-id-init-fn-name-gen.js | 88 +++++++ .../dstr/gen-meth-obj-ptrn-id-init-skipped.js | 90 +++++++ .../class/dstr/gen-meth-obj-ptrn-id-init-throws.js | 84 ++++++ .../dstr/gen-meth-obj-ptrn-id-init-unresolvable.js | 88 +++++++ .../dstr/gen-meth-obj-ptrn-id-trailing-comma.js | 80 ++++++ .../class/dstr/gen-meth-obj-ptrn-list-err.js | 85 +++++++ .../class/dstr/gen-meth-obj-ptrn-prop-ary-init.js | 89 +++++++ .../gen-meth-obj-ptrn-prop-ary-trailing-comma.js | 80 ++++++ .../dstr/gen-meth-obj-ptrn-prop-ary-value-null.js | 79 ++++++ .../class/dstr/gen-meth-obj-ptrn-prop-ary.js | 87 +++++++ .../class/dstr/gen-meth-obj-ptrn-prop-eval-err.js | 81 ++++++ .../gen-meth-obj-ptrn-prop-id-get-value-err.js | 86 +++++++ .../dstr/gen-meth-obj-ptrn-prop-id-init-skipped.js | 102 ++++++++ .../dstr/gen-meth-obj-ptrn-prop-id-init-throws.js | 84 ++++++ .../gen-meth-obj-ptrn-prop-id-init-unresolvable.js | 88 +++++++ .../class/dstr/gen-meth-obj-ptrn-prop-id-init.js | 83 ++++++ .../gen-meth-obj-ptrn-prop-id-trailing-comma.js | 84 ++++++ .../class/dstr/gen-meth-obj-ptrn-prop-id.js | 83 ++++++ .../class/dstr/gen-meth-obj-ptrn-prop-obj-init.js | 89 +++++++ .../dstr/gen-meth-obj-ptrn-prop-obj-value-null.js | 79 ++++++ .../dstr/gen-meth-obj-ptrn-prop-obj-value-undef.js | 79 ++++++ .../class/dstr/gen-meth-obj-ptrn-prop-obj.js | 87 +++++++ .../class/dstr/gen-meth-obj-ptrn-rest-getter.js | 82 ++++++ .../gen-meth-obj-ptrn-rest-skip-non-enumerable.js | 90 +++++++ .../class/dstr/gen-meth-obj-ptrn-rest-val-obj.js | 89 +++++++ .../dstr/gen-meth-static-ary-init-iter-close.js | 96 +++++++ ...static-ary-init-iter-get-err-array-prototype.js | 88 +++++++ .../dstr/gen-meth-static-ary-init-iter-get-err.js | 82 ++++++ .../dstr/gen-meth-static-ary-init-iter-no-close.js | 96 +++++++ .../dstr/gen-meth-static-ary-name-iter-val.js | 95 +++++++ .../gen-meth-static-ary-ptrn-elem-ary-elem-init.js | 87 +++++++ .../gen-meth-static-ary-ptrn-elem-ary-elem-iter.js | 88 +++++++ ...n-meth-static-ary-ptrn-elem-ary-elision-init.js | 94 +++++++ ...n-meth-static-ary-ptrn-elem-ary-elision-iter.js | 91 +++++++ ...gen-meth-static-ary-ptrn-elem-ary-empty-init.js | 90 +++++++ ...gen-meth-static-ary-ptrn-elem-ary-empty-iter.js | 87 +++++++ .../gen-meth-static-ary-ptrn-elem-ary-rest-init.js | 91 +++++++ .../gen-meth-static-ary-ptrn-elem-ary-rest-iter.js | 94 +++++++ .../gen-meth-static-ary-ptrn-elem-ary-val-null.js | 89 +++++++ ...-meth-static-ary-ptrn-elem-id-init-exhausted.js | 86 +++++++ ...h-static-ary-ptrn-elem-id-init-fn-name-arrow.js | 87 +++++++ ...h-static-ary-ptrn-elem-id-init-fn-name-class.js | 89 +++++++ ...h-static-ary-ptrn-elem-id-init-fn-name-cover.js | 88 +++++++ ...meth-static-ary-ptrn-elem-id-init-fn-name-fn.js | 88 +++++++ ...eth-static-ary-ptrn-elem-id-init-fn-name-gen.js | 89 +++++++ .../gen-meth-static-ary-ptrn-elem-id-init-hole.js | 82 ++++++ ...en-meth-static-ary-ptrn-elem-id-init-skipped.js | 91 +++++++ ...gen-meth-static-ary-ptrn-elem-id-init-throws.js | 80 ++++++ .../gen-meth-static-ary-ptrn-elem-id-init-undef.js | 85 +++++++ ...th-static-ary-ptrn-elem-id-init-unresolvable.js | 87 +++++++ ...n-meth-static-ary-ptrn-elem-id-iter-complete.js | 89 +++++++ .../gen-meth-static-ary-ptrn-elem-id-iter-done.js | 84 ++++++ ...n-meth-static-ary-ptrn-elem-id-iter-step-err.js | 89 +++++++ ...ic-ary-ptrn-elem-id-iter-val-array-prototype.js | 105 ++++++++ ...en-meth-static-ary-ptrn-elem-id-iter-val-err.js | 100 ++++++++ .../gen-meth-static-ary-ptrn-elem-id-iter-val.js | 95 +++++++ .../gen-meth-static-ary-ptrn-elem-obj-id-init.js | 87 +++++++ .../dstr/gen-meth-static-ary-ptrn-elem-obj-id.js | 87 +++++++ ...n-meth-static-ary-ptrn-elem-obj-prop-id-init.js | 97 +++++++ .../gen-meth-static-ary-ptrn-elem-obj-prop-id.js | 97 +++++++ .../gen-meth-static-ary-ptrn-elem-obj-val-null.js | 89 +++++++ .../gen-meth-static-ary-ptrn-elem-obj-val-undef.js | 89 +++++++ .../gen-meth-static-ary-ptrn-elision-exhausted.js | 92 +++++++ .../gen-meth-static-ary-ptrn-elision-step-err.js | 96 +++++++ .../class/dstr/gen-meth-static-ary-ptrn-elision.js | 101 ++++++++ .../class/dstr/gen-meth-static-ary-ptrn-empty.js | 84 ++++++ .../dstr/gen-meth-static-ary-ptrn-rest-ary-elem.js | 108 ++++++++ .../gen-meth-static-ary-ptrn-rest-ary-elision.js | 114 +++++++++ .../gen-meth-static-ary-ptrn-rest-ary-empty.js | 97 +++++++ .../dstr/gen-meth-static-ary-ptrn-rest-ary-rest.js | 93 +++++++ .../gen-meth-static-ary-ptrn-rest-id-direct.js | 88 +++++++ ...eth-static-ary-ptrn-rest-id-elision-next-err.js | 82 ++++++ .../gen-meth-static-ary-ptrn-rest-id-elision.js | 89 +++++++ .../gen-meth-static-ary-ptrn-rest-id-exhausted.js | 85 +++++++ ...n-meth-static-ary-ptrn-rest-id-iter-step-err.js | 93 +++++++ ...en-meth-static-ary-ptrn-rest-id-iter-val-err.js | 95 +++++++ .../class/dstr/gen-meth-static-ary-ptrn-rest-id.js | 86 +++++++ .../dstr/gen-meth-static-ary-ptrn-rest-init-ary.js | 82 ++++++ .../dstr/gen-meth-static-ary-ptrn-rest-init-id.js | 82 ++++++ .../dstr/gen-meth-static-ary-ptrn-rest-init-obj.js | 82 ++++++ .../gen-meth-static-ary-ptrn-rest-not-final-ary.js | 82 ++++++ .../gen-meth-static-ary-ptrn-rest-not-final-id.js | 82 ++++++ .../gen-meth-static-ary-ptrn-rest-not-final-obj.js | 82 ++++++ .../dstr/gen-meth-static-ary-ptrn-rest-obj-id.js | 86 +++++++ .../gen-meth-static-ary-ptrn-rest-obj-prop-id.js | 93 +++++++ .../gen-meth-static-dflt-ary-init-iter-close.js | 96 +++++++ ...c-dflt-ary-init-iter-get-err-array-prototype.js | 88 +++++++ .../gen-meth-static-dflt-ary-init-iter-get-err.js | 82 ++++++ .../gen-meth-static-dflt-ary-init-iter-no-close.js | 96 +++++++ .../dstr/gen-meth-static-dflt-ary-name-iter-val.js | 95 +++++++ ...meth-static-dflt-ary-ptrn-elem-ary-elem-init.js | 87 +++++++ ...meth-static-dflt-ary-ptrn-elem-ary-elem-iter.js | 88 +++++++ ...h-static-dflt-ary-ptrn-elem-ary-elision-init.js | 94 +++++++ ...h-static-dflt-ary-ptrn-elem-ary-elision-iter.js | 91 +++++++ ...eth-static-dflt-ary-ptrn-elem-ary-empty-init.js | 90 +++++++ ...eth-static-dflt-ary-ptrn-elem-ary-empty-iter.js | 87 +++++++ ...meth-static-dflt-ary-ptrn-elem-ary-rest-init.js | 91 +++++++ ...meth-static-dflt-ary-ptrn-elem-ary-rest-iter.js | 94 +++++++ ...-meth-static-dflt-ary-ptrn-elem-ary-val-null.js | 89 +++++++ ...-static-dflt-ary-ptrn-elem-id-init-exhausted.js | 86 +++++++ ...tic-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js | 87 +++++++ ...tic-dflt-ary-ptrn-elem-id-init-fn-name-class.js | 89 +++++++ ...tic-dflt-ary-ptrn-elem-id-init-fn-name-cover.js | 88 +++++++ ...static-dflt-ary-ptrn-elem-id-init-fn-name-fn.js | 88 +++++++ ...tatic-dflt-ary-ptrn-elem-id-init-fn-name-gen.js | 89 +++++++ ...-meth-static-dflt-ary-ptrn-elem-id-init-hole.js | 82 ++++++ ...th-static-dflt-ary-ptrn-elem-id-init-skipped.js | 91 +++++++ ...eth-static-dflt-ary-ptrn-elem-id-init-throws.js | 80 ++++++ ...meth-static-dflt-ary-ptrn-elem-id-init-undef.js | 85 +++++++ ...atic-dflt-ary-ptrn-elem-id-init-unresolvable.js | 87 +++++++ ...h-static-dflt-ary-ptrn-elem-id-iter-complete.js | 89 +++++++ ...-meth-static-dflt-ary-ptrn-elem-id-iter-done.js | 84 ++++++ ...h-static-dflt-ary-ptrn-elem-id-iter-step-err.js | 89 +++++++ ...lt-ary-ptrn-elem-id-iter-val-array-prototype.js | 105 ++++++++ ...th-static-dflt-ary-ptrn-elem-id-iter-val-err.js | 100 ++++++++ ...n-meth-static-dflt-ary-ptrn-elem-id-iter-val.js | 95 +++++++ ...n-meth-static-dflt-ary-ptrn-elem-obj-id-init.js | 87 +++++++ .../gen-meth-static-dflt-ary-ptrn-elem-obj-id.js | 87 +++++++ ...h-static-dflt-ary-ptrn-elem-obj-prop-id-init.js | 97 +++++++ ...n-meth-static-dflt-ary-ptrn-elem-obj-prop-id.js | 97 +++++++ ...-meth-static-dflt-ary-ptrn-elem-obj-val-null.js | 89 +++++++ ...meth-static-dflt-ary-ptrn-elem-obj-val-undef.js | 89 +++++++ ...-meth-static-dflt-ary-ptrn-elision-exhausted.js | 92 +++++++ ...n-meth-static-dflt-ary-ptrn-elision-step-err.js | 96 +++++++ .../dstr/gen-meth-static-dflt-ary-ptrn-elision.js | 101 ++++++++ .../dstr/gen-meth-static-dflt-ary-ptrn-empty.js | 84 ++++++ .../gen-meth-static-dflt-ary-ptrn-rest-ary-elem.js | 108 ++++++++ ...n-meth-static-dflt-ary-ptrn-rest-ary-elision.js | 114 +++++++++ ...gen-meth-static-dflt-ary-ptrn-rest-ary-empty.js | 97 +++++++ .../gen-meth-static-dflt-ary-ptrn-rest-ary-rest.js | 93 +++++++ ...gen-meth-static-dflt-ary-ptrn-rest-id-direct.js | 88 +++++++ ...tatic-dflt-ary-ptrn-rest-id-elision-next-err.js | 82 ++++++ ...en-meth-static-dflt-ary-ptrn-rest-id-elision.js | 89 +++++++ ...-meth-static-dflt-ary-ptrn-rest-id-exhausted.js | 85 +++++++ ...h-static-dflt-ary-ptrn-rest-id-iter-step-err.js | 93 +++++++ ...th-static-dflt-ary-ptrn-rest-id-iter-val-err.js | 95 +++++++ .../dstr/gen-meth-static-dflt-ary-ptrn-rest-id.js | 86 +++++++ .../gen-meth-static-dflt-ary-ptrn-rest-init-ary.js | 82 ++++++ .../gen-meth-static-dflt-ary-ptrn-rest-init-id.js | 82 ++++++ .../gen-meth-static-dflt-ary-ptrn-rest-init-obj.js | 82 ++++++ ...meth-static-dflt-ary-ptrn-rest-not-final-ary.js | 82 ++++++ ...-meth-static-dflt-ary-ptrn-rest-not-final-id.js | 82 ++++++ ...meth-static-dflt-ary-ptrn-rest-not-final-obj.js | 82 ++++++ .../gen-meth-static-dflt-ary-ptrn-rest-obj-id.js | 86 +++++++ ...n-meth-static-dflt-ary-ptrn-rest-obj-prop-id.js | 93 +++++++ .../dstr/gen-meth-static-dflt-obj-init-null.js | 76 ++++++ .../gen-meth-static-dflt-obj-init-undefined.js | 76 ++++++ .../dstr/gen-meth-static-dflt-obj-ptrn-empty.js | 85 +++++++ ...n-meth-static-dflt-obj-ptrn-id-get-value-err.js | 83 ++++++ ...h-static-dflt-obj-ptrn-id-init-fn-name-arrow.js | 86 +++++++ ...h-static-dflt-obj-ptrn-id-init-fn-name-class.js | 88 +++++++ ...h-static-dflt-obj-ptrn-id-init-fn-name-cover.js | 87 +++++++ ...meth-static-dflt-obj-ptrn-id-init-fn-name-fn.js | 87 +++++++ ...eth-static-dflt-obj-ptrn-id-init-fn-name-gen.js | 88 +++++++ ...en-meth-static-dflt-obj-ptrn-id-init-skipped.js | 90 +++++++ ...gen-meth-static-dflt-obj-ptrn-id-init-throws.js | 83 ++++++ ...th-static-dflt-obj-ptrn-id-init-unresolvable.js | 87 +++++++ ...-meth-static-dflt-obj-ptrn-id-trailing-comma.js | 80 ++++++ .../dstr/gen-meth-static-dflt-obj-ptrn-list-err.js | 84 ++++++ .../gen-meth-static-dflt-obj-ptrn-prop-ary-init.js | 89 +++++++ ...static-dflt-obj-ptrn-prop-ary-trailing-comma.js | 80 ++++++ ...eth-static-dflt-obj-ptrn-prop-ary-value-null.js | 78 ++++++ .../dstr/gen-meth-static-dflt-obj-ptrn-prop-ary.js | 87 +++++++ .../gen-meth-static-dflt-obj-ptrn-prop-eval-err.js | 80 ++++++ ...h-static-dflt-obj-ptrn-prop-id-get-value-err.js | 85 +++++++ ...th-static-dflt-obj-ptrn-prop-id-init-skipped.js | 102 ++++++++ ...eth-static-dflt-obj-ptrn-prop-id-init-throws.js | 83 ++++++ ...atic-dflt-obj-ptrn-prop-id-init-unresolvable.js | 87 +++++++ .../gen-meth-static-dflt-obj-ptrn-prop-id-init.js | 83 ++++++ ...-static-dflt-obj-ptrn-prop-id-trailing-comma.js | 84 ++++++ .../dstr/gen-meth-static-dflt-obj-ptrn-prop-id.js | 83 ++++++ .../gen-meth-static-dflt-obj-ptrn-prop-obj-init.js | 89 +++++++ ...eth-static-dflt-obj-ptrn-prop-obj-value-null.js | 78 ++++++ ...th-static-dflt-obj-ptrn-prop-obj-value-undef.js | 78 ++++++ .../dstr/gen-meth-static-dflt-obj-ptrn-prop-obj.js | 87 +++++++ .../gen-meth-static-dflt-obj-ptrn-rest-getter.js | 82 ++++++ ...tatic-dflt-obj-ptrn-rest-skip-non-enumerable.js | 90 +++++++ .../gen-meth-static-dflt-obj-ptrn-rest-val-obj.js | 89 +++++++ .../class/dstr/gen-meth-static-obj-init-null.js | 76 ++++++ .../dstr/gen-meth-static-obj-init-undefined.js | 76 ++++++ .../class/dstr/gen-meth-static-obj-ptrn-empty.js | 85 +++++++ .../gen-meth-static-obj-ptrn-id-get-value-err.js | 83 ++++++ ...n-meth-static-obj-ptrn-id-init-fn-name-arrow.js | 86 +++++++ ...n-meth-static-obj-ptrn-id-init-fn-name-class.js | 88 +++++++ ...n-meth-static-obj-ptrn-id-init-fn-name-cover.js | 87 +++++++ .../gen-meth-static-obj-ptrn-id-init-fn-name-fn.js | 87 +++++++ ...gen-meth-static-obj-ptrn-id-init-fn-name-gen.js | 88 +++++++ .../gen-meth-static-obj-ptrn-id-init-skipped.js | 90 +++++++ .../gen-meth-static-obj-ptrn-id-init-throws.js | 83 ++++++ ...en-meth-static-obj-ptrn-id-init-unresolvable.js | 87 +++++++ .../gen-meth-static-obj-ptrn-id-trailing-comma.js | 80 ++++++ .../dstr/gen-meth-static-obj-ptrn-list-err.js | 84 ++++++ .../dstr/gen-meth-static-obj-ptrn-prop-ary-init.js | 89 +++++++ ...meth-static-obj-ptrn-prop-ary-trailing-comma.js | 80 ++++++ ...gen-meth-static-obj-ptrn-prop-ary-value-null.js | 78 ++++++ .../dstr/gen-meth-static-obj-ptrn-prop-ary.js | 87 +++++++ .../dstr/gen-meth-static-obj-ptrn-prop-eval-err.js | 80 ++++++ ...n-meth-static-obj-ptrn-prop-id-get-value-err.js | 85 +++++++ ...en-meth-static-obj-ptrn-prop-id-init-skipped.js | 102 ++++++++ ...gen-meth-static-obj-ptrn-prop-id-init-throws.js | 83 ++++++ ...th-static-obj-ptrn-prop-id-init-unresolvable.js | 87 +++++++ .../dstr/gen-meth-static-obj-ptrn-prop-id-init.js | 83 ++++++ ...-meth-static-obj-ptrn-prop-id-trailing-comma.js | 84 ++++++ .../class/dstr/gen-meth-static-obj-ptrn-prop-id.js | 83 ++++++ .../dstr/gen-meth-static-obj-ptrn-prop-obj-init.js | 89 +++++++ ...gen-meth-static-obj-ptrn-prop-obj-value-null.js | 78 ++++++ ...en-meth-static-obj-ptrn-prop-obj-value-undef.js | 78 ++++++ .../dstr/gen-meth-static-obj-ptrn-prop-obj.js | 87 +++++++ .../dstr/gen-meth-static-obj-ptrn-rest-getter.js | 82 ++++++ ...eth-static-obj-ptrn-rest-skip-non-enumerable.js | 90 +++++++ .../dstr/gen-meth-static-obj-ptrn-rest-val-obj.js | 89 +++++++ .../class/dstr/meth-ary-init-iter-close.js | 94 +++++++ .../meth-ary-init-iter-get-err-array-prototype.js | 88 +++++++ .../class/dstr/meth-ary-init-iter-get-err.js | 82 ++++++ .../class/dstr/meth-ary-init-iter-no-close.js | 94 +++++++ .../class/dstr/meth-ary-name-iter-val.js | 93 +++++++ .../class/dstr/meth-ary-ptrn-elem-ary-elem-init.js | 85 +++++++ .../class/dstr/meth-ary-ptrn-elem-ary-elem-iter.js | 86 +++++++ .../dstr/meth-ary-ptrn-elem-ary-elision-init.js | 92 +++++++ .../dstr/meth-ary-ptrn-elem-ary-elision-iter.js | 89 +++++++ .../dstr/meth-ary-ptrn-elem-ary-empty-init.js | 88 +++++++ .../dstr/meth-ary-ptrn-elem-ary-empty-iter.js | 85 +++++++ .../class/dstr/meth-ary-ptrn-elem-ary-rest-init.js | 89 +++++++ .../class/dstr/meth-ary-ptrn-elem-ary-rest-iter.js | 92 +++++++ .../class/dstr/meth-ary-ptrn-elem-ary-val-null.js | 89 +++++++ .../dstr/meth-ary-ptrn-elem-id-init-exhausted.js | 84 ++++++ .../meth-ary-ptrn-elem-id-init-fn-name-arrow.js | 85 +++++++ .../meth-ary-ptrn-elem-id-init-fn-name-class.js | 87 +++++++ .../meth-ary-ptrn-elem-id-init-fn-name-cover.js | 86 +++++++ .../dstr/meth-ary-ptrn-elem-id-init-fn-name-fn.js | 86 +++++++ .../dstr/meth-ary-ptrn-elem-id-init-fn-name-gen.js | 87 +++++++ .../class/dstr/meth-ary-ptrn-elem-id-init-hole.js | 80 ++++++ .../dstr/meth-ary-ptrn-elem-id-init-skipped.js | 89 +++++++ .../dstr/meth-ary-ptrn-elem-id-init-throws.js | 80 ++++++ .../class/dstr/meth-ary-ptrn-elem-id-init-undef.js | 83 ++++++ .../meth-ary-ptrn-elem-id-init-unresolvable.js | 87 +++++++ .../dstr/meth-ary-ptrn-elem-id-iter-complete.js | 87 +++++++ .../class/dstr/meth-ary-ptrn-elem-id-iter-done.js | 82 ++++++ .../dstr/meth-ary-ptrn-elem-id-iter-step-err.js | 89 +++++++ ...th-ary-ptrn-elem-id-iter-val-array-prototype.js | 103 ++++++++ .../dstr/meth-ary-ptrn-elem-id-iter-val-err.js | 100 ++++++++ .../class/dstr/meth-ary-ptrn-elem-id-iter-val.js | 93 +++++++ .../class/dstr/meth-ary-ptrn-elem-obj-id-init.js | 85 +++++++ .../class/dstr/meth-ary-ptrn-elem-obj-id.js | 85 +++++++ .../dstr/meth-ary-ptrn-elem-obj-prop-id-init.js | 95 +++++++ .../class/dstr/meth-ary-ptrn-elem-obj-prop-id.js | 95 +++++++ .../class/dstr/meth-ary-ptrn-elem-obj-val-null.js | 89 +++++++ .../class/dstr/meth-ary-ptrn-elem-obj-val-undef.js | 89 +++++++ .../class/dstr/meth-ary-ptrn-elision-exhausted.js | 90 +++++++ .../class/dstr/meth-ary-ptrn-elision-step-err.js | 96 +++++++ .../statements/class/dstr/meth-ary-ptrn-elision.js | 99 ++++++++ .../statements/class/dstr/meth-ary-ptrn-empty.js | 82 ++++++ .../class/dstr/meth-ary-ptrn-rest-ary-elem.js | 106 ++++++++ .../class/dstr/meth-ary-ptrn-rest-ary-elision.js | 112 ++++++++ .../class/dstr/meth-ary-ptrn-rest-ary-empty.js | 95 +++++++ .../class/dstr/meth-ary-ptrn-rest-ary-rest.js | 91 +++++++ .../class/dstr/meth-ary-ptrn-rest-id-direct.js | 86 +++++++ .../dstr/meth-ary-ptrn-rest-id-elision-next-err.js | 82 ++++++ .../class/dstr/meth-ary-ptrn-rest-id-elision.js | 87 +++++++ .../class/dstr/meth-ary-ptrn-rest-id-exhausted.js | 83 ++++++ .../dstr/meth-ary-ptrn-rest-id-iter-step-err.js | 93 +++++++ .../dstr/meth-ary-ptrn-rest-id-iter-val-err.js | 95 +++++++ .../statements/class/dstr/meth-ary-ptrn-rest-id.js | 84 ++++++ .../class/dstr/meth-ary-ptrn-rest-init-ary.js | 80 ++++++ .../class/dstr/meth-ary-ptrn-rest-init-id.js | 80 ++++++ .../class/dstr/meth-ary-ptrn-rest-init-obj.js | 80 ++++++ .../class/dstr/meth-ary-ptrn-rest-not-final-ary.js | 80 ++++++ .../class/dstr/meth-ary-ptrn-rest-not-final-id.js | 80 ++++++ .../class/dstr/meth-ary-ptrn-rest-not-final-obj.js | 80 ++++++ .../class/dstr/meth-ary-ptrn-rest-obj-id.js | 84 ++++++ .../class/dstr/meth-ary-ptrn-rest-obj-prop-id.js | 91 +++++++ .../class/dstr/meth-dflt-ary-init-iter-close.js | 94 +++++++ ...h-dflt-ary-init-iter-get-err-array-prototype.js | 88 +++++++ .../class/dstr/meth-dflt-ary-init-iter-get-err.js | 82 ++++++ .../class/dstr/meth-dflt-ary-init-iter-no-close.js | 94 +++++++ .../class/dstr/meth-dflt-ary-name-iter-val.js | 93 +++++++ .../dstr/meth-dflt-ary-ptrn-elem-ary-elem-init.js | 85 +++++++ .../dstr/meth-dflt-ary-ptrn-elem-ary-elem-iter.js | 86 +++++++ .../meth-dflt-ary-ptrn-elem-ary-elision-init.js | 92 +++++++ .../meth-dflt-ary-ptrn-elem-ary-elision-iter.js | 89 +++++++ .../dstr/meth-dflt-ary-ptrn-elem-ary-empty-init.js | 88 +++++++ .../dstr/meth-dflt-ary-ptrn-elem-ary-empty-iter.js | 85 +++++++ .../dstr/meth-dflt-ary-ptrn-elem-ary-rest-init.js | 89 +++++++ .../dstr/meth-dflt-ary-ptrn-elem-ary-rest-iter.js | 92 +++++++ .../dstr/meth-dflt-ary-ptrn-elem-ary-val-null.js | 89 +++++++ .../meth-dflt-ary-ptrn-elem-id-init-exhausted.js | 84 ++++++ ...eth-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js | 85 +++++++ ...eth-dflt-ary-ptrn-elem-id-init-fn-name-class.js | 87 +++++++ ...eth-dflt-ary-ptrn-elem-id-init-fn-name-cover.js | 86 +++++++ .../meth-dflt-ary-ptrn-elem-id-init-fn-name-fn.js | 86 +++++++ .../meth-dflt-ary-ptrn-elem-id-init-fn-name-gen.js | 87 +++++++ .../dstr/meth-dflt-ary-ptrn-elem-id-init-hole.js | 80 ++++++ .../meth-dflt-ary-ptrn-elem-id-init-skipped.js | 89 +++++++ .../dstr/meth-dflt-ary-ptrn-elem-id-init-throws.js | 80 ++++++ .../dstr/meth-dflt-ary-ptrn-elem-id-init-undef.js | 83 ++++++ ...meth-dflt-ary-ptrn-elem-id-init-unresolvable.js | 87 +++++++ .../meth-dflt-ary-ptrn-elem-id-iter-complete.js | 87 +++++++ .../dstr/meth-dflt-ary-ptrn-elem-id-iter-done.js | 82 ++++++ .../meth-dflt-ary-ptrn-elem-id-iter-step-err.js | 89 +++++++ ...lt-ary-ptrn-elem-id-iter-val-array-prototype.js | 103 ++++++++ .../meth-dflt-ary-ptrn-elem-id-iter-val-err.js | 100 ++++++++ .../dstr/meth-dflt-ary-ptrn-elem-id-iter-val.js | 93 +++++++ .../dstr/meth-dflt-ary-ptrn-elem-obj-id-init.js | 85 +++++++ .../class/dstr/meth-dflt-ary-ptrn-elem-obj-id.js | 85 +++++++ .../meth-dflt-ary-ptrn-elem-obj-prop-id-init.js | 95 +++++++ .../dstr/meth-dflt-ary-ptrn-elem-obj-prop-id.js | 95 +++++++ .../dstr/meth-dflt-ary-ptrn-elem-obj-val-null.js | 89 +++++++ .../dstr/meth-dflt-ary-ptrn-elem-obj-val-undef.js | 89 +++++++ .../dstr/meth-dflt-ary-ptrn-elision-exhausted.js | 90 +++++++ .../dstr/meth-dflt-ary-ptrn-elision-step-err.js | 96 +++++++ .../class/dstr/meth-dflt-ary-ptrn-elision.js | 99 ++++++++ .../class/dstr/meth-dflt-ary-ptrn-empty.js | 82 ++++++ .../class/dstr/meth-dflt-ary-ptrn-rest-ary-elem.js | 106 ++++++++ .../dstr/meth-dflt-ary-ptrn-rest-ary-elision.js | 112 ++++++++ .../dstr/meth-dflt-ary-ptrn-rest-ary-empty.js | 95 +++++++ .../class/dstr/meth-dflt-ary-ptrn-rest-ary-rest.js | 91 +++++++ .../dstr/meth-dflt-ary-ptrn-rest-id-direct.js | 86 +++++++ .../meth-dflt-ary-ptrn-rest-id-elision-next-err.js | 82 ++++++ .../dstr/meth-dflt-ary-ptrn-rest-id-elision.js | 87 +++++++ .../dstr/meth-dflt-ary-ptrn-rest-id-exhausted.js | 83 ++++++ .../meth-dflt-ary-ptrn-rest-id-iter-step-err.js | 93 +++++++ .../meth-dflt-ary-ptrn-rest-id-iter-val-err.js | 95 +++++++ .../class/dstr/meth-dflt-ary-ptrn-rest-id.js | 84 ++++++ .../class/dstr/meth-dflt-ary-ptrn-rest-init-ary.js | 80 ++++++ .../class/dstr/meth-dflt-ary-ptrn-rest-init-id.js | 80 ++++++ .../class/dstr/meth-dflt-ary-ptrn-rest-init-obj.js | 80 ++++++ .../dstr/meth-dflt-ary-ptrn-rest-not-final-ary.js | 80 ++++++ .../dstr/meth-dflt-ary-ptrn-rest-not-final-id.js | 80 ++++++ .../dstr/meth-dflt-ary-ptrn-rest-not-final-obj.js | 80 ++++++ .../class/dstr/meth-dflt-ary-ptrn-rest-obj-id.js | 84 ++++++ .../dstr/meth-dflt-ary-ptrn-rest-obj-prop-id.js | 91 +++++++ .../class/dstr/meth-dflt-obj-init-null.js | 76 ++++++ .../class/dstr/meth-dflt-obj-init-undefined.js | 76 ++++++ .../class/dstr/meth-dflt-obj-ptrn-empty.js | 83 ++++++ .../dstr/meth-dflt-obj-ptrn-id-get-value-err.js | 83 ++++++ .../meth-dflt-obj-ptrn-id-init-fn-name-arrow.js | 84 ++++++ .../meth-dflt-obj-ptrn-id-init-fn-name-class.js | 86 +++++++ .../meth-dflt-obj-ptrn-id-init-fn-name-cover.js | 85 +++++++ .../dstr/meth-dflt-obj-ptrn-id-init-fn-name-fn.js | 85 +++++++ .../dstr/meth-dflt-obj-ptrn-id-init-fn-name-gen.js | 86 +++++++ .../dstr/meth-dflt-obj-ptrn-id-init-skipped.js | 88 +++++++ .../dstr/meth-dflt-obj-ptrn-id-init-throws.js | 83 ++++++ .../meth-dflt-obj-ptrn-id-init-unresolvable.js | 87 +++++++ .../dstr/meth-dflt-obj-ptrn-id-trailing-comma.js | 78 ++++++ .../class/dstr/meth-dflt-obj-ptrn-list-err.js | 84 ++++++ .../class/dstr/meth-dflt-obj-ptrn-prop-ary-init.js | 87 +++++++ .../meth-dflt-obj-ptrn-prop-ary-trailing-comma.js | 78 ++++++ .../dstr/meth-dflt-obj-ptrn-prop-ary-value-null.js | 78 ++++++ .../class/dstr/meth-dflt-obj-ptrn-prop-ary.js | 85 +++++++ .../class/dstr/meth-dflt-obj-ptrn-prop-eval-err.js | 80 ++++++ .../meth-dflt-obj-ptrn-prop-id-get-value-err.js | 85 +++++++ .../meth-dflt-obj-ptrn-prop-id-init-skipped.js | 100 ++++++++ .../dstr/meth-dflt-obj-ptrn-prop-id-init-throws.js | 83 ++++++ ...meth-dflt-obj-ptrn-prop-id-init-unresolvable.js | 87 +++++++ .../class/dstr/meth-dflt-obj-ptrn-prop-id-init.js | 81 ++++++ .../meth-dflt-obj-ptrn-prop-id-trailing-comma.js | 82 ++++++ .../class/dstr/meth-dflt-obj-ptrn-prop-id.js | 81 ++++++ .../class/dstr/meth-dflt-obj-ptrn-prop-obj-init.js | 87 +++++++ .../dstr/meth-dflt-obj-ptrn-prop-obj-value-null.js | 78 ++++++ .../meth-dflt-obj-ptrn-prop-obj-value-undef.js | 78 ++++++ .../class/dstr/meth-dflt-obj-ptrn-prop-obj.js | 85 +++++++ .../class/dstr/meth-dflt-obj-ptrn-rest-getter.js | 80 ++++++ .../meth-dflt-obj-ptrn-rest-skip-non-enumerable.js | 88 +++++++ .../class/dstr/meth-dflt-obj-ptrn-rest-val-obj.js | 87 +++++++ .../statements/class/dstr/meth-obj-init-null.js | 76 ++++++ .../class/dstr/meth-obj-init-undefined.js | 76 ++++++ .../statements/class/dstr/meth-obj-ptrn-empty.js | 83 ++++++ .../class/dstr/meth-obj-ptrn-id-get-value-err.js | 83 ++++++ .../dstr/meth-obj-ptrn-id-init-fn-name-arrow.js | 84 ++++++ .../dstr/meth-obj-ptrn-id-init-fn-name-class.js | 86 +++++++ .../dstr/meth-obj-ptrn-id-init-fn-name-cover.js | 85 +++++++ .../class/dstr/meth-obj-ptrn-id-init-fn-name-fn.js | 85 +++++++ .../dstr/meth-obj-ptrn-id-init-fn-name-gen.js | 86 +++++++ .../class/dstr/meth-obj-ptrn-id-init-skipped.js | 88 +++++++ .../class/dstr/meth-obj-ptrn-id-init-throws.js | 83 ++++++ .../dstr/meth-obj-ptrn-id-init-unresolvable.js | 87 +++++++ .../class/dstr/meth-obj-ptrn-id-trailing-comma.js | 78 ++++++ .../class/dstr/meth-obj-ptrn-list-err.js | 84 ++++++ .../class/dstr/meth-obj-ptrn-prop-ary-init.js | 87 +++++++ .../dstr/meth-obj-ptrn-prop-ary-trailing-comma.js | 78 ++++++ .../dstr/meth-obj-ptrn-prop-ary-value-null.js | 78 ++++++ .../class/dstr/meth-obj-ptrn-prop-ary.js | 85 +++++++ .../class/dstr/meth-obj-ptrn-prop-eval-err.js | 80 ++++++ .../dstr/meth-obj-ptrn-prop-id-get-value-err.js | 85 +++++++ .../dstr/meth-obj-ptrn-prop-id-init-skipped.js | 100 ++++++++ .../dstr/meth-obj-ptrn-prop-id-init-throws.js | 83 ++++++ .../meth-obj-ptrn-prop-id-init-unresolvable.js | 87 +++++++ .../class/dstr/meth-obj-ptrn-prop-id-init.js | 81 ++++++ .../dstr/meth-obj-ptrn-prop-id-trailing-comma.js | 82 ++++++ .../statements/class/dstr/meth-obj-ptrn-prop-id.js | 81 ++++++ .../class/dstr/meth-obj-ptrn-prop-obj-init.js | 87 +++++++ .../dstr/meth-obj-ptrn-prop-obj-value-null.js | 78 ++++++ .../dstr/meth-obj-ptrn-prop-obj-value-undef.js | 78 ++++++ .../class/dstr/meth-obj-ptrn-prop-obj.js | 85 +++++++ .../class/dstr/meth-obj-ptrn-rest-getter.js | 80 ++++++ .../dstr/meth-obj-ptrn-rest-skip-non-enumerable.js | 88 +++++++ .../class/dstr/meth-obj-ptrn-rest-val-obj.js | 87 +++++++ .../class/dstr/meth-static-ary-init-iter-close.js | 94 +++++++ ...static-ary-init-iter-get-err-array-prototype.js | 86 +++++++ .../dstr/meth-static-ary-init-iter-get-err.js | 80 ++++++ .../dstr/meth-static-ary-init-iter-no-close.js | 94 +++++++ .../class/dstr/meth-static-ary-name-iter-val.js | 93 +++++++ .../meth-static-ary-ptrn-elem-ary-elem-init.js | 85 +++++++ .../meth-static-ary-ptrn-elem-ary-elem-iter.js | 86 +++++++ .../meth-static-ary-ptrn-elem-ary-elision-init.js | 92 +++++++ .../meth-static-ary-ptrn-elem-ary-elision-iter.js | 89 +++++++ .../meth-static-ary-ptrn-elem-ary-empty-init.js | 88 +++++++ .../meth-static-ary-ptrn-elem-ary-empty-iter.js | 85 +++++++ .../meth-static-ary-ptrn-elem-ary-rest-init.js | 89 +++++++ .../meth-static-ary-ptrn-elem-ary-rest-iter.js | 92 +++++++ .../dstr/meth-static-ary-ptrn-elem-ary-val-null.js | 87 +++++++ .../meth-static-ary-ptrn-elem-id-init-exhausted.js | 84 ++++++ ...h-static-ary-ptrn-elem-id-init-fn-name-arrow.js | 85 +++++++ ...h-static-ary-ptrn-elem-id-init-fn-name-class.js | 87 +++++++ ...h-static-ary-ptrn-elem-id-init-fn-name-cover.js | 86 +++++++ ...meth-static-ary-ptrn-elem-id-init-fn-name-fn.js | 86 +++++++ ...eth-static-ary-ptrn-elem-id-init-fn-name-gen.js | 87 +++++++ .../dstr/meth-static-ary-ptrn-elem-id-init-hole.js | 80 ++++++ .../meth-static-ary-ptrn-elem-id-init-skipped.js | 89 +++++++ .../meth-static-ary-ptrn-elem-id-init-throws.js | 78 ++++++ .../meth-static-ary-ptrn-elem-id-init-undef.js | 83 ++++++ ...th-static-ary-ptrn-elem-id-init-unresolvable.js | 85 +++++++ .../meth-static-ary-ptrn-elem-id-iter-complete.js | 87 +++++++ .../dstr/meth-static-ary-ptrn-elem-id-iter-done.js | 82 ++++++ .../meth-static-ary-ptrn-elem-id-iter-step-err.js | 87 +++++++ ...ic-ary-ptrn-elem-id-iter-val-array-prototype.js | 103 ++++++++ .../meth-static-ary-ptrn-elem-id-iter-val-err.js | 98 +++++++ .../dstr/meth-static-ary-ptrn-elem-id-iter-val.js | 93 +++++++ .../dstr/meth-static-ary-ptrn-elem-obj-id-init.js | 85 +++++++ .../class/dstr/meth-static-ary-ptrn-elem-obj-id.js | 85 +++++++ .../meth-static-ary-ptrn-elem-obj-prop-id-init.js | 95 +++++++ .../dstr/meth-static-ary-ptrn-elem-obj-prop-id.js | 95 +++++++ .../dstr/meth-static-ary-ptrn-elem-obj-val-null.js | 87 +++++++ .../meth-static-ary-ptrn-elem-obj-val-undef.js | 87 +++++++ .../dstr/meth-static-ary-ptrn-elision-exhausted.js | 90 +++++++ .../dstr/meth-static-ary-ptrn-elision-step-err.js | 94 +++++++ .../class/dstr/meth-static-ary-ptrn-elision.js | 99 ++++++++ .../class/dstr/meth-static-ary-ptrn-empty.js | 82 ++++++ .../dstr/meth-static-ary-ptrn-rest-ary-elem.js | 106 ++++++++ .../dstr/meth-static-ary-ptrn-rest-ary-elision.js | 112 ++++++++ .../dstr/meth-static-ary-ptrn-rest-ary-empty.js | 95 +++++++ .../dstr/meth-static-ary-ptrn-rest-ary-rest.js | 91 +++++++ .../dstr/meth-static-ary-ptrn-rest-id-direct.js | 86 +++++++ ...eth-static-ary-ptrn-rest-id-elision-next-err.js | 80 ++++++ .../dstr/meth-static-ary-ptrn-rest-id-elision.js | 87 +++++++ .../dstr/meth-static-ary-ptrn-rest-id-exhausted.js | 83 ++++++ .../meth-static-ary-ptrn-rest-id-iter-step-err.js | 91 +++++++ .../meth-static-ary-ptrn-rest-id-iter-val-err.js | 93 +++++++ .../class/dstr/meth-static-ary-ptrn-rest-id.js | 84 ++++++ .../dstr/meth-static-ary-ptrn-rest-init-ary.js | 80 ++++++ .../dstr/meth-static-ary-ptrn-rest-init-id.js | 80 ++++++ .../dstr/meth-static-ary-ptrn-rest-init-obj.js | 80 ++++++ .../meth-static-ary-ptrn-rest-not-final-ary.js | 80 ++++++ .../dstr/meth-static-ary-ptrn-rest-not-final-id.js | 80 ++++++ .../meth-static-ary-ptrn-rest-not-final-obj.js | 80 ++++++ .../class/dstr/meth-static-ary-ptrn-rest-obj-id.js | 84 ++++++ .../dstr/meth-static-ary-ptrn-rest-obj-prop-id.js | 91 +++++++ .../dstr/meth-static-dflt-ary-init-iter-close.js | 94 +++++++ ...c-dflt-ary-init-iter-get-err-array-prototype.js | 86 +++++++ .../dstr/meth-static-dflt-ary-init-iter-get-err.js | 80 ++++++ .../meth-static-dflt-ary-init-iter-no-close.js | 94 +++++++ .../dstr/meth-static-dflt-ary-name-iter-val.js | 93 +++++++ ...meth-static-dflt-ary-ptrn-elem-ary-elem-init.js | 85 +++++++ ...meth-static-dflt-ary-ptrn-elem-ary-elem-iter.js | 86 +++++++ ...h-static-dflt-ary-ptrn-elem-ary-elision-init.js | 92 +++++++ ...h-static-dflt-ary-ptrn-elem-ary-elision-iter.js | 89 +++++++ ...eth-static-dflt-ary-ptrn-elem-ary-empty-init.js | 88 +++++++ ...eth-static-dflt-ary-ptrn-elem-ary-empty-iter.js | 85 +++++++ ...meth-static-dflt-ary-ptrn-elem-ary-rest-init.js | 89 +++++++ ...meth-static-dflt-ary-ptrn-elem-ary-rest-iter.js | 92 +++++++ .../meth-static-dflt-ary-ptrn-elem-ary-val-null.js | 87 +++++++ ...-static-dflt-ary-ptrn-elem-id-init-exhausted.js | 84 ++++++ ...tic-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js | 85 +++++++ ...tic-dflt-ary-ptrn-elem-id-init-fn-name-class.js | 87 +++++++ ...tic-dflt-ary-ptrn-elem-id-init-fn-name-cover.js | 86 +++++++ ...static-dflt-ary-ptrn-elem-id-init-fn-name-fn.js | 86 +++++++ ...tatic-dflt-ary-ptrn-elem-id-init-fn-name-gen.js | 87 +++++++ .../meth-static-dflt-ary-ptrn-elem-id-init-hole.js | 80 ++++++ ...th-static-dflt-ary-ptrn-elem-id-init-skipped.js | 89 +++++++ ...eth-static-dflt-ary-ptrn-elem-id-init-throws.js | 78 ++++++ ...meth-static-dflt-ary-ptrn-elem-id-init-undef.js | 83 ++++++ ...atic-dflt-ary-ptrn-elem-id-init-unresolvable.js | 85 +++++++ ...h-static-dflt-ary-ptrn-elem-id-iter-complete.js | 87 +++++++ .../meth-static-dflt-ary-ptrn-elem-id-iter-done.js | 82 ++++++ ...h-static-dflt-ary-ptrn-elem-id-iter-step-err.js | 87 +++++++ ...lt-ary-ptrn-elem-id-iter-val-array-prototype.js | 103 ++++++++ ...th-static-dflt-ary-ptrn-elem-id-iter-val-err.js | 98 +++++++ .../meth-static-dflt-ary-ptrn-elem-id-iter-val.js | 93 +++++++ .../meth-static-dflt-ary-ptrn-elem-obj-id-init.js | 85 +++++++ .../dstr/meth-static-dflt-ary-ptrn-elem-obj-id.js | 85 +++++++ ...h-static-dflt-ary-ptrn-elem-obj-prop-id-init.js | 95 +++++++ .../meth-static-dflt-ary-ptrn-elem-obj-prop-id.js | 95 +++++++ .../meth-static-dflt-ary-ptrn-elem-obj-val-null.js | 87 +++++++ ...meth-static-dflt-ary-ptrn-elem-obj-val-undef.js | 87 +++++++ .../meth-static-dflt-ary-ptrn-elision-exhausted.js | 90 +++++++ .../meth-static-dflt-ary-ptrn-elision-step-err.js | 94 +++++++ .../dstr/meth-static-dflt-ary-ptrn-elision.js | 99 ++++++++ .../class/dstr/meth-static-dflt-ary-ptrn-empty.js | 82 ++++++ .../meth-static-dflt-ary-ptrn-rest-ary-elem.js | 106 ++++++++ .../meth-static-dflt-ary-ptrn-rest-ary-elision.js | 112 ++++++++ .../meth-static-dflt-ary-ptrn-rest-ary-empty.js | 95 +++++++ .../meth-static-dflt-ary-ptrn-rest-ary-rest.js | 91 +++++++ .../meth-static-dflt-ary-ptrn-rest-id-direct.js | 86 +++++++ ...tatic-dflt-ary-ptrn-rest-id-elision-next-err.js | 80 ++++++ .../meth-static-dflt-ary-ptrn-rest-id-elision.js | 87 +++++++ .../meth-static-dflt-ary-ptrn-rest-id-exhausted.js | 83 ++++++ ...h-static-dflt-ary-ptrn-rest-id-iter-step-err.js | 91 +++++++ ...th-static-dflt-ary-ptrn-rest-id-iter-val-err.js | 93 +++++++ .../dstr/meth-static-dflt-ary-ptrn-rest-id.js | 84 ++++++ .../meth-static-dflt-ary-ptrn-rest-init-ary.js | 80 ++++++ .../dstr/meth-static-dflt-ary-ptrn-rest-init-id.js | 80 ++++++ .../meth-static-dflt-ary-ptrn-rest-init-obj.js | 80 ++++++ ...meth-static-dflt-ary-ptrn-rest-not-final-ary.js | 80 ++++++ .../meth-static-dflt-ary-ptrn-rest-not-final-id.js | 80 ++++++ ...meth-static-dflt-ary-ptrn-rest-not-final-obj.js | 80 ++++++ .../dstr/meth-static-dflt-ary-ptrn-rest-obj-id.js | 84 ++++++ .../meth-static-dflt-ary-ptrn-rest-obj-prop-id.js | 91 +++++++ .../class/dstr/meth-static-dflt-obj-init-null.js | 74 ++++++ .../dstr/meth-static-dflt-obj-init-undefined.js | 74 ++++++ .../class/dstr/meth-static-dflt-obj-ptrn-empty.js | 83 ++++++ .../meth-static-dflt-obj-ptrn-id-get-value-err.js | 81 ++++++ ...h-static-dflt-obj-ptrn-id-init-fn-name-arrow.js | 84 ++++++ ...h-static-dflt-obj-ptrn-id-init-fn-name-class.js | 86 +++++++ ...h-static-dflt-obj-ptrn-id-init-fn-name-cover.js | 85 +++++++ ...meth-static-dflt-obj-ptrn-id-init-fn-name-fn.js | 85 +++++++ ...eth-static-dflt-obj-ptrn-id-init-fn-name-gen.js | 86 +++++++ .../meth-static-dflt-obj-ptrn-id-init-skipped.js | 88 +++++++ .../meth-static-dflt-obj-ptrn-id-init-throws.js | 81 ++++++ ...th-static-dflt-obj-ptrn-id-init-unresolvable.js | 85 +++++++ .../meth-static-dflt-obj-ptrn-id-trailing-comma.js | 78 ++++++ .../dstr/meth-static-dflt-obj-ptrn-list-err.js | 82 ++++++ .../meth-static-dflt-obj-ptrn-prop-ary-init.js | 87 +++++++ ...static-dflt-obj-ptrn-prop-ary-trailing-comma.js | 78 ++++++ ...eth-static-dflt-obj-ptrn-prop-ary-value-null.js | 76 ++++++ .../dstr/meth-static-dflt-obj-ptrn-prop-ary.js | 85 +++++++ .../meth-static-dflt-obj-ptrn-prop-eval-err.js | 78 ++++++ ...h-static-dflt-obj-ptrn-prop-id-get-value-err.js | 83 ++++++ ...th-static-dflt-obj-ptrn-prop-id-init-skipped.js | 100 ++++++++ ...eth-static-dflt-obj-ptrn-prop-id-init-throws.js | 81 ++++++ ...atic-dflt-obj-ptrn-prop-id-init-unresolvable.js | 85 +++++++ .../dstr/meth-static-dflt-obj-ptrn-prop-id-init.js | 81 ++++++ ...-static-dflt-obj-ptrn-prop-id-trailing-comma.js | 82 ++++++ .../dstr/meth-static-dflt-obj-ptrn-prop-id.js | 81 ++++++ .../meth-static-dflt-obj-ptrn-prop-obj-init.js | 87 +++++++ ...eth-static-dflt-obj-ptrn-prop-obj-value-null.js | 76 ++++++ ...th-static-dflt-obj-ptrn-prop-obj-value-undef.js | 76 ++++++ .../dstr/meth-static-dflt-obj-ptrn-prop-obj.js | 85 +++++++ .../dstr/meth-static-dflt-obj-ptrn-rest-getter.js | 80 ++++++ ...tatic-dflt-obj-ptrn-rest-skip-non-enumerable.js | 88 +++++++ .../dstr/meth-static-dflt-obj-ptrn-rest-val-obj.js | 87 +++++++ .../class/dstr/meth-static-obj-init-null.js | 74 ++++++ .../class/dstr/meth-static-obj-init-undefined.js | 74 ++++++ .../class/dstr/meth-static-obj-ptrn-empty.js | 83 ++++++ .../dstr/meth-static-obj-ptrn-id-get-value-err.js | 81 ++++++ .../meth-static-obj-ptrn-id-init-fn-name-arrow.js | 84 ++++++ .../meth-static-obj-ptrn-id-init-fn-name-class.js | 86 +++++++ .../meth-static-obj-ptrn-id-init-fn-name-cover.js | 85 +++++++ .../meth-static-obj-ptrn-id-init-fn-name-fn.js | 85 +++++++ .../meth-static-obj-ptrn-id-init-fn-name-gen.js | 86 +++++++ .../dstr/meth-static-obj-ptrn-id-init-skipped.js | 88 +++++++ .../dstr/meth-static-obj-ptrn-id-init-throws.js | 81 ++++++ .../meth-static-obj-ptrn-id-init-unresolvable.js | 85 +++++++ .../dstr/meth-static-obj-ptrn-id-trailing-comma.js | 78 ++++++ .../class/dstr/meth-static-obj-ptrn-list-err.js | 82 ++++++ .../dstr/meth-static-obj-ptrn-prop-ary-init.js | 87 +++++++ ...meth-static-obj-ptrn-prop-ary-trailing-comma.js | 78 ++++++ .../meth-static-obj-ptrn-prop-ary-value-null.js | 76 ++++++ .../class/dstr/meth-static-obj-ptrn-prop-ary.js | 85 +++++++ .../dstr/meth-static-obj-ptrn-prop-eval-err.js | 78 ++++++ .../meth-static-obj-ptrn-prop-id-get-value-err.js | 83 ++++++ .../meth-static-obj-ptrn-prop-id-init-skipped.js | 100 ++++++++ .../meth-static-obj-ptrn-prop-id-init-throws.js | 81 ++++++ ...th-static-obj-ptrn-prop-id-init-unresolvable.js | 85 +++++++ .../dstr/meth-static-obj-ptrn-prop-id-init.js | 81 ++++++ .../meth-static-obj-ptrn-prop-id-trailing-comma.js | 82 ++++++ .../class/dstr/meth-static-obj-ptrn-prop-id.js | 81 ++++++ .../dstr/meth-static-obj-ptrn-prop-obj-init.js | 87 +++++++ .../meth-static-obj-ptrn-prop-obj-value-null.js | 76 ++++++ .../meth-static-obj-ptrn-prop-obj-value-undef.js | 76 ++++++ .../class/dstr/meth-static-obj-ptrn-prop-obj.js | 85 +++++++ .../class/dstr/meth-static-obj-ptrn-rest-getter.js | 80 ++++++ ...eth-static-obj-ptrn-rest-skip-non-enumerable.js | 88 +++++++ .../dstr/meth-static-obj-ptrn-rest-val-obj.js | 87 +++++++ .../dstr/private-gen-meth-ary-init-iter-close.js | 100 ++++++++ .../private-gen-meth-ary-init-iter-no-close.js | 100 ++++++++ .../dstr/private-gen-meth-ary-name-iter-val.js | 99 ++++++++ ...private-gen-meth-ary-ptrn-elem-ary-elem-init.js | 91 +++++++ ...private-gen-meth-ary-ptrn-elem-ary-elem-iter.js | 92 +++++++ ...vate-gen-meth-ary-ptrn-elem-ary-elision-init.js | 98 +++++++ ...vate-gen-meth-ary-ptrn-elem-ary-elision-iter.js | 95 +++++++ ...rivate-gen-meth-ary-ptrn-elem-ary-empty-init.js | 94 +++++++ ...rivate-gen-meth-ary-ptrn-elem-ary-empty-iter.js | 91 +++++++ ...private-gen-meth-ary-ptrn-elem-ary-rest-init.js | 95 +++++++ ...private-gen-meth-ary-ptrn-elem-ary-rest-iter.js | 98 +++++++ ...ate-gen-meth-ary-ptrn-elem-id-init-exhausted.js | 90 +++++++ ...gen-meth-ary-ptrn-elem-id-init-fn-name-arrow.js | 91 +++++++ ...gen-meth-ary-ptrn-elem-id-init-fn-name-class.js | 93 +++++++ ...gen-meth-ary-ptrn-elem-id-init-fn-name-cover.js | 92 +++++++ ...te-gen-meth-ary-ptrn-elem-id-init-fn-name-fn.js | 92 +++++++ ...e-gen-meth-ary-ptrn-elem-id-init-fn-name-gen.js | 93 +++++++ .../private-gen-meth-ary-ptrn-elem-id-init-hole.js | 86 +++++++ ...ivate-gen-meth-ary-ptrn-elem-id-init-skipped.js | 95 +++++++ ...private-gen-meth-ary-ptrn-elem-id-init-undef.js | 89 +++++++ ...vate-gen-meth-ary-ptrn-elem-id-iter-complete.js | 93 +++++++ .../private-gen-meth-ary-ptrn-elem-id-iter-done.js | 88 +++++++ ...th-ary-ptrn-elem-id-iter-val-array-prototype.js | 109 ++++++++ .../private-gen-meth-ary-ptrn-elem-id-iter-val.js | 99 ++++++++ .../private-gen-meth-ary-ptrn-elem-obj-id-init.js | 91 +++++++ .../dstr/private-gen-meth-ary-ptrn-elem-obj-id.js | 91 +++++++ ...vate-gen-meth-ary-ptrn-elem-obj-prop-id-init.js | 101 ++++++++ .../private-gen-meth-ary-ptrn-elem-obj-prop-id.js | 101 ++++++++ .../private-gen-meth-ary-ptrn-elision-exhausted.js | 96 +++++++ .../dstr/private-gen-meth-ary-ptrn-elision.js | 105 ++++++++ .../class/dstr/private-gen-meth-ary-ptrn-empty.js | 88 +++++++ .../private-gen-meth-ary-ptrn-rest-ary-elem.js | 112 ++++++++ .../private-gen-meth-ary-ptrn-rest-ary-elision.js | 118 +++++++++ .../private-gen-meth-ary-ptrn-rest-ary-empty.js | 101 ++++++++ .../private-gen-meth-ary-ptrn-rest-ary-rest.js | 97 +++++++ .../private-gen-meth-ary-ptrn-rest-id-direct.js | 92 +++++++ .../private-gen-meth-ary-ptrn-rest-id-elision.js | 93 +++++++ .../private-gen-meth-ary-ptrn-rest-id-exhausted.js | 89 +++++++ .../dstr/private-gen-meth-ary-ptrn-rest-id.js | 90 +++++++ .../private-gen-meth-ary-ptrn-rest-init-ary.js | 86 +++++++ .../dstr/private-gen-meth-ary-ptrn-rest-init-id.js | 86 +++++++ .../private-gen-meth-ary-ptrn-rest-init-obj.js | 86 +++++++ ...private-gen-meth-ary-ptrn-rest-not-final-ary.js | 86 +++++++ .../private-gen-meth-ary-ptrn-rest-not-final-id.js | 86 +++++++ ...private-gen-meth-ary-ptrn-rest-not-final-obj.js | 86 +++++++ .../dstr/private-gen-meth-ary-ptrn-rest-obj-id.js | 90 +++++++ .../private-gen-meth-ary-ptrn-rest-obj-prop-id.js | 97 +++++++ .../private-gen-meth-dflt-ary-init-iter-close.js | 100 ++++++++ ...private-gen-meth-dflt-ary-init-iter-no-close.js | 100 ++++++++ .../private-gen-meth-dflt-ary-name-iter-val.js | 99 ++++++++ ...te-gen-meth-dflt-ary-ptrn-elem-ary-elem-init.js | 91 +++++++ ...te-gen-meth-dflt-ary-ptrn-elem-ary-elem-iter.js | 92 +++++++ ...gen-meth-dflt-ary-ptrn-elem-ary-elision-init.js | 98 +++++++ ...gen-meth-dflt-ary-ptrn-elem-ary-elision-iter.js | 95 +++++++ ...e-gen-meth-dflt-ary-ptrn-elem-ary-empty-init.js | 94 +++++++ ...e-gen-meth-dflt-ary-ptrn-elem-ary-empty-iter.js | 91 +++++++ ...te-gen-meth-dflt-ary-ptrn-elem-ary-rest-init.js | 95 +++++++ ...te-gen-meth-dflt-ary-ptrn-elem-ary-rest-iter.js | 98 +++++++ ...en-meth-dflt-ary-ptrn-elem-id-init-exhausted.js | 90 +++++++ ...eth-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js | 91 +++++++ ...eth-dflt-ary-ptrn-elem-id-init-fn-name-class.js | 93 +++++++ ...eth-dflt-ary-ptrn-elem-id-init-fn-name-cover.js | 92 +++++++ ...n-meth-dflt-ary-ptrn-elem-id-init-fn-name-fn.js | 92 +++++++ ...-meth-dflt-ary-ptrn-elem-id-init-fn-name-gen.js | 93 +++++++ ...ate-gen-meth-dflt-ary-ptrn-elem-id-init-hole.js | 86 +++++++ ...-gen-meth-dflt-ary-ptrn-elem-id-init-skipped.js | 95 +++++++ ...te-gen-meth-dflt-ary-ptrn-elem-id-init-undef.js | 89 +++++++ ...gen-meth-dflt-ary-ptrn-elem-id-iter-complete.js | 93 +++++++ ...ate-gen-meth-dflt-ary-ptrn-elem-id-iter-done.js | 88 +++++++ ...lt-ary-ptrn-elem-id-iter-val-array-prototype.js | 109 ++++++++ ...vate-gen-meth-dflt-ary-ptrn-elem-id-iter-val.js | 99 ++++++++ ...vate-gen-meth-dflt-ary-ptrn-elem-obj-id-init.js | 91 +++++++ .../private-gen-meth-dflt-ary-ptrn-elem-obj-id.js | 91 +++++++ ...gen-meth-dflt-ary-ptrn-elem-obj-prop-id-init.js | 101 ++++++++ ...vate-gen-meth-dflt-ary-ptrn-elem-obj-prop-id.js | 101 ++++++++ ...ate-gen-meth-dflt-ary-ptrn-elision-exhausted.js | 96 +++++++ .../dstr/private-gen-meth-dflt-ary-ptrn-elision.js | 105 ++++++++ .../dstr/private-gen-meth-dflt-ary-ptrn-empty.js | 88 +++++++ ...private-gen-meth-dflt-ary-ptrn-rest-ary-elem.js | 112 ++++++++ ...vate-gen-meth-dflt-ary-ptrn-rest-ary-elision.js | 118 +++++++++ ...rivate-gen-meth-dflt-ary-ptrn-rest-ary-empty.js | 101 ++++++++ ...private-gen-meth-dflt-ary-ptrn-rest-ary-rest.js | 97 +++++++ ...rivate-gen-meth-dflt-ary-ptrn-rest-id-direct.js | 92 +++++++ ...ivate-gen-meth-dflt-ary-ptrn-rest-id-elision.js | 93 +++++++ ...ate-gen-meth-dflt-ary-ptrn-rest-id-exhausted.js | 89 +++++++ .../dstr/private-gen-meth-dflt-ary-ptrn-rest-id.js | 90 +++++++ ...private-gen-meth-dflt-ary-ptrn-rest-init-ary.js | 86 +++++++ .../private-gen-meth-dflt-ary-ptrn-rest-init-id.js | 86 +++++++ ...private-gen-meth-dflt-ary-ptrn-rest-init-obj.js | 86 +++++++ ...te-gen-meth-dflt-ary-ptrn-rest-not-final-ary.js | 86 +++++++ ...ate-gen-meth-dflt-ary-ptrn-rest-not-final-id.js | 86 +++++++ ...te-gen-meth-dflt-ary-ptrn-rest-not-final-obj.js | 86 +++++++ .../private-gen-meth-dflt-ary-ptrn-rest-obj-id.js | 90 +++++++ ...vate-gen-meth-dflt-ary-ptrn-rest-obj-prop-id.js | 97 +++++++ .../dstr/private-gen-meth-dflt-obj-ptrn-empty.js | 89 +++++++ ...gen-meth-dflt-obj-ptrn-id-init-fn-name-arrow.js | 90 +++++++ ...gen-meth-dflt-obj-ptrn-id-init-fn-name-class.js | 92 +++++++ ...gen-meth-dflt-obj-ptrn-id-init-fn-name-cover.js | 91 +++++++ ...te-gen-meth-dflt-obj-ptrn-id-init-fn-name-fn.js | 91 +++++++ ...e-gen-meth-dflt-obj-ptrn-id-init-fn-name-gen.js | 92 +++++++ ...ivate-gen-meth-dflt-obj-ptrn-id-init-skipped.js | 94 +++++++ ...ate-gen-meth-dflt-obj-ptrn-id-trailing-comma.js | 84 ++++++ ...private-gen-meth-dflt-obj-ptrn-prop-ary-init.js | 93 +++++++ ...n-meth-dflt-obj-ptrn-prop-ary-trailing-comma.js | 84 ++++++ .../private-gen-meth-dflt-obj-ptrn-prop-ary.js | 91 +++++++ ...-gen-meth-dflt-obj-ptrn-prop-id-init-skipped.js | 106 ++++++++ .../private-gen-meth-dflt-obj-ptrn-prop-id-init.js | 87 +++++++ ...en-meth-dflt-obj-ptrn-prop-id-trailing-comma.js | 88 +++++++ .../dstr/private-gen-meth-dflt-obj-ptrn-prop-id.js | 87 +++++++ ...private-gen-meth-dflt-obj-ptrn-prop-obj-init.js | 93 +++++++ .../private-gen-meth-dflt-obj-ptrn-prop-obj.js | 91 +++++++ .../private-gen-meth-dflt-obj-ptrn-rest-getter.js | 86 +++++++ ...-meth-dflt-obj-ptrn-rest-skip-non-enumerable.js | 94 +++++++ .../private-gen-meth-dflt-obj-ptrn-rest-val-obj.js | 93 +++++++ .../class/dstr/private-gen-meth-obj-ptrn-empty.js | 89 +++++++ ...vate-gen-meth-obj-ptrn-id-init-fn-name-arrow.js | 90 +++++++ ...vate-gen-meth-obj-ptrn-id-init-fn-name-class.js | 92 +++++++ ...vate-gen-meth-obj-ptrn-id-init-fn-name-cover.js | 91 +++++++ ...private-gen-meth-obj-ptrn-id-init-fn-name-fn.js | 91 +++++++ ...rivate-gen-meth-obj-ptrn-id-init-fn-name-gen.js | 92 +++++++ .../private-gen-meth-obj-ptrn-id-init-skipped.js | 94 +++++++ .../private-gen-meth-obj-ptrn-id-trailing-comma.js | 84 ++++++ .../private-gen-meth-obj-ptrn-prop-ary-init.js | 93 +++++++ ...te-gen-meth-obj-ptrn-prop-ary-trailing-comma.js | 84 ++++++ .../dstr/private-gen-meth-obj-ptrn-prop-ary.js | 91 +++++++ ...ivate-gen-meth-obj-ptrn-prop-id-init-skipped.js | 106 ++++++++ .../dstr/private-gen-meth-obj-ptrn-prop-id-init.js | 87 +++++++ ...ate-gen-meth-obj-ptrn-prop-id-trailing-comma.js | 88 +++++++ .../dstr/private-gen-meth-obj-ptrn-prop-id.js | 87 +++++++ .../private-gen-meth-obj-ptrn-prop-obj-init.js | 93 +++++++ .../dstr/private-gen-meth-obj-ptrn-prop-obj.js | 91 +++++++ .../dstr/private-gen-meth-obj-ptrn-rest-getter.js | 86 +++++++ ...e-gen-meth-obj-ptrn-rest-skip-non-enumerable.js | 94 +++++++ .../dstr/private-gen-meth-obj-ptrn-rest-val-obj.js | 93 +++++++ .../private-gen-meth-static-ary-init-iter-close.js | 100 ++++++++ ...ivate-gen-meth-static-ary-init-iter-no-close.js | 100 ++++++++ .../private-gen-meth-static-ary-name-iter-val.js | 99 ++++++++ ...-gen-meth-static-ary-ptrn-elem-ary-elem-init.js | 91 +++++++ ...-gen-meth-static-ary-ptrn-elem-ary-elem-iter.js | 92 +++++++ ...n-meth-static-ary-ptrn-elem-ary-elision-init.js | 98 +++++++ ...n-meth-static-ary-ptrn-elem-ary-elision-iter.js | 95 +++++++ ...gen-meth-static-ary-ptrn-elem-ary-empty-init.js | 94 +++++++ ...gen-meth-static-ary-ptrn-elem-ary-empty-iter.js | 91 +++++++ ...-gen-meth-static-ary-ptrn-elem-ary-rest-init.js | 95 +++++++ ...-gen-meth-static-ary-ptrn-elem-ary-rest-iter.js | 98 +++++++ ...-meth-static-ary-ptrn-elem-id-init-exhausted.js | 90 +++++++ ...h-static-ary-ptrn-elem-id-init-fn-name-arrow.js | 91 +++++++ ...h-static-ary-ptrn-elem-id-init-fn-name-class.js | 93 +++++++ ...h-static-ary-ptrn-elem-id-init-fn-name-cover.js | 92 +++++++ ...meth-static-ary-ptrn-elem-id-init-fn-name-fn.js | 92 +++++++ ...eth-static-ary-ptrn-elem-id-init-fn-name-gen.js | 93 +++++++ ...e-gen-meth-static-ary-ptrn-elem-id-init-hole.js | 86 +++++++ ...en-meth-static-ary-ptrn-elem-id-init-skipped.js | 95 +++++++ ...-gen-meth-static-ary-ptrn-elem-id-init-undef.js | 89 +++++++ ...n-meth-static-ary-ptrn-elem-id-iter-complete.js | 93 +++++++ ...e-gen-meth-static-ary-ptrn-elem-id-iter-done.js | 88 +++++++ ...ic-ary-ptrn-elem-id-iter-val-array-prototype.js | 109 ++++++++ ...te-gen-meth-static-ary-ptrn-elem-id-iter-val.js | 99 ++++++++ ...te-gen-meth-static-ary-ptrn-elem-obj-id-init.js | 91 +++++++ ...private-gen-meth-static-ary-ptrn-elem-obj-id.js | 91 +++++++ ...n-meth-static-ary-ptrn-elem-obj-prop-id-init.js | 101 ++++++++ ...te-gen-meth-static-ary-ptrn-elem-obj-prop-id.js | 101 ++++++++ ...e-gen-meth-static-ary-ptrn-elision-exhausted.js | 96 +++++++ .../private-gen-meth-static-ary-ptrn-elision.js | 105 ++++++++ .../dstr/private-gen-meth-static-ary-ptrn-empty.js | 88 +++++++ ...ivate-gen-meth-static-ary-ptrn-rest-ary-elem.js | 112 ++++++++ ...te-gen-meth-static-ary-ptrn-rest-ary-elision.js | 118 +++++++++ ...vate-gen-meth-static-ary-ptrn-rest-ary-empty.js | 101 ++++++++ ...ivate-gen-meth-static-ary-ptrn-rest-ary-rest.js | 97 +++++++ ...vate-gen-meth-static-ary-ptrn-rest-id-direct.js | 92 +++++++ ...ate-gen-meth-static-ary-ptrn-rest-id-elision.js | 93 +++++++ ...e-gen-meth-static-ary-ptrn-rest-id-exhausted.js | 89 +++++++ .../private-gen-meth-static-ary-ptrn-rest-id.js | 90 +++++++ ...ivate-gen-meth-static-ary-ptrn-rest-init-ary.js | 86 +++++++ ...rivate-gen-meth-static-ary-ptrn-rest-init-id.js | 86 +++++++ ...ivate-gen-meth-static-ary-ptrn-rest-init-obj.js | 86 +++++++ ...-gen-meth-static-ary-ptrn-rest-not-final-ary.js | 86 +++++++ ...e-gen-meth-static-ary-ptrn-rest-not-final-id.js | 86 +++++++ ...-gen-meth-static-ary-ptrn-rest-not-final-obj.js | 86 +++++++ ...private-gen-meth-static-ary-ptrn-rest-obj-id.js | 90 +++++++ ...te-gen-meth-static-ary-ptrn-rest-obj-prop-id.js | 97 +++++++ ...ate-gen-meth-static-dflt-ary-init-iter-close.js | 100 ++++++++ ...-gen-meth-static-dflt-ary-init-iter-no-close.js | 100 ++++++++ ...ivate-gen-meth-static-dflt-ary-name-iter-val.js | 99 ++++++++ ...meth-static-dflt-ary-ptrn-elem-ary-elem-init.js | 91 +++++++ ...meth-static-dflt-ary-ptrn-elem-ary-elem-iter.js | 92 +++++++ ...h-static-dflt-ary-ptrn-elem-ary-elision-init.js | 98 +++++++ ...h-static-dflt-ary-ptrn-elem-ary-elision-iter.js | 95 +++++++ ...eth-static-dflt-ary-ptrn-elem-ary-empty-init.js | 94 +++++++ ...eth-static-dflt-ary-ptrn-elem-ary-empty-iter.js | 91 +++++++ ...meth-static-dflt-ary-ptrn-elem-ary-rest-init.js | 95 +++++++ ...meth-static-dflt-ary-ptrn-elem-ary-rest-iter.js | 98 +++++++ ...-static-dflt-ary-ptrn-elem-id-init-exhausted.js | 90 +++++++ ...tic-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js | 91 +++++++ ...tic-dflt-ary-ptrn-elem-id-init-fn-name-class.js | 93 +++++++ ...tic-dflt-ary-ptrn-elem-id-init-fn-name-cover.js | 92 +++++++ ...static-dflt-ary-ptrn-elem-id-init-fn-name-fn.js | 92 +++++++ ...tatic-dflt-ary-ptrn-elem-id-init-fn-name-gen.js | 93 +++++++ ...-meth-static-dflt-ary-ptrn-elem-id-init-hole.js | 86 +++++++ ...th-static-dflt-ary-ptrn-elem-id-init-skipped.js | 95 +++++++ ...meth-static-dflt-ary-ptrn-elem-id-init-undef.js | 89 +++++++ ...h-static-dflt-ary-ptrn-elem-id-iter-complete.js | 93 +++++++ ...-meth-static-dflt-ary-ptrn-elem-id-iter-done.js | 88 +++++++ ...lt-ary-ptrn-elem-id-iter-val-array-prototype.js | 109 ++++++++ ...n-meth-static-dflt-ary-ptrn-elem-id-iter-val.js | 99 ++++++++ ...n-meth-static-dflt-ary-ptrn-elem-obj-id-init.js | 91 +++++++ ...te-gen-meth-static-dflt-ary-ptrn-elem-obj-id.js | 91 +++++++ ...h-static-dflt-ary-ptrn-elem-obj-prop-id-init.js | 101 ++++++++ ...n-meth-static-dflt-ary-ptrn-elem-obj-prop-id.js | 101 ++++++++ ...-meth-static-dflt-ary-ptrn-elision-exhausted.js | 96 +++++++ ...rivate-gen-meth-static-dflt-ary-ptrn-elision.js | 105 ++++++++ .../private-gen-meth-static-dflt-ary-ptrn-empty.js | 88 +++++++ ...-gen-meth-static-dflt-ary-ptrn-rest-ary-elem.js | 112 ++++++++ ...n-meth-static-dflt-ary-ptrn-rest-ary-elision.js | 118 +++++++++ ...gen-meth-static-dflt-ary-ptrn-rest-ary-empty.js | 101 ++++++++ ...-gen-meth-static-dflt-ary-ptrn-rest-ary-rest.js | 97 +++++++ ...gen-meth-static-dflt-ary-ptrn-rest-id-direct.js | 92 +++++++ ...en-meth-static-dflt-ary-ptrn-rest-id-elision.js | 93 +++++++ ...-meth-static-dflt-ary-ptrn-rest-id-exhausted.js | 89 +++++++ ...rivate-gen-meth-static-dflt-ary-ptrn-rest-id.js | 90 +++++++ ...-gen-meth-static-dflt-ary-ptrn-rest-init-ary.js | 86 +++++++ ...e-gen-meth-static-dflt-ary-ptrn-rest-init-id.js | 86 +++++++ ...-gen-meth-static-dflt-ary-ptrn-rest-init-obj.js | 86 +++++++ ...meth-static-dflt-ary-ptrn-rest-not-final-ary.js | 86 +++++++ ...-meth-static-dflt-ary-ptrn-rest-not-final-id.js | 86 +++++++ ...meth-static-dflt-ary-ptrn-rest-not-final-obj.js | 86 +++++++ ...te-gen-meth-static-dflt-ary-ptrn-rest-obj-id.js | 90 +++++++ ...n-meth-static-dflt-ary-ptrn-rest-obj-prop-id.js | 97 +++++++ .../private-gen-meth-static-dflt-obj-ptrn-empty.js | 89 +++++++ ...h-static-dflt-obj-ptrn-id-init-fn-name-arrow.js | 90 +++++++ ...h-static-dflt-obj-ptrn-id-init-fn-name-class.js | 92 +++++++ ...h-static-dflt-obj-ptrn-id-init-fn-name-cover.js | 91 +++++++ ...meth-static-dflt-obj-ptrn-id-init-fn-name-fn.js | 91 +++++++ ...eth-static-dflt-obj-ptrn-id-init-fn-name-gen.js | 92 +++++++ ...en-meth-static-dflt-obj-ptrn-id-init-skipped.js | 94 +++++++ ...-meth-static-dflt-obj-ptrn-id-trailing-comma.js | 84 ++++++ ...-gen-meth-static-dflt-obj-ptrn-prop-ary-init.js | 93 +++++++ ...static-dflt-obj-ptrn-prop-ary-trailing-comma.js | 84 ++++++ ...ivate-gen-meth-static-dflt-obj-ptrn-prop-ary.js | 91 +++++++ ...th-static-dflt-obj-ptrn-prop-id-init-skipped.js | 106 ++++++++ ...e-gen-meth-static-dflt-obj-ptrn-prop-id-init.js | 87 +++++++ ...-static-dflt-obj-ptrn-prop-id-trailing-comma.js | 88 +++++++ ...rivate-gen-meth-static-dflt-obj-ptrn-prop-id.js | 87 +++++++ ...-gen-meth-static-dflt-obj-ptrn-prop-obj-init.js | 93 +++++++ ...ivate-gen-meth-static-dflt-obj-ptrn-prop-obj.js | 91 +++++++ ...te-gen-meth-static-dflt-obj-ptrn-rest-getter.js | 86 +++++++ ...tatic-dflt-obj-ptrn-rest-skip-non-enumerable.js | 94 +++++++ ...e-gen-meth-static-dflt-obj-ptrn-rest-val-obj.js | 93 +++++++ .../dstr/private-gen-meth-static-obj-ptrn-empty.js | 89 +++++++ ...n-meth-static-obj-ptrn-id-init-fn-name-arrow.js | 90 +++++++ ...n-meth-static-obj-ptrn-id-init-fn-name-class.js | 92 +++++++ ...n-meth-static-obj-ptrn-id-init-fn-name-cover.js | 91 +++++++ ...-gen-meth-static-obj-ptrn-id-init-fn-name-fn.js | 91 +++++++ ...gen-meth-static-obj-ptrn-id-init-fn-name-gen.js | 92 +++++++ ...ate-gen-meth-static-obj-ptrn-id-init-skipped.js | 94 +++++++ ...e-gen-meth-static-obj-ptrn-id-trailing-comma.js | 84 ++++++ ...ivate-gen-meth-static-obj-ptrn-prop-ary-init.js | 93 +++++++ ...meth-static-obj-ptrn-prop-ary-trailing-comma.js | 84 ++++++ .../private-gen-meth-static-obj-ptrn-prop-ary.js | 91 +++++++ ...en-meth-static-obj-ptrn-prop-id-init-skipped.js | 106 ++++++++ ...rivate-gen-meth-static-obj-ptrn-prop-id-init.js | 87 +++++++ ...-meth-static-obj-ptrn-prop-id-trailing-comma.js | 88 +++++++ .../private-gen-meth-static-obj-ptrn-prop-id.js | 87 +++++++ ...ivate-gen-meth-static-obj-ptrn-prop-obj-init.js | 93 +++++++ .../private-gen-meth-static-obj-ptrn-prop-obj.js | 91 +++++++ ...private-gen-meth-static-obj-ptrn-rest-getter.js | 86 +++++++ ...eth-static-obj-ptrn-rest-skip-non-enumerable.js | 94 +++++++ ...rivate-gen-meth-static-obj-ptrn-rest-val-obj.js | 93 +++++++ .../class/dstr/private-meth-ary-init-iter-close.js | 98 +++++++ .../dstr/private-meth-ary-init-iter-no-close.js | 98 +++++++ .../class/dstr/private-meth-ary-name-iter-val.js | 97 +++++++ .../private-meth-ary-ptrn-elem-ary-elem-init.js | 89 +++++++ .../private-meth-ary-ptrn-elem-ary-elem-iter.js | 90 +++++++ .../private-meth-ary-ptrn-elem-ary-elision-init.js | 96 +++++++ .../private-meth-ary-ptrn-elem-ary-elision-iter.js | 93 +++++++ .../private-meth-ary-ptrn-elem-ary-empty-init.js | 92 +++++++ .../private-meth-ary-ptrn-elem-ary-empty-iter.js | 89 +++++++ .../private-meth-ary-ptrn-elem-ary-rest-init.js | 93 +++++++ .../private-meth-ary-ptrn-elem-ary-rest-iter.js | 96 +++++++ ...private-meth-ary-ptrn-elem-id-init-exhausted.js | 88 +++++++ ...ate-meth-ary-ptrn-elem-id-init-fn-name-arrow.js | 89 +++++++ ...ate-meth-ary-ptrn-elem-id-init-fn-name-class.js | 91 +++++++ ...ate-meth-ary-ptrn-elem-id-init-fn-name-cover.js | 90 +++++++ ...rivate-meth-ary-ptrn-elem-id-init-fn-name-fn.js | 90 +++++++ ...ivate-meth-ary-ptrn-elem-id-init-fn-name-gen.js | 91 +++++++ .../private-meth-ary-ptrn-elem-id-init-hole.js | 84 ++++++ .../private-meth-ary-ptrn-elem-id-init-skipped.js | 93 +++++++ .../private-meth-ary-ptrn-elem-id-init-undef.js | 87 +++++++ .../private-meth-ary-ptrn-elem-id-iter-complete.js | 91 +++++++ .../private-meth-ary-ptrn-elem-id-iter-done.js | 86 +++++++ ...th-ary-ptrn-elem-id-iter-val-array-prototype.js | 107 ++++++++ .../dstr/private-meth-ary-ptrn-elem-id-iter-val.js | 97 +++++++ .../dstr/private-meth-ary-ptrn-elem-obj-id-init.js | 89 +++++++ .../dstr/private-meth-ary-ptrn-elem-obj-id.js | 89 +++++++ .../private-meth-ary-ptrn-elem-obj-prop-id-init.js | 99 ++++++++ .../dstr/private-meth-ary-ptrn-elem-obj-prop-id.js | 99 ++++++++ .../private-meth-ary-ptrn-elision-exhausted.js | 94 +++++++ .../class/dstr/private-meth-ary-ptrn-elision.js | 103 ++++++++ .../class/dstr/private-meth-ary-ptrn-empty.js | 86 +++++++ .../dstr/private-meth-ary-ptrn-rest-ary-elem.js | 110 ++++++++ .../dstr/private-meth-ary-ptrn-rest-ary-elision.js | 116 +++++++++ .../dstr/private-meth-ary-ptrn-rest-ary-empty.js | 99 ++++++++ .../dstr/private-meth-ary-ptrn-rest-ary-rest.js | 95 +++++++ .../dstr/private-meth-ary-ptrn-rest-id-direct.js | 90 +++++++ .../dstr/private-meth-ary-ptrn-rest-id-elision.js | 91 +++++++ .../private-meth-ary-ptrn-rest-id-exhausted.js | 87 +++++++ .../class/dstr/private-meth-ary-ptrn-rest-id.js | 88 +++++++ .../dstr/private-meth-ary-ptrn-rest-init-ary.js | 84 ++++++ .../dstr/private-meth-ary-ptrn-rest-init-id.js | 84 ++++++ .../dstr/private-meth-ary-ptrn-rest-init-obj.js | 84 ++++++ .../private-meth-ary-ptrn-rest-not-final-ary.js | 84 ++++++ .../private-meth-ary-ptrn-rest-not-final-id.js | 84 ++++++ .../private-meth-ary-ptrn-rest-not-final-obj.js | 84 ++++++ .../dstr/private-meth-ary-ptrn-rest-obj-id.js | 88 +++++++ .../dstr/private-meth-ary-ptrn-rest-obj-prop-id.js | 95 +++++++ .../dstr/private-meth-dflt-ary-init-iter-close.js | 98 +++++++ .../private-meth-dflt-ary-init-iter-no-close.js | 98 +++++++ .../dstr/private-meth-dflt-ary-name-iter-val.js | 97 +++++++ ...rivate-meth-dflt-ary-ptrn-elem-ary-elem-init.js | 89 +++++++ ...rivate-meth-dflt-ary-ptrn-elem-ary-elem-iter.js | 90 +++++++ ...ate-meth-dflt-ary-ptrn-elem-ary-elision-init.js | 96 +++++++ ...ate-meth-dflt-ary-ptrn-elem-ary-elision-iter.js | 93 +++++++ ...ivate-meth-dflt-ary-ptrn-elem-ary-empty-init.js | 92 +++++++ ...ivate-meth-dflt-ary-ptrn-elem-ary-empty-iter.js | 89 +++++++ ...rivate-meth-dflt-ary-ptrn-elem-ary-rest-init.js | 93 +++++++ ...rivate-meth-dflt-ary-ptrn-elem-ary-rest-iter.js | 96 +++++++ ...te-meth-dflt-ary-ptrn-elem-id-init-exhausted.js | 88 +++++++ ...eth-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js | 89 +++++++ ...eth-dflt-ary-ptrn-elem-id-init-fn-name-class.js | 91 +++++++ ...eth-dflt-ary-ptrn-elem-id-init-fn-name-cover.js | 90 +++++++ ...e-meth-dflt-ary-ptrn-elem-id-init-fn-name-fn.js | 90 +++++++ ...-meth-dflt-ary-ptrn-elem-id-init-fn-name-gen.js | 91 +++++++ ...private-meth-dflt-ary-ptrn-elem-id-init-hole.js | 84 ++++++ ...vate-meth-dflt-ary-ptrn-elem-id-init-skipped.js | 93 +++++++ ...rivate-meth-dflt-ary-ptrn-elem-id-init-undef.js | 87 +++++++ ...ate-meth-dflt-ary-ptrn-elem-id-iter-complete.js | 91 +++++++ ...private-meth-dflt-ary-ptrn-elem-id-iter-done.js | 86 +++++++ ...lt-ary-ptrn-elem-id-iter-val-array-prototype.js | 107 ++++++++ .../private-meth-dflt-ary-ptrn-elem-id-iter-val.js | 97 +++++++ .../private-meth-dflt-ary-ptrn-elem-obj-id-init.js | 89 +++++++ .../dstr/private-meth-dflt-ary-ptrn-elem-obj-id.js | 89 +++++++ ...ate-meth-dflt-ary-ptrn-elem-obj-prop-id-init.js | 99 ++++++++ .../private-meth-dflt-ary-ptrn-elem-obj-prop-id.js | 99 ++++++++ ...private-meth-dflt-ary-ptrn-elision-exhausted.js | 94 +++++++ .../dstr/private-meth-dflt-ary-ptrn-elision.js | 103 ++++++++ .../class/dstr/private-meth-dflt-ary-ptrn-empty.js | 86 +++++++ .../private-meth-dflt-ary-ptrn-rest-ary-elem.js | 110 ++++++++ .../private-meth-dflt-ary-ptrn-rest-ary-elision.js | 116 +++++++++ .../private-meth-dflt-ary-ptrn-rest-ary-empty.js | 99 ++++++++ .../private-meth-dflt-ary-ptrn-rest-ary-rest.js | 95 +++++++ .../private-meth-dflt-ary-ptrn-rest-id-direct.js | 90 +++++++ .../private-meth-dflt-ary-ptrn-rest-id-elision.js | 91 +++++++ ...private-meth-dflt-ary-ptrn-rest-id-exhausted.js | 87 +++++++ .../dstr/private-meth-dflt-ary-ptrn-rest-id.js | 88 +++++++ .../private-meth-dflt-ary-ptrn-rest-init-ary.js | 84 ++++++ .../private-meth-dflt-ary-ptrn-rest-init-id.js | 84 ++++++ .../private-meth-dflt-ary-ptrn-rest-init-obj.js | 84 ++++++ ...rivate-meth-dflt-ary-ptrn-rest-not-final-ary.js | 84 ++++++ ...private-meth-dflt-ary-ptrn-rest-not-final-id.js | 84 ++++++ ...rivate-meth-dflt-ary-ptrn-rest-not-final-obj.js | 84 ++++++ .../dstr/private-meth-dflt-ary-ptrn-rest-obj-id.js | 88 +++++++ .../private-meth-dflt-ary-ptrn-rest-obj-prop-id.js | 95 +++++++ .../class/dstr/private-meth-dflt-obj-ptrn-empty.js | 87 +++++++ ...ate-meth-dflt-obj-ptrn-id-init-fn-name-arrow.js | 88 +++++++ ...ate-meth-dflt-obj-ptrn-id-init-fn-name-class.js | 90 +++++++ ...ate-meth-dflt-obj-ptrn-id-init-fn-name-cover.js | 89 +++++++ ...rivate-meth-dflt-obj-ptrn-id-init-fn-name-fn.js | 89 +++++++ ...ivate-meth-dflt-obj-ptrn-id-init-fn-name-gen.js | 90 +++++++ .../private-meth-dflt-obj-ptrn-id-init-skipped.js | 92 +++++++ ...private-meth-dflt-obj-ptrn-id-trailing-comma.js | 82 ++++++ .../private-meth-dflt-obj-ptrn-prop-ary-init.js | 91 +++++++ ...e-meth-dflt-obj-ptrn-prop-ary-trailing-comma.js | 82 ++++++ .../dstr/private-meth-dflt-obj-ptrn-prop-ary.js | 89 +++++++ ...vate-meth-dflt-obj-ptrn-prop-id-init-skipped.js | 104 ++++++++ .../private-meth-dflt-obj-ptrn-prop-id-init.js | 85 +++++++ ...te-meth-dflt-obj-ptrn-prop-id-trailing-comma.js | 86 +++++++ .../dstr/private-meth-dflt-obj-ptrn-prop-id.js | 85 +++++++ .../private-meth-dflt-obj-ptrn-prop-obj-init.js | 91 +++++++ .../dstr/private-meth-dflt-obj-ptrn-prop-obj.js | 89 +++++++ .../dstr/private-meth-dflt-obj-ptrn-rest-getter.js | 84 ++++++ ...-meth-dflt-obj-ptrn-rest-skip-non-enumerable.js | 92 +++++++ .../private-meth-dflt-obj-ptrn-rest-val-obj.js | 91 +++++++ .../class/dstr/private-meth-obj-ptrn-empty.js | 87 +++++++ .../private-meth-obj-ptrn-id-init-fn-name-arrow.js | 88 +++++++ .../private-meth-obj-ptrn-id-init-fn-name-class.js | 90 +++++++ .../private-meth-obj-ptrn-id-init-fn-name-cover.js | 89 +++++++ .../private-meth-obj-ptrn-id-init-fn-name-fn.js | 89 +++++++ .../private-meth-obj-ptrn-id-init-fn-name-gen.js | 90 +++++++ .../dstr/private-meth-obj-ptrn-id-init-skipped.js | 92 +++++++ .../private-meth-obj-ptrn-id-trailing-comma.js | 82 ++++++ .../dstr/private-meth-obj-ptrn-prop-ary-init.js | 91 +++++++ ...rivate-meth-obj-ptrn-prop-ary-trailing-comma.js | 82 ++++++ .../class/dstr/private-meth-obj-ptrn-prop-ary.js | 89 +++++++ .../private-meth-obj-ptrn-prop-id-init-skipped.js | 104 ++++++++ .../dstr/private-meth-obj-ptrn-prop-id-init.js | 85 +++++++ ...private-meth-obj-ptrn-prop-id-trailing-comma.js | 86 +++++++ .../class/dstr/private-meth-obj-ptrn-prop-id.js | 85 +++++++ .../dstr/private-meth-obj-ptrn-prop-obj-init.js | 91 +++++++ .../class/dstr/private-meth-obj-ptrn-prop-obj.js | 89 +++++++ .../dstr/private-meth-obj-ptrn-rest-getter.js | 84 ++++++ ...ivate-meth-obj-ptrn-rest-skip-non-enumerable.js | 92 +++++++ .../dstr/private-meth-obj-ptrn-rest-val-obj.js | 91 +++++++ .../private-meth-static-ary-init-iter-close.js | 98 +++++++ .../private-meth-static-ary-init-iter-no-close.js | 98 +++++++ .../dstr/private-meth-static-ary-name-iter-val.js | 97 +++++++ ...vate-meth-static-ary-ptrn-elem-ary-elem-init.js | 89 +++++++ ...vate-meth-static-ary-ptrn-elem-ary-elem-iter.js | 90 +++++++ ...e-meth-static-ary-ptrn-elem-ary-elision-init.js | 96 +++++++ ...e-meth-static-ary-ptrn-elem-ary-elision-iter.js | 93 +++++++ ...ate-meth-static-ary-ptrn-elem-ary-empty-init.js | 92 +++++++ ...ate-meth-static-ary-ptrn-elem-ary-empty-iter.js | 89 +++++++ ...vate-meth-static-ary-ptrn-elem-ary-rest-init.js | 93 +++++++ ...vate-meth-static-ary-ptrn-elem-ary-rest-iter.js | 96 +++++++ ...-meth-static-ary-ptrn-elem-id-init-exhausted.js | 88 +++++++ ...h-static-ary-ptrn-elem-id-init-fn-name-arrow.js | 89 +++++++ ...h-static-ary-ptrn-elem-id-init-fn-name-class.js | 91 +++++++ ...h-static-ary-ptrn-elem-id-init-fn-name-cover.js | 90 +++++++ ...meth-static-ary-ptrn-elem-id-init-fn-name-fn.js | 90 +++++++ ...eth-static-ary-ptrn-elem-id-init-fn-name-gen.js | 91 +++++++ ...ivate-meth-static-ary-ptrn-elem-id-init-hole.js | 84 ++++++ ...te-meth-static-ary-ptrn-elem-id-init-skipped.js | 93 +++++++ ...vate-meth-static-ary-ptrn-elem-id-init-undef.js | 87 +++++++ ...e-meth-static-ary-ptrn-elem-id-iter-complete.js | 91 +++++++ ...ivate-meth-static-ary-ptrn-elem-id-iter-done.js | 86 +++++++ ...ic-ary-ptrn-elem-id-iter-val-array-prototype.js | 107 ++++++++ ...rivate-meth-static-ary-ptrn-elem-id-iter-val.js | 97 +++++++ ...rivate-meth-static-ary-ptrn-elem-obj-id-init.js | 89 +++++++ .../private-meth-static-ary-ptrn-elem-obj-id.js | 89 +++++++ ...e-meth-static-ary-ptrn-elem-obj-prop-id-init.js | 99 ++++++++ ...rivate-meth-static-ary-ptrn-elem-obj-prop-id.js | 99 ++++++++ ...ivate-meth-static-ary-ptrn-elision-exhausted.js | 94 +++++++ .../dstr/private-meth-static-ary-ptrn-elision.js | 103 ++++++++ .../dstr/private-meth-static-ary-ptrn-empty.js | 86 +++++++ .../private-meth-static-ary-ptrn-rest-ary-elem.js | 110 ++++++++ ...rivate-meth-static-ary-ptrn-rest-ary-elision.js | 116 +++++++++ .../private-meth-static-ary-ptrn-rest-ary-empty.js | 99 ++++++++ .../private-meth-static-ary-ptrn-rest-ary-rest.js | 95 +++++++ .../private-meth-static-ary-ptrn-rest-id-direct.js | 90 +++++++ ...private-meth-static-ary-ptrn-rest-id-elision.js | 91 +++++++ ...ivate-meth-static-ary-ptrn-rest-id-exhausted.js | 87 +++++++ .../dstr/private-meth-static-ary-ptrn-rest-id.js | 88 +++++++ .../private-meth-static-ary-ptrn-rest-init-ary.js | 84 ++++++ .../private-meth-static-ary-ptrn-rest-init-id.js | 84 ++++++ .../private-meth-static-ary-ptrn-rest-init-obj.js | 84 ++++++ ...vate-meth-static-ary-ptrn-rest-not-final-ary.js | 84 ++++++ ...ivate-meth-static-ary-ptrn-rest-not-final-id.js | 84 ++++++ ...vate-meth-static-ary-ptrn-rest-not-final-obj.js | 84 ++++++ .../private-meth-static-ary-ptrn-rest-obj-id.js | 88 +++++++ ...rivate-meth-static-ary-ptrn-rest-obj-prop-id.js | 95 +++++++ ...private-meth-static-dflt-ary-init-iter-close.js | 98 +++++++ ...vate-meth-static-dflt-ary-init-iter-no-close.js | 98 +++++++ .../private-meth-static-dflt-ary-name-iter-val.js | 97 +++++++ ...meth-static-dflt-ary-ptrn-elem-ary-elem-init.js | 89 +++++++ ...meth-static-dflt-ary-ptrn-elem-ary-elem-iter.js | 90 +++++++ ...h-static-dflt-ary-ptrn-elem-ary-elision-init.js | 96 +++++++ ...h-static-dflt-ary-ptrn-elem-ary-elision-iter.js | 93 +++++++ ...eth-static-dflt-ary-ptrn-elem-ary-empty-init.js | 92 +++++++ ...eth-static-dflt-ary-ptrn-elem-ary-empty-iter.js | 89 +++++++ ...meth-static-dflt-ary-ptrn-elem-ary-rest-init.js | 93 +++++++ ...meth-static-dflt-ary-ptrn-elem-ary-rest-iter.js | 96 +++++++ ...-static-dflt-ary-ptrn-elem-id-init-exhausted.js | 88 +++++++ ...tic-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js | 89 +++++++ ...tic-dflt-ary-ptrn-elem-id-init-fn-name-class.js | 91 +++++++ ...tic-dflt-ary-ptrn-elem-id-init-fn-name-cover.js | 90 +++++++ ...static-dflt-ary-ptrn-elem-id-init-fn-name-fn.js | 90 +++++++ ...tatic-dflt-ary-ptrn-elem-id-init-fn-name-gen.js | 91 +++++++ ...-meth-static-dflt-ary-ptrn-elem-id-init-hole.js | 84 ++++++ ...th-static-dflt-ary-ptrn-elem-id-init-skipped.js | 93 +++++++ ...meth-static-dflt-ary-ptrn-elem-id-init-undef.js | 87 +++++++ ...h-static-dflt-ary-ptrn-elem-id-iter-complete.js | 91 +++++++ ...-meth-static-dflt-ary-ptrn-elem-id-iter-done.js | 86 +++++++ ...lt-ary-ptrn-elem-id-iter-val-array-prototype.js | 107 ++++++++ ...e-meth-static-dflt-ary-ptrn-elem-id-iter-val.js | 97 +++++++ ...e-meth-static-dflt-ary-ptrn-elem-obj-id-init.js | 89 +++++++ ...rivate-meth-static-dflt-ary-ptrn-elem-obj-id.js | 89 +++++++ ...h-static-dflt-ary-ptrn-elem-obj-prop-id-init.js | 99 ++++++++ ...e-meth-static-dflt-ary-ptrn-elem-obj-prop-id.js | 99 ++++++++ ...-meth-static-dflt-ary-ptrn-elision-exhausted.js | 94 +++++++ .../private-meth-static-dflt-ary-ptrn-elision.js | 103 ++++++++ .../private-meth-static-dflt-ary-ptrn-empty.js | 86 +++++++ ...vate-meth-static-dflt-ary-ptrn-rest-ary-elem.js | 110 ++++++++ ...e-meth-static-dflt-ary-ptrn-rest-ary-elision.js | 116 +++++++++ ...ate-meth-static-dflt-ary-ptrn-rest-ary-empty.js | 99 ++++++++ ...vate-meth-static-dflt-ary-ptrn-rest-ary-rest.js | 95 +++++++ ...ate-meth-static-dflt-ary-ptrn-rest-id-direct.js | 90 +++++++ ...te-meth-static-dflt-ary-ptrn-rest-id-elision.js | 91 +++++++ ...-meth-static-dflt-ary-ptrn-rest-id-exhausted.js | 87 +++++++ .../private-meth-static-dflt-ary-ptrn-rest-id.js | 88 +++++++ ...vate-meth-static-dflt-ary-ptrn-rest-init-ary.js | 84 ++++++ ...ivate-meth-static-dflt-ary-ptrn-rest-init-id.js | 84 ++++++ ...vate-meth-static-dflt-ary-ptrn-rest-init-obj.js | 84 ++++++ ...meth-static-dflt-ary-ptrn-rest-not-final-ary.js | 84 ++++++ ...-meth-static-dflt-ary-ptrn-rest-not-final-id.js | 84 ++++++ ...meth-static-dflt-ary-ptrn-rest-not-final-obj.js | 84 ++++++ ...rivate-meth-static-dflt-ary-ptrn-rest-obj-id.js | 88 +++++++ ...e-meth-static-dflt-ary-ptrn-rest-obj-prop-id.js | 95 +++++++ .../private-meth-static-dflt-obj-ptrn-empty.js | 87 +++++++ ...h-static-dflt-obj-ptrn-id-init-fn-name-arrow.js | 88 +++++++ ...h-static-dflt-obj-ptrn-id-init-fn-name-class.js | 90 +++++++ ...h-static-dflt-obj-ptrn-id-init-fn-name-cover.js | 89 +++++++ ...meth-static-dflt-obj-ptrn-id-init-fn-name-fn.js | 89 +++++++ ...eth-static-dflt-obj-ptrn-id-init-fn-name-gen.js | 90 +++++++ ...te-meth-static-dflt-obj-ptrn-id-init-skipped.js | 92 +++++++ ...-meth-static-dflt-obj-ptrn-id-trailing-comma.js | 82 ++++++ ...vate-meth-static-dflt-obj-ptrn-prop-ary-init.js | 91 +++++++ ...static-dflt-obj-ptrn-prop-ary-trailing-comma.js | 82 ++++++ .../private-meth-static-dflt-obj-ptrn-prop-ary.js | 89 +++++++ ...th-static-dflt-obj-ptrn-prop-id-init-skipped.js | 104 ++++++++ ...ivate-meth-static-dflt-obj-ptrn-prop-id-init.js | 85 +++++++ ...-static-dflt-obj-ptrn-prop-id-trailing-comma.js | 86 +++++++ .../private-meth-static-dflt-obj-ptrn-prop-id.js | 85 +++++++ ...vate-meth-static-dflt-obj-ptrn-prop-obj-init.js | 91 +++++++ .../private-meth-static-dflt-obj-ptrn-prop-obj.js | 89 +++++++ ...rivate-meth-static-dflt-obj-ptrn-rest-getter.js | 84 ++++++ ...tatic-dflt-obj-ptrn-rest-skip-non-enumerable.js | 92 +++++++ ...ivate-meth-static-dflt-obj-ptrn-rest-val-obj.js | 91 +++++++ .../dstr/private-meth-static-obj-ptrn-empty.js | 87 +++++++ ...e-meth-static-obj-ptrn-id-init-fn-name-arrow.js | 88 +++++++ ...e-meth-static-obj-ptrn-id-init-fn-name-class.js | 90 +++++++ ...e-meth-static-obj-ptrn-id-init-fn-name-cover.js | 89 +++++++ ...vate-meth-static-obj-ptrn-id-init-fn-name-fn.js | 89 +++++++ ...ate-meth-static-obj-ptrn-id-init-fn-name-gen.js | 90 +++++++ ...private-meth-static-obj-ptrn-id-init-skipped.js | 92 +++++++ ...ivate-meth-static-obj-ptrn-id-trailing-comma.js | 82 ++++++ .../private-meth-static-obj-ptrn-prop-ary-init.js | 91 +++++++ ...meth-static-obj-ptrn-prop-ary-trailing-comma.js | 82 ++++++ .../dstr/private-meth-static-obj-ptrn-prop-ary.js | 89 +++++++ ...te-meth-static-obj-ptrn-prop-id-init-skipped.js | 104 ++++++++ .../private-meth-static-obj-ptrn-prop-id-init.js | 85 +++++++ ...-meth-static-obj-ptrn-prop-id-trailing-comma.js | 86 +++++++ .../dstr/private-meth-static-obj-ptrn-prop-id.js | 85 +++++++ .../private-meth-static-obj-ptrn-prop-obj-init.js | 91 +++++++ .../dstr/private-meth-static-obj-ptrn-prop-obj.js | 89 +++++++ .../private-meth-static-obj-ptrn-rest-getter.js | 84 ++++++ ...eth-static-obj-ptrn-rest-skip-non-enumerable.js | 92 +++++++ .../private-meth-static-obj-ptrn-rest-val-obj.js | 91 +++++++ .../language/statements/class/dstr/shell.js | 0 .../abrupt-completition-on-field-initializer.js | 55 ++++ .../elements/after-same-line-gen-computed-names.js | 107 ++++++++ .../after-same-line-gen-computed-symbol-names.js | 105 ++++++++ ...privatename-identifier-semantics-stringvalue.js | 109 ++++++++ .../after-same-line-gen-literal-names-asi.js | 77 ++++++ .../elements/after-same-line-gen-literal-names.js | 96 +++++++ .../after-same-line-gen-private-field-usage.js | 49 ++++ ...er-same-line-gen-private-method-getter-usage.js | 49 ++++ .../after-same-line-gen-private-method-usage.js | 49 ++++ .../elements/after-same-line-gen-private-names.js | 71 ++++++ ...ame-line-gen-rs-field-identifier-initializer.js | 87 +++++++ .../after-same-line-gen-rs-field-identifier.js | 94 +++++++ .../after-same-line-gen-rs-private-getter-alt.js | 128 ++++++++++ .../after-same-line-gen-rs-private-getter.js | 128 ++++++++++ .../after-same-line-gen-rs-private-method-alt.js | 127 ++++++++++ .../after-same-line-gen-rs-private-method.js | 127 ++++++++++ .../after-same-line-gen-rs-private-setter-alt.js | 127 ++++++++++ .../after-same-line-gen-rs-private-setter.js | 127 ++++++++++ ...-same-line-gen-rs-privatename-identifier-alt.js | 109 ++++++++ ...en-rs-privatename-identifier-initializer-alt.js | 103 ++++++++ ...ne-gen-rs-privatename-identifier-initializer.js | 103 ++++++++ ...fter-same-line-gen-rs-privatename-identifier.js | 109 ++++++++ ...-generator-method-privatename-identifier-alt.js | 134 ++++++++++ ...sync-generator-method-privatename-identifier.js | 135 ++++++++++ ...atic-async-method-privatename-identifier-alt.js | 134 ++++++++++ ...s-static-async-method-privatename-identifier.js | 135 ++++++++++ ...-generator-method-privatename-identifier-alt.js | 124 +++++++++ ...atic-generator-method-privatename-identifier.js | 125 +++++++++ ...-rs-static-method-privatename-identifier-alt.js | 122 +++++++++ ...-gen-rs-static-method-privatename-identifier.js | 122 +++++++++ ...atic-privatename-identifier-alt-by-classname.js | 110 ++++++++ ...ine-gen-rs-static-privatename-identifier-alt.js | 110 ++++++++ ...s-static-privatename-identifier-by-classname.js | 110 ++++++++ ...name-identifier-initializer-alt-by-classname.js | 104 ++++++++ ...tatic-privatename-identifier-initializer-alt.js | 104 ++++++++ ...rs-static-privatename-identifier-initializer.js | 104 ++++++++ ...me-line-gen-rs-static-privatename-identifier.js | 110 ++++++++ .../after-same-line-gen-static-private-fields.js | 71 ++++++ ...-line-gen-static-private-methods-with-fields.js | 88 +++++++ .../after-same-line-gen-static-private-methods.js | 75 ++++++ .../after-same-line-gen-string-literal-names.js | 109 ++++++++ .../after-same-line-method-computed-names.js | 107 ++++++++ ...after-same-line-method-computed-symbol-names.js | 105 ++++++++ ...privatename-identifier-semantics-stringvalue.js | 109 ++++++++ .../after-same-line-method-literal-names-asi.js | 77 ++++++ .../after-same-line-method-literal-names.js | 96 +++++++ .../after-same-line-method-private-field-usage.js | 49 ++++ ...same-line-method-private-method-getter-usage.js | 49 ++++ .../after-same-line-method-private-method-usage.js | 49 ++++ .../after-same-line-method-private-names.js | 71 ++++++ ...-line-method-rs-field-identifier-initializer.js | 87 +++++++ .../after-same-line-method-rs-field-identifier.js | 94 +++++++ ...after-same-line-method-rs-private-getter-alt.js | 128 ++++++++++ .../after-same-line-method-rs-private-getter.js | 128 ++++++++++ ...after-same-line-method-rs-private-method-alt.js | 127 ++++++++++ .../after-same-line-method-rs-private-method.js | 127 ++++++++++ ...after-same-line-method-rs-private-setter-alt.js | 127 ++++++++++ .../after-same-line-method-rs-private-setter.js | 127 ++++++++++ ...me-line-method-rs-privatename-identifier-alt.js | 109 ++++++++ ...od-rs-privatename-identifier-initializer-alt.js | 103 ++++++++ ...method-rs-privatename-identifier-initializer.js | 103 ++++++++ ...r-same-line-method-rs-privatename-identifier.js | 109 ++++++++ ...-generator-method-privatename-identifier-alt.js | 134 ++++++++++ ...sync-generator-method-privatename-identifier.js | 135 ++++++++++ ...atic-async-method-privatename-identifier-alt.js | 134 ++++++++++ ...s-static-async-method-privatename-identifier.js | 135 ++++++++++ ...-generator-method-privatename-identifier-alt.js | 124 +++++++++ ...atic-generator-method-privatename-identifier.js | 125 +++++++++ ...-rs-static-method-privatename-identifier-alt.js | 122 +++++++++ ...thod-rs-static-method-privatename-identifier.js | 122 +++++++++ ...atic-privatename-identifier-alt-by-classname.js | 110 ++++++++ ...-method-rs-static-privatename-identifier-alt.js | 110 ++++++++ ...s-static-privatename-identifier-by-classname.js | 110 ++++++++ ...name-identifier-initializer-alt-by-classname.js | 104 ++++++++ ...tatic-privatename-identifier-initializer-alt.js | 104 ++++++++ ...rs-static-privatename-identifier-initializer.js | 104 ++++++++ ...line-method-rs-static-privatename-identifier.js | 110 ++++++++ ...after-same-line-method-static-private-fields.js | 71 ++++++ ...ne-method-static-private-methods-with-fields.js | 88 +++++++ ...fter-same-line-method-static-private-methods.js | 75 ++++++ .../after-same-line-method-string-literal-names.js | 109 ++++++++ ...er-same-line-static-async-gen-computed-names.js | 123 +++++++++ ...-line-static-async-gen-computed-symbol-names.js | 121 +++++++++ ...privatename-identifier-semantics-stringvalue.js | 125 +++++++++ ...same-line-static-async-gen-literal-names-asi.js | 93 +++++++ ...ter-same-line-static-async-gen-literal-names.js | 112 ++++++++ ...me-line-static-async-gen-private-field-usage.js | 65 +++++ ...static-async-gen-private-method-getter-usage.js | 65 +++++ ...e-line-static-async-gen-private-method-usage.js | 65 +++++ ...ter-same-line-static-async-gen-private-names.js | 87 +++++++ ...ic-async-gen-rs-field-identifier-initializer.js | 103 ++++++++ ...me-line-static-async-gen-rs-field-identifier.js | 110 ++++++++ ...-line-static-async-gen-rs-private-getter-alt.js | 144 +++++++++++ ...same-line-static-async-gen-rs-private-getter.js | 144 +++++++++++ ...-line-static-async-gen-rs-private-method-alt.js | 143 +++++++++++ ...same-line-static-async-gen-rs-private-method.js | 143 +++++++++++ ...-line-static-async-gen-rs-private-setter-alt.js | 143 +++++++++++ ...same-line-static-async-gen-rs-private-setter.js | 143 +++++++++++ ...atic-async-gen-rs-privatename-identifier-alt.js | 125 +++++++++ ...en-rs-privatename-identifier-initializer-alt.js | 119 +++++++++ ...nc-gen-rs-privatename-identifier-initializer.js | 119 +++++++++ ...e-static-async-gen-rs-privatename-identifier.js | 125 +++++++++ ...-generator-method-privatename-identifier-alt.js | 151 +++++++++++ ...sync-generator-method-privatename-identifier.js | 152 +++++++++++ ...atic-async-method-privatename-identifier-alt.js | 151 +++++++++++ ...s-static-async-method-privatename-identifier.js | 152 +++++++++++ ...-generator-method-privatename-identifier-alt.js | 140 ++++++++++ ...atic-generator-method-privatename-identifier.js | 141 +++++++++++ ...-rs-static-method-privatename-identifier-alt.js | 138 ++++++++++ ...-gen-rs-static-method-privatename-identifier.js | 138 ++++++++++ ...atic-privatename-identifier-alt-by-classname.js | 126 +++++++++ ...ync-gen-rs-static-privatename-identifier-alt.js | 126 +++++++++ ...s-static-privatename-identifier-by-classname.js | 126 +++++++++ ...name-identifier-initializer-alt-by-classname.js | 120 +++++++++ ...tatic-privatename-identifier-initializer-alt.js | 120 +++++++++ ...rs-static-privatename-identifier-initializer.js | 120 +++++++++ ...c-async-gen-rs-static-privatename-identifier.js | 126 +++++++++ ...-line-static-async-gen-static-private-fields.js | 87 +++++++ ...async-gen-static-private-methods-with-fields.js | 104 ++++++++ ...line-static-async-gen-static-private-methods.js | 91 +++++++ ...e-line-static-async-gen-string-literal-names.js | 125 +++++++++ ...same-line-static-async-method-computed-names.js | 122 +++++++++ ...ne-static-async-method-computed-symbol-names.js | 120 +++++++++ ...privatename-identifier-semantics-stringvalue.js | 124 +++++++++ ...e-line-static-async-method-literal-names-asi.js | 92 +++++++ ...-same-line-static-async-method-literal-names.js | 111 ++++++++ ...line-static-async-method-private-field-usage.js | 64 +++++ ...tic-async-method-private-method-getter-usage.js | 64 +++++ ...ine-static-async-method-private-method-usage.js | 64 +++++ ...-same-line-static-async-method-private-names.js | 86 +++++++ ...async-method-rs-field-identifier-initializer.js | 102 ++++++++ ...line-static-async-method-rs-field-identifier.js | 109 ++++++++ ...ne-static-async-method-rs-private-getter-alt.js | 143 +++++++++++ ...e-line-static-async-method-rs-private-getter.js | 143 +++++++++++ ...ne-static-async-method-rs-private-method-alt.js | 142 +++++++++++ ...e-line-static-async-method-rs-private-method.js | 142 +++++++++++ ...ne-static-async-method-rs-private-setter-alt.js | 142 +++++++++++ ...e-line-static-async-method-rs-private-setter.js | 142 +++++++++++ ...c-async-method-rs-privatename-identifier-alt.js | 124 +++++++++ ...od-rs-privatename-identifier-initializer-alt.js | 118 +++++++++ ...method-rs-privatename-identifier-initializer.js | 118 +++++++++ ...tatic-async-method-rs-privatename-identifier.js | 124 +++++++++ ...-generator-method-privatename-identifier-alt.js | 150 +++++++++++ ...sync-generator-method-privatename-identifier.js | 151 +++++++++++ ...atic-async-method-privatename-identifier-alt.js | 150 +++++++++++ ...s-static-async-method-privatename-identifier.js | 151 +++++++++++ ...-generator-method-privatename-identifier-alt.js | 139 ++++++++++ ...atic-generator-method-privatename-identifier.js | 140 ++++++++++ ...-rs-static-method-privatename-identifier-alt.js | 137 ++++++++++ ...thod-rs-static-method-privatename-identifier.js | 137 ++++++++++ ...atic-privatename-identifier-alt-by-classname.js | 125 +++++++++ ...-method-rs-static-privatename-identifier-alt.js | 125 +++++++++ ...s-static-privatename-identifier-by-classname.js | 125 +++++++++ ...name-identifier-initializer-alt-by-classname.js | 119 +++++++++ ...tatic-privatename-identifier-initializer-alt.js | 119 +++++++++ ...rs-static-privatename-identifier-initializer.js | 119 +++++++++ ...sync-method-rs-static-privatename-identifier.js | 125 +++++++++ ...ne-static-async-method-static-private-fields.js | 86 +++++++ ...nc-method-static-private-methods-with-fields.js | 103 ++++++++ ...e-static-async-method-static-private-methods.js | 90 +++++++ ...ine-static-async-method-string-literal-names.js | 124 +++++++++ .../after-same-line-static-gen-computed-names.js | 110 ++++++++ ...r-same-line-static-gen-computed-symbol-names.js | 108 ++++++++ ...privatename-identifier-semantics-stringvalue.js | 112 ++++++++ ...after-same-line-static-gen-literal-names-asi.js | 80 ++++++ .../after-same-line-static-gen-literal-names.js | 99 ++++++++ ...ter-same-line-static-gen-private-field-usage.js | 52 ++++ ...-line-static-gen-private-method-getter-usage.js | 52 ++++ ...er-same-line-static-gen-private-method-usage.js | 52 ++++ .../after-same-line-static-gen-private-names.js | 74 ++++++ ...e-static-gen-rs-field-identifier-initializer.js | 90 +++++++ ...ter-same-line-static-gen-rs-field-identifier.js | 97 +++++++ ...r-same-line-static-gen-rs-private-getter-alt.js | 131 ++++++++++ ...after-same-line-static-gen-rs-private-getter.js | 131 ++++++++++ ...r-same-line-static-gen-rs-private-method-alt.js | 130 ++++++++++ ...after-same-line-static-gen-rs-private-method.js | 130 ++++++++++ ...r-same-line-static-gen-rs-private-setter-alt.js | 130 ++++++++++ ...after-same-line-static-gen-rs-private-setter.js | 130 ++++++++++ ...ine-static-gen-rs-privatename-identifier-alt.js | 112 ++++++++ ...en-rs-privatename-identifier-initializer-alt.js | 106 ++++++++ ...ic-gen-rs-privatename-identifier-initializer.js | 106 ++++++++ ...me-line-static-gen-rs-privatename-identifier.js | 112 ++++++++ ...-generator-method-privatename-identifier-alt.js | 137 ++++++++++ ...sync-generator-method-privatename-identifier.js | 138 ++++++++++ ...atic-async-method-privatename-identifier-alt.js | 137 ++++++++++ ...s-static-async-method-privatename-identifier.js | 138 ++++++++++ ...-generator-method-privatename-identifier-alt.js | 127 ++++++++++ ...atic-generator-method-privatename-identifier.js | 128 ++++++++++ ...-rs-static-method-privatename-identifier-alt.js | 125 +++++++++ ...-gen-rs-static-method-privatename-identifier.js | 125 +++++++++ ...atic-privatename-identifier-alt-by-classname.js | 113 +++++++++ ...tic-gen-rs-static-privatename-identifier-alt.js | 113 +++++++++ ...s-static-privatename-identifier-by-classname.js | 113 +++++++++ ...name-identifier-initializer-alt-by-classname.js | 107 ++++++++ ...tatic-privatename-identifier-initializer-alt.js | 107 ++++++++ ...rs-static-privatename-identifier-initializer.js | 107 ++++++++ ...-static-gen-rs-static-privatename-identifier.js | 113 +++++++++ ...r-same-line-static-gen-static-private-fields.js | 74 ++++++ ...tatic-gen-static-private-methods-with-fields.js | 91 +++++++ ...-same-line-static-gen-static-private-methods.js | 78 ++++++ ...er-same-line-static-gen-string-literal-names.js | 112 ++++++++ ...after-same-line-static-method-computed-names.js | 110 ++++++++ ...ame-line-static-method-computed-symbol-names.js | 108 ++++++++ ...privatename-identifier-semantics-stringvalue.js | 112 ++++++++ ...er-same-line-static-method-literal-names-asi.js | 80 ++++++ .../after-same-line-static-method-literal-names.js | 99 ++++++++ ...-same-line-static-method-private-field-usage.js | 52 ++++ ...ne-static-method-private-method-getter-usage.js | 52 ++++ ...same-line-static-method-private-method-usage.js | 52 ++++ .../after-same-line-static-method-private-names.js | 74 ++++++ ...tatic-method-rs-field-identifier-initializer.js | 90 +++++++ ...-same-line-static-method-rs-field-identifier.js | 97 +++++++ ...ame-line-static-method-rs-private-getter-alt.js | 131 ++++++++++ ...er-same-line-static-method-rs-private-getter.js | 131 ++++++++++ ...ame-line-static-method-rs-private-method-alt.js | 130 ++++++++++ ...er-same-line-static-method-rs-private-method.js | 130 ++++++++++ ...ame-line-static-method-rs-private-setter-alt.js | 130 ++++++++++ ...er-same-line-static-method-rs-private-setter.js | 130 ++++++++++ ...-static-method-rs-privatename-identifier-alt.js | 112 ++++++++ ...od-rs-privatename-identifier-initializer-alt.js | 106 ++++++++ ...method-rs-privatename-identifier-initializer.js | 106 ++++++++ ...line-static-method-rs-privatename-identifier.js | 112 ++++++++ ...-generator-method-privatename-identifier-alt.js | 137 ++++++++++ ...sync-generator-method-privatename-identifier.js | 138 ++++++++++ ...atic-async-method-privatename-identifier-alt.js | 137 ++++++++++ ...s-static-async-method-privatename-identifier.js | 138 ++++++++++ ...-generator-method-privatename-identifier-alt.js | 127 ++++++++++ ...atic-generator-method-privatename-identifier.js | 128 ++++++++++ ...-rs-static-method-privatename-identifier-alt.js | 125 +++++++++ ...thod-rs-static-method-privatename-identifier.js | 125 +++++++++ ...atic-privatename-identifier-alt-by-classname.js | 113 +++++++++ ...-method-rs-static-privatename-identifier-alt.js | 113 +++++++++ ...s-static-privatename-identifier-by-classname.js | 113 +++++++++ ...name-identifier-initializer-alt-by-classname.js | 107 ++++++++ ...tatic-privatename-identifier-initializer-alt.js | 107 ++++++++ ...rs-static-privatename-identifier-initializer.js | 107 ++++++++ ...atic-method-rs-static-privatename-identifier.js | 113 +++++++++ ...ame-line-static-method-static-private-fields.js | 74 ++++++ ...ic-method-static-private-methods-with-fields.js | 91 +++++++ ...me-line-static-method-static-private-methods.js | 78 ++++++ ...same-line-static-method-string-literal-names.js | 112 ++++++++ ...ved-cls-direct-eval-contains-superproperty-1.js | 36 +++ ...ved-cls-direct-eval-contains-superproperty-2.js | 33 +++ ...ved-cls-direct-eval-err-contains-supercall-1.js | 38 +++ ...ved-cls-direct-eval-err-contains-supercall-2.js | 31 +++ ...rived-cls-direct-eval-err-contains-supercall.js | 38 +++ ...d-cls-indirect-eval-contains-superproperty-1.js | 36 +++ ...d-cls-indirect-eval-contains-superproperty-2.js | 33 +++ ...d-cls-indirect-eval-err-contains-supercall-1.js | 36 +++ ...d-cls-indirect-eval-err-contains-supercall-2.js | 29 +++ ...ved-cls-indirect-eval-err-contains-supercall.js | 36 +++ ...rrow-body-direct-eval-err-contains-arguments.js | 38 +++ ...rrow-body-direct-eval-err-contains-newtarget.js | 36 +++ ...ow-body-indirect-eval-err-contains-newtarget.js | 35 +++ ...ved-cls-direct-eval-contains-superproperty-1.js | 39 +++ ...ved-cls-direct-eval-contains-superproperty-2.js | 36 +++ ...ved-cls-direct-eval-err-contains-supercall-1.js | 38 +++ ...ved-cls-direct-eval-err-contains-supercall-2.js | 31 +++ ...rived-cls-direct-eval-err-contains-supercall.js | 38 +++ ...d-cls-indirect-eval-contains-superproperty-1.js | 36 +++ ...d-cls-indirect-eval-contains-superproperty-2.js | 33 +++ ...d-cls-indirect-eval-err-contains-supercall-1.js | 36 +++ ...d-cls-indirect-eval-err-contains-supercall-2.js | 29 +++ ...ved-cls-indirect-eval-err-contains-supercall.js | 36 +++ ...y-private-direct-eval-err-contains-arguments.js | 41 +++ ...y-private-direct-eval-err-contains-newtarget.js | 39 +++ ...private-indirect-eval-err-contains-newtarget.js | 35 +++ .../arrow-fnc-init-err-contains-arguments.js | 35 +++ .../elements/arrow-fnc-init-err-contains-super.js | 28 ++ .../await-as-binding-identifier-escaped.js | 37 +++ .../await-as-binding-identifier.js | 37 +++ .../await-as-identifier-reference-escaped.js | 37 +++ .../await-as-identifier-reference.js | 37 +++ .../await-as-label-identifier-escaped.js | 37 +++ .../await-as-label-identifier.js | 37 +++ .../async-gen-private-method-static/browser.js | 0 .../async-gen-private-method-static/shell.js | 0 .../yield-as-binding-identifier-escaped.js | 37 +++ .../yield-as-binding-identifier.js | 37 +++ .../yield-as-identifier-reference-escaped.js | 37 +++ .../yield-as-identifier-reference.js | 37 +++ .../yield-as-label-identifier-escaped.js | 37 +++ .../yield-as-label-identifier.js | 37 +++ .../yield-identifier-spread-strict-strict.js | 76 ++++++ .../yield-identifier-strict-strict.js | 67 +++++ .../yield-promise-reject-next-catch.js | 72 ++++++ ...mise-reject-next-for-await-of-async-iterator.js | 78 ++++++ ...omise-reject-next-for-await-of-sync-iterator.js | 77 ++++++ ...romise-reject-next-yield-star-async-iterator.js | 76 ++++++ ...promise-reject-next-yield-star-sync-iterator.js | 75 ++++++ .../yield-promise-reject-next.js | 72 ++++++ .../yield-spread-arr-multiple.js | 78 ++++++ .../yield-spread-arr-single.js | 77 ++++++ .../yield-spread-obj.js | 80 ++++++ .../yield-star-async-next.js | 247 ++++++++++++++++++ .../yield-star-async-return.js | 263 +++++++++++++++++++ .../yield-star-async-throw.js | 271 ++++++++++++++++++++ .../yield-star-expr-abrupt.js | 82 ++++++ .../yield-star-getiter-async-get-abrupt.js | 102 ++++++++ ...tar-getiter-async-not-callable-boolean-throw.js | 101 ++++++++ ...star-getiter-async-not-callable-number-throw.js | 101 ++++++++ ...star-getiter-async-not-callable-object-throw.js | 101 ++++++++ ...star-getiter-async-not-callable-string-throw.js | 101 ++++++++ ...star-getiter-async-not-callable-symbol-throw.js | 101 ++++++++ ...ield-star-getiter-async-null-sync-get-abrupt.js | 107 ++++++++ .../yield-star-getiter-async-returns-abrupt.js | 98 +++++++ ...eld-star-getiter-async-returns-boolean-throw.js | 98 +++++++ .../yield-star-getiter-async-returns-null-throw.js | 98 +++++++ ...ield-star-getiter-async-returns-number-throw.js | 98 +++++++ ...ield-star-getiter-async-returns-string-throw.js | 98 +++++++ ...ield-star-getiter-async-returns-symbol-throw.js | 98 +++++++ ...d-star-getiter-async-returns-undefined-throw.js | 98 +++++++ ...star-getiter-async-undefined-sync-get-abrupt.js | 107 ++++++++ .../yield-star-getiter-sync-get-abrupt.js | 101 ++++++++ ...star-getiter-sync-not-callable-boolean-throw.js | 100 ++++++++ ...-star-getiter-sync-not-callable-number-throw.js | 100 ++++++++ ...-star-getiter-sync-not-callable-object-throw.js | 100 ++++++++ ...-star-getiter-sync-not-callable-string-throw.js | 100 ++++++++ ...-star-getiter-sync-not-callable-symbol-throw.js | 100 ++++++++ .../yield-star-getiter-sync-returns-abrupt.js | 95 +++++++ ...ield-star-getiter-sync-returns-boolean-throw.js | 100 ++++++++ .../yield-star-getiter-sync-returns-null-throw.js | 100 ++++++++ ...yield-star-getiter-sync-returns-number-throw.js | 100 ++++++++ ...yield-star-getiter-sync-returns-string-throw.js | 100 ++++++++ ...yield-star-getiter-sync-returns-symbol-throw.js | 100 ++++++++ ...ld-star-getiter-sync-returns-undefined-throw.js | 100 ++++++++ .../yield-star-next-call-done-get-abrupt.js | 101 ++++++++ .../yield-star-next-call-returns-abrupt.js | 93 +++++++ .../yield-star-next-call-value-get-abrupt.js | 103 ++++++++ .../yield-star-next-get-abrupt.js | 93 +++++++ .../yield-star-next-non-object-ignores-then.js | 113 +++++++++ .../yield-star-next-not-callable-boolean-throw.js | 90 +++++++ .../yield-star-next-not-callable-null-throw.js | 90 +++++++ .../yield-star-next-not-callable-number-throw.js | 90 +++++++ .../yield-star-next-not-callable-object-throw.js | 90 +++++++ .../yield-star-next-not-callable-string-throw.js | 90 +++++++ .../yield-star-next-not-callable-symbol-throw.js | 90 +++++++ ...yield-star-next-not-callable-undefined-throw.js | 90 +++++++ .../yield-star-next-then-get-abrupt.js | 117 +++++++++ ...ext-then-non-callable-boolean-fulfillpromise.js | 111 ++++++++ ...r-next-then-non-callable-null-fulfillpromise.js | 111 ++++++++ ...next-then-non-callable-number-fulfillpromise.js | 111 ++++++++ ...next-then-non-callable-object-fulfillpromise.js | 111 ++++++++ ...next-then-non-callable-string-fulfillpromise.js | 111 ++++++++ ...next-then-non-callable-symbol-fulfillpromise.js | 111 ++++++++ ...t-then-non-callable-undefined-fulfillpromise.js | 111 ++++++++ .../yield-star-next-then-returns-abrupt.js | 117 +++++++++ .../yield-star-sync-next.js | 250 ++++++++++++++++++ .../yield-star-sync-return.js | 225 +++++++++++++++++ .../yield-star-sync-throw.js | 231 +++++++++++++++++ .../await-as-binding-identifier-escaped.js | 37 +++ .../await-as-binding-identifier.js | 37 +++ .../await-as-identifier-reference-escaped.js | 37 +++ .../await-as-identifier-reference.js | 37 +++ .../await-as-label-identifier-escaped.js | 37 +++ .../await-as-label-identifier.js | 37 +++ .../elements/async-gen-private-method/browser.js | 0 .../elements/async-gen-private-method/shell.js | 0 .../yield-as-binding-identifier-escaped.js | 37 +++ .../yield-as-binding-identifier.js | 37 +++ .../yield-as-identifier-reference-escaped.js | 37 +++ .../yield-as-identifier-reference.js | 37 +++ .../yield-as-label-identifier-escaped.js | 37 +++ .../yield-as-label-identifier.js | 37 +++ .../yield-identifier-spread-strict-strict.js | 86 +++++++ .../yield-identifier-strict-strict.js | 77 ++++++ .../yield-promise-reject-next-catch.js | 82 ++++++ ...mise-reject-next-for-await-of-async-iterator.js | 88 +++++++ ...omise-reject-next-for-await-of-sync-iterator.js | 87 +++++++ ...romise-reject-next-yield-star-async-iterator.js | 86 +++++++ ...promise-reject-next-yield-star-sync-iterator.js | 85 +++++++ .../yield-promise-reject-next.js | 82 ++++++ .../yield-spread-arr-multiple.js | 88 +++++++ .../yield-spread-arr-single.js | 87 +++++++ .../async-gen-private-method/yield-spread-obj.js | 90 +++++++ .../yield-star-async-next.js | 257 +++++++++++++++++++ .../yield-star-async-return.js | 273 ++++++++++++++++++++ .../yield-star-async-throw.js | 281 +++++++++++++++++++++ .../yield-star-expr-abrupt.js | 92 +++++++ .../yield-star-getiter-async-get-abrupt.js | 112 ++++++++ ...tar-getiter-async-not-callable-boolean-throw.js | 111 ++++++++ ...star-getiter-async-not-callable-number-throw.js | 111 ++++++++ ...star-getiter-async-not-callable-object-throw.js | 111 ++++++++ ...star-getiter-async-not-callable-string-throw.js | 111 ++++++++ ...star-getiter-async-not-callable-symbol-throw.js | 111 ++++++++ ...ield-star-getiter-async-null-sync-get-abrupt.js | 117 +++++++++ .../yield-star-getiter-async-returns-abrupt.js | 108 ++++++++ ...eld-star-getiter-async-returns-boolean-throw.js | 108 ++++++++ .../yield-star-getiter-async-returns-null-throw.js | 108 ++++++++ ...ield-star-getiter-async-returns-number-throw.js | 108 ++++++++ ...ield-star-getiter-async-returns-string-throw.js | 108 ++++++++ ...ield-star-getiter-async-returns-symbol-throw.js | 108 ++++++++ ...d-star-getiter-async-returns-undefined-throw.js | 108 ++++++++ ...star-getiter-async-undefined-sync-get-abrupt.js | 117 +++++++++ .../yield-star-getiter-sync-get-abrupt.js | 111 ++++++++ ...star-getiter-sync-not-callable-boolean-throw.js | 110 ++++++++ ...-star-getiter-sync-not-callable-number-throw.js | 110 ++++++++ ...-star-getiter-sync-not-callable-object-throw.js | 110 ++++++++ ...-star-getiter-sync-not-callable-string-throw.js | 110 ++++++++ ...-star-getiter-sync-not-callable-symbol-throw.js | 110 ++++++++ .../yield-star-getiter-sync-returns-abrupt.js | 105 ++++++++ ...ield-star-getiter-sync-returns-boolean-throw.js | 110 ++++++++ .../yield-star-getiter-sync-returns-null-throw.js | 110 ++++++++ ...yield-star-getiter-sync-returns-number-throw.js | 110 ++++++++ ...yield-star-getiter-sync-returns-string-throw.js | 110 ++++++++ ...yield-star-getiter-sync-returns-symbol-throw.js | 110 ++++++++ ...ld-star-getiter-sync-returns-undefined-throw.js | 110 ++++++++ .../yield-star-next-call-done-get-abrupt.js | 111 ++++++++ .../yield-star-next-call-returns-abrupt.js | 103 ++++++++ .../yield-star-next-call-value-get-abrupt.js | 113 +++++++++ .../yield-star-next-get-abrupt.js | 103 ++++++++ .../yield-star-next-non-object-ignores-then.js | 123 +++++++++ .../yield-star-next-not-callable-boolean-throw.js | 100 ++++++++ .../yield-star-next-not-callable-null-throw.js | 100 ++++++++ .../yield-star-next-not-callable-number-throw.js | 100 ++++++++ .../yield-star-next-not-callable-object-throw.js | 100 ++++++++ .../yield-star-next-not-callable-string-throw.js | 100 ++++++++ .../yield-star-next-not-callable-symbol-throw.js | 100 ++++++++ ...yield-star-next-not-callable-undefined-throw.js | 100 ++++++++ .../yield-star-next-then-get-abrupt.js | 127 ++++++++++ ...ext-then-non-callable-boolean-fulfillpromise.js | 121 +++++++++ ...r-next-then-non-callable-null-fulfillpromise.js | 121 +++++++++ ...next-then-non-callable-number-fulfillpromise.js | 121 +++++++++ ...next-then-non-callable-object-fulfillpromise.js | 121 +++++++++ ...next-then-non-callable-string-fulfillpromise.js | 121 +++++++++ ...next-then-non-callable-symbol-fulfillpromise.js | 121 +++++++++ ...t-then-non-callable-undefined-fulfillpromise.js | 121 +++++++++ .../yield-star-next-then-returns-abrupt.js | 127 ++++++++++ .../yield-star-sync-next.js | 260 +++++++++++++++++++ .../yield-star-sync-return.js | 235 +++++++++++++++++ .../yield-star-sync-throw.js | 241 ++++++++++++++++++ .../await-as-binding-identifier-escaped.js | 41 +++ .../await-as-binding-identifier.js | 41 +++ .../await-as-identifier-reference-escaped.js | 41 +++ .../await-as-identifier-reference.js | 41 +++ .../await-as-label-identifier-escaped.js | 41 +++ .../await-as-label-identifier.js | 41 +++ .../async-private-method-static/browser.js | 0 ...arrow-returns-arguments-from-parent-function.js | 44 ++++ .../returns-async-arrow-returns-newtarget.js | 43 ++++ .../returns-async-arrow.js | 43 ++++ ...function-returns-arguments-from-own-function.js | 44 ++++ .../returns-async-function-returns-newtarget.js | 43 ++++ .../returns-async-function.js | 43 ++++ .../elements/async-private-method-static/shell.js | 0 .../await-as-binding-identifier-escaped.js | 39 +++ .../await-as-binding-identifier.js | 39 +++ .../await-as-identifier-reference-escaped.js | 39 +++ .../await-as-identifier-reference.js | 39 +++ .../await-as-label-identifier-escaped.js | 39 +++ .../await-as-label-identifier.js | 39 +++ .../class/elements/async-private-method/browser.js | 0 ...arrow-returns-arguments-from-parent-function.js | 45 ++++ .../returns-async-arrow-returns-newtarget.js | 44 ++++ .../async-private-method/returns-async-arrow.js | 44 ++++ ...function-returns-arguments-from-own-function.js | 45 ++++ .../returns-async-function-returns-newtarget.js | 44 ++++ .../async-private-method/returns-async-function.js | 44 ++++ .../class/elements/async-private-method/shell.js | 0 .../language/statements/class/elements/browser.js | 0 .../elements/class-field-is-observable-by-proxy.js | 48 ++++ .../class-field-on-frozen-objects-strict.js | 30 +++ .../comp-name-init-err-contains-arguments.js | 36 +++ .../elements/comp-name-init-err-contains-super.js | 29 +++ .../elements/computed-name-toprimitive-symbol.js | 123 +++++++++ .../class/elements/computed-name-toprimitive.js | 120 +++++++++ .../computed-property-abrupt-completition.js | 45 ++++ .../elements/ctor-called-after-fields-init.js | 35 +++ ...ved-cls-direct-eval-contains-superproperty-1.js | 36 +++ ...ved-cls-direct-eval-contains-superproperty-2.js | 33 +++ ...ved-cls-direct-eval-err-contains-supercall-1.js | 38 +++ ...ved-cls-direct-eval-err-contains-supercall-2.js | 31 +++ ...rived-cls-direct-eval-err-contains-supercall.js | 38 +++ ...d-cls-indirect-eval-contains-superproperty-1.js | 38 +++ ...d-cls-indirect-eval-contains-superproperty-2.js | 35 +++ ...d-cls-indirect-eval-err-contains-supercall-1.js | 38 +++ ...d-cls-indirect-eval-err-contains-supercall-2.js | 31 +++ ...ved-cls-indirect-eval-err-contains-supercall.js | 38 +++ .../elements/direct-eval-err-contains-arguments.js | 38 +++ .../elements/direct-eval-err-contains-newtarget.js | 36 +++ .../equality-init-err-contains-arguments.js | 35 +++ .../elements/equality-init-err-contains-super.js | 28 ++ .../class/elements/evaluation-error/browser.js | 0 .../computed-name-referenceerror.js | 58 +++++ .../computed-name-toprimitive-err.js | 60 +++++ ...omputed-name-toprimitive-returns-noncallable.js | 59 +++++ .../computed-name-toprimitive-returns-nonobject.js | 58 +++++ .../evaluation-error/computed-name-tostring-err.js | 61 +++++ .../evaluation-error/computed-name-valueof-err.js | 61 +++++ .../class/elements/evaluation-error/shell.js | 0 .../statements/class/elements/field-declaration.js | 111 ++++++++ ...field-definition-accessor-no-line-terminator.js | 52 ++++ ...ielddefinition-initializer-abrupt-completion.js | 48 ++++ .../elements/fields-anonymous-function-length.js | 48 ++++ .../statements/class/elements/fields-asi-1.js | 21 ++ .../statements/class/elements/fields-asi-2.js | 19 ++ .../statements/class/elements/fields-asi-3.js | 19 ++ .../statements/class/elements/fields-asi-4.js | 19 ++ .../statements/class/elements/fields-asi-5.js | 30 +++ .../class/elements/fields-asi-same-line-1.js | 18 ++ .../class/elements/fields-asi-same-line-2.js | 18 ++ .../fields-computed-name-propname-constructor.js | 54 ++++ ...ame-static-computed-var-propname-constructor.js | 82 ++++++ ...-name-static-computed-var-propname-prototype.js | 34 +++ ...ds-computed-name-static-propname-constructor.js | 81 ++++++ ...elds-computed-name-static-propname-prototype.js | 32 +++ .../elements/fields-duplicate-privatenames.js | 25 ++ .../fields-hash-constructor-is-a-valid-name.js | 42 +++ .../fields-literal-name-propname-constructor.js | 30 +++ ...lds-literal-name-static-propname-constructor.js | 30 +++ ...ields-literal-name-static-propname-prototype.js | 30 +++ .../fields-string-name-propname-constructor.js | 31 +++ ...elds-string-name-static-propname-constructor.js | 31 +++ ...fields-string-name-static-propname-prototype.js | 31 +++ .../elements/gen-private-method-static/browser.js | 0 .../elements/gen-private-method-static/shell.js | 0 .../yield-as-binding-identifier-escaped.js | 36 +++ .../yield-as-binding-identifier.js | 36 +++ .../yield-as-identifier-reference-escaped.js | 36 +++ .../yield-as-identifier-reference.js | 36 +++ .../yield-as-label-identifier-escaped.js | 36 +++ .../yield-as-label-identifier.js | 36 +++ .../yield-identifier-spread-strict-strict.js | 75 ++++++ .../yield-identifier-strict-strict.js | 66 +++++ .../yield-spread-arr-multiple.js | 73 ++++++ .../yield-spread-arr-single.js | 75 ++++++ .../gen-private-method-static/yield-spread-obj.js | 78 ++++++ .../class/elements/gen-private-method/browser.js | 0 .../class/elements/gen-private-method/shell.js | 0 .../yield-as-binding-identifier-escaped.js | 36 +++ .../yield-as-binding-identifier.js | 36 +++ .../yield-as-identifier-reference-escaped.js | 36 +++ .../yield-as-identifier-reference.js | 36 +++ .../yield-as-label-identifier-escaped.js | 36 +++ .../yield-as-label-identifier.js | 36 +++ .../yield-identifier-spread-strict-strict.js | 85 +++++++ .../yield-identifier-strict-strict.js | 76 ++++++ .../yield-spread-arr-multiple.js | 83 ++++++ .../gen-private-method/yield-spread-arr-single.js | 85 +++++++ .../gen-private-method/yield-spread-obj.js | 88 +++++++ .../get-access-of-missing-private-getter.js | 41 +++ .../get-access-of-missing-private-static-getter.js | 40 +++ ...et-access-of-missing-shadowed-private-getter.js | 91 +++++++ .../grammar-private-field-optional-chaining.js | 42 +++ .../elements/indirect-eval-contains-arguments.js | 23 ++ .../indirect-eval-err-contains-newtarget.js | 37 +++ .../class/elements/init-err-evaluation.js | 38 +++ .../elements/init-value-defined-after-class.js | 50 ++++ .../class/elements/init-value-incremental.js | 70 +++++ ...tercalated-static-non-static-computed-fields.js | 78 ++++++ .../literal-name-init-err-contains-arguments.js | 35 +++ .../literal-name-init-err-contains-super.js | 28 ++ .../multiple-definitions-computed-names.js | 158 ++++++++++++ .../multiple-definitions-computed-symbol-names.js | 156 ++++++++++++ ...privatename-identifier-semantics-stringvalue.js | 160 ++++++++++++ .../multiple-definitions-literal-names-asi.js | 128 ++++++++++ .../elements/multiple-definitions-literal-names.js | 147 +++++++++++ .../multiple-definitions-private-field-usage.js | 100 ++++++++ ...iple-definitions-private-method-getter-usage.js | 100 ++++++++ .../multiple-definitions-private-method-usage.js | 100 ++++++++ .../elements/multiple-definitions-private-names.js | 122 +++++++++ ...-definitions-rs-field-identifier-initializer.js | 138 ++++++++++ .../multiple-definitions-rs-field-identifier.js | 145 +++++++++++ .../multiple-definitions-rs-private-getter-alt.js | 179 +++++++++++++ .../multiple-definitions-rs-private-getter.js | 179 +++++++++++++ .../multiple-definitions-rs-private-method-alt.js | 178 +++++++++++++ .../multiple-definitions-rs-private-method.js | 178 +++++++++++++ .../multiple-definitions-rs-private-setter-alt.js | 178 +++++++++++++ .../multiple-definitions-rs-private-setter.js | 178 +++++++++++++ ...le-definitions-rs-privatename-identifier-alt.js | 160 ++++++++++++ ...ns-rs-privatename-identifier-initializer-alt.js | 154 +++++++++++ ...itions-rs-privatename-identifier-initializer.js | 154 +++++++++++ ...ltiple-definitions-rs-privatename-identifier.js | 160 ++++++++++++ ...-generator-method-privatename-identifier-alt.js | 185 ++++++++++++++ ...sync-generator-method-privatename-identifier.js | 186 ++++++++++++++ ...atic-async-method-privatename-identifier-alt.js | 185 ++++++++++++++ ...s-static-async-method-privatename-identifier.js | 186 ++++++++++++++ ...-generator-method-privatename-identifier-alt.js | 175 +++++++++++++ ...atic-generator-method-privatename-identifier.js | 176 +++++++++++++ ...-rs-static-method-privatename-identifier-alt.js | 173 +++++++++++++ ...ions-rs-static-method-privatename-identifier.js | 173 +++++++++++++ ...atic-privatename-identifier-alt-by-classname.js | 161 ++++++++++++ ...nitions-rs-static-privatename-identifier-alt.js | 161 ++++++++++++ ...s-static-privatename-identifier-by-classname.js | 161 ++++++++++++ ...name-identifier-initializer-alt-by-classname.js | 155 ++++++++++++ ...tatic-privatename-identifier-initializer-alt.js | 155 ++++++++++++ ...rs-static-privatename-identifier-initializer.js | 155 ++++++++++++ ...definitions-rs-static-privatename-identifier.js | 161 ++++++++++++ .../multiple-definitions-static-private-fields.js | 122 +++++++++ ...finitions-static-private-methods-with-fields.js | 139 ++++++++++ .../multiple-definitions-static-private-methods.js | 126 +++++++++ .../multiple-definitions-string-literal-names.js | 160 ++++++++++++ .../multiple-stacked-definitions-computed-names.js | 130 ++++++++++ ...le-stacked-definitions-computed-symbol-names.js | 128 ++++++++++ ...privatename-identifier-semantics-stringvalue.js | 132 ++++++++++ ...ltiple-stacked-definitions-literal-names-asi.js | 100 ++++++++ .../multiple-stacked-definitions-literal-names.js | 119 +++++++++ ...iple-stacked-definitions-private-field-usage.js | 72 ++++++ ...cked-definitions-private-method-getter-usage.js | 72 ++++++ ...ple-stacked-definitions-private-method-usage.js | 72 ++++++ .../multiple-stacked-definitions-private-names.js | 94 +++++++ ...-definitions-rs-field-identifier-initializer.js | 110 ++++++++ ...iple-stacked-definitions-rs-field-identifier.js | 117 +++++++++ ...le-stacked-definitions-rs-private-getter-alt.js | 151 +++++++++++ ...ltiple-stacked-definitions-rs-private-getter.js | 151 +++++++++++ ...le-stacked-definitions-rs-private-method-alt.js | 150 +++++++++++ ...ltiple-stacked-definitions-rs-private-method.js | 150 +++++++++++ ...le-stacked-definitions-rs-private-setter-alt.js | 150 +++++++++++ ...ltiple-stacked-definitions-rs-private-setter.js | 150 +++++++++++ ...ed-definitions-rs-privatename-identifier-alt.js | 132 ++++++++++ ...ns-rs-privatename-identifier-initializer-alt.js | 126 +++++++++ ...itions-rs-privatename-identifier-initializer.js | 126 +++++++++ ...tacked-definitions-rs-privatename-identifier.js | 132 ++++++++++ ...-generator-method-privatename-identifier-alt.js | 157 ++++++++++++ ...sync-generator-method-privatename-identifier.js | 158 ++++++++++++ ...atic-async-method-privatename-identifier-alt.js | 157 ++++++++++++ ...s-static-async-method-privatename-identifier.js | 158 ++++++++++++ ...-generator-method-privatename-identifier-alt.js | 147 +++++++++++ ...atic-generator-method-privatename-identifier.js | 148 +++++++++++ ...-rs-static-method-privatename-identifier-alt.js | 145 +++++++++++ ...ions-rs-static-method-privatename-identifier.js | 145 +++++++++++ ...atic-privatename-identifier-alt-by-classname.js | 133 ++++++++++ ...nitions-rs-static-privatename-identifier-alt.js | 133 ++++++++++ ...s-static-privatename-identifier-by-classname.js | 133 ++++++++++ ...name-identifier-initializer-alt-by-classname.js | 127 ++++++++++ ...tatic-privatename-identifier-initializer-alt.js | 127 ++++++++++ ...rs-static-privatename-identifier-initializer.js | 127 ++++++++++ ...definitions-rs-static-privatename-identifier.js | 133 ++++++++++ ...le-stacked-definitions-static-private-fields.js | 94 +++++++ ...finitions-static-private-methods-with-fields.js | 111 ++++++++ ...e-stacked-definitions-static-private-methods.js | 98 +++++++ ...ple-stacked-definitions-string-literal-names.js | 132 ++++++++++ ...nested-arrow-fnc-init-err-contains-arguments.js | 37 +++ .../nested-arrow-fnc-init-err-contains-super.js | 30 +++ ...nested-comp-name-init-err-contains-arguments.js | 35 +++ .../nested-comp-name-init-err-contains-super.js | 28 ++ ...ved-cls-direct-eval-contains-superproperty-1.js | 36 +++ ...ved-cls-direct-eval-contains-superproperty-2.js | 33 +++ ...ved-cls-direct-eval-err-contains-supercall-1.js | 38 +++ ...ved-cls-direct-eval-err-contains-supercall-2.js | 31 +++ ...rived-cls-direct-eval-err-contains-supercall.js | 38 +++ ...d-cls-indirect-eval-contains-superproperty-1.js | 38 +++ ...d-cls-indirect-eval-contains-superproperty-2.js | 35 +++ ...d-cls-indirect-eval-err-contains-supercall-1.js | 38 +++ ...d-cls-indirect-eval-err-contains-supercall-2.js | 31 +++ ...ved-cls-indirect-eval-err-contains-supercall.js | 38 +++ .../nested-direct-eval-err-contains-arguments.js | 41 +++ .../nested-direct-eval-err-contains-newtarget.js | 36 +++ .../nested-equality-init-err-contains-arguments.js | 34 +++ .../nested-equality-init-err-contains-super.js | 27 ++ .../nested-indirect-eval-contains-arguments.js | 25 ++ .../nested-indirect-eval-err-contains-newtarget.js | 37 +++ ...ted-literal-name-init-err-contains-arguments.js | 34 +++ .../nested-literal-name-init-err-contains-super.js | 27 ++ ...rivate-arrow-fnc-init-err-contains-arguments.js | 39 +++ ...ed-private-arrow-fnc-init-err-contains-super.js | 32 +++ ...ved-cls-direct-eval-contains-superproperty-1.js | 36 +++ ...ved-cls-direct-eval-contains-superproperty-2.js | 33 +++ ...ved-cls-direct-eval-err-contains-supercall-1.js | 38 +++ ...ved-cls-direct-eval-err-contains-supercall-2.js | 31 +++ ...rived-cls-direct-eval-err-contains-supercall.js | 38 +++ ...d-cls-indirect-eval-contains-superproperty-1.js | 38 +++ ...d-cls-indirect-eval-contains-superproperty-2.js | 35 +++ ...d-cls-indirect-eval-err-contains-supercall-1.js | 38 +++ ...d-cls-indirect-eval-err-contains-supercall-2.js | 31 +++ ...ved-cls-indirect-eval-err-contains-supercall.js | 38 +++ ...d-private-direct-eval-err-contains-arguments.js | 44 ++++ ...d-private-direct-eval-err-contains-newtarget.js | 36 +++ ...ted-private-indirect-eval-contains-arguments.js | 26 ++ ...private-indirect-eval-err-contains-newtarget.js | 37 +++ ...ate-literal-name-init-err-contains-arguments.js | 34 +++ ...private-literal-name-init-err-contains-super.js | 27 ++ ...-private-ternary-init-err-contains-arguments.js | 34 +++ ...sted-private-ternary-init-err-contains-super.js | 27 ++ ...d-private-typeof-init-err-contains-arguments.js | 34 +++ ...ested-private-typeof-init-err-contains-super.js | 27 ++ ...static-comp-name-init-err-contains-arguments.js | 35 +++ ...ted-static-comp-name-init-err-contains-super.js | 28 ++ ...d-static-literal-init-err-contains-arguments.js | 34 +++ ...ested-static-literal-init-err-contains-super.js | 27 ++ ...d-static-private-init-err-contains-arguments.js | 34 +++ ...ested-static-private-init-err-contains-super.js | 27 ++ ...ing-literal-name-init-err-contains-arguments.js | 34 +++ ...-string-literal-name-init-err-contains-super.js | 27 ++ ...ing-literal-name-init-err-contains-arguments.js | 34 +++ ...-string-literal-name-init-err-contains-super.js | 27 ++ .../nested-ternary-init-err-contains-arguments.js | 34 +++ .../nested-ternary-init-err-contains-super.js | 27 ++ .../nested-typeof-init-err-contains-arguments.js | 34 +++ .../nested-typeof-init-err-contains-super.js | 27 ++ .../new-no-sc-line-method-computed-names.js | 108 ++++++++ .../new-no-sc-line-method-computed-symbol-names.js | 106 ++++++++ ...privatename-identifier-semantics-stringvalue.js | 110 ++++++++ .../new-no-sc-line-method-literal-names-asi.js | 78 ++++++ .../new-no-sc-line-method-literal-names.js | 97 +++++++ .../new-no-sc-line-method-private-field-usage.js | 50 ++++ ...o-sc-line-method-private-method-getter-usage.js | 50 ++++ .../new-no-sc-line-method-private-method-usage.js | 50 ++++ .../new-no-sc-line-method-private-names.js | 72 ++++++ ...-line-method-rs-field-identifier-initializer.js | 88 +++++++ .../new-no-sc-line-method-rs-field-identifier.js | 95 +++++++ .../new-no-sc-line-method-rs-private-getter-alt.js | 129 ++++++++++ .../new-no-sc-line-method-rs-private-getter.js | 129 ++++++++++ .../new-no-sc-line-method-rs-private-method-alt.js | 128 ++++++++++ .../new-no-sc-line-method-rs-private-method.js | 128 ++++++++++ .../new-no-sc-line-method-rs-private-setter-alt.js | 128 ++++++++++ .../new-no-sc-line-method-rs-private-setter.js | 128 ++++++++++ ...sc-line-method-rs-privatename-identifier-alt.js | 110 ++++++++ ...od-rs-privatename-identifier-initializer-alt.js | 104 ++++++++ ...method-rs-privatename-identifier-initializer.js | 104 ++++++++ ...-no-sc-line-method-rs-privatename-identifier.js | 110 ++++++++ ...-generator-method-privatename-identifier-alt.js | 135 ++++++++++ ...sync-generator-method-privatename-identifier.js | 136 ++++++++++ ...atic-async-method-privatename-identifier-alt.js | 135 ++++++++++ ...s-static-async-method-privatename-identifier.js | 136 ++++++++++ ...-generator-method-privatename-identifier-alt.js | 125 +++++++++ ...atic-generator-method-privatename-identifier.js | 126 +++++++++ ...-rs-static-method-privatename-identifier-alt.js | 123 +++++++++ ...thod-rs-static-method-privatename-identifier.js | 123 +++++++++ ...atic-privatename-identifier-alt-by-classname.js | 111 ++++++++ ...-method-rs-static-privatename-identifier-alt.js | 111 ++++++++ ...s-static-privatename-identifier-by-classname.js | 111 ++++++++ ...name-identifier-initializer-alt-by-classname.js | 105 ++++++++ ...tatic-privatename-identifier-initializer-alt.js | 105 ++++++++ ...rs-static-privatename-identifier-initializer.js | 105 ++++++++ ...line-method-rs-static-privatename-identifier.js | 111 ++++++++ .../new-no-sc-line-method-static-private-fields.js | 72 ++++++ ...ne-method-static-private-methods-with-fields.js | 89 +++++++ ...new-no-sc-line-method-static-private-methods.js | 76 ++++++ .../new-no-sc-line-method-string-literal-names.js | 110 ++++++++ .../elements/new-sc-line-gen-computed-names.js | 108 ++++++++ .../new-sc-line-gen-computed-symbol-names.js | 106 ++++++++ ...privatename-identifier-semantics-stringvalue.js | 110 ++++++++ .../elements/new-sc-line-gen-literal-names-asi.js | 78 ++++++ .../elements/new-sc-line-gen-literal-names.js | 97 +++++++ .../new-sc-line-gen-private-field-usage.js | 50 ++++ .../new-sc-line-gen-private-method-getter-usage.js | 50 ++++ .../new-sc-line-gen-private-method-usage.js | 50 ++++ .../elements/new-sc-line-gen-private-names.js | 72 ++++++ ...-sc-line-gen-rs-field-identifier-initializer.js | 88 +++++++ .../new-sc-line-gen-rs-field-identifier.js | 95 +++++++ .../new-sc-line-gen-rs-private-getter-alt.js | 129 ++++++++++ .../elements/new-sc-line-gen-rs-private-getter.js | 129 ++++++++++ .../new-sc-line-gen-rs-private-method-alt.js | 128 ++++++++++ .../elements/new-sc-line-gen-rs-private-method.js | 128 ++++++++++ .../new-sc-line-gen-rs-private-setter-alt.js | 128 ++++++++++ .../elements/new-sc-line-gen-rs-private-setter.js | 128 ++++++++++ ...ew-sc-line-gen-rs-privatename-identifier-alt.js | 110 ++++++++ ...en-rs-privatename-identifier-initializer-alt.js | 104 ++++++++ ...ne-gen-rs-privatename-identifier-initializer.js | 104 ++++++++ .../new-sc-line-gen-rs-privatename-identifier.js | 110 ++++++++ ...-generator-method-privatename-identifier-alt.js | 135 ++++++++++ ...sync-generator-method-privatename-identifier.js | 136 ++++++++++ ...atic-async-method-privatename-identifier-alt.js | 135 ++++++++++ ...s-static-async-method-privatename-identifier.js | 136 ++++++++++ ...-generator-method-privatename-identifier-alt.js | 125 +++++++++ ...atic-generator-method-privatename-identifier.js | 126 +++++++++ ...-rs-static-method-privatename-identifier-alt.js | 123 +++++++++ ...-gen-rs-static-method-privatename-identifier.js | 123 +++++++++ ...atic-privatename-identifier-alt-by-classname.js | 111 ++++++++ ...ine-gen-rs-static-privatename-identifier-alt.js | 111 ++++++++ ...s-static-privatename-identifier-by-classname.js | 111 ++++++++ ...name-identifier-initializer-alt-by-classname.js | 105 ++++++++ ...tatic-privatename-identifier-initializer-alt.js | 105 ++++++++ ...rs-static-privatename-identifier-initializer.js | 105 ++++++++ ...sc-line-gen-rs-static-privatename-identifier.js | 111 ++++++++ .../new-sc-line-gen-static-private-fields.js | 72 ++++++ ...-line-gen-static-private-methods-with-fields.js | 89 +++++++ .../new-sc-line-gen-static-private-methods.js | 76 ++++++ .../new-sc-line-gen-string-literal-names.js | 110 ++++++++ .../elements/new-sc-line-method-computed-names.js | 108 ++++++++ .../new-sc-line-method-computed-symbol-names.js | 106 ++++++++ ...privatename-identifier-semantics-stringvalue.js | 110 ++++++++ .../new-sc-line-method-literal-names-asi.js | 78 ++++++ .../elements/new-sc-line-method-literal-names.js | 97 +++++++ .../new-sc-line-method-private-field-usage.js | 50 ++++ ...w-sc-line-method-private-method-getter-usage.js | 50 ++++ .../new-sc-line-method-private-method-usage.js | 50 ++++ .../elements/new-sc-line-method-private-names.js | 72 ++++++ ...-line-method-rs-field-identifier-initializer.js | 88 +++++++ .../new-sc-line-method-rs-field-identifier.js | 95 +++++++ .../new-sc-line-method-rs-private-getter-alt.js | 129 ++++++++++ .../new-sc-line-method-rs-private-getter.js | 129 ++++++++++ .../new-sc-line-method-rs-private-method-alt.js | 128 ++++++++++ .../new-sc-line-method-rs-private-method.js | 128 ++++++++++ .../new-sc-line-method-rs-private-setter-alt.js | 128 ++++++++++ .../new-sc-line-method-rs-private-setter.js | 128 ++++++++++ ...sc-line-method-rs-privatename-identifier-alt.js | 110 ++++++++ ...od-rs-privatename-identifier-initializer-alt.js | 104 ++++++++ ...method-rs-privatename-identifier-initializer.js | 104 ++++++++ ...new-sc-line-method-rs-privatename-identifier.js | 110 ++++++++ ...-generator-method-privatename-identifier-alt.js | 135 ++++++++++ ...sync-generator-method-privatename-identifier.js | 136 ++++++++++ ...atic-async-method-privatename-identifier-alt.js | 135 ++++++++++ ...s-static-async-method-privatename-identifier.js | 136 ++++++++++ ...-generator-method-privatename-identifier-alt.js | 125 +++++++++ ...atic-generator-method-privatename-identifier.js | 126 +++++++++ ...-rs-static-method-privatename-identifier-alt.js | 123 +++++++++ ...thod-rs-static-method-privatename-identifier.js | 123 +++++++++ ...atic-privatename-identifier-alt-by-classname.js | 111 ++++++++ ...-method-rs-static-privatename-identifier-alt.js | 111 ++++++++ ...s-static-privatename-identifier-by-classname.js | 111 ++++++++ ...name-identifier-initializer-alt-by-classname.js | 105 ++++++++ ...tatic-privatename-identifier-initializer-alt.js | 105 ++++++++ ...rs-static-privatename-identifier-initializer.js | 105 ++++++++ ...line-method-rs-static-privatename-identifier.js | 111 ++++++++ .../new-sc-line-method-static-private-fields.js | 72 ++++++ ...ne-method-static-private-methods-with-fields.js | 89 +++++++ .../new-sc-line-method-static-private-methods.js | 76 ++++++ .../new-sc-line-method-string-literal-names.js | 110 ++++++++ ...e-accessor-is-visible-in-computed-properties.js | 34 +++ .../elements/private-accessor-name/browser.js | 0 .../inst-private-escape-sequence-ZWJ.js | 80 ++++++ .../inst-private-escape-sequence-ZWNJ.js | 80 ++++++ .../inst-private-escape-sequence-u2118.js | 80 ++++++ .../inst-private-escape-sequence-u6F.js | 80 ++++++ .../private-accessor-name/inst-private-name-ZWJ.js | 80 ++++++ .../inst-private-name-ZWNJ.js | 80 ++++++ .../inst-private-name-common.js | 80 ++++++ .../inst-private-name-dollar.js | 80 ++++++ .../inst-private-name-u2118.js | 80 ++++++ .../inst-private-name-underscore.js | 80 ++++++ .../class/elements/private-accessor-name/shell.js | 0 .../static-private-escape-sequence-ZWJ.js | 79 ++++++ .../static-private-escape-sequence-ZWNJ.js | 79 ++++++ .../static-private-escape-sequence-u2118.js | 79 ++++++ .../static-private-escape-sequence-u6F.js | 79 ++++++ .../static-private-name-ZWJ.js | 79 ++++++ .../static-private-name-ZWNJ.js | 79 ++++++ .../static-private-name-common.js | 79 ++++++ .../static-private-name-dollar.js | 79 ++++++ .../static-private-name-u2118.js | 79 ++++++ .../static-private-name-underscore.js | 79 ++++++ ...rivate-arrow-fnc-init-err-contains-arguments.js | 36 +++ .../private-arrow-fnc-init-err-contains-super.js | 29 +++ .../private-async-generator-method-name.js | 61 +++++ .../class/elements/private-async-method-name.js | 61 +++++ ...private-class-field-on-frozen-objects-strict.js | 34 +++ ...ved-cls-direct-eval-contains-superproperty-1.js | 36 +++ ...ved-cls-direct-eval-contains-superproperty-2.js | 33 +++ ...ved-cls-direct-eval-err-contains-supercall-1.js | 38 +++ ...ved-cls-direct-eval-err-contains-supercall-2.js | 31 +++ ...rived-cls-direct-eval-err-contains-supercall.js | 38 +++ ...d-cls-indirect-eval-contains-superproperty-1.js | 38 +++ ...d-cls-indirect-eval-contains-superproperty-2.js | 35 +++ ...d-cls-indirect-eval-err-contains-supercall-1.js | 38 +++ ...d-cls-indirect-eval-err-contains-supercall-2.js | 31 +++ ...ved-cls-indirect-eval-err-contains-supercall.js | 38 +++ .../private-direct-eval-err-contains-arguments.js | 38 +++ .../private-direct-eval-err-contains-newtarget.js | 36 +++ ...private-field-access-on-inner-arrow-function.js | 43 ++++ .../private-field-access-on-inner-function.js | 44 ++++ .../elements/private-field-after-optional-chain.js | 46 ++++ .../elements/private-field-as-arrow-function.js | 35 +++ .../private-field-as-async-arrow-function.js | 37 +++ .../elements/private-field-as-async-function.js | 37 +++ .../class/elements/private-field-as-function.js | 35 +++ ...-field-is-not-clobbered-by-computed-property.js | 45 ++++ ...vate-field-is-visible-in-computed-properties.js | 51 ++++ .../elements/private-field-on-nested-class.js | 47 ++++ ...-field-visible-to-direct-eval-on-initializer.js | 49 ++++ .../private-field-visible-to-direct-eval.js | 61 +++++ ...ialized-id-is-visible-in-computed-properties.js | 78 ++++++ .../elements/private-generator-method-name.js | 61 +++++ ...rivate-getter-access-on-inner-arrow-function.js | 43 ++++ .../private-getter-access-on-inner-function.js | 44 ++++ ...er-brand-check-multiple-evaluations-of-class.js | 49 ++++ .../private-getter-brand-check-super-class.js | 50 ++++ .../class/elements/private-getter-brand-check.js | 47 ++++ .../private-getter-is-not-a-own-property.js | 47 ++++ ...getter-is-not-clobbered-by-computed-property.js | 45 ++++ .../elements/private-getter-on-nested-class.js | 38 +++ ...ate-getter-shadowed-by-field-on-nested-class.js | 46 ++++ ...te-getter-shadowed-by-getter-on-nested-class.js | 46 ++++ ...te-getter-shadowed-by-method-on-nested-class.js | 43 ++++ ...te-getter-shadowed-by-setter-on-nested-class.js | 51 ++++ ...getter-visible-to-direct-eval-on-initializer.js | 49 ++++ .../private-getter-visible-to-direct-eval.js | 61 +++++ .../private-indirect-eval-contains-arguments.js | 25 ++ ...private-indirect-eval-err-contains-newtarget.js | 37 +++ ...ate-literal-name-init-err-contains-arguments.js | 35 +++ ...private-literal-name-init-err-contains-super.js | 28 ++ ...rivate-method-access-on-inner-arrow-function.js | 43 ++++ .../private-method-access-on-inner-function.js | 44 ++++ ...od-brand-check-multiple-evaluations-of-class.js | 49 ++++ .../private-method-brand-check-super-class.js | 50 ++++ .../class/elements/private-method-brand-check.js | 47 ++++ ...hod-comparison-multiple-evaluations-of-class.js | 47 ++++ .../class/elements/private-method-comparison.js | 47 ++++ ...ate-method-double-initialisation-get-and-set.js | 37 +++ .../private-method-double-initialisation-get.js | 36 +++ .../private-method-double-initialisation-set.js | 36 +++ .../private-method-double-initialisation.js | 36 +++ .../class/elements/private-method-get-and-call.js | 49 ++++ .../private-method-is-not-a-own-property.js | 45 ++++ ...method-is-not-clobbered-by-computed-property.js | 45 ++++ ...ate-method-is-visible-in-computed-properties.js | 34 +++ .../class/elements/private-method-length.js | 49 ++++ .../class/elements/private-method-not-writable.js | 35 +++ .../elements/private-method-on-nested-class.js | 38 +++ ...private-method-referenced-from-static-method.js | 40 +++ ...ate-method-shadowed-by-field-on-nested-class.js | 46 ++++ ...te-method-shadowed-by-getter-on-nested-class.js | 49 ++++ ...te-method-shadowed-by-setter-on-nested-class.js | 51 ++++ .../private-method-shadowed-on-nested-class.js | 40 +++ ...method-visible-to-direct-eval-on-initializer.js | 49 ++++ .../private-method-visible-to-direct-eval.js | 61 +++++ .../class/elements/private-methods/browser.js | 0 .../prod-private-async-generator.js | 134 ++++++++++ .../private-methods/prod-private-async-method.js | 129 ++++++++++ .../private-methods/prod-private-generator.js | 126 +++++++++ .../prod-private-method-initialize-order.js | 141 +++++++++++ .../private-methods/prod-private-method.js | 122 +++++++++ .../class/elements/private-methods/shell.js | 0 ...rivate-setter-access-on-inner-arrow-function.js | 44 ++++ .../private-setter-access-on-inner-function.js | 45 ++++ ...er-brand-check-multiple-evaluations-of-class.js | 51 ++++ .../private-setter-brand-check-super-class.js | 55 ++++ .../class/elements/private-setter-brand-check.js | 48 ++++ .../private-setter-is-not-a-own-property.js | 48 ++++ ...setter-is-not-clobbered-by-computed-property.js | 46 ++++ .../elements/private-setter-on-nested-class.js | 39 +++ ...ate-setter-shadowed-by-field-on-nested-class.js | 53 ++++ ...te-setter-shadowed-by-getter-on-nested-class.js | 52 ++++ ...te-setter-shadowed-by-method-on-nested-class.js | 52 ++++ ...te-setter-shadowed-by-setter-on-nested-class.js | 51 ++++ ...setter-visible-to-direct-eval-on-initializer.js | 50 ++++ .../private-setter-visible-to-direct-eval.js | 63 +++++ .../private-static-async-generator-method-name.js | 62 +++++ .../elements/private-static-async-method-name.js | 62 +++++ ...atic-field-shadowed-by-field-on-nested-class.js | 91 +++++++ ...tic-field-shadowed-by-getter-on-nested-class.js | 92 +++++++ ...tic-field-shadowed-by-method-on-nested-class.js | 92 +++++++ ...tic-field-shadowed-by-setter-on-nested-class.js | 93 +++++++ ...ivate-static-field-usage-inside-nested-class.js | 81 ++++++ .../private-static-field-visible-to-direct-eval.js | 59 +++++ .../private-static-generator-method-name.js | 62 +++++ .../private-static-getter-abrupt-completition.js | 41 +++ ...private-static-getter-visible-to-direct-eval.js | 63 +++++ .../class/elements/private-static-method-length.js | 48 ++++ .../class/elements/private-static-method-name.js | 73 ++++++ .../elements/private-static-method-not-writable.js | 33 +++ ...tic-method-shadowed-by-field-on-nested-class.js | 91 +++++++ ...ic-method-shadowed-by-getter-on-nested-class.js | 92 +++++++ ...ic-method-shadowed-by-method-on-nested-class.js | 92 +++++++ ...ic-method-shadowed-by-setter-on-nested-class.js | 93 +++++++ ...vate-static-method-usage-inside-nested-class.js | 83 ++++++ ...private-static-method-visible-to-direct-eval.js | 63 +++++ .../private-static-setter-abrupt-completition.js | 42 +++ ...private-static-setter-visible-to-direct-eval.js | 64 +++++ .../private-ternary-init-err-contains-arguments.js | 35 +++ .../private-ternary-init-err-contains-super.js | 28 ++ .../private-typeof-init-err-contains-arguments.js | 35 +++ .../private-typeof-init-err-contains-super.js | 28 ++ .../class/elements/privatefield-on-proxy.js | 55 ++++ .../class/elements/privatefieldadd-typeerror.js | 63 +++++ .../elements/privatefieldget-primitive-receiver.js | 78 ++++++ .../class/elements/privatefieldget-success-1.js | 48 ++++ .../class/elements/privatefieldget-success-2.js | 46 ++++ .../class/elements/privatefieldget-success-3.js | 43 ++++ .../class/elements/privatefieldget-success-4.js | 42 +++ .../class/elements/privatefieldget-success-5.js | 42 +++ .../class/elements/privatefieldget-typeerror-1.js | 41 +++ .../class/elements/privatefieldget-typeerror-2.js | 57 +++++ .../class/elements/privatefieldget-typeerror-3.js | 55 ++++ .../class/elements/privatefieldget-typeerror-4.js | 55 ++++ .../class/elements/privatefieldget-typeerror-5.js | 60 +++++ .../elements/privatefieldput-primitive-receiver.js | 78 ++++++ .../elements/privatefieldset-evaluation-order-1.js | 45 ++++ .../elements/privatefieldset-evaluation-order-2.js | 38 +++ .../elements/privatefieldset-evaluation-order-3.js | 47 ++++ .../class/elements/privatefieldset-typeerror-1.js | 41 +++ .../class/elements/privatefieldset-typeerror-10.js | 47 ++++ .../class/elements/privatefieldset-typeerror-11.js | 47 ++++ .../class/elements/privatefieldset-typeerror-2.js | 57 +++++ .../class/elements/privatefieldset-typeerror-3.js | 66 +++++ .../class/elements/privatefieldset-typeerror-4.js | 55 ++++ .../class/elements/privatefieldset-typeerror-5.js | 61 +++++ .../class/elements/privatefieldset-typeerror-6.js | 47 ++++ .../class/elements/privatefieldset-typeerror-7.js | 47 ++++ .../class/elements/privatefieldset-typeerror-8.js | 47 ++++ .../class/elements/privatefieldset-typeerror-9.js | 47 ++++ .../class/elements/privategetter-on-proxy.js | 61 +++++ .../class/elements/privatemethods-on-proxy.js | 57 +++++ .../privatename-not-valid-earlyerr-script-1.js | 25 ++ .../privatename-not-valid-earlyerr-script-2.js | 25 ++ .../privatename-not-valid-earlyerr-script-3.js | 23 ++ .../privatename-not-valid-earlyerr-script-4.js | 28 ++ .../privatename-not-valid-earlyerr-script-5.js | 25 ++ .../privatename-not-valid-earlyerr-script-6.js | 23 ++ .../privatename-not-valid-earlyerr-script-7.js | 23 ++ .../privatename-not-valid-earlyerr-script-8.js | 23 ++ .../privatename-not-valid-eval-earlyerr-1.js | 29 +++ .../privatename-not-valid-eval-earlyerr-2.js | 29 +++ .../privatename-not-valid-eval-earlyerr-3.js | 27 ++ .../privatename-not-valid-eval-earlyerr-4.js | 32 +++ .../privatename-not-valid-eval-earlyerr-5.js | 27 ++ .../privatename-not-valid-eval-earlyerr-6.js | 24 ++ .../privatename-not-valid-eval-earlyerr-7.js | 24 ++ .../privatename-not-valid-eval-earlyerr-8.js | 28 ++ .../elements/privatename-valid-no-earlyerr.js | 46 ++++ ...te-getter-before-super-return-in-constructor.js | 48 ++++ ...ter-before-super-return-in-field-initializer.js | 46 ++++ ...te-method-before-super-return-in-constructor.js | 48 ++++ ...hod-before-super-return-in-field-initializer.js | 46 ++++ ...te-setter-before-super-return-in-constructor.js | 48 ++++ ...ter-before-super-return-in-field-initializer.js | 46 ++++ ...ass-field-initialization-is-visible-to-proxy.js | 33 +++ ...ld-initialization-on-super-class-with-setter.js | 39 +++ .../class/elements/redeclaration-symbol.js | 63 +++++ .../statements/class/elements/redeclaration.js | 63 +++++ .../elements/regular-definitions-computed-names.js | 94 +++++++ .../regular-definitions-computed-symbol-names.js | 92 +++++++ ...privatename-identifier-semantics-stringvalue.js | 95 +++++++ .../regular-definitions-literal-names-asi.js | 64 +++++ .../elements/regular-definitions-literal-names.js | 83 ++++++ .../regular-definitions-private-field-usage.js | 35 +++ ...ular-definitions-private-method-getter-usage.js | 35 +++ .../regular-definitions-private-method-usage.js | 35 +++ .../elements/regular-definitions-private-names.js | 57 +++++ ...-definitions-rs-field-identifier-initializer.js | 73 ++++++ .../regular-definitions-rs-field-identifier.js | 80 ++++++ .../regular-definitions-rs-private-getter-alt.js | 114 +++++++++ .../regular-definitions-rs-private-getter.js | 114 +++++++++ .../regular-definitions-rs-private-method-alt.js | 113 +++++++++ .../regular-definitions-rs-private-method.js | 113 +++++++++ .../regular-definitions-rs-private-setter-alt.js | 113 +++++++++ .../regular-definitions-rs-private-setter.js | 113 +++++++++ ...ar-definitions-rs-privatename-identifier-alt.js | 95 +++++++ ...ns-rs-privatename-identifier-initializer-alt.js | 89 +++++++ ...itions-rs-privatename-identifier-initializer.js | 89 +++++++ ...egular-definitions-rs-privatename-identifier.js | 95 +++++++ ...-generator-method-privatename-identifier-alt.js | 120 +++++++++ ...sync-generator-method-privatename-identifier.js | 121 +++++++++ ...atic-async-method-privatename-identifier-alt.js | 120 +++++++++ ...s-static-async-method-privatename-identifier.js | 121 +++++++++ ...-generator-method-privatename-identifier-alt.js | 110 ++++++++ ...atic-generator-method-privatename-identifier.js | 111 ++++++++ ...-rs-static-method-privatename-identifier-alt.js | 108 ++++++++ ...ions-rs-static-method-privatename-identifier.js | 108 ++++++++ ...atic-privatename-identifier-alt-by-classname.js | 96 +++++++ ...nitions-rs-static-privatename-identifier-alt.js | 96 +++++++ ...s-static-privatename-identifier-by-classname.js | 96 +++++++ ...name-identifier-initializer-alt-by-classname.js | 90 +++++++ ...tatic-privatename-identifier-initializer-alt.js | 90 +++++++ ...rs-static-privatename-identifier-initializer.js | 90 +++++++ ...definitions-rs-static-privatename-identifier.js | 96 +++++++ .../regular-definitions-static-private-fields.js | 57 +++++ ...finitions-static-private-methods-with-fields.js | 74 ++++++ .../regular-definitions-static-private-methods.js | 61 +++++ .../regular-definitions-string-literal-names.js | 96 +++++++ .../elements/same-line-async-gen-computed-names.js | 120 +++++++++ .../same-line-async-gen-computed-symbol-names.js | 118 +++++++++ ...privatename-identifier-semantics-stringvalue.js | 122 +++++++++ .../same-line-async-gen-literal-names-asi.js | 90 +++++++ .../elements/same-line-async-gen-literal-names.js | 109 ++++++++ .../same-line-async-gen-private-field-usage.js | 62 +++++ ...e-line-async-gen-private-method-getter-usage.js | 62 +++++ .../same-line-async-gen-private-method-usage.js | 62 +++++ .../elements/same-line-async-gen-private-names.js | 84 ++++++ ...ne-async-gen-rs-field-identifier-initializer.js | 100 ++++++++ .../same-line-async-gen-rs-field-identifier.js | 107 ++++++++ .../same-line-async-gen-rs-private-getter-alt.js | 141 +++++++++++ .../same-line-async-gen-rs-private-getter.js | 141 +++++++++++ .../same-line-async-gen-rs-private-method-alt.js | 140 ++++++++++ .../same-line-async-gen-rs-private-method.js | 140 ++++++++++ .../same-line-async-gen-rs-private-setter-alt.js | 140 ++++++++++ .../same-line-async-gen-rs-private-setter.js | 140 ++++++++++ ...line-async-gen-rs-privatename-identifier-alt.js | 122 +++++++++ ...en-rs-privatename-identifier-initializer-alt.js | 116 +++++++++ ...nc-gen-rs-privatename-identifier-initializer.js | 116 +++++++++ ...ame-line-async-gen-rs-privatename-identifier.js | 122 +++++++++ ...-generator-method-privatename-identifier-alt.js | 148 +++++++++++ ...sync-generator-method-privatename-identifier.js | 149 +++++++++++ ...atic-async-method-privatename-identifier-alt.js | 148 +++++++++++ ...s-static-async-method-privatename-identifier.js | 149 +++++++++++ ...-generator-method-privatename-identifier-alt.js | 137 ++++++++++ ...atic-generator-method-privatename-identifier.js | 138 ++++++++++ ...-rs-static-method-privatename-identifier-alt.js | 135 ++++++++++ ...-gen-rs-static-method-privatename-identifier.js | 135 ++++++++++ ...atic-privatename-identifier-alt-by-classname.js | 123 +++++++++ ...ync-gen-rs-static-privatename-identifier-alt.js | 123 +++++++++ ...s-static-privatename-identifier-by-classname.js | 123 +++++++++ ...name-identifier-initializer-alt-by-classname.js | 117 +++++++++ ...tatic-privatename-identifier-initializer-alt.js | 117 +++++++++ ...rs-static-privatename-identifier-initializer.js | 117 +++++++++ ...e-async-gen-rs-static-privatename-identifier.js | 123 +++++++++ .../same-line-async-gen-static-private-fields.js | 84 ++++++ ...async-gen-static-private-methods-with-fields.js | 101 ++++++++ .../same-line-async-gen-static-private-methods.js | 88 +++++++ .../same-line-async-gen-string-literal-names.js | 122 +++++++++ .../same-line-async-method-computed-names.js | 119 +++++++++ ...same-line-async-method-computed-symbol-names.js | 117 +++++++++ ...privatename-identifier-semantics-stringvalue.js | 121 +++++++++ .../same-line-async-method-literal-names-asi.js | 89 +++++++ .../same-line-async-method-literal-names.js | 108 ++++++++ .../same-line-async-method-private-field-usage.js | 61 +++++ ...ine-async-method-private-method-getter-usage.js | 61 +++++ .../same-line-async-method-private-method-usage.js | 61 +++++ .../same-line-async-method-private-names.js | 83 ++++++ ...async-method-rs-field-identifier-initializer.js | 99 ++++++++ .../same-line-async-method-rs-field-identifier.js | 106 ++++++++ ...same-line-async-method-rs-private-getter-alt.js | 140 ++++++++++ .../same-line-async-method-rs-private-getter.js | 140 ++++++++++ ...same-line-async-method-rs-private-method-alt.js | 139 ++++++++++ .../same-line-async-method-rs-private-method.js | 139 ++++++++++ ...same-line-async-method-rs-private-setter-alt.js | 139 ++++++++++ .../same-line-async-method-rs-private-setter.js | 139 ++++++++++ ...e-async-method-rs-privatename-identifier-alt.js | 121 +++++++++ ...od-rs-privatename-identifier-initializer-alt.js | 115 +++++++++ ...method-rs-privatename-identifier-initializer.js | 115 +++++++++ ...-line-async-method-rs-privatename-identifier.js | 121 +++++++++ ...-generator-method-privatename-identifier-alt.js | 147 +++++++++++ ...sync-generator-method-privatename-identifier.js | 148 +++++++++++ ...atic-async-method-privatename-identifier-alt.js | 147 +++++++++++ ...s-static-async-method-privatename-identifier.js | 148 +++++++++++ ...-generator-method-privatename-identifier-alt.js | 136 ++++++++++ ...atic-generator-method-privatename-identifier.js | 137 ++++++++++ ...-rs-static-method-privatename-identifier-alt.js | 134 ++++++++++ ...thod-rs-static-method-privatename-identifier.js | 134 ++++++++++ ...atic-privatename-identifier-alt-by-classname.js | 122 +++++++++ ...-method-rs-static-privatename-identifier-alt.js | 122 +++++++++ ...s-static-privatename-identifier-by-classname.js | 122 +++++++++ ...name-identifier-initializer-alt-by-classname.js | 116 +++++++++ ...tatic-privatename-identifier-initializer-alt.js | 116 +++++++++ ...rs-static-privatename-identifier-initializer.js | 116 +++++++++ ...sync-method-rs-static-privatename-identifier.js | 122 +++++++++ ...same-line-async-method-static-private-fields.js | 83 ++++++ ...nc-method-static-private-methods-with-fields.js | 100 ++++++++ ...ame-line-async-method-static-private-methods.js | 87 +++++++ .../same-line-async-method-string-literal-names.js | 121 +++++++++ .../class/elements/same-line-gen-computed-names.js | 107 ++++++++ .../same-line-gen-computed-symbol-names.js | 105 ++++++++ ...privatename-identifier-semantics-stringvalue.js | 109 ++++++++ .../elements/same-line-gen-literal-names-asi.js | 77 ++++++ .../class/elements/same-line-gen-literal-names.js | 96 +++++++ .../elements/same-line-gen-private-field-usage.js | 49 ++++ .../same-line-gen-private-method-getter-usage.js | 49 ++++ .../elements/same-line-gen-private-method-usage.js | 49 ++++ .../class/elements/same-line-gen-private-names.js | 71 ++++++ ...ame-line-gen-rs-field-identifier-initializer.js | 87 +++++++ .../elements/same-line-gen-rs-field-identifier.js | 94 +++++++ .../same-line-gen-rs-private-getter-alt.js | 128 ++++++++++ .../elements/same-line-gen-rs-private-getter.js | 128 ++++++++++ .../same-line-gen-rs-private-method-alt.js | 127 ++++++++++ .../elements/same-line-gen-rs-private-method.js | 127 ++++++++++ .../same-line-gen-rs-private-setter-alt.js | 127 ++++++++++ .../elements/same-line-gen-rs-private-setter.js | 127 ++++++++++ .../same-line-gen-rs-privatename-identifier-alt.js | 109 ++++++++ ...en-rs-privatename-identifier-initializer-alt.js | 103 ++++++++ ...ne-gen-rs-privatename-identifier-initializer.js | 103 ++++++++ .../same-line-gen-rs-privatename-identifier.js | 109 ++++++++ ...-generator-method-privatename-identifier-alt.js | 134 ++++++++++ ...sync-generator-method-privatename-identifier.js | 135 ++++++++++ ...atic-async-method-privatename-identifier-alt.js | 134 ++++++++++ ...s-static-async-method-privatename-identifier.js | 135 ++++++++++ ...-generator-method-privatename-identifier-alt.js | 124 +++++++++ ...atic-generator-method-privatename-identifier.js | 125 +++++++++ ...-rs-static-method-privatename-identifier-alt.js | 122 +++++++++ ...-gen-rs-static-method-privatename-identifier.js | 122 +++++++++ ...atic-privatename-identifier-alt-by-classname.js | 110 ++++++++ ...ine-gen-rs-static-privatename-identifier-alt.js | 110 ++++++++ ...s-static-privatename-identifier-by-classname.js | 110 ++++++++ ...name-identifier-initializer-alt-by-classname.js | 104 ++++++++ ...tatic-privatename-identifier-initializer-alt.js | 104 ++++++++ ...rs-static-privatename-identifier-initializer.js | 104 ++++++++ ...me-line-gen-rs-static-privatename-identifier.js | 110 ++++++++ .../same-line-gen-static-private-fields.js | 71 ++++++ ...-line-gen-static-private-methods-with-fields.js | 88 +++++++ .../same-line-gen-static-private-methods.js | 75 ++++++ .../elements/same-line-gen-string-literal-names.js | 109 ++++++++ .../elements/same-line-method-computed-names.js | 107 ++++++++ .../same-line-method-computed-symbol-names.js | 105 ++++++++ ...privatename-identifier-semantics-stringvalue.js | 109 ++++++++ .../elements/same-line-method-literal-names-asi.js | 77 ++++++ .../elements/same-line-method-literal-names.js | 96 +++++++ .../same-line-method-private-field-usage.js | 49 ++++ ...same-line-method-private-method-getter-usage.js | 49 ++++ .../same-line-method-private-method-usage.js | 49 ++++ .../elements/same-line-method-private-names.js | 71 ++++++ ...-line-method-rs-field-identifier-initializer.js | 87 +++++++ .../same-line-method-rs-field-identifier.js | 94 +++++++ .../same-line-method-rs-private-getter-alt.js | 128 ++++++++++ .../elements/same-line-method-rs-private-getter.js | 128 ++++++++++ .../same-line-method-rs-private-method-alt.js | 127 ++++++++++ .../elements/same-line-method-rs-private-method.js | 127 ++++++++++ .../same-line-method-rs-private-setter-alt.js | 127 ++++++++++ .../elements/same-line-method-rs-private-setter.js | 127 ++++++++++ ...me-line-method-rs-privatename-identifier-alt.js | 109 ++++++++ ...od-rs-privatename-identifier-initializer-alt.js | 103 ++++++++ ...method-rs-privatename-identifier-initializer.js | 103 ++++++++ .../same-line-method-rs-privatename-identifier.js | 109 ++++++++ ...-generator-method-privatename-identifier-alt.js | 134 ++++++++++ ...sync-generator-method-privatename-identifier.js | 135 ++++++++++ ...atic-async-method-privatename-identifier-alt.js | 134 ++++++++++ ...s-static-async-method-privatename-identifier.js | 135 ++++++++++ ...-generator-method-privatename-identifier-alt.js | 124 +++++++++ ...atic-generator-method-privatename-identifier.js | 125 +++++++++ ...-rs-static-method-privatename-identifier-alt.js | 122 +++++++++ ...thod-rs-static-method-privatename-identifier.js | 122 +++++++++ ...atic-privatename-identifier-alt-by-classname.js | 110 ++++++++ ...-method-rs-static-privatename-identifier-alt.js | 110 ++++++++ ...s-static-privatename-identifier-by-classname.js | 110 ++++++++ ...name-identifier-initializer-alt-by-classname.js | 104 ++++++++ ...tatic-privatename-identifier-initializer-alt.js | 104 ++++++++ ...rs-static-privatename-identifier-initializer.js | 104 ++++++++ ...line-method-rs-static-privatename-identifier.js | 110 ++++++++ .../same-line-method-static-private-fields.js | 71 ++++++ ...ne-method-static-private-methods-with-fields.js | 88 +++++++ .../same-line-method-static-private-methods.js | 75 ++++++ .../same-line-method-string-literal-names.js | 109 ++++++++ .../set-access-of-missing-private-setter.js | 42 +++ .../set-access-of-missing-private-static-setter.js | 41 +++ ...et-access-of-missing-shadowed-private-setter.js | 92 +++++++ .../class/elements/set-access-of-private-method.js | 43 ++++ .../set-access-of-shadowed-private-method.js | 92 +++++++ .../language/statements/class/elements/shell.js | 0 .../static-as-valid-instance-field-assigned.js | 38 +++ .../elements/static-as-valid-instance-field.js | 38 +++ .../static-as-valid-static-field-assigned.js | 30 +++ .../class/elements/static-as-valid-static-field.js | 30 +++ ...static-comp-name-init-err-contains-arguments.js | 36 +++ .../static-comp-name-init-err-contains-super.js | 29 +++ .../static-field-anonymous-function-length.js | 63 +++++ .../static-field-anonymous-function-name.js | 72 ++++++ .../class/elements/static-field-declaration.js | 132 ++++++++++ ...static-field-init-this-inside-arrow-function.js | 65 +++++ .../class/elements/static-field-init-with-this.js | 69 +++++ .../elements/static-field-initializer-error.js | 60 +++++ .../class/elements/static-field-redeclaration.js | 71 ++++++ ...ielddefinition-initializer-abrupt-completion.js | 35 +++ .../static-literal-init-err-contains-arguments.js | 35 +++ .../static-literal-init-err-contains-super.js | 28 ++ ...-private-fields-proxy-default-handler-throws.js | 30 +++ ...rivate-getter-access-on-inner-arrow-function.js | 46 ++++ .../static-private-getter-access-on-inner-class.js | 44 ++++ ...atic-private-getter-access-on-inner-function.js | 48 ++++ .../class/elements/static-private-getter.js | 57 +++++ .../static-private-init-err-contains-arguments.js | 35 +++ .../static-private-init-err-contains-super.js | 28 ++ ...rivate-method-access-on-inner-arrow-function.js | 44 ++++ ...atic-private-method-access-on-inner-function.js | 46 ++++ ...ivate-method-and-instance-method-brand-check.js | 66 +++++ ...ivate-method-referenced-from-instance-method.js | 40 +++ .../static-private-method-subclass-receiver.js | 39 +++ ...rivate-setter-access-on-inner-arrow-function.js | 47 ++++ .../static-private-setter-access-on-inner-class.js | 46 ++++ ...atic-private-setter-access-on-inner-function.js | 49 ++++ .../class/elements/static-private-setter.js | 58 +++++ ...ing-literal-name-init-err-contains-arguments.js | 35 +++ ...-string-literal-name-init-err-contains-super.js | 28 ++ ...ing-literal-name-init-err-contains-arguments.js | 35 +++ .../string-literal-name-init-err-contains-super.js | 28 ++ .../super-access-from-arrow-func-on-field.js | 39 +++ .../super-access-inside-a-private-getter.js | 52 ++++ .../super-access-inside-a-private-method.js | 52 ++++ .../super-access-inside-a-private-setter.js | 52 ++++ ...ielddefinition-initializer-abrupt-completion.js | 58 +++++ .../statements/class/elements/syntax/browser.js | 0 .../class/elements/syntax/early-errors/browser.js | 0 .../class-heritage-array-literal-arrow-heritage.js | 26 ++ ...-heritage-array-literal-async-arrow-heritage.js | 26 ++ .../elements/syntax/early-errors/delete/browser.js | 0 ...-call-expression-private-method-accessor-get.js | 42 +++ ...-call-expression-private-method-accessor-set.js | 42 +++ ...ete-call-expression-private-method-async-gen.js | 42 +++ ...-delete-call-expression-private-method-async.js | 42 +++ ...rr-delete-call-expression-private-method-gen.js | 42 +++ ...ed-err-delete-call-expression-private-method.js | 42 +++ ...-delete-call-expression-private-no-reference.js | 42 +++ ...vered-err-delete-call-expression-privatename.js | 42 +++ ...ember-expression-private-method-accessor-get.js | 41 +++ ...ember-expression-private-method-accessor-set.js | 41 +++ ...e-member-expression-private-method-async-gen.js | 41 +++ ...elete-member-expression-private-method-async.js | 41 +++ ...-delete-member-expression-private-method-gen.js | 41 +++ ...-err-delete-member-expression-private-method.js | 41 +++ ...elete-member-expression-private-no-reference.js | 40 +++ ...red-err-delete-member-expression-privatename.js | 40 +++ ...-call-expression-private-method-accessor-get.js | 39 +++ ...-call-expression-private-method-accessor-set.js | 39 +++ ...ete-call-expression-private-method-async-gen.js | 39 +++ ...-delete-call-expression-private-method-async.js | 39 +++ ...rr-delete-call-expression-private-method-gen.js | 39 +++ ...te-err-delete-call-expression-private-method.js | 39 +++ ...-delete-call-expression-private-no-reference.js | 39 +++ ...elete-err-delete-call-expression-privatename.js | 39 +++ ...ember-expression-private-method-accessor-get.js | 38 +++ ...ember-expression-private-method-accessor-set.js | 38 +++ ...e-member-expression-private-method-async-gen.js | 38 +++ ...elete-member-expression-private-method-async.js | 38 +++ ...-delete-member-expression-private-method-gen.js | 38 +++ ...-err-delete-member-expression-private-method.js | 38 +++ ...elete-member-expression-private-no-reference.js | 37 +++ ...ete-err-delete-member-expression-privatename.js | 37 +++ ...-call-expression-private-method-accessor-get.js | 43 ++++ ...-call-expression-private-method-accessor-set.js | 43 ++++ ...ete-call-expression-private-method-async-gen.js | 43 ++++ ...-delete-call-expression-private-method-async.js | 43 ++++ ...rr-delete-call-expression-private-method-gen.js | 43 ++++ ...ed-err-delete-call-expression-private-method.js | 43 ++++ ...-delete-call-expression-private-no-reference.js | 43 ++++ ...vered-err-delete-call-expression-privatename.js | 43 ++++ ...ember-expression-private-method-accessor-get.js | 42 +++ ...ember-expression-private-method-accessor-set.js | 42 +++ ...e-member-expression-private-method-async-gen.js | 42 +++ ...elete-member-expression-private-method-async.js | 42 +++ ...-delete-member-expression-private-method-gen.js | 42 +++ ...-err-delete-member-expression-private-method.js | 42 +++ ...elete-member-expression-private-no-reference.js | 41 +++ ...red-err-delete-member-expression-privatename.js | 41 +++ ...-call-expression-private-method-accessor-get.js | 49 ++++ ...-call-expression-private-method-accessor-set.js | 49 ++++ ...ete-call-expression-private-method-async-gen.js | 49 ++++ ...-delete-call-expression-private-method-async.js | 49 ++++ ...rr-delete-call-expression-private-method-gen.js | 49 ++++ ...ed-err-delete-call-expression-private-method.js | 49 ++++ ...-delete-call-expression-private-no-reference.js | 49 ++++ ...vered-err-delete-call-expression-privatename.js | 49 ++++ ...ember-expression-private-method-accessor-get.js | 48 ++++ ...ember-expression-private-method-accessor-set.js | 48 ++++ ...e-member-expression-private-method-async-gen.js | 48 ++++ ...elete-member-expression-private-method-async.js | 48 ++++ ...-delete-member-expression-private-method-gen.js | 48 ++++ ...-err-delete-member-expression-private-method.js | 48 ++++ ...elete-member-expression-private-no-reference.js | 47 ++++ ...red-err-delete-member-expression-privatename.js | 47 ++++ ...-call-expression-private-method-accessor-get.js | 43 ++++ ...-call-expression-private-method-accessor-set.js | 43 ++++ ...ete-call-expression-private-method-async-gen.js | 43 ++++ ...-delete-call-expression-private-method-async.js | 43 ++++ ...rr-delete-call-expression-private-method-gen.js | 43 ++++ ...te-err-delete-call-expression-private-method.js | 43 ++++ ...-delete-call-expression-private-no-reference.js | 43 ++++ ...elete-err-delete-call-expression-privatename.js | 43 ++++ ...ember-expression-private-method-accessor-get.js | 42 +++ ...ember-expression-private-method-accessor-set.js | 42 +++ ...e-member-expression-private-method-async-gen.js | 42 +++ ...elete-member-expression-private-method-async.js | 42 +++ ...-delete-member-expression-private-method-gen.js | 42 +++ ...-err-delete-member-expression-private-method.js | 42 +++ ...elete-member-expression-private-no-reference.js | 41 +++ ...ete-err-delete-member-expression-privatename.js | 41 +++ ...-call-expression-private-method-accessor-get.js | 49 ++++ ...-call-expression-private-method-accessor-set.js | 49 ++++ ...ete-call-expression-private-method-async-gen.js | 49 ++++ ...-delete-call-expression-private-method-async.js | 49 ++++ ...rr-delete-call-expression-private-method-gen.js | 49 ++++ ...ed-err-delete-call-expression-private-method.js | 49 ++++ ...-delete-call-expression-private-no-reference.js | 49 ++++ ...vered-err-delete-call-expression-privatename.js | 49 ++++ ...ember-expression-private-method-accessor-get.js | 48 ++++ ...ember-expression-private-method-accessor-set.js | 48 ++++ ...e-member-expression-private-method-async-gen.js | 48 ++++ ...elete-member-expression-private-method-async.js | 48 ++++ ...-delete-member-expression-private-method-gen.js | 48 ++++ ...-err-delete-member-expression-private-method.js | 48 ++++ ...elete-member-expression-private-no-reference.js | 47 ++++ ...red-err-delete-member-expression-privatename.js | 47 ++++ .../elements/syntax/early-errors/delete/shell.js | 0 .../grammar-class-body-ctor-duplicate.js | 26 ++ .../early-errors/grammar-ctor-super-no-heritage.js | 30 +++ .../grammar-field-identifier-invalid-ues-error.js | 71 ++++++ .../grammar-field-identifier-invalid-zwj-error.js | 71 ++++++ .../grammar-field-identifier-invalid-zwnj-error.js | 71 ++++++ .../early-errors/grammar-fields-same-line-error.js | 34 +++ ...-environment-on-class-heritage-array-literal.js | 40 +++ ...-environment-on-class-heritage-chained-usage.js | 40 +++ ...onment-on-class-heritage-function-expression.js | 40 +++ ...te-environment-on-class-heritage-obj-literal.js | 40 +++ ...vate-environment-on-class-heritage-recursive.js | 40 +++ ...rammar-private-environment-on-class-heritage.js | 40 +++ ...rammar-private-field-on-object-destructuring.js | 33 +++ .../grammar-private-field-super-access.js | 36 +++ .../grammar-privatemeth-duplicate-async-gen.js | 27 ++ .../grammar-privatemeth-duplicate-async.js | 27 ++ .../grammar-privatemeth-duplicate-gen.js | 27 ++ .../grammar-privatemeth-duplicate-get-field.js | 27 ++ .../grammar-privatemeth-duplicate-get-get.js | 27 ++ .../grammar-privatemeth-duplicate-meth-field.js | 27 ++ .../grammar-privatemeth-duplicate-meth-get.js | 27 ++ .../grammar-privatemeth-duplicate-meth-meth.js | 27 ++ .../grammar-privatemeth-duplicate-meth-set.js | 27 ++ ...ammar-privatemeth-duplicate-meth-staticfield.js | 27 ++ ...rammar-privatemeth-duplicate-meth-staticmeth.js | 27 ++ .../grammar-privatemeth-duplicate-set-field.js | 27 ++ .../grammar-privatemeth-duplicate-set-set.js | 27 ++ .../grammar-privatename-constructor.js | 26 ++ .../early-errors/grammar-privatename-error.js | 37 +++ .../grammar-privatename-identifier-invalid-ues.js | 65 +++++ ...mar-privatename-identifier-invalid-zwj-error.js | 66 +++++ ...ar-privatename-identifier-invalid-zwnj-error.js | 66 +++++ ...mar-privatename-in-computed-property-missing.js | 53 ++++ ...ivatename-whitespace-error-accessor-get-meth.js | 30 +++ ...ivatename-whitespace-error-accessor-set-meth.js | 30 +++ ...-privatename-whitespace-error-async-gen-meth.js | 30 +++ ...mmar-privatename-whitespace-error-async-meth.js | 30 +++ ...ammar-privatename-whitespace-error-call-expr.js | 40 +++ ...mmar-privatename-whitespace-error-field-init.js | 30 +++ .../grammar-privatename-whitespace-error-field.js | 30 +++ ...rammar-privatename-whitespace-error-gen-meth.js | 30 +++ ...mar-privatename-whitespace-error-member-expr.js | 35 +++ ...ammar-privatename-whitespace-error-meth.case.js | 30 +++ ...me-whitespace-error-static-accessor-get-meth.js | 30 +++ ...me-whitespace-error-static-accessor-set-meth.js | 30 +++ ...ename-whitespace-error-static-async-gen-meth.js | 30 +++ ...ivatename-whitespace-error-static-async-meth.js | 30 +++ ...ivatename-whitespace-error-static-field-init.js | 30 +++ ...ar-privatename-whitespace-error-static-field.js | 30 +++ ...privatename-whitespace-error-static-gen-meth.js | 30 +++ ...mar-privatename-whitespace-error-static-meth.js | 30 +++ .../grammar-privatenames-same-line-error.js | 37 +++ ...rammar-special-meth-contains-super-async-gen.js | 28 ++ .../grammar-special-meth-contains-super-async.js | 28 ++ .../grammar-special-meth-contains-super-gen.js | 28 ++ .../grammar-special-meth-contains-super-get.js | 28 ++ .../grammar-special-meth-contains-super-method.js | 28 ++ ...pecial-meth-contains-super-private-async-gen.js | 28 ++ ...ar-special-meth-contains-super-private-async.js | 28 ++ ...mmar-special-meth-contains-super-private-gen.js | 28 ++ ...r-special-meth-contains-super-private-method.js | 28 ++ .../grammar-special-meth-contains-super-set.js | 28 ++ .../grammar-special-meth-ctor-async-gen.js | 26 ++ .../grammar-special-meth-ctor-async-meth.js | 26 ++ .../early-errors/grammar-special-meth-ctor-gen.js | 26 ++ .../early-errors/grammar-special-meth-ctor-get.js | 26 ++ .../early-errors/grammar-special-meth-ctor-set.js | 26 ++ .../grammar-static-async-gen-meth-prototype.js | 26 ++ .../grammar-static-async-gen-meth-super.js | 28 ++ .../grammar-static-async-meth-prototype.js | 26 ++ .../grammar-static-async-meth-super.js | 28 ++ .../grammar-static-gen-meth-prototype.js | 26 ++ .../early-errors/grammar-static-gen-meth-super.js | 28 ++ .../grammar-static-get-meth-prototype.js | 26 ++ .../early-errors/grammar-static-get-meth-super.js | 28 ++ .../early-errors/grammar-static-meth-prototype.js | 26 ++ .../early-errors/grammar-static-meth-super.js | 28 ++ ...ar-static-private-async-gen-meth-constructor.js | 26 ++ .../grammar-static-private-async-gen-meth-super.js | 28 ++ ...rammar-static-private-async-meth-constructor.js | 26 ++ .../grammar-static-private-async-meth-super.js | 28 ++ .../grammar-static-private-gen-meth-constructor.js | 26 ++ .../grammar-static-private-gen-meth-super.js | 28 ++ .../grammar-static-private-meth-constructor.js | 26 ++ .../grammar-static-private-meth-super.js | 28 ++ .../grammar-static-privatename-constructor.js | 26 ++ .../grammar-static-set-meth-prototype.js | 26 ++ .../early-errors/grammar-static-set-meth-super.js | 28 ++ .../syntax/early-errors/invalid-names/browser.js | 0 .../field-init-call-expression-bad-reference.js | 43 ++++ .../field-init-call-expression-this.js | 43 ++++ .../field-init-fn-call-expression-bad-reference.js | 43 ++++ .../field-init-fn-call-expression-this.js | 43 ++++ ...ield-init-fn-member-expression-bad-reference.js | 43 ++++ .../field-init-fn-member-expression-this.js | 43 ++++ .../field-init-member-expression-bad-reference.js | 43 ++++ .../field-init-member-expression-this.js | 43 ++++ ...-init-heritage-call-expression-bad-reference.js | 58 +++++ .../fields-init-heritage-call-expression-this.js | 58 +++++ ...nit-heritage-member-expression-bad-reference.js | 58 +++++ .../fields-init-heritage-member-expression-this.js | 58 +++++ .../method-call-expression-bad-reference.js | 43 ++++ .../invalid-names/method-call-expression-this.js | 43 ++++ .../method-fn-call-expression-bad-reference.js | 45 ++++ .../method-fn-call-expression-this.js | 45 ++++ .../method-fn-member-expression-bad-reference.js | 45 ++++ .../method-fn-member-expression-this.js | 45 ++++ ...ethod-heritage-call-expression-bad-reference.js | 59 +++++ .../method-heritage-call-expression-this.js | 59 +++++ ...hod-heritage-member-expression-bad-reference.js | 59 +++++ .../method-heritage-member-expression-this.js | 59 +++++ .../method-member-expression-bad-reference.js | 43 ++++ .../invalid-names/method-member-expression-this.js | 43 ++++ .../method-outter-call-expression-bad-reference.js | 59 +++++ .../method-outter-call-expression-this.js | 59 +++++ ...ethod-outter-member-expression-bad-reference.js | 59 +++++ .../method-outter-member-expression-this.js | 59 +++++ .../syntax/early-errors/invalid-names/shell.js | 0 .../private-async-generator-cannot-escape-token.js | 26 ++ .../private-async-method-cannot-escape-token.js | 26 ++ .../private-call-exp-cannot-escape-token.js | 34 +++ .../private-field-cannot-escape-token.js | 26 ++ .../private-generator-cannot-escape-token.js | 26 ++ .../private-member-exp-cannot-escape-token.js | 34 +++ .../private-method-cannot-escape-token.js | 26 ++ .../class/elements/syntax/early-errors/shell.js | 0 .../early-errors/super-private-access-invalid.js | 37 +++ .../statements/class/elements/syntax/shell.js | 0 .../class/elements/syntax/valid/browser.js | 0 .../valid/grammar-class-body-ctor-no-heritage.js | 24 ++ .../syntax/valid/grammar-field-accessor.js | 27 ++ ...ammar-field-classelementname-initializer-alt.js | 72 ++++++ .../grammar-field-classelementname-initializer.js | 72 ++++++ .../syntax/valid/grammar-field-identifier-alt.js | 72 ++++++ .../syntax/valid/grammar-field-identifier.js | 72 ++++++ .../syntax/valid/grammar-fields-multi-line.js | 31 +++ .../valid/grammar-privatemeth-duplicate-get-set.js | 23 ++ ...r-privatemeth-duplicate-meth-nestedclassmeth.js | 28 ++ ...privatename-classelementname-initializer-alt.js | 69 +++++ ...mar-privatename-classelementname-initializer.js | 69 +++++ .../syntax/valid/grammar-privatename-identifier.js | 66 +++++ ...ammar-privatename-no-initializer-with-method.js | 34 +++ .../valid/grammar-privatenames-multi-line.js | 34 +++ ...rammar-special-prototype-accessor-meth-valid.js | 58 +++++ ...ammar-special-prototype-async-gen-meth-valid.js | 51 ++++ .../grammar-special-prototype-async-meth-valid.js | 51 ++++ .../grammar-special-prototype-gen-meth-valid.js | 51 ++++ .../valid/grammar-special-prototype-meth-valid.js | 51 ++++ .../grammar-static-ctor-accessor-meth-valid.js | 32 +++ .../grammar-static-ctor-async-gen-meth-valid.js | 31 +++ .../valid/grammar-static-ctor-async-meth-valid.js | 31 +++ .../valid/grammar-static-ctor-gen-meth-valid.js | 31 +++ .../syntax/valid/grammar-static-ctor-meth-valid.js | 31 +++ ...mmar-static-private-async-gen-meth-prototype.js | 22 ++ .../grammar-static-private-async-meth-prototype.js | 22 ++ .../grammar-static-private-gen-meth-prototype.js | 22 ++ .../valid/grammar-static-private-meth-prototype.js | 22 ++ .../class/elements/syntax/valid/shell.js | 0 .../ternary-init-err-contains-arguments.js | 35 +++ .../elements/ternary-init-err-contains-super.js | 28 ++ .../elements/typeof-init-err-contains-arguments.js | 35 +++ .../elements/typeof-init-err-contains-super.js | 28 ++ .../class/elements/wrapped-in-sc-computed-names.js | 96 +++++++ .../wrapped-in-sc-computed-symbol-names.js | 94 +++++++ ...privatename-identifier-semantics-stringvalue.js | 97 +++++++ .../elements/wrapped-in-sc-literal-names-asi.js | 66 +++++ .../class/elements/wrapped-in-sc-literal-names.js | 85 +++++++ .../elements/wrapped-in-sc-private-field-usage.js | 37 +++ .../wrapped-in-sc-private-method-getter-usage.js | 37 +++ .../elements/wrapped-in-sc-private-method-usage.js | 37 +++ .../class/elements/wrapped-in-sc-private-names.js | 59 +++++ ...rapped-in-sc-rs-field-identifier-initializer.js | 75 ++++++ .../elements/wrapped-in-sc-rs-field-identifier.js | 82 ++++++ .../wrapped-in-sc-rs-private-getter-alt.js | 116 +++++++++ .../elements/wrapped-in-sc-rs-private-getter.js | 116 +++++++++ .../wrapped-in-sc-rs-private-method-alt.js | 115 +++++++++ .../elements/wrapped-in-sc-rs-private-method.js | 115 +++++++++ .../wrapped-in-sc-rs-private-setter-alt.js | 115 +++++++++ .../elements/wrapped-in-sc-rs-private-setter.js | 115 +++++++++ .../wrapped-in-sc-rs-privatename-identifier-alt.js | 97 +++++++ ...sc-rs-privatename-identifier-initializer-alt.js | 91 +++++++ ...-in-sc-rs-privatename-identifier-initializer.js | 91 +++++++ .../wrapped-in-sc-rs-privatename-identifier.js | 97 +++++++ ...-generator-method-privatename-identifier-alt.js | 122 +++++++++ ...sync-generator-method-privatename-identifier.js | 123 +++++++++ ...atic-async-method-privatename-identifier-alt.js | 122 +++++++++ ...s-static-async-method-privatename-identifier.js | 123 +++++++++ ...-generator-method-privatename-identifier-alt.js | 112 ++++++++ ...atic-generator-method-privatename-identifier.js | 113 +++++++++ ...-rs-static-method-privatename-identifier-alt.js | 110 ++++++++ ...n-sc-rs-static-method-privatename-identifier.js | 110 ++++++++ ...atic-privatename-identifier-alt-by-classname.js | 98 +++++++ ...d-in-sc-rs-static-privatename-identifier-alt.js | 98 +++++++ ...s-static-privatename-identifier-by-classname.js | 98 +++++++ ...name-identifier-initializer-alt-by-classname.js | 92 +++++++ ...tatic-privatename-identifier-initializer-alt.js | 92 +++++++ ...rs-static-privatename-identifier-initializer.js | 92 +++++++ ...apped-in-sc-rs-static-privatename-identifier.js | 98 +++++++ .../wrapped-in-sc-static-private-fields.js | 59 +++++ ...ped-in-sc-static-private-methods-with-fields.js | 76 ++++++ .../wrapped-in-sc-static-private-methods.js | 63 +++++ .../elements/wrapped-in-sc-string-literal-names.js | 98 +++++++ .../statements/class/gen-method-length-dflt.js | 69 +++++ .../class/gen-method-param-dflt-yield.js | 28 ++ .../array-destructuring-param-strict-body.js | 157 ++++++++++++ .../statements/class/gen-method-static/browser.js | 0 .../class/gen-method-static/dflt-params-abrupt.js | 88 +++++++ .../dflt-params-arg-val-not-undefined.js | 112 ++++++++ .../dflt-params-arg-val-undefined.js | 95 +++++++ .../gen-method-static/dflt-params-duplicates.js | 86 +++++++ .../gen-method-static/dflt-params-ref-later.js | 89 +++++++ .../gen-method-static/dflt-params-ref-prior.js | 92 +++++++ .../gen-method-static/dflt-params-ref-self.js | 89 +++++++ .../class/gen-method-static/dflt-params-rest.js | 90 +++++++ .../dflt-params-trailing-comma.js | 87 +++++++ .../gen-method-static/forbidden-ext/b1/browser.js | 0 ...c-forbidden-ext-direct-access-prop-arguments.js | 38 +++ ...atic-forbidden-ext-direct-access-prop-caller.js | 38 +++ .../gen-method-static/forbidden-ext/b1/shell.js | 0 .../gen-method-static/forbidden-ext/b2/browser.js | 0 ...dden-ext-indirect-access-own-prop-caller-get.js | 64 +++++ ...en-ext-indirect-access-own-prop-caller-value.js | 64 +++++ ...ic-forbidden-ext-indirect-access-prop-caller.js | 64 +++++ .../gen-method-static/forbidden-ext/b2/shell.js | 0 .../gen-method-static/forbidden-ext/browser.js | 0 .../class/gen-method-static/forbidden-ext/shell.js | 0 .../object-destructuring-param-strict-body.js | 157 ++++++++++++ .../params-trailing-comma-multiple.js | 87 +++++++ .../params-trailing-comma-single.js | 86 +++++++ .../gen-method-static/rest-param-strict-body.js | 157 ++++++++++++ .../rest-params-trailing-comma-early-error.js | 83 ++++++ .../statements/class/gen-method-static/shell.js | 0 .../yield-as-binding-identifier-escaped.js | 36 +++ .../yield-as-binding-identifier.js | 36 +++ .../yield-as-identifier-reference-escaped.js | 36 +++ .../yield-as-identifier-reference.js | 36 +++ .../yield-as-label-identifier-escaped.js | 36 +++ .../gen-method-static/yield-as-label-identifier.js | 36 +++ .../yield-identifier-spread-strict-strict.js | 54 ++++ .../yield-identifier-strict-strict.js | 45 ++++ .../gen-method-static/yield-spread-arr-multiple.js | 52 ++++ .../gen-method-static/yield-spread-arr-single.js | 54 ++++ .../class/gen-method-static/yield-spread-obj.js | 57 +++++ .../array-destructuring-param-strict-body.js | 157 ++++++++++++ .../statements/class/gen-method/browser.js | 0 .../class/gen-method/dflt-params-abrupt.js | 87 +++++++ .../dflt-params-arg-val-not-undefined.js | 112 ++++++++ .../gen-method/dflt-params-arg-val-undefined.js | 95 +++++++ .../class/gen-method/dflt-params-duplicates.js | 86 +++++++ .../class/gen-method/dflt-params-ref-later.js | 88 +++++++ .../class/gen-method/dflt-params-ref-prior.js | 92 +++++++ .../class/gen-method/dflt-params-ref-self.js | 88 +++++++ .../class/gen-method/dflt-params-rest.js | 90 +++++++ .../class/gen-method/dflt-params-trailing-comma.js | 87 +++++++ .../class/gen-method/forbidden-ext/b1/browser.js | 0 ...h-forbidden-ext-direct-access-prop-arguments.js | 37 +++ ...meth-forbidden-ext-direct-access-prop-caller.js | 37 +++ .../class/gen-method/forbidden-ext/b1/shell.js | 0 .../class/gen-method/forbidden-ext/b2/browser.js | 0 ...dden-ext-indirect-access-own-prop-caller-get.js | 63 +++++ ...en-ext-indirect-access-own-prop-caller-value.js | 63 +++++ ...th-forbidden-ext-indirect-access-prop-caller.js | 63 +++++ .../class/gen-method/forbidden-ext/b2/shell.js | 0 .../class/gen-method/forbidden-ext/browser.js | 0 .../class/gen-method/forbidden-ext/shell.js | 0 .../object-destructuring-param-strict-body.js | 157 ++++++++++++ .../gen-method/params-trailing-comma-multiple.js | 87 +++++++ .../gen-method/params-trailing-comma-single.js | 86 +++++++ .../class/gen-method/rest-param-strict-body.js | 157 ++++++++++++ .../rest-params-trailing-comma-early-error.js | 83 ++++++ .../language/statements/class/gen-method/shell.js | 0 .../yield-as-binding-identifier-escaped.js | 36 +++ .../gen-method/yield-as-binding-identifier.js | 36 +++ .../yield-as-identifier-reference-escaped.js | 36 +++ .../gen-method/yield-as-identifier-reference.js | 36 +++ .../yield-as-label-identifier-escaped.js | 36 +++ .../class/gen-method/yield-as-label-identifier.js | 36 +++ .../yield-identifier-spread-strict-strict.js | 54 ++++ .../gen-method/yield-identifier-strict-strict.js | 45 ++++ .../class/gen-method/yield-spread-arr-multiple.js | 52 ++++ .../class/gen-method/yield-spread-arr-single.js | 54 ++++ .../class/gen-method/yield-spread-obj.js | 57 +++++ .../language/statements/class/getter-param-dflt.js | 24 ++ .../class/ident-name-method-def-break-escaped.js | 48 ++++ .../class/ident-name-method-def-case-escaped.js | 48 ++++ .../class/ident-name-method-def-catch-escaped.js | 48 ++++ .../class/ident-name-method-def-class-escaped.js | 48 ++++ .../class/ident-name-method-def-const-escaped.js | 48 ++++ .../ident-name-method-def-continue-escaped.js | 48 ++++ .../ident-name-method-def-debugger-escaped.js | 48 ++++ .../ident-name-method-def-default-escaped-ext.js | 48 ++++ .../class/ident-name-method-def-default-escaped.js | 48 ++++ .../class/ident-name-method-def-default.js | 48 ++++ .../class/ident-name-method-def-delete-escaped.js | 48 ++++ .../class/ident-name-method-def-do-escaped.js | 48 ++++ .../class/ident-name-method-def-else-escaped.js | 48 ++++ .../class/ident-name-method-def-enum-escaped.js | 48 ++++ .../class/ident-name-method-def-export-escaped.js | 48 ++++ .../ident-name-method-def-extends-escaped-ext.js | 48 ++++ .../class/ident-name-method-def-extends-escaped.js | 48 ++++ .../class/ident-name-method-def-extends.js | 48 ++++ .../class/ident-name-method-def-finally-escaped.js | 48 ++++ .../class/ident-name-method-def-for-escaped.js | 48 ++++ .../ident-name-method-def-function-escaped.js | 48 ++++ .../class/ident-name-method-def-if-escaped.js | 48 ++++ .../ident-name-method-def-implements-escaped.js | 48 ++++ .../class/ident-name-method-def-import-escaped.js | 48 ++++ .../class/ident-name-method-def-in-escaped.js | 48 ++++ .../ident-name-method-def-instanceof-escaped.js | 48 ++++ .../ident-name-method-def-interface-escaped.js | 48 ++++ .../class/ident-name-method-def-let-escaped.js | 48 ++++ .../class/ident-name-method-def-new-escaped.js | 48 ++++ .../class/ident-name-method-def-package-escaped.js | 48 ++++ .../class/ident-name-method-def-private-escaped.js | 48 ++++ .../ident-name-method-def-protected-escaped.js | 48 ++++ .../class/ident-name-method-def-public-escaped.js | 48 ++++ .../class/ident-name-method-def-return-escaped.js | 48 ++++ .../class/ident-name-method-def-static-escaped.js | 48 ++++ .../class/ident-name-method-def-super-escaped.js | 48 ++++ .../class/ident-name-method-def-switch-escaped.js | 48 ++++ .../class/ident-name-method-def-this-escaped.js | 48 ++++ .../class/ident-name-method-def-throw-escaped.js | 48 ++++ .../class/ident-name-method-def-try-escaped.js | 48 ++++ .../class/ident-name-method-def-typeof-escaped.js | 48 ++++ .../class/ident-name-method-def-var-escaped.js | 48 ++++ .../class/ident-name-method-def-void-escaped.js | 48 ++++ .../class/ident-name-method-def-while-escaped.js | 48 ++++ .../class/ident-name-method-def-with-escaped.js | 48 ++++ .../statements/class/method-length-dflt.js | 69 +++++ .../statements/class/method-param-yield.js | 23 ++ .../array-destructuring-param-strict-body.js | 154 +++++++++++ .../statements/class/method-static/browser.js | 0 .../class/method-static/dflt-params-abrupt.js | 84 ++++++ .../dflt-params-arg-val-not-undefined.js | 109 ++++++++ .../method-static/dflt-params-arg-val-undefined.js | 92 +++++++ .../class/method-static/dflt-params-duplicates.js | 83 ++++++ .../class/method-static/dflt-params-ref-later.js | 85 +++++++ .../class/method-static/dflt-params-ref-prior.js | 89 +++++++ .../class/method-static/dflt-params-ref-self.js | 85 +++++++ .../class/method-static/dflt-params-rest.js | 87 +++++++ .../method-static/dflt-params-trailing-comma.js | 83 ++++++ .../method-static/forbidden-ext/b1/browser.js | 0 ...c-forbidden-ext-direct-access-prop-arguments.js | 37 +++ ...atic-forbidden-ext-direct-access-prop-caller.js | 37 +++ .../class/method-static/forbidden-ext/b1/shell.js | 0 .../method-static/forbidden-ext/b2/browser.js | 0 ...dden-ext-indirect-access-own-prop-caller-get.js | 63 +++++ ...en-ext-indirect-access-own-prop-caller-value.js | 63 +++++ ...ic-forbidden-ext-indirect-access-prop-caller.js | 63 +++++ .../class/method-static/forbidden-ext/b2/shell.js | 0 .../class/method-static/forbidden-ext/browser.js | 0 .../class/method-static/forbidden-ext/shell.js | 0 .../object-destructuring-param-strict-body.js | 154 +++++++++++ .../params-trailing-comma-multiple.js | 83 ++++++ .../method-static/params-trailing-comma-single.js | 82 ++++++ .../class/method-static/rest-param-strict-body.js | 154 +++++++++++ .../rest-params-trailing-comma-early-error.js | 79 ++++++ .../statements/class/method-static/shell.js | 0 .../array-destructuring-param-strict-body.js | 154 +++++++++++ .../language/statements/class/method/browser.js | 0 .../statements/class/method/dflt-params-abrupt.js | 84 ++++++ .../method/dflt-params-arg-val-not-undefined.js | 109 ++++++++ .../class/method/dflt-params-arg-val-undefined.js | 92 +++++++ .../class/method/dflt-params-duplicates.js | 83 ++++++ .../class/method/dflt-params-ref-later.js | 85 +++++++ .../class/method/dflt-params-ref-prior.js | 89 +++++++ .../class/method/dflt-params-ref-self.js | 85 +++++++ .../statements/class/method/dflt-params-rest.js | 87 +++++++ .../class/method/dflt-params-trailing-comma.js | 83 ++++++ .../class/method/forbidden-ext/b1/browser.js | 0 ...h-forbidden-ext-direct-access-prop-arguments.js | 37 +++ ...meth-forbidden-ext-direct-access-prop-caller.js | 37 +++ .../class/method/forbidden-ext/b1/shell.js | 0 .../class/method/forbidden-ext/b2/browser.js | 0 ...dden-ext-indirect-access-own-prop-caller-get.js | 63 +++++ ...en-ext-indirect-access-own-prop-caller-value.js | 63 +++++ ...th-forbidden-ext-indirect-access-prop-caller.js | 63 +++++ .../class/method/forbidden-ext/b2/shell.js | 0 .../class/method/forbidden-ext/browser.js | 0 .../statements/class/method/forbidden-ext/shell.js | 0 .../object-destructuring-param-strict-body.js | 154 +++++++++++ .../class/method/params-trailing-comma-multiple.js | 83 ++++++ .../class/method/params-trailing-comma-single.js | 82 ++++++ .../class/method/rest-param-strict-body.js | 154 +++++++++++ .../rest-params-trailing-comma-early-error.js | 79 ++++++ .../language/statements/class/method/shell.js | 0 .../statements/class/name-binding/basic.js | 38 +++ .../statements/class/name-binding/browser.js | 0 .../statements/class/name-binding/const.js | 33 +++ .../statements/class/name-binding/expression.js | 43 ++++ .../name-binding/in-extends-expression-assigned.js | 12 + .../name-binding/in-extends-expression-grouped.js | 13 + .../class/name-binding/in-extends-expression.js | 12 + .../statements/class/name-binding/shell.js | 0 .../test262/language/statements/class/name.js | 23 ++ .../class/params-dflt-gen-meth-args-unmapped.js | 106 ++++++++ .../class/params-dflt-gen-meth-ref-arguments.js | 85 +++++++ .../params-dflt-gen-meth-static-args-unmapped.js | 106 ++++++++ .../params-dflt-gen-meth-static-ref-arguments.js | 85 +++++++ .../class/params-dflt-meth-args-unmapped.js | 104 ++++++++ .../class/params-dflt-meth-ref-arguments.js | 83 ++++++ .../class/params-dflt-meth-static-args-unmapped.js | 104 ++++++++ .../class/params-dflt-meth-static-ref-arguments.js | 83 ++++++ .../statements/class/poisoned-underscore-proto.js | 30 +++ ...-non-static-getter-static-setter-early-error.js | 20 ++ ...-non-static-setter-static-getter-early-error.js | 20 ++ ...-static-getter-non-static-setter-early-error.js | 20 ++ ...-static-setter-non-static-getter-early-error.js | 20 ++ .../statements/class/restricted-properties.js | 62 +++++ .../class/scope-gen-meth-paramsbody-var-close.js | 40 +++ .../class/scope-gen-meth-paramsbody-var-open.js | 38 +++ .../class/scope-meth-paramsbody-var-close.js | 39 +++ .../class/scope-meth-paramsbody-var-open.js | 37 +++ .../statements/class/scope-name-lex-close.js | 24 ++ .../class/scope-name-lex-open-heritage.js | 48 ++++ .../class/scope-name-lex-open-no-heritage.js | 47 ++++ .../class/scope-setter-paramsbody-var-close.js | 39 +++ .../class/scope-setter-paramsbody-var-open.js | 37 +++ .../scope-static-gen-meth-paramsbody-var-close.js | 40 +++ .../scope-static-gen-meth-paramsbody-var-open.js | 38 +++ .../scope-static-meth-paramsbody-var-close.js | 39 +++ .../class/scope-static-meth-paramsbody-var-open.js | 37 +++ .../scope-static-setter-paramsbody-var-close.js | 39 +++ .../scope-static-setter-paramsbody-var-open.js | 37 +++ .../statements/class/setter-length-dflt.js | 41 +++ .../test262/language/statements/class/shell.js | 0 .../static-classelementname-abrupt-completion.js | 35 +++ .../class/static-gen-method-param-dflt-yield.js | 28 ++ .../statements/class/static-init-abrupt.js | 48 ++++ .../class/static-init-arguments-functions.js | 42 +++ .../class/static-init-arguments-methods.js | 60 +++++ .../class/static-init-await-binding-invalid.js | 27 ++ .../class/static-init-await-binding-valid.js | 20 ++ .../class/static-init-expr-new-target.js | 25 ++ .../statements/class/static-init-expr-this.js | 25 ++ .../class/static-init-invalid-arguments.js | 24 ++ .../statements/class/static-init-invalid-await.js | 34 +++ .../class/static-init-invalid-label-dup.js | 25 ++ .../class/static-init-invalid-lex-dup.js | 25 ++ .../class/static-init-invalid-lex-var.js | 26 ++ .../statements/class/static-init-invalid-return.js | 28 ++ .../class/static-init-invalid-super-call.js | 23 ++ .../static-init-invalid-undefined-break-target.js | 26 ++ ...tatic-init-invalid-undefined-continue-target.js | 26 ++ .../statements/class/static-init-invalid-yield.js | 28 ++ .../class/static-init-scope-lex-close.js | 29 +++ .../class/static-init-scope-lex-derived.js | 25 ++ .../statements/class/static-init-scope-lex-open.js | 33 +++ .../statements/class/static-init-scope-private.js | 27 ++ .../class/static-init-scope-var-close.js | 29 +++ .../class/static-init-scope-var-derived.js | 26 ++ .../statements/class/static-init-scope-var-open.js | 33 +++ .../statements/class/static-init-sequence.js | 40 +++ .../class/static-init-statement-list-optional.js | 20 ++ .../statements/class/static-init-super-property.js | 26 ++ .../static-method-gen-non-configurable-err.js | 19 ++ .../statements/class/static-method-length-dflt.js | 69 +++++ .../class/static-method-non-configurable-err.js | 18 ++ .../statements/class/static-method-param-yield.js | 23 ++ .../class/strict-mode/arguments-callee.js | 18 ++ .../statements/class/strict-mode/browser.js | 0 .../language/statements/class/strict-mode/shell.js | 0 .../language/statements/class/strict-mode/with.js | 16 ++ .../statements/class/subclass-builtins/browser.js | 0 .../statements/class/subclass-builtins/shell.js | 0 .../subclass-builtins/subclass-AggregateError.js | 17 ++ .../class/subclass-builtins/subclass-Array.js | 16 ++ .../subclass-builtins/subclass-ArrayBuffer.js | 17 ++ .../subclass-builtins/subclass-BigInt64Array.js | 17 ++ .../subclass-builtins/subclass-BigUint64Array.js | 17 ++ .../class/subclass-builtins/subclass-Boolean.js | 16 ++ .../class/subclass-builtins/subclass-DataView.js | 17 ++ .../class/subclass-builtins/subclass-Date.js | 16 ++ .../class/subclass-builtins/subclass-Error.js | 16 ++ .../class/subclass-builtins/subclass-EvalError.js | 16 ++ .../subclass-builtins/subclass-Float32Array.js | 17 ++ .../subclass-builtins/subclass-Float64Array.js | 17 ++ .../class/subclass-builtins/subclass-Function.js | 16 ++ .../class/subclass-builtins/subclass-Int16Array.js | 17 ++ .../class/subclass-builtins/subclass-Int32Array.js | 17 ++ .../class/subclass-builtins/subclass-Int8Array.js | 17 ++ .../class/subclass-builtins/subclass-Map.js | 17 ++ .../class/subclass-builtins/subclass-Number.js | 16 ++ .../class/subclass-builtins/subclass-Object.js | 16 ++ .../class/subclass-builtins/subclass-Promise.js | 17 ++ .../class/subclass-builtins/subclass-RangeError.js | 16 ++ .../subclass-builtins/subclass-ReferenceError.js | 16 ++ .../class/subclass-builtins/subclass-RegExp.js | 16 ++ .../class/subclass-builtins/subclass-Set.js | 17 ++ .../subclass-SharedArrayBuffer.js | 18 ++ .../class/subclass-builtins/subclass-String.js | 16 ++ .../subclass-builtins/subclass-SyntaxError.js | 16 ++ .../class/subclass-builtins/subclass-TypeError.js | 16 ++ .../class/subclass-builtins/subclass-URIError.js | 16 ++ .../subclass-builtins/subclass-Uint16Array.js | 17 ++ .../subclass-builtins/subclass-Uint32Array.js | 17 ++ .../class/subclass-builtins/subclass-Uint8Array.js | 17 ++ .../subclass-Uint8ClampedArray.js | 17 ++ .../class/subclass-builtins/subclass-WeakMap.js | 17 ++ .../class/subclass-builtins/subclass-WeakRef.js | 18 ++ .../class/subclass-builtins/subclass-WeakSet.js | 17 ++ .../language/statements/class/subclass/binding.js | 54 ++++ .../language/statements/class/subclass/browser.js | 0 .../subclass/builtin-objects/Array/browser.js | 0 .../contructor-calls-super-multiple-arguments.js | 28 ++ .../contructor-calls-super-single-argument.js | 27 ++ .../class/subclass/builtin-objects/Array/length.js | 38 +++ .../builtin-objects/Array/regular-subclassing.js | 35 +++ .../class/subclass/builtin-objects/Array/shell.js | 0 .../builtin-objects/Array/super-must-be-called.js | 34 +++ .../builtin-objects/ArrayBuffer/browser.js | 0 .../ArrayBuffer/regular-subclassing.js | 28 ++ .../subclass/builtin-objects/ArrayBuffer/shell.js | 0 .../ArrayBuffer/super-must-be-called.js | 35 +++ .../subclass/builtin-objects/Boolean/browser.js | 0 .../builtin-objects/Boolean/regular-subclassing.js | 25 ++ .../subclass/builtin-objects/Boolean/shell.js | 0 .../Boolean/super-must-be-called.js | 33 +++ .../subclass/builtin-objects/DataView/browser.js | 0 .../DataView/regular-subclassing.js | 30 +++ .../subclass/builtin-objects/DataView/shell.js | 0 .../DataView/super-must-be-called.js | 37 +++ .../class/subclass/builtin-objects/Date/browser.js | 0 .../builtin-objects/Date/regular-subclassing.js | 39 +++ .../class/subclass/builtin-objects/Date/shell.js | 0 .../builtin-objects/Date/super-must-be-called.js | 37 +++ .../subclass/builtin-objects/Error/browser.js | 0 .../Error/message-property-assignment.js | 38 +++ .../builtin-objects/Error/regular-subclassing.js | 24 ++ .../class/subclass/builtin-objects/Error/shell.js | 0 .../builtin-objects/Error/super-must-be-called.js | 25 ++ .../subclass/builtin-objects/Function/browser.js | 0 .../builtin-objects/Function/instance-length.js | 29 +++ .../builtin-objects/Function/instance-name.js | 41 +++ .../Function/regular-subclassing.js | 22 ++ .../subclass/builtin-objects/Function/shell.js | 0 .../Function/super-must-be-called.js | 37 +++ .../builtin-objects/GeneratorFunction/browser.js | 0 .../GeneratorFunction/instance-length.js | 33 +++ .../GeneratorFunction/instance-name.js | 48 ++++ .../GeneratorFunction/instance-prototype.js | 40 +++ .../GeneratorFunction/regular-subclassing.js | 31 +++ .../builtin-objects/GeneratorFunction/shell.js | 0 .../GeneratorFunction/super-must-be-called.js | 40 +++ .../class/subclass/builtin-objects/Map/browser.js | 0 .../builtin-objects/Map/regular-subclassing.js | 28 ++ .../class/subclass/builtin-objects/Map/shell.js | 0 .../builtin-objects/Map/super-must-be-called.js | 34 +++ .../NativeError/EvalError-message.js | 37 +++ .../builtin-objects/NativeError/EvalError-name.js | 20 ++ .../builtin-objects/NativeError/EvalError-super.js | 25 ++ .../NativeError/RangeError-message.js | 37 +++ .../builtin-objects/NativeError/RangeError-name.js | 20 ++ .../NativeError/RangeError-super.js | 25 ++ .../NativeError/ReferenceError-message.js | 37 +++ .../NativeError/ReferenceError-name.js | 20 ++ .../NativeError/ReferenceError-super.js | 25 ++ .../NativeError/SyntaxError-message.js | 37 +++ .../NativeError/SyntaxError-name.js | 20 ++ .../NativeError/SyntaxError-super.js | 25 ++ .../NativeError/TypeError-message.js | 37 +++ .../builtin-objects/NativeError/TypeError-name.js | 20 ++ .../builtin-objects/NativeError/TypeError-super.js | 25 ++ .../NativeError/URIError-message.js | 37 +++ .../builtin-objects/NativeError/URIError-name.js | 20 ++ .../builtin-objects/NativeError/URIError-super.js | 25 ++ .../builtin-objects/NativeError/browser.js | 0 .../subclass/builtin-objects/NativeError/shell.js | 0 .../subclass/builtin-objects/Number/browser.js | 0 .../builtin-objects/Number/regular-subclassing.js | 25 ++ .../class/subclass/builtin-objects/Number/shell.js | 0 .../builtin-objects/Number/super-must-be-called.js | 34 +++ .../subclass/builtin-objects/Object/browser.js | 0 .../Object/constructor-return-undefined-throws.js | 47 ++++ .../Object/constructor-returns-non-object.js | 42 +++ .../builtin-objects/Object/regular-subclassing.js | 22 ++ .../builtin-objects/Object/replacing-prototype.js | 23 ++ .../class/subclass/builtin-objects/Object/shell.js | 0 .../subclass/builtin-objects/Promise/browser.js | 0 .../builtin-objects/Promise/regular-subclassing.js | 38 +++ .../subclass/builtin-objects/Promise/shell.js | 0 .../Promise/super-must-be-called.js | 35 +++ .../subclass/builtin-objects/Proxy/browser.js | 0 .../builtin-objects/Proxy/no-prototype-throws.js | 34 +++ .../class/subclass/builtin-objects/Proxy/shell.js | 0 .../subclass/builtin-objects/RegExp/browser.js | 0 .../subclass/builtin-objects/RegExp/lastIndex.js | 28 ++ .../builtin-objects/RegExp/regular-subclassing.js | 25 ++ .../class/subclass/builtin-objects/RegExp/shell.js | 0 .../builtin-objects/RegExp/super-must-be-called.js | 34 +++ .../class/subclass/builtin-objects/Set/browser.js | 0 .../builtin-objects/Set/regular-subclassing.js | 28 ++ .../class/subclass/builtin-objects/Set/shell.js | 0 .../builtin-objects/Set/super-must-be-called.js | 34 +++ .../subclass/builtin-objects/String/browser.js | 0 .../subclass/builtin-objects/String/length.js | 32 +++ .../builtin-objects/String/regular-subclassing.js | 24 ++ .../class/subclass/builtin-objects/String/shell.js | 0 .../builtin-objects/String/super-must-be-called.js | 33 +++ .../subclass/builtin-objects/Symbol/browser.js | 0 .../Symbol/new-symbol-with-super-throws.js | 38 +++ .../class/subclass/builtin-objects/Symbol/shell.js | 0 .../Symbol/symbol-valid-as-extends-value.js | 19 ++ .../subclass/builtin-objects/TypedArray/browser.js | 0 .../TypedArray/regular-subclassing.js | 37 +++ .../subclass/builtin-objects/TypedArray/shell.js | 0 .../TypedArray/super-must-be-called.js | 47 ++++ .../subclass/builtin-objects/WeakMap/browser.js | 0 .../builtin-objects/WeakMap/regular-subclassing.js | 31 +++ .../subclass/builtin-objects/WeakMap/shell.js | 0 .../WeakMap/super-must-be-called.js | 36 +++ .../subclass/builtin-objects/WeakSet/browser.js | 0 .../builtin-objects/WeakSet/regular-subclassing.js | 30 +++ .../subclass/builtin-objects/WeakSet/shell.js | 0 .../WeakSet/super-must-be-called.js | 36 +++ .../class/subclass/builtin-objects/browser.js | 0 .../class/subclass/builtin-objects/shell.js | 0 .../language/statements/class/subclass/builtins.js | 32 +++ ...valuation-empty-constructor-heritage-present.js | 37 +++ ...finition-null-proto-contains-return-override.js | 35 +++ ...efinition-null-proto-missing-return-override.js | 41 +++ .../subclass/class-definition-null-proto-super.js | 54 ++++ .../subclass/class-definition-null-proto-this.js | 41 +++ .../class/subclass/class-definition-null-proto.js | 31 +++ .../subclass/class-definition-parent-proto-null.js | 26 ++ .../class/subclass/default-constructor-2.js | 65 +++++ .../default-constructor-spread-override.js | 27 ++ .../class/subclass/default-constructor.js | 22 ++ ...ed-class-return-override-catch-finally-arrow.js | 29 +++ .../derived-class-return-override-catch-finally.js | 26 ++ ...ived-class-return-override-catch-super-arrow.js | 27 ++ .../derived-class-return-override-catch-super.js | 24 ++ .../derived-class-return-override-catch.js | 26 ++ ...ed-class-return-override-finally-super-arrow.js | 27 ++ .../derived-class-return-override-finally-super.js | 24 ++ .../derived-class-return-override-for-of-arrow.js | 40 +++ .../derived-class-return-override-for-of.js | 39 +++ .../derived-class-return-override-with-boolean.js | 32 +++ .../derived-class-return-override-with-empty.js | 42 +++ .../derived-class-return-override-with-null.js | 32 +++ .../derived-class-return-override-with-number.js | 32 +++ .../derived-class-return-override-with-object.js | 42 +++ .../derived-class-return-override-with-string.js | 32 +++ .../derived-class-return-override-with-symbol.js | 33 +++ .../derived-class-return-override-with-this.js | 43 ++++ ...derived-class-return-override-with-undefined.js | 43 ++++ .../language/statements/class/subclass/shell.js | 0 .../class/subclass/superclass-arrow-function.js | 53 ++++ .../class/subclass/superclass-async-function.js | 53 ++++ .../superclass-async-generator-function.js | 44 ++++ .../class/subclass/superclass-bound-function.js | 27 ++ .../subclass/superclass-generator-function.js | 44 ++++ .../superclass-prototype-setter-constructor.js | 20 ++ .../superclass-prototype-setter-method-override.js | 24 ++ .../subclass/superclass-static-method-override.js | 23 ++ .../language/statements/class/super/browser.js | 0 .../in-constructor-superproperty-evaluation.js | 19 ++ .../statements/class/super/in-constructor.js | 23 ++ .../language/statements/class/super/in-getter.js | 24 ++ .../language/statements/class/super/in-methods.js | 24 ++ .../language/statements/class/super/in-setter.js | 25 ++ .../statements/class/super/in-static-getter.js | 24 ++ .../statements/class/super/in-static-methods.js | 24 ++ .../statements/class/super/in-static-setter.js | 25 ++ .../language/statements/class/super/shell.js | 0 .../language/statements/class/syntax/browser.js | 0 .../class-body-has-direct-super-class-heritage.js | 25 ++ .../class-body-method-definition-super-property.js | 25 ++ ...ration-binding-identifier-class-element-list.js | 37 +++ ...class-declaration-computed-method-definition.js | 32 +++ ...aration-computed-method-generator-definition.js | 32 +++ ...tage-identifier-reference-class-element-list.js | 56 ++++ ...on-binding-identifier-opt-class-element-list.js | 41 +++ ...ass-expression-heritage-identifier-reference.js | 18 ++ .../statements/class/syntax/class-expression.js | 12 + .../syntax/class-method-propname-constructor.js | 19 ++ .../class/syntax/early-errors/browser.js | 0 ...efinition-evaluation-block-duplicate-binding.js | 19 ++ ...tion-evaluation-scriptbody-duplicate-binding.js | 17 ++ .../statements/class/syntax/early-errors/shell.js | 0 .../statements/class/syntax/escaped-static.js | 26 ++ .../language/statements/class/syntax/shell.js | 0 4536 files changed, 336478 insertions(+) create mode 100644 js/src/tests/test262/language/statements/class/accessor-name-inst-computed-yield-expr.js create mode 100644 js/src/tests/test262/language/statements/class/accessor-name-inst/browser.js create mode 100644 js/src/tests/test262/language/statements/class/accessor-name-inst/computed-err-evaluation.js create mode 100644 js/src/tests/test262/language/statements/class/accessor-name-inst/computed-err-to-prop-key.js create mode 100644 js/src/tests/test262/language/statements/class/accessor-name-inst/computed-err-unresolvable.js create mode 100644 js/src/tests/test262/language/statements/class/accessor-name-inst/computed.js create mode 100644 js/src/tests/test262/language/statements/class/accessor-name-inst/literal-numeric-binary.js create mode 100644 js/src/tests/test262/language/statements/class/accessor-name-inst/literal-numeric-exponent.js create mode 100644 js/src/tests/test262/language/statements/class/accessor-name-inst/literal-numeric-hex.js create mode 100644 js/src/tests/test262/language/statements/class/accessor-name-inst/literal-numeric-leading-decimal.js create mode 100644 js/src/tests/test262/language/statements/class/accessor-name-inst/literal-numeric-non-canonical.js create mode 100644 js/src/tests/test262/language/statements/class/accessor-name-inst/literal-numeric-octal.js create mode 100644 js/src/tests/test262/language/statements/class/accessor-name-inst/literal-numeric-zero.js create mode 100644 js/src/tests/test262/language/statements/class/accessor-name-inst/literal-string-char-escape.js create mode 100644 js/src/tests/test262/language/statements/class/accessor-name-inst/literal-string-default-escaped-ext.js create mode 100644 js/src/tests/test262/language/statements/class/accessor-name-inst/literal-string-default-escaped.js create mode 100644 js/src/tests/test262/language/statements/class/accessor-name-inst/literal-string-default.js create mode 100644 js/src/tests/test262/language/statements/class/accessor-name-inst/literal-string-double-quote.js create mode 100644 js/src/tests/test262/language/statements/class/accessor-name-inst/literal-string-empty.js create mode 100644 js/src/tests/test262/language/statements/class/accessor-name-inst/literal-string-hex-escape.js create mode 100644 js/src/tests/test262/language/statements/class/accessor-name-inst/literal-string-line-continuation.js create mode 100644 js/src/tests/test262/language/statements/class/accessor-name-inst/literal-string-single-quote.js create mode 100644 js/src/tests/test262/language/statements/class/accessor-name-inst/literal-string-unicode-escape.js create mode 100644 js/src/tests/test262/language/statements/class/accessor-name-inst/shell.js create mode 100644 js/src/tests/test262/language/statements/class/accessor-name-static-computed-yield-expr.js create mode 100644 js/src/tests/test262/language/statements/class/accessor-name-static/browser.js create mode 100644 js/src/tests/test262/language/statements/class/accessor-name-static/computed-err-evaluation.js create mode 100644 js/src/tests/test262/language/statements/class/accessor-name-static/computed-err-to-prop-key.js create mode 100644 js/src/tests/test262/language/statements/class/accessor-name-static/computed-err-unresolvable.js create mode 100644 js/src/tests/test262/language/statements/class/accessor-name-static/computed.js create mode 100644 js/src/tests/test262/language/statements/class/accessor-name-static/literal-numeric-binary.js create mode 100644 js/src/tests/test262/language/statements/class/accessor-name-static/literal-numeric-exponent.js create mode 100644 js/src/tests/test262/language/statements/class/accessor-name-static/literal-numeric-hex.js create mode 100644 js/src/tests/test262/language/statements/class/accessor-name-static/literal-numeric-leading-decimal.js create mode 100644 js/src/tests/test262/language/statements/class/accessor-name-static/literal-numeric-non-canonical.js create mode 100644 js/src/tests/test262/language/statements/class/accessor-name-static/literal-numeric-octal.js create mode 100644 js/src/tests/test262/language/statements/class/accessor-name-static/literal-numeric-zero.js create mode 100644 js/src/tests/test262/language/statements/class/accessor-name-static/literal-string-char-escape.js create mode 100644 js/src/tests/test262/language/statements/class/accessor-name-static/literal-string-default-escaped-ext.js create mode 100644 js/src/tests/test262/language/statements/class/accessor-name-static/literal-string-default-escaped.js create mode 100644 js/src/tests/test262/language/statements/class/accessor-name-static/literal-string-default.js create mode 100644 js/src/tests/test262/language/statements/class/accessor-name-static/literal-string-double-quote.js create mode 100644 js/src/tests/test262/language/statements/class/accessor-name-static/literal-string-empty.js create mode 100644 js/src/tests/test262/language/statements/class/accessor-name-static/literal-string-hex-escape.js create mode 100644 js/src/tests/test262/language/statements/class/accessor-name-static/literal-string-line-continuation.js create mode 100644 js/src/tests/test262/language/statements/class/accessor-name-static/literal-string-single-quote.js create mode 100644 js/src/tests/test262/language/statements/class/accessor-name-static/literal-string-unicode-escape.js create mode 100644 js/src/tests/test262/language/statements/class/accessor-name-static/shell.js create mode 100644 js/src/tests/test262/language/statements/class/arguments/access.js create mode 100644 js/src/tests/test262/language/statements/class/arguments/browser.js create mode 100644 js/src/tests/test262/language/statements/class/arguments/default-constructor.js create mode 100644 js/src/tests/test262/language/statements/class/arguments/shell.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-meth-escaped-async.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method-static/array-destructuring-param-strict-body.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method-static/await-as-binding-identifier-escaped.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method-static/await-as-binding-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method-static/await-as-identifier-reference-escaped.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method-static/await-as-identifier-reference.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method-static/await-as-label-identifier-escaped.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method-static/await-as-label-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method-static/browser.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method-static/dflt-params-abrupt.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method-static/dflt-params-arg-val-not-undefined.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method-static/dflt-params-arg-val-undefined.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method-static/dflt-params-duplicates.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method-static/dflt-params-ref-later.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method-static/dflt-params-ref-prior.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method-static/dflt-params-ref-self.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method-static/dflt-params-rest.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method-static/dflt-params-trailing-comma.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method-static/forbidden-ext/b1/browser.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method-static/forbidden-ext/b1/cls-decl-async-gen-meth-static-forbidden-ext-direct-access-prop-arguments.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method-static/forbidden-ext/b1/cls-decl-async-gen-meth-static-forbidden-ext-direct-access-prop-caller.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method-static/forbidden-ext/b1/shell.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method-static/forbidden-ext/b2/browser.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method-static/forbidden-ext/b2/cls-decl-async-gen-meth-static-forbidden-ext-indirect-access-own-prop-caller-get.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method-static/forbidden-ext/b2/cls-decl-async-gen-meth-static-forbidden-ext-indirect-access-own-prop-caller-value.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method-static/forbidden-ext/b2/cls-decl-async-gen-meth-static-forbidden-ext-indirect-access-prop-caller.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method-static/forbidden-ext/b2/shell.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method-static/forbidden-ext/browser.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method-static/forbidden-ext/shell.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method-static/object-destructuring-param-strict-body.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method-static/params-trailing-comma-multiple.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method-static/params-trailing-comma-single.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method-static/rest-param-strict-body.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method-static/rest-params-trailing-comma-early-error.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method-static/shell.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method-static/yield-as-binding-identifier-escaped.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method-static/yield-as-binding-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method-static/yield-as-identifier-reference-escaped.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method-static/yield-as-identifier-reference.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method-static/yield-as-label-identifier-escaped.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method-static/yield-as-label-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method-static/yield-identifier-spread-strict-strict.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method-static/yield-identifier-strict-strict.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method-static/yield-promise-reject-next-catch.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method-static/yield-promise-reject-next-for-await-of-async-iterator.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method-static/yield-promise-reject-next-for-await-of-sync-iterator.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method-static/yield-promise-reject-next-yield-star-async-iterator.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method-static/yield-promise-reject-next-yield-star-sync-iterator.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method-static/yield-promise-reject-next.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method-static/yield-spread-arr-multiple.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method-static/yield-spread-arr-single.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method-static/yield-spread-obj.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-async-next.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-async-return.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-async-throw.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-expr-abrupt.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-async-get-abrupt.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-async-not-callable-boolean-throw.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-async-not-callable-number-throw.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-async-not-callable-object-throw.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-async-not-callable-string-throw.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-async-not-callable-symbol-throw.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-async-null-sync-get-abrupt.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-async-returns-abrupt.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-async-returns-boolean-throw.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-async-returns-null-throw.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-async-returns-number-throw.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-async-returns-string-throw.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-async-returns-symbol-throw.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-async-returns-undefined-throw.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-async-undefined-sync-get-abrupt.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-sync-get-abrupt.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-sync-not-callable-boolean-throw.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-sync-not-callable-number-throw.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-sync-not-callable-object-throw.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-sync-not-callable-string-throw.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-sync-not-callable-symbol-throw.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-sync-returns-abrupt.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-sync-returns-boolean-throw.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-sync-returns-null-throw.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-sync-returns-number-throw.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-sync-returns-string-throw.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-sync-returns-symbol-throw.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-sync-returns-undefined-throw.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-call-done-get-abrupt.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-call-returns-abrupt.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-call-value-get-abrupt.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-get-abrupt.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-non-object-ignores-then.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-not-callable-boolean-throw.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-not-callable-null-throw.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-not-callable-number-throw.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-not-callable-object-throw.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-not-callable-string-throw.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-not-callable-symbol-throw.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-not-callable-undefined-throw.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-then-get-abrupt.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-then-non-callable-boolean-fulfillpromise.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-then-non-callable-null-fulfillpromise.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-then-non-callable-number-fulfillpromise.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-then-non-callable-object-fulfillpromise.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-then-non-callable-string-fulfillpromise.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-then-non-callable-symbol-fulfillpromise.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-then-non-callable-undefined-fulfillpromise.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-then-returns-abrupt.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-sync-next.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-sync-return.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-sync-throw.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method/array-destructuring-param-strict-body.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method/await-as-binding-identifier-escaped.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method/await-as-binding-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method/await-as-identifier-reference-escaped.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method/await-as-identifier-reference.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method/await-as-label-identifier-escaped.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method/await-as-label-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method/browser.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method/dflt-params-abrupt.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method/dflt-params-arg-val-not-undefined.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method/dflt-params-arg-val-undefined.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method/dflt-params-duplicates.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method/dflt-params-ref-later.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method/dflt-params-ref-prior.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method/dflt-params-ref-self.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method/dflt-params-rest.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method/dflt-params-trailing-comma.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method/forbidden-ext/b1/browser.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method/forbidden-ext/b1/cls-decl-async-gen-meth-forbidden-ext-direct-access-prop-arguments.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method/forbidden-ext/b1/cls-decl-async-gen-meth-forbidden-ext-direct-access-prop-caller.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method/forbidden-ext/b1/shell.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method/forbidden-ext/b2/browser.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method/forbidden-ext/b2/cls-decl-async-gen-meth-forbidden-ext-indirect-access-own-prop-caller-get.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method/forbidden-ext/b2/cls-decl-async-gen-meth-forbidden-ext-indirect-access-own-prop-caller-value.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method/forbidden-ext/b2/cls-decl-async-gen-meth-forbidden-ext-indirect-access-prop-caller.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method/forbidden-ext/b2/shell.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method/forbidden-ext/browser.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method/forbidden-ext/shell.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method/object-destructuring-param-strict-body.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method/params-trailing-comma-multiple.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method/params-trailing-comma-single.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method/rest-param-strict-body.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method/rest-params-trailing-comma-early-error.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method/shell.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method/yield-as-binding-identifier-escaped.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method/yield-as-binding-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method/yield-as-identifier-reference-escaped.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method/yield-as-identifier-reference.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method/yield-as-label-identifier-escaped.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method/yield-as-label-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method/yield-identifier-spread-strict-strict.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method/yield-identifier-strict-strict.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method/yield-promise-reject-next-catch.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method/yield-promise-reject-next-for-await-of-async-iterator.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method/yield-promise-reject-next-for-await-of-sync-iterator.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method/yield-promise-reject-next-yield-star-async-iterator.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method/yield-promise-reject-next-yield-star-sync-iterator.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method/yield-promise-reject-next.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method/yield-spread-arr-multiple.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method/yield-spread-arr-single.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method/yield-spread-obj.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method/yield-star-async-next.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method/yield-star-async-return.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method/yield-star-async-throw.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method/yield-star-expr-abrupt.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method/yield-star-getiter-async-get-abrupt.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method/yield-star-getiter-async-not-callable-boolean-throw.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method/yield-star-getiter-async-not-callable-number-throw.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method/yield-star-getiter-async-not-callable-object-throw.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method/yield-star-getiter-async-not-callable-string-throw.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method/yield-star-getiter-async-not-callable-symbol-throw.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method/yield-star-getiter-async-null-sync-get-abrupt.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method/yield-star-getiter-async-returns-abrupt.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method/yield-star-getiter-async-returns-boolean-throw.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method/yield-star-getiter-async-returns-null-throw.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method/yield-star-getiter-async-returns-number-throw.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method/yield-star-getiter-async-returns-string-throw.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method/yield-star-getiter-async-returns-symbol-throw.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method/yield-star-getiter-async-returns-undefined-throw.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method/yield-star-getiter-async-undefined-sync-get-abrupt.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method/yield-star-getiter-sync-get-abrupt.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method/yield-star-getiter-sync-not-callable-boolean-throw.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method/yield-star-getiter-sync-not-callable-number-throw.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method/yield-star-getiter-sync-not-callable-object-throw.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method/yield-star-getiter-sync-not-callable-string-throw.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method/yield-star-getiter-sync-not-callable-symbol-throw.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method/yield-star-getiter-sync-returns-abrupt.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method/yield-star-getiter-sync-returns-boolean-throw.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method/yield-star-getiter-sync-returns-null-throw.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method/yield-star-getiter-sync-returns-number-throw.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method/yield-star-getiter-sync-returns-string-throw.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method/yield-star-getiter-sync-returns-symbol-throw.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method/yield-star-getiter-sync-returns-undefined-throw.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method/yield-star-next-call-done-get-abrupt.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method/yield-star-next-call-returns-abrupt.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method/yield-star-next-call-value-get-abrupt.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method/yield-star-next-get-abrupt.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method/yield-star-next-non-object-ignores-then.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method/yield-star-next-not-callable-boolean-throw.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method/yield-star-next-not-callable-null-throw.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method/yield-star-next-not-callable-number-throw.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method/yield-star-next-not-callable-object-throw.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method/yield-star-next-not-callable-string-throw.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method/yield-star-next-not-callable-symbol-throw.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method/yield-star-next-not-callable-undefined-throw.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method/yield-star-next-then-get-abrupt.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method/yield-star-next-then-non-callable-boolean-fulfillpromise.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method/yield-star-next-then-non-callable-null-fulfillpromise.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method/yield-star-next-then-non-callable-number-fulfillpromise.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method/yield-star-next-then-non-callable-object-fulfillpromise.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method/yield-star-next-then-non-callable-string-fulfillpromise.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method/yield-star-next-then-non-callable-symbol-fulfillpromise.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method/yield-star-next-then-non-callable-undefined-fulfillpromise.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method/yield-star-next-then-returns-abrupt.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method/yield-star-sync-next.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method/yield-star-sync-return.js create mode 100644 js/src/tests/test262/language/statements/class/async-gen-method/yield-star-sync-throw.js create mode 100644 js/src/tests/test262/language/statements/class/async-meth-escaped-async.js create mode 100644 js/src/tests/test262/language/statements/class/async-method-static/array-destructuring-param-strict-body.js create mode 100644 js/src/tests/test262/language/statements/class/async-method-static/await-as-binding-identifier-escaped.js create mode 100644 js/src/tests/test262/language/statements/class/async-method-static/await-as-binding-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/async-method-static/await-as-identifier-reference-escaped.js create mode 100644 js/src/tests/test262/language/statements/class/async-method-static/await-as-identifier-reference.js create mode 100644 js/src/tests/test262/language/statements/class/async-method-static/await-as-label-identifier-escaped.js create mode 100644 js/src/tests/test262/language/statements/class/async-method-static/await-as-label-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/async-method-static/browser.js create mode 100644 js/src/tests/test262/language/statements/class/async-method-static/dflt-params-abrupt.js create mode 100644 js/src/tests/test262/language/statements/class/async-method-static/dflt-params-arg-val-not-undefined.js create mode 100644 js/src/tests/test262/language/statements/class/async-method-static/dflt-params-arg-val-undefined.js create mode 100644 js/src/tests/test262/language/statements/class/async-method-static/dflt-params-duplicates.js create mode 100644 js/src/tests/test262/language/statements/class/async-method-static/dflt-params-ref-later.js create mode 100644 js/src/tests/test262/language/statements/class/async-method-static/dflt-params-ref-prior.js create mode 100644 js/src/tests/test262/language/statements/class/async-method-static/dflt-params-ref-self.js create mode 100644 js/src/tests/test262/language/statements/class/async-method-static/dflt-params-rest.js create mode 100644 js/src/tests/test262/language/statements/class/async-method-static/dflt-params-trailing-comma.js create mode 100644 js/src/tests/test262/language/statements/class/async-method-static/forbidden-ext/b1/browser.js create mode 100644 js/src/tests/test262/language/statements/class/async-method-static/forbidden-ext/b1/cls-decl-async-meth-static-forbidden-ext-direct-access-prop-arguments.js create mode 100644 js/src/tests/test262/language/statements/class/async-method-static/forbidden-ext/b1/cls-decl-async-meth-static-forbidden-ext-direct-access-prop-caller.js create mode 100644 js/src/tests/test262/language/statements/class/async-method-static/forbidden-ext/b1/shell.js create mode 100644 js/src/tests/test262/language/statements/class/async-method-static/forbidden-ext/b2/browser.js create mode 100644 js/src/tests/test262/language/statements/class/async-method-static/forbidden-ext/b2/cls-decl-async-meth-static-forbidden-ext-indirect-access-own-prop-caller-get.js create mode 100644 js/src/tests/test262/language/statements/class/async-method-static/forbidden-ext/b2/cls-decl-async-meth-static-forbidden-ext-indirect-access-own-prop-caller-value.js create mode 100644 js/src/tests/test262/language/statements/class/async-method-static/forbidden-ext/b2/cls-decl-async-meth-static-forbidden-ext-indirect-access-prop-caller.js create mode 100644 js/src/tests/test262/language/statements/class/async-method-static/forbidden-ext/b2/shell.js create mode 100644 js/src/tests/test262/language/statements/class/async-method-static/forbidden-ext/browser.js create mode 100644 js/src/tests/test262/language/statements/class/async-method-static/forbidden-ext/shell.js create mode 100644 js/src/tests/test262/language/statements/class/async-method-static/object-destructuring-param-strict-body.js create mode 100644 js/src/tests/test262/language/statements/class/async-method-static/params-trailing-comma-multiple.js create mode 100644 js/src/tests/test262/language/statements/class/async-method-static/params-trailing-comma-single.js create mode 100644 js/src/tests/test262/language/statements/class/async-method-static/rest-param-strict-body.js create mode 100644 js/src/tests/test262/language/statements/class/async-method-static/rest-params-trailing-comma-early-error.js create mode 100644 js/src/tests/test262/language/statements/class/async-method-static/returns-async-arrow-returns-arguments-from-parent-function.js create mode 100644 js/src/tests/test262/language/statements/class/async-method-static/returns-async-arrow-returns-newtarget.js create mode 100644 js/src/tests/test262/language/statements/class/async-method-static/returns-async-arrow.js create mode 100644 js/src/tests/test262/language/statements/class/async-method-static/returns-async-function-returns-arguments-from-own-function.js create mode 100644 js/src/tests/test262/language/statements/class/async-method-static/returns-async-function-returns-newtarget.js create mode 100644 js/src/tests/test262/language/statements/class/async-method-static/returns-async-function.js create mode 100644 js/src/tests/test262/language/statements/class/async-method-static/shell.js create mode 100644 js/src/tests/test262/language/statements/class/async-method/array-destructuring-param-strict-body.js create mode 100644 js/src/tests/test262/language/statements/class/async-method/await-as-binding-identifier-escaped.js create mode 100644 js/src/tests/test262/language/statements/class/async-method/await-as-binding-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/async-method/await-as-identifier-reference-escaped.js create mode 100644 js/src/tests/test262/language/statements/class/async-method/await-as-identifier-reference.js create mode 100644 js/src/tests/test262/language/statements/class/async-method/await-as-label-identifier-escaped.js create mode 100644 js/src/tests/test262/language/statements/class/async-method/await-as-label-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/async-method/browser.js create mode 100644 js/src/tests/test262/language/statements/class/async-method/dflt-params-abrupt.js create mode 100644 js/src/tests/test262/language/statements/class/async-method/dflt-params-arg-val-not-undefined.js create mode 100644 js/src/tests/test262/language/statements/class/async-method/dflt-params-arg-val-undefined.js create mode 100644 js/src/tests/test262/language/statements/class/async-method/dflt-params-duplicates.js create mode 100644 js/src/tests/test262/language/statements/class/async-method/dflt-params-ref-later.js create mode 100644 js/src/tests/test262/language/statements/class/async-method/dflt-params-ref-prior.js create mode 100644 js/src/tests/test262/language/statements/class/async-method/dflt-params-ref-self.js create mode 100644 js/src/tests/test262/language/statements/class/async-method/dflt-params-rest.js create mode 100644 js/src/tests/test262/language/statements/class/async-method/dflt-params-trailing-comma.js create mode 100644 js/src/tests/test262/language/statements/class/async-method/forbidden-ext/b1/browser.js create mode 100644 js/src/tests/test262/language/statements/class/async-method/forbidden-ext/b1/cls-decl-async-meth-forbidden-ext-direct-access-prop-arguments.js create mode 100644 js/src/tests/test262/language/statements/class/async-method/forbidden-ext/b1/cls-decl-async-meth-forbidden-ext-direct-access-prop-caller.js create mode 100644 js/src/tests/test262/language/statements/class/async-method/forbidden-ext/b1/shell.js create mode 100644 js/src/tests/test262/language/statements/class/async-method/forbidden-ext/b2/browser.js create mode 100644 js/src/tests/test262/language/statements/class/async-method/forbidden-ext/b2/cls-decl-async-meth-forbidden-ext-indirect-access-own-prop-caller-get.js create mode 100644 js/src/tests/test262/language/statements/class/async-method/forbidden-ext/b2/cls-decl-async-meth-forbidden-ext-indirect-access-own-prop-caller-value.js create mode 100644 js/src/tests/test262/language/statements/class/async-method/forbidden-ext/b2/cls-decl-async-meth-forbidden-ext-indirect-access-prop-caller.js create mode 100644 js/src/tests/test262/language/statements/class/async-method/forbidden-ext/b2/shell.js create mode 100644 js/src/tests/test262/language/statements/class/async-method/forbidden-ext/browser.js create mode 100644 js/src/tests/test262/language/statements/class/async-method/forbidden-ext/shell.js create mode 100644 js/src/tests/test262/language/statements/class/async-method/object-destructuring-param-strict-body.js create mode 100644 js/src/tests/test262/language/statements/class/async-method/params-trailing-comma-multiple.js create mode 100644 js/src/tests/test262/language/statements/class/async-method/params-trailing-comma-single.js create mode 100644 js/src/tests/test262/language/statements/class/async-method/rest-param-strict-body.js create mode 100644 js/src/tests/test262/language/statements/class/async-method/rest-params-trailing-comma-early-error.js create mode 100644 js/src/tests/test262/language/statements/class/async-method/returns-async-arrow-returns-arguments-from-parent-function.js create mode 100644 js/src/tests/test262/language/statements/class/async-method/returns-async-arrow-returns-newtarget.js create mode 100644 js/src/tests/test262/language/statements/class/async-method/returns-async-arrow.js create mode 100644 js/src/tests/test262/language/statements/class/async-method/returns-async-function-returns-arguments-from-own-function.js create mode 100644 js/src/tests/test262/language/statements/class/async-method/returns-async-function-returns-newtarget.js create mode 100644 js/src/tests/test262/language/statements/class/async-method/returns-async-function.js create mode 100644 js/src/tests/test262/language/statements/class/async-method/shell.js create mode 100644 js/src/tests/test262/language/statements/class/browser.js create mode 100644 js/src/tests/test262/language/statements/class/class-name-ident-await-escaped-module.js create mode 100644 js/src/tests/test262/language/statements/class/class-name-ident-await-escaped.js create mode 100644 js/src/tests/test262/language/statements/class/class-name-ident-await-module.js create mode 100644 js/src/tests/test262/language/statements/class/class-name-ident-await.js create mode 100644 js/src/tests/test262/language/statements/class/class-name-ident-let-escaped.js create mode 100644 js/src/tests/test262/language/statements/class/class-name-ident-let.js create mode 100644 js/src/tests/test262/language/statements/class/class-name-ident-static-escaped.js create mode 100644 js/src/tests/test262/language/statements/class/class-name-ident-static.js create mode 100644 js/src/tests/test262/language/statements/class/class-name-ident-yield-escaped.js create mode 100644 js/src/tests/test262/language/statements/class/class-name-ident-yield.js create mode 100644 js/src/tests/test262/language/statements/class/classelementname-abrupt-completion.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-additive-expression-add.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-additive-expression-subtract.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-arrow-function-expression.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-assignment-expression-assignment.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-assignment-expression-bitwise-or.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-assignment-expression-coalesce.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-assignment-expression-logical-and.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-assignment-expression-logical-or.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-async-arrow-function-expression.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-await-expression.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-condition-expression-false.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-condition-expression-true.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-decimal-e-notational-literal.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-decimal-literal.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-exponetiation-expression.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-expression-coalesce.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-expression-logical-and.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-expression-logical-or.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-function-declaration.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-function-expression.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-generator-function-declaration.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-integer-e-notational-literal.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-integer-separators.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-math.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-multiplicative-expression-div.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-multiplicative-expression-mult.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-null.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-numeric-literal.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-string-literal.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-yield-expression.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-additive-expression-add.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-additive-expression-subtract.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-arrow-function-expression.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-assignment-expression-assignment.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-assignment-expression-bitwise-or.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-assignment-expression-coalesce.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-assignment-expression-logical-and.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-assignment-expression-logical-or.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-async-arrow-function-expression.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-await-expression.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-condition-expression-false.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-condition-expression-true.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-decimal-e-notational-literal.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-decimal-literal.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-exponetiation-expression.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-expression-coalesce.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-expression-logical-and.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-expression-logical-or.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-function-declaration.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-function-expression.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-generator-function-declaration.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-integer-e-notational-literal.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-integer-separators.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-math.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-multiplicative-expression-div.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-multiplicative-expression-mult.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-null.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-numeric-literal.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-string-literal.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-yield-expression.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-additive-expression-add.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-additive-expression-subtract.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-arrow-function-expression.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-assignment-expression-assignment.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-assignment-expression-bitwise-or.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-assignment-expression-coalesce.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-assignment-expression-logical-and.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-assignment-expression-logical-or.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-async-arrow-function-expression.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-await-expression.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-condition-expression-false.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-condition-expression-true.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-decimal-e-notational-literal.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-decimal-literal.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-exponetiation-expression.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-expression-coalesce.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-expression-logical-and.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-expression-logical-or.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-function-declaration.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-function-expression.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-generator-function-declaration.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-integer-e-notational-literal.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-integer-separators.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-math.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-multiplicative-expression-div.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-multiplicative-expression-mult.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-null.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-numeric-literal.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-string-literal.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-yield-expression.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-additive-expression-add.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-additive-expression-subtract.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-arrow-function-expression.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-assignment-expression-assignment.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-assignment-expression-bitwise-or.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-assignment-expression-coalesce.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-assignment-expression-logical-and.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-assignment-expression-logical-or.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-async-arrow-function-expression.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-await-expression.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-condition-expression-false.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-condition-expression-true.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-decimal-e-notational-literal.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-decimal-literal.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-exponetiation-expression.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-expression-coalesce.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-expression-logical-and.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-expression-logical-or.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-function-declaration.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-function-expression.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-generator-function-declaration.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-integer-e-notational-literal.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-integer-separators.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-math.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-multiplicative-expression-div.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-multiplicative-expression-mult.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-null.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-numeric-literal.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-string-literal.js create mode 100644 js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-yield-expression.js create mode 100644 js/src/tests/test262/language/statements/class/cptn-decl.js create mode 100644 js/src/tests/test262/language/statements/class/decorator/browser.js create mode 100644 js/src/tests/test262/language/statements/class/decorator/shell.js create mode 100644 js/src/tests/test262/language/statements/class/decorator/syntax/browser.js create mode 100644 js/src/tests/test262/language/statements/class/decorator/syntax/class-valid/browser.js create mode 100644 js/src/tests/test262/language/statements/class/decorator/syntax/class-valid/decorator-member-expr-private-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/decorator/syntax/class-valid/shell.js create mode 100644 js/src/tests/test262/language/statements/class/decorator/syntax/shell.js create mode 100644 js/src/tests/test262/language/statements/class/decorator/syntax/valid/browser.js create mode 100644 js/src/tests/test262/language/statements/class/decorator/syntax/valid/class-element-decorator-call-expr-identifier-reference.js create mode 100644 js/src/tests/test262/language/statements/class/decorator/syntax/valid/class-element-decorator-member-expr-decorator-member-expr.js create mode 100644 js/src/tests/test262/language/statements/class/decorator/syntax/valid/class-element-decorator-member-expr-identifier-reference.js create mode 100644 js/src/tests/test262/language/statements/class/decorator/syntax/valid/class-element-decorator-parenthesized-expr-identifier-reference.js create mode 100644 js/src/tests/test262/language/statements/class/decorator/syntax/valid/decorator-call-expr-identifier-reference-yield.js create mode 100644 js/src/tests/test262/language/statements/class/decorator/syntax/valid/decorator-call-expr-identifier-reference.js create mode 100644 js/src/tests/test262/language/statements/class/decorator/syntax/valid/decorator-member-expr-decorator-member-expr.js create mode 100644 js/src/tests/test262/language/statements/class/decorator/syntax/valid/decorator-member-expr-identifier-reference-yield.js create mode 100644 js/src/tests/test262/language/statements/class/decorator/syntax/valid/decorator-member-expr-identifier-reference.js create mode 100644 js/src/tests/test262/language/statements/class/decorator/syntax/valid/decorator-parenthesized-expr-identifier-reference-yield.js create mode 100644 js/src/tests/test262/language/statements/class/decorator/syntax/valid/decorator-parenthesized-expr-identifier-reference.js create mode 100644 js/src/tests/test262/language/statements/class/decorator/syntax/valid/shell.js create mode 100644 js/src/tests/test262/language/statements/class/definition/accessors.js create mode 100644 js/src/tests/test262/language/statements/class/definition/basics.js create mode 100644 js/src/tests/test262/language/statements/class/definition/browser.js create mode 100644 js/src/tests/test262/language/statements/class/definition/class-method-returns-promise.js create mode 100644 js/src/tests/test262/language/statements/class/definition/constructable-but-no-prototype.js create mode 100644 js/src/tests/test262/language/statements/class/definition/constructor-property.js create mode 100644 js/src/tests/test262/language/statements/class/definition/constructor-strict-by-default.js create mode 100644 js/src/tests/test262/language/statements/class/definition/constructor.js create mode 100644 js/src/tests/test262/language/statements/class/definition/early-errors-class-async-method-duplicate-parameters.js create mode 100644 js/src/tests/test262/language/statements/class/definition/early-errors-class-method-NSPL-with-USD.js create mode 100644 js/src/tests/test262/language/statements/class/definition/early-errors-class-method-arguments-in-formal-parameters.js create mode 100644 js/src/tests/test262/language/statements/class/definition/early-errors-class-method-await-in-formals-default.js create mode 100644 js/src/tests/test262/language/statements/class/definition/early-errors-class-method-await-in-formals.js create mode 100644 js/src/tests/test262/language/statements/class/definition/early-errors-class-method-body-contains-super-call.js create mode 100644 js/src/tests/test262/language/statements/class/definition/early-errors-class-method-duplicate-parameters.js create mode 100644 js/src/tests/test262/language/statements/class/definition/early-errors-class-method-eval-in-formal-parameters.js create mode 100644 js/src/tests/test262/language/statements/class/definition/early-errors-class-method-formals-body-duplicate.js create mode 100644 js/src/tests/test262/language/statements/class/definition/early-errors-class-method-formals-contains-super-call.js create mode 100644 js/src/tests/test262/language/statements/class/definition/fn-length-static-precedence-order.js create mode 100644 js/src/tests/test262/language/statements/class/definition/fn-length-static-precedence.js create mode 100644 js/src/tests/test262/language/statements/class/definition/fn-name-accessor-get.js create mode 100644 js/src/tests/test262/language/statements/class/definition/fn-name-accessor-set.js create mode 100644 js/src/tests/test262/language/statements/class/definition/fn-name-gen-method.js create mode 100644 js/src/tests/test262/language/statements/class/definition/fn-name-method.js create mode 100644 js/src/tests/test262/language/statements/class/definition/fn-name-static-precedence-order.js create mode 100644 js/src/tests/test262/language/statements/class/definition/fn-name-static-precedence.js create mode 100644 js/src/tests/test262/language/statements/class/definition/getters-non-configurable-err.js create mode 100644 js/src/tests/test262/language/statements/class/definition/getters-prop-desc.js create mode 100644 js/src/tests/test262/language/statements/class/definition/getters-restricted-ids.js create mode 100644 js/src/tests/test262/language/statements/class/definition/implicit-constructor.js create mode 100644 js/src/tests/test262/language/statements/class/definition/invalid-extends.js create mode 100644 js/src/tests/test262/language/statements/class/definition/methods-async-super-call-body.js create mode 100644 js/src/tests/test262/language/statements/class/definition/methods-async-super-call-param.js create mode 100644 js/src/tests/test262/language/statements/class/definition/methods-gen-no-yield.js create mode 100644 js/src/tests/test262/language/statements/class/definition/methods-gen-return.js create mode 100644 js/src/tests/test262/language/statements/class/definition/methods-gen-yield-as-expression-with-rhs.js create mode 100644 js/src/tests/test262/language/statements/class/definition/methods-gen-yield-as-expression-without-rhs.js create mode 100644 js/src/tests/test262/language/statements/class/definition/methods-gen-yield-as-function-expression-binding-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/definition/methods-gen-yield-as-generator-method-binding-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/definition/methods-gen-yield-as-identifier-in-nested-function.js create mode 100644 js/src/tests/test262/language/statements/class/definition/methods-gen-yield-as-literal-property-name.js create mode 100644 js/src/tests/test262/language/statements/class/definition/methods-gen-yield-as-logical-or-expression.js create mode 100644 js/src/tests/test262/language/statements/class/definition/methods-gen-yield-as-parameter.js create mode 100644 js/src/tests/test262/language/statements/class/definition/methods-gen-yield-as-property-name.js create mode 100644 js/src/tests/test262/language/statements/class/definition/methods-gen-yield-as-statement.js create mode 100644 js/src/tests/test262/language/statements/class/definition/methods-gen-yield-as-yield-operand.js create mode 100644 js/src/tests/test262/language/statements/class/definition/methods-gen-yield-newline.js create mode 100644 js/src/tests/test262/language/statements/class/definition/methods-gen-yield-star-after-newline.js create mode 100644 js/src/tests/test262/language/statements/class/definition/methods-gen-yield-star-before-newline.js create mode 100644 js/src/tests/test262/language/statements/class/definition/methods-gen-yield-weak-binding.js create mode 100644 js/src/tests/test262/language/statements/class/definition/methods-named-eval-arguments.js create mode 100644 js/src/tests/test262/language/statements/class/definition/methods-restricted-properties.js create mode 100644 js/src/tests/test262/language/statements/class/definition/methods.js create mode 100644 js/src/tests/test262/language/statements/class/definition/numeric-property-names.js create mode 100644 js/src/tests/test262/language/statements/class/definition/prototype-getter.js create mode 100644 js/src/tests/test262/language/statements/class/definition/prototype-property.js create mode 100644 js/src/tests/test262/language/statements/class/definition/prototype-setter.js create mode 100644 js/src/tests/test262/language/statements/class/definition/prototype-wiring.js create mode 100644 js/src/tests/test262/language/statements/class/definition/setters-non-configurable-err.js create mode 100644 js/src/tests/test262/language/statements/class/definition/setters-prop-desc.js create mode 100644 js/src/tests/test262/language/statements/class/definition/setters-restricted-ids.js create mode 100644 js/src/tests/test262/language/statements/class/definition/shell.js create mode 100644 js/src/tests/test262/language/statements/class/definition/side-effects-in-extends.js create mode 100644 js/src/tests/test262/language/statements/class/definition/side-effects-in-property-define.js create mode 100644 js/src/tests/test262/language/statements/class/definition/this-access-restriction-2.js create mode 100644 js/src/tests/test262/language/statements/class/definition/this-access-restriction.js create mode 100644 js/src/tests/test262/language/statements/class/definition/this-check-ordering.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-init-iter-close.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-init-iter-get-err-array-prototype.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-init-iter-get-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-init-iter-no-close.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-name-iter-val.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-ary-elem-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-ary-elem-iter.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-ary-elision-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-ary-elision-iter.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-ary-empty-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-ary-empty-iter.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-ary-rest-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-ary-rest-iter.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-ary-val-null.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-id-init-exhausted.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-id-init-fn-name-arrow.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-id-init-fn-name-class.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-id-init-fn-name-cover.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-id-init-fn-name-fn.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-id-init-fn-name-gen.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-id-init-hole.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-id-init-skipped.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-id-init-throws.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-id-init-undef.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-id-init-unresolvable.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-id-iter-complete.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-id-iter-done.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-id-iter-step-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-id-iter-val-array-prototype.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-id-iter-val-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-id-iter-val.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-obj-id-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-obj-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-obj-prop-id-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-obj-prop-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-obj-val-null.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-obj-val-undef.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elision-exhausted.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elision-step-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elision.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-empty.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-rest-ary-elem.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-rest-ary-elision.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-rest-ary-empty.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-rest-ary-rest.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-rest-id-direct.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-rest-id-elision-next-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-rest-id-elision.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-rest-id-exhausted.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-rest-id-iter-step-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-rest-id-iter-val-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-rest-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-rest-init-ary.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-rest-init-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-rest-init-obj.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-rest-not-final-ary.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-rest-not-final-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-rest-not-final-obj.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-rest-obj-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-rest-obj-prop-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-init-iter-close.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-init-iter-get-err-array-prototype.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-init-iter-get-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-init-iter-no-close.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-name-iter-val.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-ary-elem-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-ary-elem-iter.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-ary-elision-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-ary-elision-iter.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-ary-empty-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-ary-empty-iter.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-ary-rest-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-ary-rest-iter.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-ary-val-null.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-init-exhausted.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-class.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-cover.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-fn.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-gen.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-init-hole.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-init-skipped.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-init-throws.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-init-undef.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-init-unresolvable.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-iter-complete.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-iter-done.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-iter-step-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-iter-val-array-prototype.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-iter-val-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-iter-val.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-obj-id-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-obj-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-obj-prop-id-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-obj-prop-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-obj-val-null.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-obj-val-undef.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elision-exhausted.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elision-step-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elision.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-empty.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-rest-ary-elem.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-rest-ary-elision.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-rest-ary-empty.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-rest-ary-rest.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-rest-id-direct.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-rest-id-elision-next-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-rest-id-elision.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-rest-id-exhausted.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-rest-id-iter-step-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-rest-id-iter-val-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-rest-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-rest-init-ary.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-rest-init-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-rest-init-obj.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-rest-not-final-ary.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-rest-not-final-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-rest-not-final-obj.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-rest-obj-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-rest-obj-prop-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-init-null.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-init-undefined.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-empty.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-id-get-value-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-id-init-fn-name-arrow.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-id-init-fn-name-class.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-id-init-fn-name-cover.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-id-init-fn-name-fn.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-id-init-fn-name-gen.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-id-init-skipped.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-id-init-throws.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-id-init-unresolvable.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-id-trailing-comma.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-list-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-prop-ary-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-prop-ary-trailing-comma.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-prop-ary-value-null.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-prop-ary.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-prop-eval-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-prop-id-get-value-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-prop-id-init-skipped.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-prop-id-init-throws.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-prop-id-init-unresolvable.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-prop-id-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-prop-id-trailing-comma.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-prop-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-prop-obj-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-prop-obj-value-null.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-prop-obj-value-undef.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-prop-obj.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-rest-getter.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-rest-skip-non-enumerable.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-rest-val-obj.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-init-null.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-init-undefined.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-empty.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-id-get-value-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-id-init-fn-name-arrow.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-id-init-fn-name-class.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-id-init-fn-name-cover.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-id-init-fn-name-fn.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-id-init-fn-name-gen.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-id-init-skipped.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-id-init-throws.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-id-init-unresolvable.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-id-trailing-comma.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-list-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-prop-ary-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-prop-ary-trailing-comma.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-prop-ary-value-null.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-prop-ary.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-prop-eval-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-prop-id-get-value-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-prop-id-init-skipped.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-prop-id-init-throws.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-prop-id-init-unresolvable.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-prop-id-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-prop-id-trailing-comma.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-prop-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-prop-obj-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-prop-obj-value-null.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-prop-obj-value-undef.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-prop-obj.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-rest-getter.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-rest-skip-non-enumerable.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-rest-val-obj.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-init-iter-close.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-init-iter-get-err-array-prototype.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-init-iter-get-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-init-iter-no-close.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-name-iter-val.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-ary-elem-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-ary-elem-iter.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-ary-elision-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-ary-elision-iter.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-ary-empty-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-ary-empty-iter.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-ary-rest-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-ary-rest-iter.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-ary-val-null.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-id-init-exhausted.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-id-init-fn-name-arrow.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-id-init-fn-name-class.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-id-init-fn-name-cover.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-id-init-fn-name-fn.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-id-init-fn-name-gen.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-id-init-hole.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-id-init-skipped.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-id-init-throws.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-id-init-undef.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-id-init-unresolvable.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-id-iter-complete.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-id-iter-done.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-id-iter-step-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-id-iter-val-array-prototype.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-id-iter-val-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-id-iter-val.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-obj-id-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-obj-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-obj-prop-id-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-obj-prop-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-obj-val-null.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-obj-val-undef.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elision-exhausted.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elision-step-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elision.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-empty.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-rest-ary-elem.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-rest-ary-elision.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-rest-ary-empty.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-rest-ary-rest.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-rest-id-direct.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-rest-id-elision-next-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-rest-id-elision.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-rest-id-exhausted.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-rest-id-iter-step-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-rest-id-iter-val-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-rest-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-rest-init-ary.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-rest-init-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-rest-init-obj.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-rest-not-final-ary.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-rest-not-final-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-rest-not-final-obj.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-rest-obj-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-rest-obj-prop-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-init-iter-close.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-init-iter-get-err-array-prototype.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-init-iter-get-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-init-iter-no-close.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-name-iter-val.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-ary-elem-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-ary-elem-iter.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-ary-elision-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-ary-elision-iter.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-ary-empty-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-ary-empty-iter.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-ary-rest-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-ary-rest-iter.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-ary-val-null.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-id-init-exhausted.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-class.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-cover.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-fn.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-gen.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-id-init-hole.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-id-init-skipped.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-id-init-throws.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-id-init-undef.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-id-init-unresolvable.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-id-iter-complete.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-id-iter-done.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-id-iter-step-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-id-iter-val-array-prototype.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-id-iter-val-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-id-iter-val.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-obj-id-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-obj-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-obj-prop-id-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-obj-prop-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-obj-val-null.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-obj-val-undef.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elision-exhausted.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elision-step-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elision.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-empty.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-rest-ary-elem.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-rest-ary-elision.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-rest-ary-empty.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-rest-ary-rest.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-rest-id-direct.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-rest-id-elision-next-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-rest-id-elision.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-rest-id-exhausted.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-rest-id-iter-step-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-rest-id-iter-val-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-rest-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-rest-init-ary.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-rest-init-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-rest-init-obj.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-rest-not-final-ary.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-rest-not-final-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-rest-not-final-obj.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-rest-obj-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-rest-obj-prop-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-init-null.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-init-undefined.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-empty.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-id-get-value-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-id-init-fn-name-arrow.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-id-init-fn-name-class.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-id-init-fn-name-cover.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-id-init-fn-name-fn.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-id-init-fn-name-gen.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-id-init-skipped.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-id-init-throws.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-id-init-unresolvable.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-id-trailing-comma.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-list-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-prop-ary-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-prop-ary-trailing-comma.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-prop-ary-value-null.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-prop-ary.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-prop-eval-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-prop-id-get-value-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-prop-id-init-skipped.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-prop-id-init-throws.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-prop-id-init-unresolvable.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-prop-id-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-prop-id-trailing-comma.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-prop-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-prop-obj-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-prop-obj-value-null.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-prop-obj-value-undef.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-prop-obj.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-rest-getter.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-rest-skip-non-enumerable.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-rest-val-obj.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-init-null.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-init-undefined.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-empty.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-id-get-value-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-id-init-fn-name-arrow.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-id-init-fn-name-class.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-id-init-fn-name-cover.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-id-init-fn-name-fn.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-id-init-fn-name-gen.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-id-init-skipped.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-id-init-throws.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-id-init-unresolvable.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-id-trailing-comma.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-list-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-prop-ary-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-prop-ary-trailing-comma.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-prop-ary-value-null.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-prop-ary.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-prop-eval-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-prop-id-get-value-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-prop-id-init-skipped.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-prop-id-init-throws.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-prop-id-init-unresolvable.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-prop-id-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-prop-id-trailing-comma.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-prop-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-prop-obj-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-prop-obj-value-null.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-prop-obj-value-undef.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-prop-obj.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-rest-getter.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-rest-skip-non-enumerable.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-rest-val-obj.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-init-iter-close.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-init-iter-no-close.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-name-iter-val.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-elem-ary-elem-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-elem-ary-elem-iter.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-elem-ary-elision-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-elem-ary-elision-iter.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-elem-ary-empty-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-elem-ary-empty-iter.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-elem-ary-rest-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-elem-ary-rest-iter.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-elem-id-init-exhausted.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-elem-id-init-fn-name-arrow.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-elem-id-init-fn-name-class.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-elem-id-init-fn-name-cover.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-elem-id-init-fn-name-fn.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-elem-id-init-fn-name-gen.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-elem-id-init-hole.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-elem-id-init-skipped.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-elem-id-init-undef.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-elem-id-iter-complete.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-elem-id-iter-done.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-elem-id-iter-val-array-prototype.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-elem-id-iter-val.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-elem-obj-id-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-elem-obj-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-elem-obj-prop-id-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-elem-obj-prop-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-elision-exhausted.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-elision.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-empty.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-rest-ary-elem.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-rest-ary-elision.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-rest-ary-empty.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-rest-ary-rest.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-rest-id-direct.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-rest-id-elision.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-rest-id-exhausted.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-rest-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-rest-init-ary.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-rest-init-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-rest-init-obj.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-rest-not-final-ary.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-rest-not-final-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-rest-not-final-obj.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-rest-obj-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-rest-obj-prop-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-init-iter-close.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-init-iter-no-close.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-name-iter-val.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-elem-ary-elem-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-elem-ary-elem-iter.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-elem-ary-elision-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-elem-ary-elision-iter.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-elem-ary-empty-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-elem-ary-empty-iter.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-elem-ary-rest-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-elem-ary-rest-iter.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-elem-id-init-exhausted.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-class.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-cover.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-fn.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-gen.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-elem-id-init-hole.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-elem-id-init-skipped.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-elem-id-init-undef.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-elem-id-iter-complete.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-elem-id-iter-done.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-elem-id-iter-val-array-prototype.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-elem-id-iter-val.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-elem-obj-id-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-elem-obj-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-elem-obj-prop-id-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-elem-obj-prop-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-elision-exhausted.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-elision.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-empty.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-rest-ary-elem.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-rest-ary-elision.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-rest-ary-empty.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-rest-ary-rest.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-rest-id-direct.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-rest-id-elision.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-rest-id-exhausted.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-rest-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-rest-init-ary.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-rest-init-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-rest-init-obj.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-rest-not-final-ary.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-rest-not-final-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-rest-not-final-obj.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-rest-obj-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-rest-obj-prop-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-obj-ptrn-empty.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-obj-ptrn-id-init-fn-name-arrow.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-obj-ptrn-id-init-fn-name-class.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-obj-ptrn-id-init-fn-name-cover.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-obj-ptrn-id-init-fn-name-fn.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-obj-ptrn-id-init-fn-name-gen.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-obj-ptrn-id-init-skipped.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-obj-ptrn-id-trailing-comma.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-obj-ptrn-prop-ary-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-obj-ptrn-prop-ary-trailing-comma.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-obj-ptrn-prop-ary.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-obj-ptrn-prop-id-init-skipped.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-obj-ptrn-prop-id-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-obj-ptrn-prop-id-trailing-comma.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-obj-ptrn-prop-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-obj-ptrn-prop-obj-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-obj-ptrn-prop-obj.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-obj-ptrn-rest-getter.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-obj-ptrn-rest-skip-non-enumerable.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-obj-ptrn-rest-val-obj.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-obj-ptrn-empty.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-obj-ptrn-id-init-fn-name-arrow.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-obj-ptrn-id-init-fn-name-class.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-obj-ptrn-id-init-fn-name-cover.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-obj-ptrn-id-init-fn-name-fn.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-obj-ptrn-id-init-fn-name-gen.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-obj-ptrn-id-init-skipped.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-obj-ptrn-id-trailing-comma.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-obj-ptrn-prop-ary-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-obj-ptrn-prop-ary-trailing-comma.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-obj-ptrn-prop-ary.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-obj-ptrn-prop-id-init-skipped.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-obj-ptrn-prop-id-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-obj-ptrn-prop-id-trailing-comma.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-obj-ptrn-prop-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-obj-ptrn-prop-obj-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-obj-ptrn-prop-obj.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-obj-ptrn-rest-getter.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-obj-ptrn-rest-skip-non-enumerable.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-obj-ptrn-rest-val-obj.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-init-iter-close.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-init-iter-no-close.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-name-iter-val.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-elem-ary-elem-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-elem-ary-elem-iter.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-elem-ary-elision-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-elem-ary-elision-iter.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-elem-ary-empty-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-elem-ary-empty-iter.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-elem-ary-rest-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-elem-ary-rest-iter.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-elem-id-init-exhausted.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-elem-id-init-fn-name-arrow.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-elem-id-init-fn-name-class.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-elem-id-init-fn-name-cover.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-elem-id-init-fn-name-fn.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-elem-id-init-fn-name-gen.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-elem-id-init-hole.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-elem-id-init-skipped.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-elem-id-init-undef.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-elem-id-iter-complete.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-elem-id-iter-done.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-elem-id-iter-val-array-prototype.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-elem-id-iter-val.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-elem-obj-id-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-elem-obj-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-elem-obj-prop-id-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-elem-obj-prop-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-elision-exhausted.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-elision.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-empty.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-rest-ary-elem.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-rest-ary-elision.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-rest-ary-empty.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-rest-ary-rest.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-rest-id-direct.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-rest-id-elision.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-rest-id-exhausted.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-rest-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-rest-init-ary.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-rest-init-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-rest-init-obj.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-rest-not-final-ary.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-rest-not-final-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-rest-not-final-obj.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-rest-obj-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-rest-obj-prop-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-init-iter-close.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-init-iter-no-close.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-name-iter-val.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-elem-ary-elem-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-elem-ary-elem-iter.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-elem-ary-elision-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-elem-ary-elision-iter.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-elem-ary-empty-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-elem-ary-empty-iter.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-elem-ary-rest-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-elem-ary-rest-iter.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-elem-id-init-exhausted.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-class.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-cover.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-fn.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-gen.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-elem-id-init-hole.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-elem-id-init-skipped.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-elem-id-init-undef.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-elem-id-iter-complete.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-elem-id-iter-done.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-elem-id-iter-val-array-prototype.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-elem-id-iter-val.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-elem-obj-id-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-elem-obj-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-elem-obj-prop-id-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-elem-obj-prop-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-elision-exhausted.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-elision.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-empty.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-rest-ary-elem.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-rest-ary-elision.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-rest-ary-empty.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-rest-ary-rest.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-rest-id-direct.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-rest-id-elision.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-rest-id-exhausted.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-rest-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-rest-init-ary.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-rest-init-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-rest-init-obj.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-rest-not-final-ary.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-rest-not-final-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-rest-not-final-obj.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-rest-obj-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-rest-obj-prop-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-obj-ptrn-empty.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-obj-ptrn-id-init-fn-name-arrow.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-obj-ptrn-id-init-fn-name-class.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-obj-ptrn-id-init-fn-name-cover.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-obj-ptrn-id-init-fn-name-fn.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-obj-ptrn-id-init-fn-name-gen.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-obj-ptrn-id-init-skipped.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-obj-ptrn-id-trailing-comma.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-obj-ptrn-prop-ary-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-obj-ptrn-prop-ary-trailing-comma.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-obj-ptrn-prop-ary.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-obj-ptrn-prop-id-init-skipped.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-obj-ptrn-prop-id-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-obj-ptrn-prop-id-trailing-comma.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-obj-ptrn-prop-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-obj-ptrn-prop-obj-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-obj-ptrn-prop-obj.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-obj-ptrn-rest-getter.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-obj-ptrn-rest-skip-non-enumerable.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-obj-ptrn-rest-val-obj.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-obj-ptrn-empty.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-obj-ptrn-id-init-fn-name-arrow.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-obj-ptrn-id-init-fn-name-class.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-obj-ptrn-id-init-fn-name-cover.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-obj-ptrn-id-init-fn-name-fn.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-obj-ptrn-id-init-fn-name-gen.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-obj-ptrn-id-init-skipped.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-obj-ptrn-id-trailing-comma.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-obj-ptrn-prop-ary-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-obj-ptrn-prop-ary-trailing-comma.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-obj-ptrn-prop-ary.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-obj-ptrn-prop-id-init-skipped.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-obj-ptrn-prop-id-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-obj-ptrn-prop-id-trailing-comma.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-obj-ptrn-prop-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-obj-ptrn-prop-obj-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-obj-ptrn-prop-obj.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-obj-ptrn-rest-getter.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-obj-ptrn-rest-skip-non-enumerable.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-obj-ptrn-rest-val-obj.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/browser.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-init-iter-close.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-init-iter-get-err-array-prototype.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-init-iter-get-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-init-iter-no-close.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-name-iter-val.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-ary-elem-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-ary-elem-iter.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-ary-elision-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-ary-elision-iter.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-ary-empty-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-ary-empty-iter.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-ary-rest-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-ary-rest-iter.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-ary-val-null.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-id-init-exhausted.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-id-init-fn-name-arrow.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-id-init-fn-name-class.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-id-init-fn-name-cover.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-id-init-fn-name-fn.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-id-init-fn-name-gen.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-id-init-hole.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-id-init-skipped.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-id-init-throws.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-id-init-undef.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-id-init-unresolvable.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-id-iter-complete.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-id-iter-done.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-id-iter-step-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-id-iter-val-array-prototype.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-id-iter-val-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-id-iter-val.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-obj-id-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-obj-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-obj-prop-id-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-obj-prop-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-obj-val-null.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-obj-val-undef.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elision-exhausted.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elision-step-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elision.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-empty.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-rest-ary-elem.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-rest-ary-elision.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-rest-ary-empty.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-rest-ary-rest.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-rest-id-direct.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-rest-id-elision-next-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-rest-id-elision.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-rest-id-exhausted.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-rest-id-iter-step-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-rest-id-iter-val-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-rest-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-rest-init-ary.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-rest-init-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-rest-init-obj.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-rest-not-final-ary.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-rest-not-final-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-rest-not-final-obj.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-rest-obj-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-rest-obj-prop-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-init-iter-close.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-init-iter-get-err-array-prototype.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-init-iter-get-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-init-iter-no-close.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-name-iter-val.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-ary-elem-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-ary-elem-iter.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-ary-elision-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-ary-elision-iter.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-ary-empty-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-ary-empty-iter.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-ary-rest-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-ary-rest-iter.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-ary-val-null.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-id-init-exhausted.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-class.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-cover.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-fn.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-gen.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-id-init-hole.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-id-init-skipped.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-id-init-throws.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-id-init-undef.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-id-init-unresolvable.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-id-iter-complete.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-id-iter-done.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-id-iter-step-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-id-iter-val-array-prototype.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-id-iter-val-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-id-iter-val.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-obj-id-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-obj-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-obj-prop-id-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-obj-prop-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-obj-val-null.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-obj-val-undef.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elision-exhausted.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elision-step-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elision.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-empty.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-rest-ary-elem.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-rest-ary-elision.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-rest-ary-empty.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-rest-ary-rest.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-rest-id-direct.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-rest-id-elision-next-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-rest-id-elision.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-rest-id-exhausted.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-rest-id-iter-step-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-rest-id-iter-val-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-rest-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-rest-init-ary.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-rest-init-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-rest-init-obj.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-rest-not-final-ary.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-rest-not-final-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-rest-not-final-obj.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-rest-obj-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-rest-obj-prop-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-init-null.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-init-undefined.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-empty.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-id-get-value-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-id-init-fn-name-arrow.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-id-init-fn-name-class.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-id-init-fn-name-cover.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-id-init-fn-name-fn.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-id-init-fn-name-gen.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-id-init-skipped.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-id-init-throws.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-id-init-unresolvable.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-id-trailing-comma.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-list-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-prop-ary-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-prop-ary-trailing-comma.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-prop-ary-value-null.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-prop-ary.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-prop-eval-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-prop-id-get-value-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-prop-id-init-skipped.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-prop-id-init-throws.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-prop-id-init-unresolvable.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-prop-id-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-prop-id-trailing-comma.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-prop-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-prop-obj-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-prop-obj-value-null.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-prop-obj-value-undef.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-prop-obj.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-rest-getter.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-rest-skip-non-enumerable.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-rest-val-obj.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-init-null.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-init-undefined.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-empty.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-id-get-value-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-id-init-fn-name-arrow.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-id-init-fn-name-class.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-id-init-fn-name-cover.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-id-init-fn-name-fn.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-id-init-fn-name-gen.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-id-init-skipped.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-id-init-throws.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-id-init-unresolvable.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-id-trailing-comma.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-list-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-prop-ary-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-prop-ary-trailing-comma.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-prop-ary-value-null.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-prop-ary.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-prop-eval-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-prop-id-get-value-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-prop-id-init-skipped.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-prop-id-init-throws.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-prop-id-init-unresolvable.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-prop-id-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-prop-id-trailing-comma.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-prop-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-prop-obj-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-prop-obj-value-null.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-prop-obj-value-undef.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-prop-obj.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-rest-getter.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-rest-skip-non-enumerable.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-rest-val-obj.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-init-iter-close.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-init-iter-get-err-array-prototype.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-init-iter-get-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-init-iter-no-close.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-name-iter-val.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-ary-elem-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-ary-elem-iter.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-ary-elision-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-ary-elision-iter.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-ary-empty-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-ary-empty-iter.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-ary-rest-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-ary-rest-iter.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-ary-val-null.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-id-init-exhausted.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-id-init-fn-name-arrow.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-id-init-fn-name-class.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-id-init-fn-name-cover.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-id-init-fn-name-fn.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-id-init-fn-name-gen.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-id-init-hole.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-id-init-skipped.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-id-init-throws.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-id-init-undef.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-id-init-unresolvable.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-id-iter-complete.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-id-iter-done.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-id-iter-step-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-id-iter-val-array-prototype.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-id-iter-val-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-id-iter-val.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-obj-id-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-obj-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-obj-prop-id-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-obj-prop-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-obj-val-null.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-obj-val-undef.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elision-exhausted.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elision-step-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elision.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-empty.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-rest-ary-elem.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-rest-ary-elision.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-rest-ary-empty.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-rest-ary-rest.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-rest-id-direct.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-rest-id-elision-next-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-rest-id-elision.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-rest-id-exhausted.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-rest-id-iter-step-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-rest-id-iter-val-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-rest-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-rest-init-ary.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-rest-init-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-rest-init-obj.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-rest-not-final-ary.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-rest-not-final-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-rest-not-final-obj.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-rest-obj-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-rest-obj-prop-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-init-iter-close.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-init-iter-get-err-array-prototype.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-init-iter-get-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-init-iter-no-close.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-name-iter-val.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-ary-elem-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-ary-elem-iter.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-ary-elision-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-ary-elision-iter.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-ary-empty-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-ary-empty-iter.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-ary-rest-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-ary-rest-iter.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-ary-val-null.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-id-init-exhausted.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-class.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-cover.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-fn.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-gen.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-id-init-hole.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-id-init-skipped.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-id-init-throws.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-id-init-undef.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-id-init-unresolvable.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-id-iter-complete.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-id-iter-done.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-id-iter-step-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-id-iter-val-array-prototype.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-id-iter-val-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-id-iter-val.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-obj-id-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-obj-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-obj-prop-id-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-obj-prop-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-obj-val-null.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-obj-val-undef.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elision-exhausted.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elision-step-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elision.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-empty.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-rest-ary-elem.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-rest-ary-elision.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-rest-ary-empty.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-rest-ary-rest.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-rest-id-direct.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-rest-id-elision-next-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-rest-id-elision.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-rest-id-exhausted.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-rest-id-iter-step-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-rest-id-iter-val-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-rest-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-rest-init-ary.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-rest-init-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-rest-init-obj.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-rest-not-final-ary.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-rest-not-final-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-rest-not-final-obj.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-rest-obj-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-rest-obj-prop-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-init-null.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-init-undefined.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-empty.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-id-get-value-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-id-init-fn-name-arrow.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-id-init-fn-name-class.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-id-init-fn-name-cover.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-id-init-fn-name-fn.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-id-init-fn-name-gen.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-id-init-skipped.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-id-init-throws.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-id-init-unresolvable.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-id-trailing-comma.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-list-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-prop-ary-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-prop-ary-trailing-comma.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-prop-ary-value-null.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-prop-ary.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-prop-eval-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-prop-id-get-value-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-prop-id-init-skipped.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-prop-id-init-throws.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-prop-id-init-unresolvable.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-prop-id-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-prop-id-trailing-comma.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-prop-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-prop-obj-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-prop-obj-value-null.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-prop-obj-value-undef.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-prop-obj.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-rest-getter.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-rest-skip-non-enumerable.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-rest-val-obj.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-init-null.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-init-undefined.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-empty.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-id-get-value-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-id-init-fn-name-arrow.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-id-init-fn-name-class.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-id-init-fn-name-cover.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-id-init-fn-name-fn.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-id-init-fn-name-gen.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-id-init-skipped.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-id-init-throws.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-id-init-unresolvable.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-id-trailing-comma.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-list-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-prop-ary-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-prop-ary-trailing-comma.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-prop-ary-value-null.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-prop-ary.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-prop-eval-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-prop-id-get-value-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-prop-id-init-skipped.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-prop-id-init-throws.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-prop-id-init-unresolvable.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-prop-id-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-prop-id-trailing-comma.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-prop-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-prop-obj-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-prop-obj-value-null.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-prop-obj-value-undef.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-prop-obj.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-rest-getter.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-rest-skip-non-enumerable.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-rest-val-obj.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-ary-init-iter-close.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-ary-init-iter-get-err-array-prototype.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-ary-init-iter-get-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-ary-init-iter-no-close.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-ary-name-iter-val.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-ary-elem-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-ary-elem-iter.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-ary-elision-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-ary-elision-iter.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-ary-empty-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-ary-empty-iter.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-ary-rest-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-ary-rest-iter.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-ary-val-null.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-id-init-exhausted.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-id-init-fn-name-arrow.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-id-init-fn-name-class.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-id-init-fn-name-cover.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-id-init-fn-name-fn.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-id-init-fn-name-gen.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-id-init-hole.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-id-init-skipped.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-id-init-throws.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-id-init-undef.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-id-init-unresolvable.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-id-iter-complete.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-id-iter-done.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-id-iter-step-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-id-iter-val-array-prototype.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-id-iter-val-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-id-iter-val.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-obj-id-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-obj-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-obj-prop-id-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-obj-prop-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-obj-val-null.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-obj-val-undef.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elision-exhausted.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elision-step-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elision.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-empty.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-rest-ary-elem.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-rest-ary-elision.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-rest-ary-empty.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-rest-ary-rest.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-rest-id-direct.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-rest-id-elision-next-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-rest-id-elision.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-rest-id-exhausted.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-rest-id-iter-step-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-rest-id-iter-val-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-rest-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-rest-init-ary.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-rest-init-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-rest-init-obj.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-rest-not-final-ary.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-rest-not-final-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-rest-not-final-obj.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-rest-obj-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-rest-obj-prop-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-init-iter-close.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-init-iter-get-err-array-prototype.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-init-iter-get-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-init-iter-no-close.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-name-iter-val.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-ary-elem-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-ary-elem-iter.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-ary-elision-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-ary-elision-iter.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-ary-empty-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-ary-empty-iter.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-ary-rest-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-ary-rest-iter.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-ary-val-null.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-id-init-exhausted.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-id-init-fn-name-class.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-id-init-fn-name-cover.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-id-init-fn-name-fn.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-id-init-fn-name-gen.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-id-init-hole.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-id-init-skipped.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-id-init-throws.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-id-init-undef.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-id-init-unresolvable.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-id-iter-complete.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-id-iter-done.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-id-iter-step-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-id-iter-val-array-prototype.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-id-iter-val-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-id-iter-val.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-obj-id-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-obj-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-obj-prop-id-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-obj-prop-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-obj-val-null.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-obj-val-undef.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elision-exhausted.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elision-step-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elision.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-empty.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-rest-ary-elem.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-rest-ary-elision.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-rest-ary-empty.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-rest-ary-rest.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-rest-id-direct.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-rest-id-elision-next-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-rest-id-elision.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-rest-id-exhausted.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-rest-id-iter-step-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-rest-id-iter-val-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-rest-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-rest-init-ary.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-rest-init-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-rest-init-obj.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-rest-not-final-ary.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-rest-not-final-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-rest-not-final-obj.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-rest-obj-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-rest-obj-prop-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-init-null.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-init-undefined.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-empty.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-id-get-value-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-id-init-fn-name-arrow.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-id-init-fn-name-class.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-id-init-fn-name-cover.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-id-init-fn-name-fn.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-id-init-fn-name-gen.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-id-init-skipped.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-id-init-throws.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-id-init-unresolvable.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-id-trailing-comma.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-list-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-prop-ary-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-prop-ary-trailing-comma.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-prop-ary-value-null.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-prop-ary.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-prop-eval-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-prop-id-get-value-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-prop-id-init-skipped.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-prop-id-init-throws.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-prop-id-init-unresolvable.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-prop-id-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-prop-id-trailing-comma.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-prop-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-prop-obj-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-prop-obj-value-null.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-prop-obj-value-undef.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-prop-obj.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-rest-getter.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-rest-skip-non-enumerable.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-rest-val-obj.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-obj-init-null.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-obj-init-undefined.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-empty.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-id-get-value-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-id-init-fn-name-arrow.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-id-init-fn-name-class.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-id-init-fn-name-cover.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-id-init-fn-name-fn.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-id-init-fn-name-gen.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-id-init-skipped.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-id-init-throws.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-id-init-unresolvable.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-id-trailing-comma.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-list-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-prop-ary-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-prop-ary-trailing-comma.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-prop-ary-value-null.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-prop-ary.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-prop-eval-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-prop-id-get-value-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-prop-id-init-skipped.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-prop-id-init-throws.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-prop-id-init-unresolvable.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-prop-id-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-prop-id-trailing-comma.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-prop-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-prop-obj-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-prop-obj-value-null.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-prop-obj-value-undef.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-prop-obj.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-rest-getter.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-rest-skip-non-enumerable.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-rest-val-obj.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-ary-init-iter-close.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-ary-init-iter-get-err-array-prototype.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-ary-init-iter-get-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-ary-init-iter-no-close.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-ary-name-iter-val.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-ary-elem-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-ary-elem-iter.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-ary-elision-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-ary-elision-iter.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-ary-empty-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-ary-empty-iter.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-ary-rest-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-ary-rest-iter.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-ary-val-null.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-id-init-exhausted.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-id-init-fn-name-arrow.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-id-init-fn-name-class.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-id-init-fn-name-cover.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-id-init-fn-name-fn.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-id-init-fn-name-gen.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-id-init-hole.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-id-init-skipped.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-id-init-throws.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-id-init-undef.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-id-init-unresolvable.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-id-iter-complete.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-id-iter-done.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-id-iter-step-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-id-iter-val-array-prototype.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-id-iter-val-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-id-iter-val.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-obj-id-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-obj-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-obj-prop-id-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-obj-prop-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-obj-val-null.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-obj-val-undef.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elision-exhausted.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elision-step-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elision.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-empty.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-rest-ary-elem.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-rest-ary-elision.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-rest-ary-empty.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-rest-ary-rest.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-rest-id-direct.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-rest-id-elision-next-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-rest-id-elision.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-rest-id-exhausted.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-rest-id-iter-step-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-rest-id-iter-val-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-rest-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-rest-init-ary.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-rest-init-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-rest-init-obj.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-rest-not-final-ary.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-rest-not-final-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-rest-not-final-obj.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-rest-obj-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-rest-obj-prop-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-init-iter-close.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-init-iter-get-err-array-prototype.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-init-iter-get-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-init-iter-no-close.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-name-iter-val.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-ary-elem-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-ary-elem-iter.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-ary-elision-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-ary-elision-iter.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-ary-empty-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-ary-empty-iter.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-ary-rest-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-ary-rest-iter.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-ary-val-null.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-id-init-exhausted.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-id-init-fn-name-class.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-id-init-fn-name-cover.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-id-init-fn-name-fn.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-id-init-fn-name-gen.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-id-init-hole.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-id-init-skipped.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-id-init-throws.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-id-init-undef.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-id-init-unresolvable.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-id-iter-complete.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-id-iter-done.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-id-iter-step-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-id-iter-val-array-prototype.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-id-iter-val-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-id-iter-val.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-obj-id-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-obj-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-obj-prop-id-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-obj-prop-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-obj-val-null.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-obj-val-undef.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elision-exhausted.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elision-step-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elision.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-empty.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-rest-ary-elem.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-rest-ary-elision.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-rest-ary-empty.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-rest-ary-rest.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-rest-id-direct.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-rest-id-elision-next-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-rest-id-elision.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-rest-id-exhausted.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-rest-id-iter-step-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-rest-id-iter-val-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-rest-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-rest-init-ary.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-rest-init-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-rest-init-obj.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-rest-not-final-ary.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-rest-not-final-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-rest-not-final-obj.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-rest-obj-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-rest-obj-prop-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-init-null.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-init-undefined.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-empty.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-id-get-value-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-id-init-fn-name-arrow.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-id-init-fn-name-class.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-id-init-fn-name-cover.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-id-init-fn-name-fn.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-id-init-fn-name-gen.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-id-init-skipped.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-id-init-throws.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-id-init-unresolvable.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-id-trailing-comma.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-list-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-prop-ary-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-prop-ary-trailing-comma.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-prop-ary-value-null.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-prop-ary.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-prop-eval-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-prop-id-get-value-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-prop-id-init-skipped.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-prop-id-init-throws.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-prop-id-init-unresolvable.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-prop-id-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-prop-id-trailing-comma.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-prop-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-prop-obj-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-prop-obj-value-null.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-prop-obj-value-undef.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-prop-obj.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-rest-getter.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-rest-skip-non-enumerable.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-rest-val-obj.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-obj-init-null.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-obj-init-undefined.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-empty.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-id-get-value-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-id-init-fn-name-arrow.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-id-init-fn-name-class.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-id-init-fn-name-cover.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-id-init-fn-name-fn.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-id-init-fn-name-gen.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-id-init-skipped.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-id-init-throws.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-id-init-unresolvable.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-id-trailing-comma.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-list-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-prop-ary-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-prop-ary-trailing-comma.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-prop-ary-value-null.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-prop-ary.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-prop-eval-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-prop-id-get-value-err.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-prop-id-init-skipped.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-prop-id-init-throws.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-prop-id-init-unresolvable.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-prop-id-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-prop-id-trailing-comma.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-prop-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-prop-obj-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-prop-obj-value-null.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-prop-obj-value-undef.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-prop-obj.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-rest-getter.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-rest-skip-non-enumerable.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-rest-val-obj.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-init-iter-close.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-init-iter-no-close.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-name-iter-val.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-elem-ary-elem-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-elem-ary-elem-iter.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-elem-ary-elision-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-elem-ary-elision-iter.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-elem-ary-empty-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-elem-ary-empty-iter.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-elem-ary-rest-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-elem-ary-rest-iter.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-elem-id-init-exhausted.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-elem-id-init-fn-name-arrow.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-elem-id-init-fn-name-class.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-elem-id-init-fn-name-cover.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-elem-id-init-fn-name-fn.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-elem-id-init-fn-name-gen.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-elem-id-init-hole.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-elem-id-init-skipped.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-elem-id-init-undef.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-elem-id-iter-complete.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-elem-id-iter-done.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-elem-id-iter-val-array-prototype.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-elem-id-iter-val.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-elem-obj-id-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-elem-obj-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-elem-obj-prop-id-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-elem-obj-prop-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-elision-exhausted.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-elision.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-empty.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-rest-ary-elem.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-rest-ary-elision.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-rest-ary-empty.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-rest-ary-rest.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-rest-id-direct.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-rest-id-elision.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-rest-id-exhausted.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-rest-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-rest-init-ary.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-rest-init-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-rest-init-obj.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-rest-not-final-ary.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-rest-not-final-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-rest-not-final-obj.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-rest-obj-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-rest-obj-prop-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-init-iter-close.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-init-iter-no-close.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-name-iter-val.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-elem-ary-elem-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-elem-ary-elem-iter.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-elem-ary-elision-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-elem-ary-elision-iter.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-elem-ary-empty-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-elem-ary-empty-iter.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-elem-ary-rest-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-elem-ary-rest-iter.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-elem-id-init-exhausted.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-class.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-cover.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-fn.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-gen.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-elem-id-init-hole.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-elem-id-init-skipped.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-elem-id-init-undef.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-elem-id-iter-complete.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-elem-id-iter-done.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-elem-id-iter-val-array-prototype.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-elem-id-iter-val.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-elem-obj-id-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-elem-obj-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-elem-obj-prop-id-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-elem-obj-prop-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-elision-exhausted.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-elision.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-empty.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-rest-ary-elem.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-rest-ary-elision.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-rest-ary-empty.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-rest-ary-rest.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-rest-id-direct.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-rest-id-elision.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-rest-id-exhausted.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-rest-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-rest-init-ary.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-rest-init-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-rest-init-obj.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-rest-not-final-ary.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-rest-not-final-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-rest-not-final-obj.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-rest-obj-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-rest-obj-prop-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-obj-ptrn-empty.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-obj-ptrn-id-init-fn-name-arrow.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-obj-ptrn-id-init-fn-name-class.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-obj-ptrn-id-init-fn-name-cover.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-obj-ptrn-id-init-fn-name-fn.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-obj-ptrn-id-init-fn-name-gen.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-obj-ptrn-id-init-skipped.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-obj-ptrn-id-trailing-comma.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-obj-ptrn-prop-ary-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-obj-ptrn-prop-ary-trailing-comma.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-obj-ptrn-prop-ary.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-obj-ptrn-prop-id-init-skipped.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-obj-ptrn-prop-id-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-obj-ptrn-prop-id-trailing-comma.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-obj-ptrn-prop-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-obj-ptrn-prop-obj-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-obj-ptrn-prop-obj.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-obj-ptrn-rest-getter.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-obj-ptrn-rest-skip-non-enumerable.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-obj-ptrn-rest-val-obj.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-obj-ptrn-empty.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-obj-ptrn-id-init-fn-name-arrow.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-obj-ptrn-id-init-fn-name-class.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-obj-ptrn-id-init-fn-name-cover.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-obj-ptrn-id-init-fn-name-fn.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-obj-ptrn-id-init-fn-name-gen.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-obj-ptrn-id-init-skipped.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-obj-ptrn-id-trailing-comma.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-obj-ptrn-prop-ary-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-obj-ptrn-prop-ary-trailing-comma.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-obj-ptrn-prop-ary.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-obj-ptrn-prop-id-init-skipped.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-obj-ptrn-prop-id-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-obj-ptrn-prop-id-trailing-comma.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-obj-ptrn-prop-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-obj-ptrn-prop-obj-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-obj-ptrn-prop-obj.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-obj-ptrn-rest-getter.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-obj-ptrn-rest-skip-non-enumerable.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-obj-ptrn-rest-val-obj.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-init-iter-close.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-init-iter-no-close.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-name-iter-val.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-elem-ary-elem-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-elem-ary-elem-iter.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-elem-ary-elision-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-elem-ary-elision-iter.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-elem-ary-empty-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-elem-ary-empty-iter.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-elem-ary-rest-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-elem-ary-rest-iter.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-elem-id-init-exhausted.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-elem-id-init-fn-name-arrow.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-elem-id-init-fn-name-class.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-elem-id-init-fn-name-cover.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-elem-id-init-fn-name-fn.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-elem-id-init-fn-name-gen.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-elem-id-init-hole.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-elem-id-init-skipped.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-elem-id-init-undef.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-elem-id-iter-complete.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-elem-id-iter-done.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-elem-id-iter-val-array-prototype.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-elem-id-iter-val.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-elem-obj-id-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-elem-obj-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-elem-obj-prop-id-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-elem-obj-prop-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-elision-exhausted.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-elision.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-empty.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-rest-ary-elem.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-rest-ary-elision.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-rest-ary-empty.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-rest-ary-rest.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-rest-id-direct.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-rest-id-elision.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-rest-id-exhausted.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-rest-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-rest-init-ary.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-rest-init-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-rest-init-obj.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-rest-not-final-ary.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-rest-not-final-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-rest-not-final-obj.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-rest-obj-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-rest-obj-prop-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-init-iter-close.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-init-iter-no-close.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-name-iter-val.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-elem-ary-elem-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-elem-ary-elem-iter.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-elem-ary-elision-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-elem-ary-elision-iter.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-elem-ary-empty-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-elem-ary-empty-iter.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-elem-ary-rest-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-elem-ary-rest-iter.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-elem-id-init-exhausted.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-class.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-cover.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-fn.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-gen.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-elem-id-init-hole.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-elem-id-init-skipped.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-elem-id-init-undef.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-elem-id-iter-complete.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-elem-id-iter-done.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-elem-id-iter-val-array-prototype.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-elem-id-iter-val.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-elem-obj-id-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-elem-obj-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-elem-obj-prop-id-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-elem-obj-prop-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-elision-exhausted.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-elision.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-empty.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-rest-ary-elem.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-rest-ary-elision.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-rest-ary-empty.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-rest-ary-rest.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-rest-id-direct.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-rest-id-elision.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-rest-id-exhausted.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-rest-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-rest-init-ary.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-rest-init-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-rest-init-obj.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-rest-not-final-ary.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-rest-not-final-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-rest-not-final-obj.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-rest-obj-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-rest-obj-prop-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-obj-ptrn-empty.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-obj-ptrn-id-init-fn-name-arrow.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-obj-ptrn-id-init-fn-name-class.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-obj-ptrn-id-init-fn-name-cover.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-obj-ptrn-id-init-fn-name-fn.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-obj-ptrn-id-init-fn-name-gen.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-obj-ptrn-id-init-skipped.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-obj-ptrn-id-trailing-comma.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-obj-ptrn-prop-ary-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-obj-ptrn-prop-ary-trailing-comma.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-obj-ptrn-prop-ary.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-obj-ptrn-prop-id-init-skipped.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-obj-ptrn-prop-id-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-obj-ptrn-prop-id-trailing-comma.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-obj-ptrn-prop-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-obj-ptrn-prop-obj-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-obj-ptrn-prop-obj.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-obj-ptrn-rest-getter.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-obj-ptrn-rest-skip-non-enumerable.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-obj-ptrn-rest-val-obj.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-obj-ptrn-empty.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-obj-ptrn-id-init-fn-name-arrow.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-obj-ptrn-id-init-fn-name-class.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-obj-ptrn-id-init-fn-name-cover.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-obj-ptrn-id-init-fn-name-fn.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-obj-ptrn-id-init-fn-name-gen.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-obj-ptrn-id-init-skipped.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-obj-ptrn-id-trailing-comma.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-obj-ptrn-prop-ary-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-obj-ptrn-prop-ary-trailing-comma.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-obj-ptrn-prop-ary.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-obj-ptrn-prop-id-init-skipped.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-obj-ptrn-prop-id-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-obj-ptrn-prop-id-trailing-comma.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-obj-ptrn-prop-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-obj-ptrn-prop-obj-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-obj-ptrn-prop-obj.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-obj-ptrn-rest-getter.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-obj-ptrn-rest-skip-non-enumerable.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-obj-ptrn-rest-val-obj.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-ary-init-iter-close.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-ary-init-iter-no-close.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-ary-name-iter-val.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-elem-ary-elem-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-elem-ary-elem-iter.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-elem-ary-elision-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-elem-ary-elision-iter.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-elem-ary-empty-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-elem-ary-empty-iter.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-elem-ary-rest-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-elem-ary-rest-iter.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-elem-id-init-exhausted.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-elem-id-init-fn-name-arrow.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-elem-id-init-fn-name-class.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-elem-id-init-fn-name-cover.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-elem-id-init-fn-name-fn.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-elem-id-init-fn-name-gen.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-elem-id-init-hole.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-elem-id-init-skipped.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-elem-id-init-undef.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-elem-id-iter-complete.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-elem-id-iter-done.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-elem-id-iter-val-array-prototype.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-elem-id-iter-val.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-elem-obj-id-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-elem-obj-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-elem-obj-prop-id-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-elem-obj-prop-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-elision-exhausted.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-elision.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-empty.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-rest-ary-elem.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-rest-ary-elision.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-rest-ary-empty.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-rest-ary-rest.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-rest-id-direct.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-rest-id-elision.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-rest-id-exhausted.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-rest-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-rest-init-ary.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-rest-init-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-rest-init-obj.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-rest-not-final-ary.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-rest-not-final-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-rest-not-final-obj.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-rest-obj-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-rest-obj-prop-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-init-iter-close.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-init-iter-no-close.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-name-iter-val.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-elem-ary-elem-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-elem-ary-elem-iter.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-elem-ary-elision-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-elem-ary-elision-iter.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-elem-ary-empty-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-elem-ary-empty-iter.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-elem-ary-rest-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-elem-ary-rest-iter.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-elem-id-init-exhausted.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-elem-id-init-fn-name-class.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-elem-id-init-fn-name-cover.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-elem-id-init-fn-name-fn.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-elem-id-init-fn-name-gen.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-elem-id-init-hole.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-elem-id-init-skipped.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-elem-id-init-undef.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-elem-id-iter-complete.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-elem-id-iter-done.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-elem-id-iter-val-array-prototype.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-elem-id-iter-val.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-elem-obj-id-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-elem-obj-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-elem-obj-prop-id-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-elem-obj-prop-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-elision-exhausted.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-elision.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-empty.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-rest-ary-elem.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-rest-ary-elision.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-rest-ary-empty.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-rest-ary-rest.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-rest-id-direct.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-rest-id-elision.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-rest-id-exhausted.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-rest-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-rest-init-ary.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-rest-init-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-rest-init-obj.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-rest-not-final-ary.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-rest-not-final-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-rest-not-final-obj.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-rest-obj-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-rest-obj-prop-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-obj-ptrn-empty.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-obj-ptrn-id-init-fn-name-arrow.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-obj-ptrn-id-init-fn-name-class.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-obj-ptrn-id-init-fn-name-cover.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-obj-ptrn-id-init-fn-name-fn.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-obj-ptrn-id-init-fn-name-gen.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-obj-ptrn-id-init-skipped.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-obj-ptrn-id-trailing-comma.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-obj-ptrn-prop-ary-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-obj-ptrn-prop-ary-trailing-comma.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-obj-ptrn-prop-ary.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-obj-ptrn-prop-id-init-skipped.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-obj-ptrn-prop-id-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-obj-ptrn-prop-id-trailing-comma.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-obj-ptrn-prop-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-obj-ptrn-prop-obj-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-obj-ptrn-prop-obj.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-obj-ptrn-rest-getter.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-obj-ptrn-rest-skip-non-enumerable.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-obj-ptrn-rest-val-obj.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-obj-ptrn-empty.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-obj-ptrn-id-init-fn-name-arrow.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-obj-ptrn-id-init-fn-name-class.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-obj-ptrn-id-init-fn-name-cover.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-obj-ptrn-id-init-fn-name-fn.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-obj-ptrn-id-init-fn-name-gen.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-obj-ptrn-id-init-skipped.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-obj-ptrn-id-trailing-comma.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-obj-ptrn-prop-ary-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-obj-ptrn-prop-ary-trailing-comma.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-obj-ptrn-prop-ary.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-obj-ptrn-prop-id-init-skipped.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-obj-ptrn-prop-id-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-obj-ptrn-prop-id-trailing-comma.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-obj-ptrn-prop-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-obj-ptrn-prop-obj-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-obj-ptrn-prop-obj.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-obj-ptrn-rest-getter.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-obj-ptrn-rest-skip-non-enumerable.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-obj-ptrn-rest-val-obj.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-init-iter-close.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-init-iter-no-close.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-name-iter-val.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-elem-ary-elem-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-elem-ary-elem-iter.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-elem-ary-elision-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-elem-ary-elision-iter.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-elem-ary-empty-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-elem-ary-empty-iter.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-elem-ary-rest-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-elem-ary-rest-iter.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-elem-id-init-exhausted.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-elem-id-init-fn-name-arrow.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-elem-id-init-fn-name-class.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-elem-id-init-fn-name-cover.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-elem-id-init-fn-name-fn.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-elem-id-init-fn-name-gen.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-elem-id-init-hole.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-elem-id-init-skipped.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-elem-id-init-undef.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-elem-id-iter-complete.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-elem-id-iter-done.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-elem-id-iter-val-array-prototype.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-elem-id-iter-val.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-elem-obj-id-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-elem-obj-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-elem-obj-prop-id-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-elem-obj-prop-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-elision-exhausted.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-elision.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-empty.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-rest-ary-elem.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-rest-ary-elision.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-rest-ary-empty.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-rest-ary-rest.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-rest-id-direct.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-rest-id-elision.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-rest-id-exhausted.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-rest-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-rest-init-ary.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-rest-init-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-rest-init-obj.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-rest-not-final-ary.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-rest-not-final-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-rest-not-final-obj.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-rest-obj-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-rest-obj-prop-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-init-iter-close.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-init-iter-no-close.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-name-iter-val.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-elem-ary-elem-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-elem-ary-elem-iter.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-elem-ary-elision-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-elem-ary-elision-iter.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-elem-ary-empty-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-elem-ary-empty-iter.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-elem-ary-rest-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-elem-ary-rest-iter.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-elem-id-init-exhausted.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-class.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-cover.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-fn.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-gen.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-elem-id-init-hole.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-elem-id-init-skipped.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-elem-id-init-undef.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-elem-id-iter-complete.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-elem-id-iter-done.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-elem-id-iter-val-array-prototype.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-elem-id-iter-val.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-elem-obj-id-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-elem-obj-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-elem-obj-prop-id-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-elem-obj-prop-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-elision-exhausted.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-elision.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-empty.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-rest-ary-elem.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-rest-ary-elision.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-rest-ary-empty.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-rest-ary-rest.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-rest-id-direct.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-rest-id-elision.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-rest-id-exhausted.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-rest-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-rest-init-ary.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-rest-init-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-rest-init-obj.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-rest-not-final-ary.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-rest-not-final-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-rest-not-final-obj.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-rest-obj-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-rest-obj-prop-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-obj-ptrn-empty.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-obj-ptrn-id-init-fn-name-arrow.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-obj-ptrn-id-init-fn-name-class.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-obj-ptrn-id-init-fn-name-cover.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-obj-ptrn-id-init-fn-name-fn.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-obj-ptrn-id-init-fn-name-gen.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-obj-ptrn-id-init-skipped.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-obj-ptrn-id-trailing-comma.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-obj-ptrn-prop-ary-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-obj-ptrn-prop-ary-trailing-comma.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-obj-ptrn-prop-ary.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-obj-ptrn-prop-id-init-skipped.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-obj-ptrn-prop-id-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-obj-ptrn-prop-id-trailing-comma.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-obj-ptrn-prop-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-obj-ptrn-prop-obj-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-obj-ptrn-prop-obj.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-obj-ptrn-rest-getter.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-obj-ptrn-rest-skip-non-enumerable.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-obj-ptrn-rest-val-obj.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-obj-ptrn-empty.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-obj-ptrn-id-init-fn-name-arrow.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-obj-ptrn-id-init-fn-name-class.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-obj-ptrn-id-init-fn-name-cover.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-obj-ptrn-id-init-fn-name-fn.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-obj-ptrn-id-init-fn-name-gen.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-obj-ptrn-id-init-skipped.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-obj-ptrn-id-trailing-comma.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-obj-ptrn-prop-ary-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-obj-ptrn-prop-ary-trailing-comma.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-obj-ptrn-prop-ary.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-obj-ptrn-prop-id-init-skipped.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-obj-ptrn-prop-id-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-obj-ptrn-prop-id-trailing-comma.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-obj-ptrn-prop-id.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-obj-ptrn-prop-obj-init.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-obj-ptrn-prop-obj.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-obj-ptrn-rest-getter.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-obj-ptrn-rest-skip-non-enumerable.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/private-meth-static-obj-ptrn-rest-val-obj.js create mode 100644 js/src/tests/test262/language/statements/class/dstr/shell.js create mode 100644 js/src/tests/test262/language/statements/class/elements/abrupt-completition-on-field-initializer.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-gen-computed-names.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-gen-computed-symbol-names.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-gen-grammar-privatename-identifier-semantics-stringvalue.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-gen-literal-names-asi.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-gen-literal-names.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-gen-private-field-usage.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-gen-private-method-getter-usage.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-gen-private-method-usage.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-gen-private-names.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-gen-rs-field-identifier-initializer.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-gen-rs-field-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-gen-rs-private-getter-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-gen-rs-private-getter.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-gen-rs-private-method-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-gen-rs-private-method.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-gen-rs-private-setter-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-gen-rs-private-setter.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-gen-rs-privatename-identifier-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-gen-rs-privatename-identifier-initializer-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-gen-rs-privatename-identifier-initializer.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-gen-rs-privatename-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-gen-rs-static-async-generator-method-privatename-identifier-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-gen-rs-static-async-generator-method-privatename-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-gen-rs-static-async-method-privatename-identifier-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-gen-rs-static-async-method-privatename-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-gen-rs-static-generator-method-privatename-identifier-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-gen-rs-static-generator-method-privatename-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-gen-rs-static-method-privatename-identifier-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-gen-rs-static-method-privatename-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-gen-rs-static-privatename-identifier-alt-by-classname.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-gen-rs-static-privatename-identifier-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-gen-rs-static-privatename-identifier-by-classname.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-gen-rs-static-privatename-identifier-initializer-alt-by-classname.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-gen-rs-static-privatename-identifier-initializer-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-gen-rs-static-privatename-identifier-initializer.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-gen-rs-static-privatename-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-gen-static-private-fields.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-gen-static-private-methods-with-fields.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-gen-static-private-methods.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-gen-string-literal-names.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-method-computed-names.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-method-computed-symbol-names.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-method-grammar-privatename-identifier-semantics-stringvalue.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-method-literal-names-asi.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-method-literal-names.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-method-private-field-usage.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-method-private-method-getter-usage.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-method-private-method-usage.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-method-private-names.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-method-rs-field-identifier-initializer.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-method-rs-field-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-method-rs-private-getter-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-method-rs-private-getter.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-method-rs-private-method-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-method-rs-private-method.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-method-rs-private-setter-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-method-rs-private-setter.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-method-rs-privatename-identifier-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-method-rs-privatename-identifier-initializer-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-method-rs-privatename-identifier-initializer.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-method-rs-privatename-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-method-rs-static-async-generator-method-privatename-identifier-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-method-rs-static-async-generator-method-privatename-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-method-rs-static-async-method-privatename-identifier-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-method-rs-static-async-method-privatename-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-method-rs-static-generator-method-privatename-identifier-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-method-rs-static-generator-method-privatename-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-method-rs-static-method-privatename-identifier-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-method-rs-static-method-privatename-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-method-rs-static-privatename-identifier-alt-by-classname.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-method-rs-static-privatename-identifier-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-method-rs-static-privatename-identifier-by-classname.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-method-rs-static-privatename-identifier-initializer-alt-by-classname.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-method-rs-static-privatename-identifier-initializer-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-method-rs-static-privatename-identifier-initializer.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-method-rs-static-privatename-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-method-static-private-fields.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-method-static-private-methods-with-fields.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-method-static-private-methods.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-method-string-literal-names.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-computed-names.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-computed-symbol-names.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-grammar-privatename-identifier-semantics-stringvalue.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-literal-names-asi.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-literal-names.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-private-field-usage.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-private-method-getter-usage.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-private-method-usage.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-private-names.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-rs-field-identifier-initializer.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-rs-field-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-rs-private-getter-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-rs-private-getter.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-rs-private-method-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-rs-private-method.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-rs-private-setter-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-rs-private-setter.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-rs-privatename-identifier-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-rs-privatename-identifier-initializer-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-rs-privatename-identifier-initializer.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-rs-privatename-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-rs-static-async-generator-method-privatename-identifier-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-rs-static-async-generator-method-privatename-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-rs-static-async-method-privatename-identifier-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-rs-static-async-method-privatename-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-rs-static-generator-method-privatename-identifier-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-rs-static-generator-method-privatename-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-rs-static-method-privatename-identifier-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-rs-static-method-privatename-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-rs-static-privatename-identifier-alt-by-classname.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-rs-static-privatename-identifier-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-rs-static-privatename-identifier-by-classname.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-rs-static-privatename-identifier-initializer-alt-by-classname.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-rs-static-privatename-identifier-initializer-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-rs-static-privatename-identifier-initializer.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-rs-static-privatename-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-static-private-fields.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-static-private-methods-with-fields.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-static-private-methods.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-string-literal-names.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-computed-names.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-computed-symbol-names.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-grammar-privatename-identifier-semantics-stringvalue.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-literal-names-asi.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-literal-names.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-private-field-usage.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-private-method-getter-usage.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-private-method-usage.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-private-names.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-rs-field-identifier-initializer.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-rs-field-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-rs-private-getter-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-rs-private-getter.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-rs-private-method-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-rs-private-method.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-rs-private-setter-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-rs-private-setter.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-rs-privatename-identifier-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-rs-privatename-identifier-initializer-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-rs-privatename-identifier-initializer.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-rs-privatename-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-rs-static-async-generator-method-privatename-identifier-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-rs-static-async-generator-method-privatename-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-rs-static-async-method-privatename-identifier-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-rs-static-async-method-privatename-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-rs-static-generator-method-privatename-identifier-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-rs-static-generator-method-privatename-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-rs-static-method-privatename-identifier-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-rs-static-method-privatename-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-rs-static-privatename-identifier-alt-by-classname.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-rs-static-privatename-identifier-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-rs-static-privatename-identifier-by-classname.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-rs-static-privatename-identifier-initializer-alt-by-classname.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-rs-static-privatename-identifier-initializer-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-rs-static-privatename-identifier-initializer.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-rs-static-privatename-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-static-private-fields.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-static-private-methods-with-fields.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-static-private-methods.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-string-literal-names.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-computed-names.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-computed-symbol-names.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-grammar-privatename-identifier-semantics-stringvalue.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-literal-names-asi.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-literal-names.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-private-field-usage.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-private-method-getter-usage.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-private-method-usage.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-private-names.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-rs-field-identifier-initializer.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-rs-field-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-rs-private-getter-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-rs-private-getter.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-rs-private-method-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-rs-private-method.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-rs-private-setter-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-rs-private-setter.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-rs-privatename-identifier-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-rs-privatename-identifier-initializer-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-rs-privatename-identifier-initializer.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-rs-privatename-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-rs-static-async-generator-method-privatename-identifier-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-rs-static-async-generator-method-privatename-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-rs-static-async-method-privatename-identifier-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-rs-static-async-method-privatename-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-rs-static-generator-method-privatename-identifier-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-rs-static-generator-method-privatename-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-rs-static-method-privatename-identifier-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-rs-static-method-privatename-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-rs-static-privatename-identifier-alt-by-classname.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-rs-static-privatename-identifier-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-rs-static-privatename-identifier-by-classname.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-rs-static-privatename-identifier-initializer-alt-by-classname.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-rs-static-privatename-identifier-initializer-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-rs-static-privatename-identifier-initializer.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-rs-static-privatename-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-static-private-fields.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-static-private-methods-with-fields.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-static-private-methods.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-string-literal-names.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-computed-names.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-computed-symbol-names.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-grammar-privatename-identifier-semantics-stringvalue.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-literal-names-asi.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-literal-names.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-private-field-usage.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-private-method-getter-usage.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-private-method-usage.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-private-names.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-rs-field-identifier-initializer.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-rs-field-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-rs-private-getter-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-rs-private-getter.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-rs-private-method-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-rs-private-method.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-rs-private-setter-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-rs-private-setter.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-rs-privatename-identifier-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-rs-privatename-identifier-initializer-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-rs-privatename-identifier-initializer.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-rs-privatename-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-rs-static-async-generator-method-privatename-identifier-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-rs-static-async-generator-method-privatename-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-rs-static-async-method-privatename-identifier-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-rs-static-async-method-privatename-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-rs-static-generator-method-privatename-identifier-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-rs-static-generator-method-privatename-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-rs-static-method-privatename-identifier-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-rs-static-method-privatename-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-rs-static-privatename-identifier-alt-by-classname.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-rs-static-privatename-identifier-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-rs-static-privatename-identifier-by-classname.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-rs-static-privatename-identifier-initializer-alt-by-classname.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-rs-static-privatename-identifier-initializer-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-rs-static-privatename-identifier-initializer.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-rs-static-privatename-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-static-private-fields.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-static-private-methods-with-fields.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-static-private-methods.js create mode 100644 js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-string-literal-names.js create mode 100644 js/src/tests/test262/language/statements/class/elements/arrow-body-derived-cls-direct-eval-contains-superproperty-1.js create mode 100644 js/src/tests/test262/language/statements/class/elements/arrow-body-derived-cls-direct-eval-contains-superproperty-2.js create mode 100644 js/src/tests/test262/language/statements/class/elements/arrow-body-derived-cls-direct-eval-err-contains-supercall-1.js create mode 100644 js/src/tests/test262/language/statements/class/elements/arrow-body-derived-cls-direct-eval-err-contains-supercall-2.js create mode 100644 js/src/tests/test262/language/statements/class/elements/arrow-body-derived-cls-direct-eval-err-contains-supercall.js create mode 100644 js/src/tests/test262/language/statements/class/elements/arrow-body-derived-cls-indirect-eval-contains-superproperty-1.js create mode 100644 js/src/tests/test262/language/statements/class/elements/arrow-body-derived-cls-indirect-eval-contains-superproperty-2.js create mode 100644 js/src/tests/test262/language/statements/class/elements/arrow-body-derived-cls-indirect-eval-err-contains-supercall-1.js create mode 100644 js/src/tests/test262/language/statements/class/elements/arrow-body-derived-cls-indirect-eval-err-contains-supercall-2.js create mode 100644 js/src/tests/test262/language/statements/class/elements/arrow-body-derived-cls-indirect-eval-err-contains-supercall.js create mode 100644 js/src/tests/test262/language/statements/class/elements/arrow-body-direct-eval-err-contains-arguments.js create mode 100644 js/src/tests/test262/language/statements/class/elements/arrow-body-direct-eval-err-contains-newtarget.js create mode 100644 js/src/tests/test262/language/statements/class/elements/arrow-body-indirect-eval-err-contains-newtarget.js create mode 100644 js/src/tests/test262/language/statements/class/elements/arrow-body-private-derived-cls-direct-eval-contains-superproperty-1.js create mode 100644 js/src/tests/test262/language/statements/class/elements/arrow-body-private-derived-cls-direct-eval-contains-superproperty-2.js create mode 100644 js/src/tests/test262/language/statements/class/elements/arrow-body-private-derived-cls-direct-eval-err-contains-supercall-1.js create mode 100644 js/src/tests/test262/language/statements/class/elements/arrow-body-private-derived-cls-direct-eval-err-contains-supercall-2.js create mode 100644 js/src/tests/test262/language/statements/class/elements/arrow-body-private-derived-cls-direct-eval-err-contains-supercall.js create mode 100644 js/src/tests/test262/language/statements/class/elements/arrow-body-private-derived-cls-indirect-eval-contains-superproperty-1.js create mode 100644 js/src/tests/test262/language/statements/class/elements/arrow-body-private-derived-cls-indirect-eval-contains-superproperty-2.js create mode 100644 js/src/tests/test262/language/statements/class/elements/arrow-body-private-derived-cls-indirect-eval-err-contains-supercall-1.js create mode 100644 js/src/tests/test262/language/statements/class/elements/arrow-body-private-derived-cls-indirect-eval-err-contains-supercall-2.js create mode 100644 js/src/tests/test262/language/statements/class/elements/arrow-body-private-derived-cls-indirect-eval-err-contains-supercall.js create mode 100644 js/src/tests/test262/language/statements/class/elements/arrow-body-private-direct-eval-err-contains-arguments.js create mode 100644 js/src/tests/test262/language/statements/class/elements/arrow-body-private-direct-eval-err-contains-newtarget.js create mode 100644 js/src/tests/test262/language/statements/class/elements/arrow-body-private-indirect-eval-err-contains-newtarget.js create mode 100644 js/src/tests/test262/language/statements/class/elements/arrow-fnc-init-err-contains-arguments.js create mode 100644 js/src/tests/test262/language/statements/class/elements/arrow-fnc-init-err-contains-super.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/await-as-binding-identifier-escaped.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/await-as-binding-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/await-as-identifier-reference-escaped.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/await-as-identifier-reference.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/await-as-label-identifier-escaped.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/await-as-label-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/browser.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/shell.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-as-binding-identifier-escaped.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-as-binding-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-as-identifier-reference-escaped.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-as-identifier-reference.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-as-label-identifier-escaped.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-as-label-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-identifier-spread-strict-strict.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-identifier-strict-strict.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-promise-reject-next-catch.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-promise-reject-next-for-await-of-async-iterator.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-promise-reject-next-for-await-of-sync-iterator.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-promise-reject-next-yield-star-async-iterator.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-promise-reject-next-yield-star-sync-iterator.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-promise-reject-next.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-spread-arr-multiple.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-spread-arr-single.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-spread-obj.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-async-next.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-async-return.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-async-throw.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-expr-abrupt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-getiter-async-get-abrupt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-getiter-async-not-callable-boolean-throw.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-getiter-async-not-callable-number-throw.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-getiter-async-not-callable-object-throw.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-getiter-async-not-callable-string-throw.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-getiter-async-not-callable-symbol-throw.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-getiter-async-null-sync-get-abrupt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-getiter-async-returns-abrupt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-getiter-async-returns-boolean-throw.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-getiter-async-returns-null-throw.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-getiter-async-returns-number-throw.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-getiter-async-returns-string-throw.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-getiter-async-returns-symbol-throw.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-getiter-async-returns-undefined-throw.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-getiter-async-undefined-sync-get-abrupt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-getiter-sync-get-abrupt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-getiter-sync-not-callable-boolean-throw.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-getiter-sync-not-callable-number-throw.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-getiter-sync-not-callable-object-throw.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-getiter-sync-not-callable-string-throw.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-getiter-sync-not-callable-symbol-throw.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-getiter-sync-returns-abrupt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-getiter-sync-returns-boolean-throw.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-getiter-sync-returns-null-throw.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-getiter-sync-returns-number-throw.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-getiter-sync-returns-string-throw.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-getiter-sync-returns-symbol-throw.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-getiter-sync-returns-undefined-throw.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-next-call-done-get-abrupt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-next-call-returns-abrupt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-next-call-value-get-abrupt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-next-get-abrupt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-next-non-object-ignores-then.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-next-not-callable-boolean-throw.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-next-not-callable-null-throw.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-next-not-callable-number-throw.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-next-not-callable-object-throw.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-next-not-callable-string-throw.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-next-not-callable-symbol-throw.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-next-not-callable-undefined-throw.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-next-then-get-abrupt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-next-then-non-callable-boolean-fulfillpromise.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-next-then-non-callable-null-fulfillpromise.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-next-then-non-callable-number-fulfillpromise.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-next-then-non-callable-object-fulfillpromise.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-next-then-non-callable-string-fulfillpromise.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-next-then-non-callable-symbol-fulfillpromise.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-next-then-non-callable-undefined-fulfillpromise.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-next-then-returns-abrupt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-sync-next.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-sync-return.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-sync-throw.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method/await-as-binding-identifier-escaped.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method/await-as-binding-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method/await-as-identifier-reference-escaped.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method/await-as-identifier-reference.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method/await-as-label-identifier-escaped.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method/await-as-label-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method/browser.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method/shell.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-as-binding-identifier-escaped.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-as-binding-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-as-identifier-reference-escaped.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-as-identifier-reference.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-as-label-identifier-escaped.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-as-label-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-identifier-spread-strict-strict.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-identifier-strict-strict.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-promise-reject-next-catch.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-promise-reject-next-for-await-of-async-iterator.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-promise-reject-next-for-await-of-sync-iterator.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-promise-reject-next-yield-star-async-iterator.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-promise-reject-next-yield-star-sync-iterator.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-promise-reject-next.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-spread-arr-multiple.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-spread-arr-single.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-spread-obj.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-async-next.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-async-return.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-async-throw.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-expr-abrupt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-getiter-async-get-abrupt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-getiter-async-not-callable-boolean-throw.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-getiter-async-not-callable-number-throw.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-getiter-async-not-callable-object-throw.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-getiter-async-not-callable-string-throw.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-getiter-async-not-callable-symbol-throw.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-getiter-async-null-sync-get-abrupt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-getiter-async-returns-abrupt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-getiter-async-returns-boolean-throw.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-getiter-async-returns-null-throw.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-getiter-async-returns-number-throw.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-getiter-async-returns-string-throw.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-getiter-async-returns-symbol-throw.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-getiter-async-returns-undefined-throw.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-getiter-async-undefined-sync-get-abrupt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-getiter-sync-get-abrupt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-getiter-sync-not-callable-boolean-throw.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-getiter-sync-not-callable-number-throw.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-getiter-sync-not-callable-object-throw.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-getiter-sync-not-callable-string-throw.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-getiter-sync-not-callable-symbol-throw.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-getiter-sync-returns-abrupt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-getiter-sync-returns-boolean-throw.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-getiter-sync-returns-null-throw.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-getiter-sync-returns-number-throw.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-getiter-sync-returns-string-throw.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-getiter-sync-returns-symbol-throw.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-getiter-sync-returns-undefined-throw.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-next-call-done-get-abrupt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-next-call-returns-abrupt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-next-call-value-get-abrupt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-next-get-abrupt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-next-non-object-ignores-then.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-next-not-callable-boolean-throw.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-next-not-callable-null-throw.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-next-not-callable-number-throw.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-next-not-callable-object-throw.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-next-not-callable-string-throw.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-next-not-callable-symbol-throw.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-next-not-callable-undefined-throw.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-next-then-get-abrupt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-next-then-non-callable-boolean-fulfillpromise.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-next-then-non-callable-null-fulfillpromise.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-next-then-non-callable-number-fulfillpromise.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-next-then-non-callable-object-fulfillpromise.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-next-then-non-callable-string-fulfillpromise.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-next-then-non-callable-symbol-fulfillpromise.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-next-then-non-callable-undefined-fulfillpromise.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-next-then-returns-abrupt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-sync-next.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-sync-return.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-sync-throw.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-private-method-static/await-as-binding-identifier-escaped.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-private-method-static/await-as-binding-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-private-method-static/await-as-identifier-reference-escaped.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-private-method-static/await-as-identifier-reference.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-private-method-static/await-as-label-identifier-escaped.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-private-method-static/await-as-label-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-private-method-static/browser.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-private-method-static/returns-async-arrow-returns-arguments-from-parent-function.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-private-method-static/returns-async-arrow-returns-newtarget.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-private-method-static/returns-async-arrow.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-private-method-static/returns-async-function-returns-arguments-from-own-function.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-private-method-static/returns-async-function-returns-newtarget.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-private-method-static/returns-async-function.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-private-method-static/shell.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-private-method/await-as-binding-identifier-escaped.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-private-method/await-as-binding-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-private-method/await-as-identifier-reference-escaped.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-private-method/await-as-identifier-reference.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-private-method/await-as-label-identifier-escaped.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-private-method/await-as-label-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-private-method/browser.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-private-method/returns-async-arrow-returns-arguments-from-parent-function.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-private-method/returns-async-arrow-returns-newtarget.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-private-method/returns-async-arrow.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-private-method/returns-async-function-returns-arguments-from-own-function.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-private-method/returns-async-function-returns-newtarget.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-private-method/returns-async-function.js create mode 100644 js/src/tests/test262/language/statements/class/elements/async-private-method/shell.js create mode 100644 js/src/tests/test262/language/statements/class/elements/browser.js create mode 100644 js/src/tests/test262/language/statements/class/elements/class-field-is-observable-by-proxy.js create mode 100644 js/src/tests/test262/language/statements/class/elements/class-field-on-frozen-objects-strict.js create mode 100644 js/src/tests/test262/language/statements/class/elements/comp-name-init-err-contains-arguments.js create mode 100644 js/src/tests/test262/language/statements/class/elements/comp-name-init-err-contains-super.js create mode 100644 js/src/tests/test262/language/statements/class/elements/computed-name-toprimitive-symbol.js create mode 100644 js/src/tests/test262/language/statements/class/elements/computed-name-toprimitive.js create mode 100644 js/src/tests/test262/language/statements/class/elements/computed-property-abrupt-completition.js create mode 100644 js/src/tests/test262/language/statements/class/elements/ctor-called-after-fields-init.js create mode 100644 js/src/tests/test262/language/statements/class/elements/derived-cls-direct-eval-contains-superproperty-1.js create mode 100644 js/src/tests/test262/language/statements/class/elements/derived-cls-direct-eval-contains-superproperty-2.js create mode 100644 js/src/tests/test262/language/statements/class/elements/derived-cls-direct-eval-err-contains-supercall-1.js create mode 100644 js/src/tests/test262/language/statements/class/elements/derived-cls-direct-eval-err-contains-supercall-2.js create mode 100644 js/src/tests/test262/language/statements/class/elements/derived-cls-direct-eval-err-contains-supercall.js create mode 100644 js/src/tests/test262/language/statements/class/elements/derived-cls-indirect-eval-contains-superproperty-1.js create mode 100644 js/src/tests/test262/language/statements/class/elements/derived-cls-indirect-eval-contains-superproperty-2.js create mode 100644 js/src/tests/test262/language/statements/class/elements/derived-cls-indirect-eval-err-contains-supercall-1.js create mode 100644 js/src/tests/test262/language/statements/class/elements/derived-cls-indirect-eval-err-contains-supercall-2.js create mode 100644 js/src/tests/test262/language/statements/class/elements/derived-cls-indirect-eval-err-contains-supercall.js create mode 100644 js/src/tests/test262/language/statements/class/elements/direct-eval-err-contains-arguments.js create mode 100644 js/src/tests/test262/language/statements/class/elements/direct-eval-err-contains-newtarget.js create mode 100644 js/src/tests/test262/language/statements/class/elements/equality-init-err-contains-arguments.js create mode 100644 js/src/tests/test262/language/statements/class/elements/equality-init-err-contains-super.js create mode 100644 js/src/tests/test262/language/statements/class/elements/evaluation-error/browser.js create mode 100644 js/src/tests/test262/language/statements/class/elements/evaluation-error/computed-name-referenceerror.js create mode 100644 js/src/tests/test262/language/statements/class/elements/evaluation-error/computed-name-toprimitive-err.js create mode 100644 js/src/tests/test262/language/statements/class/elements/evaluation-error/computed-name-toprimitive-returns-noncallable.js create mode 100644 js/src/tests/test262/language/statements/class/elements/evaluation-error/computed-name-toprimitive-returns-nonobject.js create mode 100644 js/src/tests/test262/language/statements/class/elements/evaluation-error/computed-name-tostring-err.js create mode 100644 js/src/tests/test262/language/statements/class/elements/evaluation-error/computed-name-valueof-err.js create mode 100644 js/src/tests/test262/language/statements/class/elements/evaluation-error/shell.js create mode 100644 js/src/tests/test262/language/statements/class/elements/field-declaration.js create mode 100644 js/src/tests/test262/language/statements/class/elements/field-definition-accessor-no-line-terminator.js create mode 100644 js/src/tests/test262/language/statements/class/elements/fielddefinition-initializer-abrupt-completion.js create mode 100644 js/src/tests/test262/language/statements/class/elements/fields-anonymous-function-length.js create mode 100644 js/src/tests/test262/language/statements/class/elements/fields-asi-1.js create mode 100644 js/src/tests/test262/language/statements/class/elements/fields-asi-2.js create mode 100644 js/src/tests/test262/language/statements/class/elements/fields-asi-3.js create mode 100644 js/src/tests/test262/language/statements/class/elements/fields-asi-4.js create mode 100644 js/src/tests/test262/language/statements/class/elements/fields-asi-5.js create mode 100644 js/src/tests/test262/language/statements/class/elements/fields-asi-same-line-1.js create mode 100644 js/src/tests/test262/language/statements/class/elements/fields-asi-same-line-2.js create mode 100644 js/src/tests/test262/language/statements/class/elements/fields-computed-name-propname-constructor.js create mode 100644 js/src/tests/test262/language/statements/class/elements/fields-computed-name-static-computed-var-propname-constructor.js create mode 100644 js/src/tests/test262/language/statements/class/elements/fields-computed-name-static-computed-var-propname-prototype.js create mode 100644 js/src/tests/test262/language/statements/class/elements/fields-computed-name-static-propname-constructor.js create mode 100644 js/src/tests/test262/language/statements/class/elements/fields-computed-name-static-propname-prototype.js create mode 100644 js/src/tests/test262/language/statements/class/elements/fields-duplicate-privatenames.js create mode 100644 js/src/tests/test262/language/statements/class/elements/fields-hash-constructor-is-a-valid-name.js create mode 100644 js/src/tests/test262/language/statements/class/elements/fields-literal-name-propname-constructor.js create mode 100644 js/src/tests/test262/language/statements/class/elements/fields-literal-name-static-propname-constructor.js create mode 100644 js/src/tests/test262/language/statements/class/elements/fields-literal-name-static-propname-prototype.js create mode 100644 js/src/tests/test262/language/statements/class/elements/fields-string-name-propname-constructor.js create mode 100644 js/src/tests/test262/language/statements/class/elements/fields-string-name-static-propname-constructor.js create mode 100644 js/src/tests/test262/language/statements/class/elements/fields-string-name-static-propname-prototype.js create mode 100644 js/src/tests/test262/language/statements/class/elements/gen-private-method-static/browser.js create mode 100644 js/src/tests/test262/language/statements/class/elements/gen-private-method-static/shell.js create mode 100644 js/src/tests/test262/language/statements/class/elements/gen-private-method-static/yield-as-binding-identifier-escaped.js create mode 100644 js/src/tests/test262/language/statements/class/elements/gen-private-method-static/yield-as-binding-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/gen-private-method-static/yield-as-identifier-reference-escaped.js create mode 100644 js/src/tests/test262/language/statements/class/elements/gen-private-method-static/yield-as-identifier-reference.js create mode 100644 js/src/tests/test262/language/statements/class/elements/gen-private-method-static/yield-as-label-identifier-escaped.js create mode 100644 js/src/tests/test262/language/statements/class/elements/gen-private-method-static/yield-as-label-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/gen-private-method-static/yield-identifier-spread-strict-strict.js create mode 100644 js/src/tests/test262/language/statements/class/elements/gen-private-method-static/yield-identifier-strict-strict.js create mode 100644 js/src/tests/test262/language/statements/class/elements/gen-private-method-static/yield-spread-arr-multiple.js create mode 100644 js/src/tests/test262/language/statements/class/elements/gen-private-method-static/yield-spread-arr-single.js create mode 100644 js/src/tests/test262/language/statements/class/elements/gen-private-method-static/yield-spread-obj.js create mode 100644 js/src/tests/test262/language/statements/class/elements/gen-private-method/browser.js create mode 100644 js/src/tests/test262/language/statements/class/elements/gen-private-method/shell.js create mode 100644 js/src/tests/test262/language/statements/class/elements/gen-private-method/yield-as-binding-identifier-escaped.js create mode 100644 js/src/tests/test262/language/statements/class/elements/gen-private-method/yield-as-binding-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/gen-private-method/yield-as-identifier-reference-escaped.js create mode 100644 js/src/tests/test262/language/statements/class/elements/gen-private-method/yield-as-identifier-reference.js create mode 100644 js/src/tests/test262/language/statements/class/elements/gen-private-method/yield-as-label-identifier-escaped.js create mode 100644 js/src/tests/test262/language/statements/class/elements/gen-private-method/yield-as-label-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/gen-private-method/yield-identifier-spread-strict-strict.js create mode 100644 js/src/tests/test262/language/statements/class/elements/gen-private-method/yield-identifier-strict-strict.js create mode 100644 js/src/tests/test262/language/statements/class/elements/gen-private-method/yield-spread-arr-multiple.js create mode 100644 js/src/tests/test262/language/statements/class/elements/gen-private-method/yield-spread-arr-single.js create mode 100644 js/src/tests/test262/language/statements/class/elements/gen-private-method/yield-spread-obj.js create mode 100644 js/src/tests/test262/language/statements/class/elements/get-access-of-missing-private-getter.js create mode 100644 js/src/tests/test262/language/statements/class/elements/get-access-of-missing-private-static-getter.js create mode 100644 js/src/tests/test262/language/statements/class/elements/get-access-of-missing-shadowed-private-getter.js create mode 100644 js/src/tests/test262/language/statements/class/elements/grammar-private-field-optional-chaining.js create mode 100644 js/src/tests/test262/language/statements/class/elements/indirect-eval-contains-arguments.js create mode 100644 js/src/tests/test262/language/statements/class/elements/indirect-eval-err-contains-newtarget.js create mode 100644 js/src/tests/test262/language/statements/class/elements/init-err-evaluation.js create mode 100644 js/src/tests/test262/language/statements/class/elements/init-value-defined-after-class.js create mode 100644 js/src/tests/test262/language/statements/class/elements/init-value-incremental.js create mode 100644 js/src/tests/test262/language/statements/class/elements/intercalated-static-non-static-computed-fields.js create mode 100644 js/src/tests/test262/language/statements/class/elements/literal-name-init-err-contains-arguments.js create mode 100644 js/src/tests/test262/language/statements/class/elements/literal-name-init-err-contains-super.js create mode 100644 js/src/tests/test262/language/statements/class/elements/multiple-definitions-computed-names.js create mode 100644 js/src/tests/test262/language/statements/class/elements/multiple-definitions-computed-symbol-names.js create mode 100644 js/src/tests/test262/language/statements/class/elements/multiple-definitions-grammar-privatename-identifier-semantics-stringvalue.js create mode 100644 js/src/tests/test262/language/statements/class/elements/multiple-definitions-literal-names-asi.js create mode 100644 js/src/tests/test262/language/statements/class/elements/multiple-definitions-literal-names.js create mode 100644 js/src/tests/test262/language/statements/class/elements/multiple-definitions-private-field-usage.js create mode 100644 js/src/tests/test262/language/statements/class/elements/multiple-definitions-private-method-getter-usage.js create mode 100644 js/src/tests/test262/language/statements/class/elements/multiple-definitions-private-method-usage.js create mode 100644 js/src/tests/test262/language/statements/class/elements/multiple-definitions-private-names.js create mode 100644 js/src/tests/test262/language/statements/class/elements/multiple-definitions-rs-field-identifier-initializer.js create mode 100644 js/src/tests/test262/language/statements/class/elements/multiple-definitions-rs-field-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/multiple-definitions-rs-private-getter-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/multiple-definitions-rs-private-getter.js create mode 100644 js/src/tests/test262/language/statements/class/elements/multiple-definitions-rs-private-method-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/multiple-definitions-rs-private-method.js create mode 100644 js/src/tests/test262/language/statements/class/elements/multiple-definitions-rs-private-setter-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/multiple-definitions-rs-private-setter.js create mode 100644 js/src/tests/test262/language/statements/class/elements/multiple-definitions-rs-privatename-identifier-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/multiple-definitions-rs-privatename-identifier-initializer-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/multiple-definitions-rs-privatename-identifier-initializer.js create mode 100644 js/src/tests/test262/language/statements/class/elements/multiple-definitions-rs-privatename-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/multiple-definitions-rs-static-async-generator-method-privatename-identifier-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/multiple-definitions-rs-static-async-generator-method-privatename-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/multiple-definitions-rs-static-async-method-privatename-identifier-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/multiple-definitions-rs-static-async-method-privatename-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/multiple-definitions-rs-static-generator-method-privatename-identifier-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/multiple-definitions-rs-static-generator-method-privatename-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/multiple-definitions-rs-static-method-privatename-identifier-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/multiple-definitions-rs-static-method-privatename-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/multiple-definitions-rs-static-privatename-identifier-alt-by-classname.js create mode 100644 js/src/tests/test262/language/statements/class/elements/multiple-definitions-rs-static-privatename-identifier-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/multiple-definitions-rs-static-privatename-identifier-by-classname.js create mode 100644 js/src/tests/test262/language/statements/class/elements/multiple-definitions-rs-static-privatename-identifier-initializer-alt-by-classname.js create mode 100644 js/src/tests/test262/language/statements/class/elements/multiple-definitions-rs-static-privatename-identifier-initializer-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/multiple-definitions-rs-static-privatename-identifier-initializer.js create mode 100644 js/src/tests/test262/language/statements/class/elements/multiple-definitions-rs-static-privatename-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/multiple-definitions-static-private-fields.js create mode 100644 js/src/tests/test262/language/statements/class/elements/multiple-definitions-static-private-methods-with-fields.js create mode 100644 js/src/tests/test262/language/statements/class/elements/multiple-definitions-static-private-methods.js create mode 100644 js/src/tests/test262/language/statements/class/elements/multiple-definitions-string-literal-names.js create mode 100644 js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-computed-names.js create mode 100644 js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-computed-symbol-names.js create mode 100644 js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-grammar-privatename-identifier-semantics-stringvalue.js create mode 100644 js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-literal-names-asi.js create mode 100644 js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-literal-names.js create mode 100644 js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-private-field-usage.js create mode 100644 js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-private-method-getter-usage.js create mode 100644 js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-private-method-usage.js create mode 100644 js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-private-names.js create mode 100644 js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-rs-field-identifier-initializer.js create mode 100644 js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-rs-field-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-rs-private-getter-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-rs-private-getter.js create mode 100644 js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-rs-private-method-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-rs-private-method.js create mode 100644 js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-rs-private-setter-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-rs-private-setter.js create mode 100644 js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-rs-privatename-identifier-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-rs-privatename-identifier-initializer-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-rs-privatename-identifier-initializer.js create mode 100644 js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-rs-privatename-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-rs-static-async-generator-method-privatename-identifier-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-rs-static-async-generator-method-privatename-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-rs-static-async-method-privatename-identifier-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-rs-static-async-method-privatename-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-rs-static-generator-method-privatename-identifier-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-rs-static-generator-method-privatename-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-rs-static-method-privatename-identifier-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-rs-static-method-privatename-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-rs-static-privatename-identifier-alt-by-classname.js create mode 100644 js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-rs-static-privatename-identifier-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-rs-static-privatename-identifier-by-classname.js create mode 100644 js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-rs-static-privatename-identifier-initializer-alt-by-classname.js create mode 100644 js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-rs-static-privatename-identifier-initializer-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-rs-static-privatename-identifier-initializer.js create mode 100644 js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-rs-static-privatename-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-static-private-fields.js create mode 100644 js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-static-private-methods-with-fields.js create mode 100644 js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-static-private-methods.js create mode 100644 js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-string-literal-names.js create mode 100644 js/src/tests/test262/language/statements/class/elements/nested-arrow-fnc-init-err-contains-arguments.js create mode 100644 js/src/tests/test262/language/statements/class/elements/nested-arrow-fnc-init-err-contains-super.js create mode 100644 js/src/tests/test262/language/statements/class/elements/nested-comp-name-init-err-contains-arguments.js create mode 100644 js/src/tests/test262/language/statements/class/elements/nested-comp-name-init-err-contains-super.js create mode 100644 js/src/tests/test262/language/statements/class/elements/nested-derived-cls-direct-eval-contains-superproperty-1.js create mode 100644 js/src/tests/test262/language/statements/class/elements/nested-derived-cls-direct-eval-contains-superproperty-2.js create mode 100644 js/src/tests/test262/language/statements/class/elements/nested-derived-cls-direct-eval-err-contains-supercall-1.js create mode 100644 js/src/tests/test262/language/statements/class/elements/nested-derived-cls-direct-eval-err-contains-supercall-2.js create mode 100644 js/src/tests/test262/language/statements/class/elements/nested-derived-cls-direct-eval-err-contains-supercall.js create mode 100644 js/src/tests/test262/language/statements/class/elements/nested-derived-cls-indirect-eval-contains-superproperty-1.js create mode 100644 js/src/tests/test262/language/statements/class/elements/nested-derived-cls-indirect-eval-contains-superproperty-2.js create mode 100644 js/src/tests/test262/language/statements/class/elements/nested-derived-cls-indirect-eval-err-contains-supercall-1.js create mode 100644 js/src/tests/test262/language/statements/class/elements/nested-derived-cls-indirect-eval-err-contains-supercall-2.js create mode 100644 js/src/tests/test262/language/statements/class/elements/nested-derived-cls-indirect-eval-err-contains-supercall.js create mode 100644 js/src/tests/test262/language/statements/class/elements/nested-direct-eval-err-contains-arguments.js create mode 100644 js/src/tests/test262/language/statements/class/elements/nested-direct-eval-err-contains-newtarget.js create mode 100644 js/src/tests/test262/language/statements/class/elements/nested-equality-init-err-contains-arguments.js create mode 100644 js/src/tests/test262/language/statements/class/elements/nested-equality-init-err-contains-super.js create mode 100644 js/src/tests/test262/language/statements/class/elements/nested-indirect-eval-contains-arguments.js create mode 100644 js/src/tests/test262/language/statements/class/elements/nested-indirect-eval-err-contains-newtarget.js create mode 100644 js/src/tests/test262/language/statements/class/elements/nested-literal-name-init-err-contains-arguments.js create mode 100644 js/src/tests/test262/language/statements/class/elements/nested-literal-name-init-err-contains-super.js create mode 100644 js/src/tests/test262/language/statements/class/elements/nested-private-arrow-fnc-init-err-contains-arguments.js create mode 100644 js/src/tests/test262/language/statements/class/elements/nested-private-arrow-fnc-init-err-contains-super.js create mode 100644 js/src/tests/test262/language/statements/class/elements/nested-private-derived-cls-direct-eval-contains-superproperty-1.js create mode 100644 js/src/tests/test262/language/statements/class/elements/nested-private-derived-cls-direct-eval-contains-superproperty-2.js create mode 100644 js/src/tests/test262/language/statements/class/elements/nested-private-derived-cls-direct-eval-err-contains-supercall-1.js create mode 100644 js/src/tests/test262/language/statements/class/elements/nested-private-derived-cls-direct-eval-err-contains-supercall-2.js create mode 100644 js/src/tests/test262/language/statements/class/elements/nested-private-derived-cls-direct-eval-err-contains-supercall.js create mode 100644 js/src/tests/test262/language/statements/class/elements/nested-private-derived-cls-indirect-eval-contains-superproperty-1.js create mode 100644 js/src/tests/test262/language/statements/class/elements/nested-private-derived-cls-indirect-eval-contains-superproperty-2.js create mode 100644 js/src/tests/test262/language/statements/class/elements/nested-private-derived-cls-indirect-eval-err-contains-supercall-1.js create mode 100644 js/src/tests/test262/language/statements/class/elements/nested-private-derived-cls-indirect-eval-err-contains-supercall-2.js create mode 100644 js/src/tests/test262/language/statements/class/elements/nested-private-derived-cls-indirect-eval-err-contains-supercall.js create mode 100644 js/src/tests/test262/language/statements/class/elements/nested-private-direct-eval-err-contains-arguments.js create mode 100644 js/src/tests/test262/language/statements/class/elements/nested-private-direct-eval-err-contains-newtarget.js create mode 100644 js/src/tests/test262/language/statements/class/elements/nested-private-indirect-eval-contains-arguments.js create mode 100644 js/src/tests/test262/language/statements/class/elements/nested-private-indirect-eval-err-contains-newtarget.js create mode 100644 js/src/tests/test262/language/statements/class/elements/nested-private-literal-name-init-err-contains-arguments.js create mode 100644 js/src/tests/test262/language/statements/class/elements/nested-private-literal-name-init-err-contains-super.js create mode 100644 js/src/tests/test262/language/statements/class/elements/nested-private-ternary-init-err-contains-arguments.js create mode 100644 js/src/tests/test262/language/statements/class/elements/nested-private-ternary-init-err-contains-super.js create mode 100644 js/src/tests/test262/language/statements/class/elements/nested-private-typeof-init-err-contains-arguments.js create mode 100644 js/src/tests/test262/language/statements/class/elements/nested-private-typeof-init-err-contains-super.js create mode 100644 js/src/tests/test262/language/statements/class/elements/nested-static-comp-name-init-err-contains-arguments.js create mode 100644 js/src/tests/test262/language/statements/class/elements/nested-static-comp-name-init-err-contains-super.js create mode 100644 js/src/tests/test262/language/statements/class/elements/nested-static-literal-init-err-contains-arguments.js create mode 100644 js/src/tests/test262/language/statements/class/elements/nested-static-literal-init-err-contains-super.js create mode 100644 js/src/tests/test262/language/statements/class/elements/nested-static-private-init-err-contains-arguments.js create mode 100644 js/src/tests/test262/language/statements/class/elements/nested-static-private-init-err-contains-super.js create mode 100644 js/src/tests/test262/language/statements/class/elements/nested-static-string-literal-name-init-err-contains-arguments.js create mode 100644 js/src/tests/test262/language/statements/class/elements/nested-static-string-literal-name-init-err-contains-super.js create mode 100644 js/src/tests/test262/language/statements/class/elements/nested-string-literal-name-init-err-contains-arguments.js create mode 100644 js/src/tests/test262/language/statements/class/elements/nested-string-literal-name-init-err-contains-super.js create mode 100644 js/src/tests/test262/language/statements/class/elements/nested-ternary-init-err-contains-arguments.js create mode 100644 js/src/tests/test262/language/statements/class/elements/nested-ternary-init-err-contains-super.js create mode 100644 js/src/tests/test262/language/statements/class/elements/nested-typeof-init-err-contains-arguments.js create mode 100644 js/src/tests/test262/language/statements/class/elements/nested-typeof-init-err-contains-super.js create mode 100644 js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-computed-names.js create mode 100644 js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-computed-symbol-names.js create mode 100644 js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-grammar-privatename-identifier-semantics-stringvalue.js create mode 100644 js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-literal-names-asi.js create mode 100644 js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-literal-names.js create mode 100644 js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-private-field-usage.js create mode 100644 js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-private-method-getter-usage.js create mode 100644 js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-private-method-usage.js create mode 100644 js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-private-names.js create mode 100644 js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-rs-field-identifier-initializer.js create mode 100644 js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-rs-field-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-rs-private-getter-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-rs-private-getter.js create mode 100644 js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-rs-private-method-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-rs-private-method.js create mode 100644 js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-rs-private-setter-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-rs-private-setter.js create mode 100644 js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-rs-privatename-identifier-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-rs-privatename-identifier-initializer-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-rs-privatename-identifier-initializer.js create mode 100644 js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-rs-privatename-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-rs-static-async-generator-method-privatename-identifier-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-rs-static-async-generator-method-privatename-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-rs-static-async-method-privatename-identifier-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-rs-static-async-method-privatename-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-rs-static-generator-method-privatename-identifier-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-rs-static-generator-method-privatename-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-rs-static-method-privatename-identifier-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-rs-static-method-privatename-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-rs-static-privatename-identifier-alt-by-classname.js create mode 100644 js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-rs-static-privatename-identifier-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-rs-static-privatename-identifier-by-classname.js create mode 100644 js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-rs-static-privatename-identifier-initializer-alt-by-classname.js create mode 100644 js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-rs-static-privatename-identifier-initializer-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-rs-static-privatename-identifier-initializer.js create mode 100644 js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-rs-static-privatename-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-static-private-fields.js create mode 100644 js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-static-private-methods-with-fields.js create mode 100644 js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-static-private-methods.js create mode 100644 js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-string-literal-names.js create mode 100644 js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-computed-names.js create mode 100644 js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-computed-symbol-names.js create mode 100644 js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-grammar-privatename-identifier-semantics-stringvalue.js create mode 100644 js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-literal-names-asi.js create mode 100644 js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-literal-names.js create mode 100644 js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-private-field-usage.js create mode 100644 js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-private-method-getter-usage.js create mode 100644 js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-private-method-usage.js create mode 100644 js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-private-names.js create mode 100644 js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-rs-field-identifier-initializer.js create mode 100644 js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-rs-field-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-rs-private-getter-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-rs-private-getter.js create mode 100644 js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-rs-private-method-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-rs-private-method.js create mode 100644 js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-rs-private-setter-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-rs-private-setter.js create mode 100644 js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-rs-privatename-identifier-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-rs-privatename-identifier-initializer-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-rs-privatename-identifier-initializer.js create mode 100644 js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-rs-privatename-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-rs-static-async-generator-method-privatename-identifier-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-rs-static-async-generator-method-privatename-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-rs-static-async-method-privatename-identifier-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-rs-static-async-method-privatename-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-rs-static-generator-method-privatename-identifier-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-rs-static-generator-method-privatename-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-rs-static-method-privatename-identifier-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-rs-static-method-privatename-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-rs-static-privatename-identifier-alt-by-classname.js create mode 100644 js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-rs-static-privatename-identifier-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-rs-static-privatename-identifier-by-classname.js create mode 100644 js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-rs-static-privatename-identifier-initializer-alt-by-classname.js create mode 100644 js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-rs-static-privatename-identifier-initializer-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-rs-static-privatename-identifier-initializer.js create mode 100644 js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-rs-static-privatename-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-static-private-fields.js create mode 100644 js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-static-private-methods-with-fields.js create mode 100644 js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-static-private-methods.js create mode 100644 js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-string-literal-names.js create mode 100644 js/src/tests/test262/language/statements/class/elements/new-sc-line-method-computed-names.js create mode 100644 js/src/tests/test262/language/statements/class/elements/new-sc-line-method-computed-symbol-names.js create mode 100644 js/src/tests/test262/language/statements/class/elements/new-sc-line-method-grammar-privatename-identifier-semantics-stringvalue.js create mode 100644 js/src/tests/test262/language/statements/class/elements/new-sc-line-method-literal-names-asi.js create mode 100644 js/src/tests/test262/language/statements/class/elements/new-sc-line-method-literal-names.js create mode 100644 js/src/tests/test262/language/statements/class/elements/new-sc-line-method-private-field-usage.js create mode 100644 js/src/tests/test262/language/statements/class/elements/new-sc-line-method-private-method-getter-usage.js create mode 100644 js/src/tests/test262/language/statements/class/elements/new-sc-line-method-private-method-usage.js create mode 100644 js/src/tests/test262/language/statements/class/elements/new-sc-line-method-private-names.js create mode 100644 js/src/tests/test262/language/statements/class/elements/new-sc-line-method-rs-field-identifier-initializer.js create mode 100644 js/src/tests/test262/language/statements/class/elements/new-sc-line-method-rs-field-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/new-sc-line-method-rs-private-getter-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/new-sc-line-method-rs-private-getter.js create mode 100644 js/src/tests/test262/language/statements/class/elements/new-sc-line-method-rs-private-method-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/new-sc-line-method-rs-private-method.js create mode 100644 js/src/tests/test262/language/statements/class/elements/new-sc-line-method-rs-private-setter-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/new-sc-line-method-rs-private-setter.js create mode 100644 js/src/tests/test262/language/statements/class/elements/new-sc-line-method-rs-privatename-identifier-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/new-sc-line-method-rs-privatename-identifier-initializer-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/new-sc-line-method-rs-privatename-identifier-initializer.js create mode 100644 js/src/tests/test262/language/statements/class/elements/new-sc-line-method-rs-privatename-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/new-sc-line-method-rs-static-async-generator-method-privatename-identifier-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/new-sc-line-method-rs-static-async-generator-method-privatename-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/new-sc-line-method-rs-static-async-method-privatename-identifier-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/new-sc-line-method-rs-static-async-method-privatename-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/new-sc-line-method-rs-static-generator-method-privatename-identifier-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/new-sc-line-method-rs-static-generator-method-privatename-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/new-sc-line-method-rs-static-method-privatename-identifier-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/new-sc-line-method-rs-static-method-privatename-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/new-sc-line-method-rs-static-privatename-identifier-alt-by-classname.js create mode 100644 js/src/tests/test262/language/statements/class/elements/new-sc-line-method-rs-static-privatename-identifier-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/new-sc-line-method-rs-static-privatename-identifier-by-classname.js create mode 100644 js/src/tests/test262/language/statements/class/elements/new-sc-line-method-rs-static-privatename-identifier-initializer-alt-by-classname.js create mode 100644 js/src/tests/test262/language/statements/class/elements/new-sc-line-method-rs-static-privatename-identifier-initializer-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/new-sc-line-method-rs-static-privatename-identifier-initializer.js create mode 100644 js/src/tests/test262/language/statements/class/elements/new-sc-line-method-rs-static-privatename-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/new-sc-line-method-static-private-fields.js create mode 100644 js/src/tests/test262/language/statements/class/elements/new-sc-line-method-static-private-methods-with-fields.js create mode 100644 js/src/tests/test262/language/statements/class/elements/new-sc-line-method-static-private-methods.js create mode 100644 js/src/tests/test262/language/statements/class/elements/new-sc-line-method-string-literal-names.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-accessor-is-visible-in-computed-properties.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-accessor-name/browser.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-accessor-name/inst-private-escape-sequence-ZWJ.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-accessor-name/inst-private-escape-sequence-ZWNJ.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-accessor-name/inst-private-escape-sequence-u2118.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-accessor-name/inst-private-escape-sequence-u6F.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-accessor-name/inst-private-name-ZWJ.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-accessor-name/inst-private-name-ZWNJ.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-accessor-name/inst-private-name-common.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-accessor-name/inst-private-name-dollar.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-accessor-name/inst-private-name-u2118.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-accessor-name/inst-private-name-underscore.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-accessor-name/shell.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-accessor-name/static-private-escape-sequence-ZWJ.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-accessor-name/static-private-escape-sequence-ZWNJ.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-accessor-name/static-private-escape-sequence-u2118.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-accessor-name/static-private-escape-sequence-u6F.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-accessor-name/static-private-name-ZWJ.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-accessor-name/static-private-name-ZWNJ.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-accessor-name/static-private-name-common.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-accessor-name/static-private-name-dollar.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-accessor-name/static-private-name-u2118.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-accessor-name/static-private-name-underscore.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-arrow-fnc-init-err-contains-arguments.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-arrow-fnc-init-err-contains-super.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-async-generator-method-name.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-async-method-name.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-class-field-on-frozen-objects-strict.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-derived-cls-direct-eval-contains-superproperty-1.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-derived-cls-direct-eval-contains-superproperty-2.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-derived-cls-direct-eval-err-contains-supercall-1.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-derived-cls-direct-eval-err-contains-supercall-2.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-derived-cls-direct-eval-err-contains-supercall.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-derived-cls-indirect-eval-contains-superproperty-1.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-derived-cls-indirect-eval-contains-superproperty-2.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-derived-cls-indirect-eval-err-contains-supercall-1.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-derived-cls-indirect-eval-err-contains-supercall-2.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-derived-cls-indirect-eval-err-contains-supercall.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-direct-eval-err-contains-arguments.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-direct-eval-err-contains-newtarget.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-field-access-on-inner-arrow-function.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-field-access-on-inner-function.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-field-after-optional-chain.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-field-as-arrow-function.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-field-as-async-arrow-function.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-field-as-async-function.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-field-as-function.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-field-is-not-clobbered-by-computed-property.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-field-is-visible-in-computed-properties.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-field-on-nested-class.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-field-visible-to-direct-eval-on-initializer.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-field-visible-to-direct-eval.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-field-with-initialized-id-is-visible-in-computed-properties.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-generator-method-name.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-getter-access-on-inner-arrow-function.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-getter-access-on-inner-function.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-getter-brand-check-multiple-evaluations-of-class.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-getter-brand-check-super-class.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-getter-brand-check.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-getter-is-not-a-own-property.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-getter-is-not-clobbered-by-computed-property.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-getter-on-nested-class.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-getter-shadowed-by-field-on-nested-class.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-getter-shadowed-by-getter-on-nested-class.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-getter-shadowed-by-method-on-nested-class.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-getter-shadowed-by-setter-on-nested-class.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-getter-visible-to-direct-eval-on-initializer.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-getter-visible-to-direct-eval.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-indirect-eval-contains-arguments.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-indirect-eval-err-contains-newtarget.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-literal-name-init-err-contains-arguments.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-literal-name-init-err-contains-super.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-method-access-on-inner-arrow-function.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-method-access-on-inner-function.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-method-brand-check-multiple-evaluations-of-class.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-method-brand-check-super-class.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-method-brand-check.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-method-comparison-multiple-evaluations-of-class.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-method-comparison.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-method-double-initialisation-get-and-set.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-method-double-initialisation-get.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-method-double-initialisation-set.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-method-double-initialisation.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-method-get-and-call.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-method-is-not-a-own-property.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-method-is-not-clobbered-by-computed-property.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-method-is-visible-in-computed-properties.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-method-length.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-method-not-writable.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-method-on-nested-class.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-method-referenced-from-static-method.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-method-shadowed-by-field-on-nested-class.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-method-shadowed-by-getter-on-nested-class.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-method-shadowed-by-setter-on-nested-class.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-method-shadowed-on-nested-class.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-method-visible-to-direct-eval-on-initializer.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-method-visible-to-direct-eval.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-methods/browser.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-methods/prod-private-async-generator.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-methods/prod-private-async-method.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-methods/prod-private-generator.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-methods/prod-private-method-initialize-order.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-methods/prod-private-method.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-methods/shell.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-setter-access-on-inner-arrow-function.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-setter-access-on-inner-function.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-setter-brand-check-multiple-evaluations-of-class.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-setter-brand-check-super-class.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-setter-brand-check.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-setter-is-not-a-own-property.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-setter-is-not-clobbered-by-computed-property.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-setter-on-nested-class.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-setter-shadowed-by-field-on-nested-class.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-setter-shadowed-by-getter-on-nested-class.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-setter-shadowed-by-method-on-nested-class.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-setter-shadowed-by-setter-on-nested-class.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-setter-visible-to-direct-eval-on-initializer.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-setter-visible-to-direct-eval.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-static-async-generator-method-name.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-static-async-method-name.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-static-field-shadowed-by-field-on-nested-class.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-static-field-shadowed-by-getter-on-nested-class.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-static-field-shadowed-by-method-on-nested-class.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-static-field-shadowed-by-setter-on-nested-class.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-static-field-usage-inside-nested-class.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-static-field-visible-to-direct-eval.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-static-generator-method-name.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-static-getter-abrupt-completition.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-static-getter-visible-to-direct-eval.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-static-method-length.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-static-method-name.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-static-method-not-writable.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-static-method-shadowed-by-field-on-nested-class.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-static-method-shadowed-by-getter-on-nested-class.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-static-method-shadowed-by-method-on-nested-class.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-static-method-shadowed-by-setter-on-nested-class.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-static-method-usage-inside-nested-class.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-static-method-visible-to-direct-eval.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-static-setter-abrupt-completition.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-static-setter-visible-to-direct-eval.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-ternary-init-err-contains-arguments.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-ternary-init-err-contains-super.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-typeof-init-err-contains-arguments.js create mode 100644 js/src/tests/test262/language/statements/class/elements/private-typeof-init-err-contains-super.js create mode 100644 js/src/tests/test262/language/statements/class/elements/privatefield-on-proxy.js create mode 100644 js/src/tests/test262/language/statements/class/elements/privatefieldadd-typeerror.js create mode 100644 js/src/tests/test262/language/statements/class/elements/privatefieldget-primitive-receiver.js create mode 100644 js/src/tests/test262/language/statements/class/elements/privatefieldget-success-1.js create mode 100644 js/src/tests/test262/language/statements/class/elements/privatefieldget-success-2.js create mode 100644 js/src/tests/test262/language/statements/class/elements/privatefieldget-success-3.js create mode 100644 js/src/tests/test262/language/statements/class/elements/privatefieldget-success-4.js create mode 100644 js/src/tests/test262/language/statements/class/elements/privatefieldget-success-5.js create mode 100644 js/src/tests/test262/language/statements/class/elements/privatefieldget-typeerror-1.js create mode 100644 js/src/tests/test262/language/statements/class/elements/privatefieldget-typeerror-2.js create mode 100644 js/src/tests/test262/language/statements/class/elements/privatefieldget-typeerror-3.js create mode 100644 js/src/tests/test262/language/statements/class/elements/privatefieldget-typeerror-4.js create mode 100644 js/src/tests/test262/language/statements/class/elements/privatefieldget-typeerror-5.js create mode 100644 js/src/tests/test262/language/statements/class/elements/privatefieldput-primitive-receiver.js create mode 100644 js/src/tests/test262/language/statements/class/elements/privatefieldset-evaluation-order-1.js create mode 100644 js/src/tests/test262/language/statements/class/elements/privatefieldset-evaluation-order-2.js create mode 100644 js/src/tests/test262/language/statements/class/elements/privatefieldset-evaluation-order-3.js create mode 100644 js/src/tests/test262/language/statements/class/elements/privatefieldset-typeerror-1.js create mode 100644 js/src/tests/test262/language/statements/class/elements/privatefieldset-typeerror-10.js create mode 100644 js/src/tests/test262/language/statements/class/elements/privatefieldset-typeerror-11.js create mode 100644 js/src/tests/test262/language/statements/class/elements/privatefieldset-typeerror-2.js create mode 100644 js/src/tests/test262/language/statements/class/elements/privatefieldset-typeerror-3.js create mode 100644 js/src/tests/test262/language/statements/class/elements/privatefieldset-typeerror-4.js create mode 100644 js/src/tests/test262/language/statements/class/elements/privatefieldset-typeerror-5.js create mode 100644 js/src/tests/test262/language/statements/class/elements/privatefieldset-typeerror-6.js create mode 100644 js/src/tests/test262/language/statements/class/elements/privatefieldset-typeerror-7.js create mode 100644 js/src/tests/test262/language/statements/class/elements/privatefieldset-typeerror-8.js create mode 100644 js/src/tests/test262/language/statements/class/elements/privatefieldset-typeerror-9.js create mode 100644 js/src/tests/test262/language/statements/class/elements/privategetter-on-proxy.js create mode 100644 js/src/tests/test262/language/statements/class/elements/privatemethods-on-proxy.js create mode 100644 js/src/tests/test262/language/statements/class/elements/privatename-not-valid-earlyerr-script-1.js create mode 100644 js/src/tests/test262/language/statements/class/elements/privatename-not-valid-earlyerr-script-2.js create mode 100644 js/src/tests/test262/language/statements/class/elements/privatename-not-valid-earlyerr-script-3.js create mode 100644 js/src/tests/test262/language/statements/class/elements/privatename-not-valid-earlyerr-script-4.js create mode 100644 js/src/tests/test262/language/statements/class/elements/privatename-not-valid-earlyerr-script-5.js create mode 100644 js/src/tests/test262/language/statements/class/elements/privatename-not-valid-earlyerr-script-6.js create mode 100644 js/src/tests/test262/language/statements/class/elements/privatename-not-valid-earlyerr-script-7.js create mode 100644 js/src/tests/test262/language/statements/class/elements/privatename-not-valid-earlyerr-script-8.js create mode 100644 js/src/tests/test262/language/statements/class/elements/privatename-not-valid-eval-earlyerr-1.js create mode 100644 js/src/tests/test262/language/statements/class/elements/privatename-not-valid-eval-earlyerr-2.js create mode 100644 js/src/tests/test262/language/statements/class/elements/privatename-not-valid-eval-earlyerr-3.js create mode 100644 js/src/tests/test262/language/statements/class/elements/privatename-not-valid-eval-earlyerr-4.js create mode 100644 js/src/tests/test262/language/statements/class/elements/privatename-not-valid-eval-earlyerr-5.js create mode 100644 js/src/tests/test262/language/statements/class/elements/privatename-not-valid-eval-earlyerr-6.js create mode 100644 js/src/tests/test262/language/statements/class/elements/privatename-not-valid-eval-earlyerr-7.js create mode 100644 js/src/tests/test262/language/statements/class/elements/privatename-not-valid-eval-earlyerr-8.js create mode 100644 js/src/tests/test262/language/statements/class/elements/privatename-valid-no-earlyerr.js create mode 100644 js/src/tests/test262/language/statements/class/elements/prod-private-getter-before-super-return-in-constructor.js create mode 100644 js/src/tests/test262/language/statements/class/elements/prod-private-getter-before-super-return-in-field-initializer.js create mode 100644 js/src/tests/test262/language/statements/class/elements/prod-private-method-before-super-return-in-constructor.js create mode 100644 js/src/tests/test262/language/statements/class/elements/prod-private-method-before-super-return-in-field-initializer.js create mode 100644 js/src/tests/test262/language/statements/class/elements/prod-private-setter-before-super-return-in-constructor.js create mode 100644 js/src/tests/test262/language/statements/class/elements/prod-private-setter-before-super-return-in-field-initializer.js create mode 100644 js/src/tests/test262/language/statements/class/elements/public-class-field-initialization-is-visible-to-proxy.js create mode 100644 js/src/tests/test262/language/statements/class/elements/public-class-field-initialization-on-super-class-with-setter.js create mode 100644 js/src/tests/test262/language/statements/class/elements/redeclaration-symbol.js create mode 100644 js/src/tests/test262/language/statements/class/elements/redeclaration.js create mode 100644 js/src/tests/test262/language/statements/class/elements/regular-definitions-computed-names.js create mode 100644 js/src/tests/test262/language/statements/class/elements/regular-definitions-computed-symbol-names.js create mode 100644 js/src/tests/test262/language/statements/class/elements/regular-definitions-grammar-privatename-identifier-semantics-stringvalue.js create mode 100644 js/src/tests/test262/language/statements/class/elements/regular-definitions-literal-names-asi.js create mode 100644 js/src/tests/test262/language/statements/class/elements/regular-definitions-literal-names.js create mode 100644 js/src/tests/test262/language/statements/class/elements/regular-definitions-private-field-usage.js create mode 100644 js/src/tests/test262/language/statements/class/elements/regular-definitions-private-method-getter-usage.js create mode 100644 js/src/tests/test262/language/statements/class/elements/regular-definitions-private-method-usage.js create mode 100644 js/src/tests/test262/language/statements/class/elements/regular-definitions-private-names.js create mode 100644 js/src/tests/test262/language/statements/class/elements/regular-definitions-rs-field-identifier-initializer.js create mode 100644 js/src/tests/test262/language/statements/class/elements/regular-definitions-rs-field-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/regular-definitions-rs-private-getter-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/regular-definitions-rs-private-getter.js create mode 100644 js/src/tests/test262/language/statements/class/elements/regular-definitions-rs-private-method-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/regular-definitions-rs-private-method.js create mode 100644 js/src/tests/test262/language/statements/class/elements/regular-definitions-rs-private-setter-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/regular-definitions-rs-private-setter.js create mode 100644 js/src/tests/test262/language/statements/class/elements/regular-definitions-rs-privatename-identifier-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/regular-definitions-rs-privatename-identifier-initializer-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/regular-definitions-rs-privatename-identifier-initializer.js create mode 100644 js/src/tests/test262/language/statements/class/elements/regular-definitions-rs-privatename-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/regular-definitions-rs-static-async-generator-method-privatename-identifier-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/regular-definitions-rs-static-async-generator-method-privatename-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/regular-definitions-rs-static-async-method-privatename-identifier-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/regular-definitions-rs-static-async-method-privatename-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/regular-definitions-rs-static-generator-method-privatename-identifier-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/regular-definitions-rs-static-generator-method-privatename-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/regular-definitions-rs-static-method-privatename-identifier-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/regular-definitions-rs-static-method-privatename-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/regular-definitions-rs-static-privatename-identifier-alt-by-classname.js create mode 100644 js/src/tests/test262/language/statements/class/elements/regular-definitions-rs-static-privatename-identifier-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/regular-definitions-rs-static-privatename-identifier-by-classname.js create mode 100644 js/src/tests/test262/language/statements/class/elements/regular-definitions-rs-static-privatename-identifier-initializer-alt-by-classname.js create mode 100644 js/src/tests/test262/language/statements/class/elements/regular-definitions-rs-static-privatename-identifier-initializer-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/regular-definitions-rs-static-privatename-identifier-initializer.js create mode 100644 js/src/tests/test262/language/statements/class/elements/regular-definitions-rs-static-privatename-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/regular-definitions-static-private-fields.js create mode 100644 js/src/tests/test262/language/statements/class/elements/regular-definitions-static-private-methods-with-fields.js create mode 100644 js/src/tests/test262/language/statements/class/elements/regular-definitions-static-private-methods.js create mode 100644 js/src/tests/test262/language/statements/class/elements/regular-definitions-string-literal-names.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-async-gen-computed-names.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-async-gen-computed-symbol-names.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-async-gen-grammar-privatename-identifier-semantics-stringvalue.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-async-gen-literal-names-asi.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-async-gen-literal-names.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-async-gen-private-field-usage.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-async-gen-private-method-getter-usage.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-async-gen-private-method-usage.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-async-gen-private-names.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-async-gen-rs-field-identifier-initializer.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-async-gen-rs-field-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-async-gen-rs-private-getter-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-async-gen-rs-private-getter.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-async-gen-rs-private-method-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-async-gen-rs-private-method.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-async-gen-rs-private-setter-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-async-gen-rs-private-setter.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-async-gen-rs-privatename-identifier-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-async-gen-rs-privatename-identifier-initializer-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-async-gen-rs-privatename-identifier-initializer.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-async-gen-rs-privatename-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-async-gen-rs-static-async-generator-method-privatename-identifier-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-async-gen-rs-static-async-generator-method-privatename-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-async-gen-rs-static-async-method-privatename-identifier-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-async-gen-rs-static-async-method-privatename-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-async-gen-rs-static-generator-method-privatename-identifier-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-async-gen-rs-static-generator-method-privatename-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-async-gen-rs-static-method-privatename-identifier-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-async-gen-rs-static-method-privatename-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-async-gen-rs-static-privatename-identifier-alt-by-classname.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-async-gen-rs-static-privatename-identifier-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-async-gen-rs-static-privatename-identifier-by-classname.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-async-gen-rs-static-privatename-identifier-initializer-alt-by-classname.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-async-gen-rs-static-privatename-identifier-initializer-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-async-gen-rs-static-privatename-identifier-initializer.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-async-gen-rs-static-privatename-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-async-gen-static-private-fields.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-async-gen-static-private-methods-with-fields.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-async-gen-static-private-methods.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-async-gen-string-literal-names.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-async-method-computed-names.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-async-method-computed-symbol-names.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-async-method-grammar-privatename-identifier-semantics-stringvalue.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-async-method-literal-names-asi.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-async-method-literal-names.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-async-method-private-field-usage.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-async-method-private-method-getter-usage.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-async-method-private-method-usage.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-async-method-private-names.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-async-method-rs-field-identifier-initializer.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-async-method-rs-field-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-async-method-rs-private-getter-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-async-method-rs-private-getter.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-async-method-rs-private-method-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-async-method-rs-private-method.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-async-method-rs-private-setter-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-async-method-rs-private-setter.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-async-method-rs-privatename-identifier-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-async-method-rs-privatename-identifier-initializer-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-async-method-rs-privatename-identifier-initializer.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-async-method-rs-privatename-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-async-method-rs-static-async-generator-method-privatename-identifier-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-async-method-rs-static-async-generator-method-privatename-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-async-method-rs-static-async-method-privatename-identifier-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-async-method-rs-static-async-method-privatename-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-async-method-rs-static-generator-method-privatename-identifier-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-async-method-rs-static-generator-method-privatename-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-async-method-rs-static-method-privatename-identifier-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-async-method-rs-static-method-privatename-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-async-method-rs-static-privatename-identifier-alt-by-classname.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-async-method-rs-static-privatename-identifier-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-async-method-rs-static-privatename-identifier-by-classname.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-async-method-rs-static-privatename-identifier-initializer-alt-by-classname.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-async-method-rs-static-privatename-identifier-initializer-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-async-method-rs-static-privatename-identifier-initializer.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-async-method-rs-static-privatename-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-async-method-static-private-fields.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-async-method-static-private-methods-with-fields.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-async-method-static-private-methods.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-async-method-string-literal-names.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-gen-computed-names.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-gen-computed-symbol-names.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-gen-grammar-privatename-identifier-semantics-stringvalue.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-gen-literal-names-asi.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-gen-literal-names.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-gen-private-field-usage.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-gen-private-method-getter-usage.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-gen-private-method-usage.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-gen-private-names.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-gen-rs-field-identifier-initializer.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-gen-rs-field-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-gen-rs-private-getter-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-gen-rs-private-getter.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-gen-rs-private-method-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-gen-rs-private-method.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-gen-rs-private-setter-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-gen-rs-private-setter.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-gen-rs-privatename-identifier-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-gen-rs-privatename-identifier-initializer-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-gen-rs-privatename-identifier-initializer.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-gen-rs-privatename-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-gen-rs-static-async-generator-method-privatename-identifier-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-gen-rs-static-async-generator-method-privatename-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-gen-rs-static-async-method-privatename-identifier-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-gen-rs-static-async-method-privatename-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-gen-rs-static-generator-method-privatename-identifier-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-gen-rs-static-generator-method-privatename-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-gen-rs-static-method-privatename-identifier-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-gen-rs-static-method-privatename-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-gen-rs-static-privatename-identifier-alt-by-classname.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-gen-rs-static-privatename-identifier-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-gen-rs-static-privatename-identifier-by-classname.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-gen-rs-static-privatename-identifier-initializer-alt-by-classname.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-gen-rs-static-privatename-identifier-initializer-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-gen-rs-static-privatename-identifier-initializer.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-gen-rs-static-privatename-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-gen-static-private-fields.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-gen-static-private-methods-with-fields.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-gen-static-private-methods.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-gen-string-literal-names.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-method-computed-names.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-method-computed-symbol-names.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-method-grammar-privatename-identifier-semantics-stringvalue.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-method-literal-names-asi.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-method-literal-names.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-method-private-field-usage.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-method-private-method-getter-usage.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-method-private-method-usage.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-method-private-names.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-method-rs-field-identifier-initializer.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-method-rs-field-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-method-rs-private-getter-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-method-rs-private-getter.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-method-rs-private-method-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-method-rs-private-method.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-method-rs-private-setter-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-method-rs-private-setter.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-method-rs-privatename-identifier-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-method-rs-privatename-identifier-initializer-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-method-rs-privatename-identifier-initializer.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-method-rs-privatename-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-method-rs-static-async-generator-method-privatename-identifier-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-method-rs-static-async-generator-method-privatename-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-method-rs-static-async-method-privatename-identifier-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-method-rs-static-async-method-privatename-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-method-rs-static-generator-method-privatename-identifier-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-method-rs-static-generator-method-privatename-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-method-rs-static-method-privatename-identifier-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-method-rs-static-method-privatename-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-method-rs-static-privatename-identifier-alt-by-classname.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-method-rs-static-privatename-identifier-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-method-rs-static-privatename-identifier-by-classname.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-method-rs-static-privatename-identifier-initializer-alt-by-classname.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-method-rs-static-privatename-identifier-initializer-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-method-rs-static-privatename-identifier-initializer.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-method-rs-static-privatename-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-method-static-private-fields.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-method-static-private-methods-with-fields.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-method-static-private-methods.js create mode 100644 js/src/tests/test262/language/statements/class/elements/same-line-method-string-literal-names.js create mode 100644 js/src/tests/test262/language/statements/class/elements/set-access-of-missing-private-setter.js create mode 100644 js/src/tests/test262/language/statements/class/elements/set-access-of-missing-private-static-setter.js create mode 100644 js/src/tests/test262/language/statements/class/elements/set-access-of-missing-shadowed-private-setter.js create mode 100644 js/src/tests/test262/language/statements/class/elements/set-access-of-private-method.js create mode 100644 js/src/tests/test262/language/statements/class/elements/set-access-of-shadowed-private-method.js create mode 100644 js/src/tests/test262/language/statements/class/elements/shell.js create mode 100644 js/src/tests/test262/language/statements/class/elements/static-as-valid-instance-field-assigned.js create mode 100644 js/src/tests/test262/language/statements/class/elements/static-as-valid-instance-field.js create mode 100644 js/src/tests/test262/language/statements/class/elements/static-as-valid-static-field-assigned.js create mode 100644 js/src/tests/test262/language/statements/class/elements/static-as-valid-static-field.js create mode 100644 js/src/tests/test262/language/statements/class/elements/static-comp-name-init-err-contains-arguments.js create mode 100644 js/src/tests/test262/language/statements/class/elements/static-comp-name-init-err-contains-super.js create mode 100644 js/src/tests/test262/language/statements/class/elements/static-field-anonymous-function-length.js create mode 100644 js/src/tests/test262/language/statements/class/elements/static-field-anonymous-function-name.js create mode 100644 js/src/tests/test262/language/statements/class/elements/static-field-declaration.js create mode 100644 js/src/tests/test262/language/statements/class/elements/static-field-init-this-inside-arrow-function.js create mode 100644 js/src/tests/test262/language/statements/class/elements/static-field-init-with-this.js create mode 100644 js/src/tests/test262/language/statements/class/elements/static-field-initializer-error.js create mode 100644 js/src/tests/test262/language/statements/class/elements/static-field-redeclaration.js create mode 100644 js/src/tests/test262/language/statements/class/elements/static-fielddefinition-initializer-abrupt-completion.js create mode 100644 js/src/tests/test262/language/statements/class/elements/static-literal-init-err-contains-arguments.js create mode 100644 js/src/tests/test262/language/statements/class/elements/static-literal-init-err-contains-super.js create mode 100644 js/src/tests/test262/language/statements/class/elements/static-private-fields-proxy-default-handler-throws.js create mode 100644 js/src/tests/test262/language/statements/class/elements/static-private-getter-access-on-inner-arrow-function.js create mode 100644 js/src/tests/test262/language/statements/class/elements/static-private-getter-access-on-inner-class.js create mode 100644 js/src/tests/test262/language/statements/class/elements/static-private-getter-access-on-inner-function.js create mode 100644 js/src/tests/test262/language/statements/class/elements/static-private-getter.js create mode 100644 js/src/tests/test262/language/statements/class/elements/static-private-init-err-contains-arguments.js create mode 100644 js/src/tests/test262/language/statements/class/elements/static-private-init-err-contains-super.js create mode 100644 js/src/tests/test262/language/statements/class/elements/static-private-method-access-on-inner-arrow-function.js create mode 100644 js/src/tests/test262/language/statements/class/elements/static-private-method-access-on-inner-function.js create mode 100644 js/src/tests/test262/language/statements/class/elements/static-private-method-and-instance-method-brand-check.js create mode 100644 js/src/tests/test262/language/statements/class/elements/static-private-method-referenced-from-instance-method.js create mode 100644 js/src/tests/test262/language/statements/class/elements/static-private-method-subclass-receiver.js create mode 100644 js/src/tests/test262/language/statements/class/elements/static-private-setter-access-on-inner-arrow-function.js create mode 100644 js/src/tests/test262/language/statements/class/elements/static-private-setter-access-on-inner-class.js create mode 100644 js/src/tests/test262/language/statements/class/elements/static-private-setter-access-on-inner-function.js create mode 100644 js/src/tests/test262/language/statements/class/elements/static-private-setter.js create mode 100644 js/src/tests/test262/language/statements/class/elements/static-string-literal-name-init-err-contains-arguments.js create mode 100644 js/src/tests/test262/language/statements/class/elements/static-string-literal-name-init-err-contains-super.js create mode 100644 js/src/tests/test262/language/statements/class/elements/string-literal-name-init-err-contains-arguments.js create mode 100644 js/src/tests/test262/language/statements/class/elements/string-literal-name-init-err-contains-super.js create mode 100644 js/src/tests/test262/language/statements/class/elements/super-access-from-arrow-func-on-field.js create mode 100644 js/src/tests/test262/language/statements/class/elements/super-access-inside-a-private-getter.js create mode 100644 js/src/tests/test262/language/statements/class/elements/super-access-inside-a-private-method.js create mode 100644 js/src/tests/test262/language/statements/class/elements/super-access-inside-a-private-setter.js create mode 100644 js/src/tests/test262/language/statements/class/elements/super-fielddefinition-initializer-abrupt-completion.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/browser.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/browser.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/class-heritage-array-literal-arrow-heritage.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/class-heritage-array-literal-async-arrow-heritage.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/browser.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-covered-err-delete-call-expression-private-method-accessor-get.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-covered-err-delete-call-expression-private-method-accessor-set.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-covered-err-delete-call-expression-private-method-async-gen.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-covered-err-delete-call-expression-private-method-async.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-covered-err-delete-call-expression-private-method-gen.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-covered-err-delete-call-expression-private-method.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-covered-err-delete-call-expression-private-no-reference.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-covered-err-delete-call-expression-privatename.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-covered-err-delete-member-expression-private-method-accessor-get.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-covered-err-delete-member-expression-private-method-accessor-set.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-covered-err-delete-member-expression-private-method-async-gen.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-covered-err-delete-member-expression-private-method-async.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-covered-err-delete-member-expression-private-method-gen.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-covered-err-delete-member-expression-private-method.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-covered-err-delete-member-expression-private-no-reference.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-covered-err-delete-member-expression-privatename.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-err-delete-call-expression-private-method-accessor-get.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-err-delete-call-expression-private-method-accessor-set.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-err-delete-call-expression-private-method-async-gen.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-err-delete-call-expression-private-method-async.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-err-delete-call-expression-private-method-gen.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-err-delete-call-expression-private-method.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-err-delete-call-expression-private-no-reference.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-err-delete-call-expression-privatename.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-err-delete-member-expression-private-method-accessor-get.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-err-delete-member-expression-private-method-accessor-set.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-err-delete-member-expression-private-method-async-gen.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-err-delete-member-expression-private-method-async.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-err-delete-member-expression-private-method-gen.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-err-delete-member-expression-private-method.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-err-delete-member-expression-private-no-reference.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-err-delete-member-expression-privatename.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-twice-covered-err-delete-call-expression-private-method-accessor-get.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-twice-covered-err-delete-call-expression-private-method-accessor-set.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-twice-covered-err-delete-call-expression-private-method-async-gen.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-twice-covered-err-delete-call-expression-private-method-async.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-twice-covered-err-delete-call-expression-private-method-gen.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-twice-covered-err-delete-call-expression-private-method.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-twice-covered-err-delete-call-expression-private-no-reference.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-twice-covered-err-delete-call-expression-privatename.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-twice-covered-err-delete-member-expression-private-method-accessor-get.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-twice-covered-err-delete-member-expression-private-method-accessor-set.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-twice-covered-err-delete-member-expression-private-method-async-gen.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-twice-covered-err-delete-member-expression-private-method-async.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-twice-covered-err-delete-member-expression-private-method-gen.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-twice-covered-err-delete-member-expression-private-method.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-twice-covered-err-delete-member-expression-private-no-reference.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-twice-covered-err-delete-member-expression-privatename.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-covered-err-delete-call-expression-private-method-accessor-get.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-covered-err-delete-call-expression-private-method-accessor-set.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-covered-err-delete-call-expression-private-method-async-gen.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-covered-err-delete-call-expression-private-method-async.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-covered-err-delete-call-expression-private-method-gen.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-covered-err-delete-call-expression-private-method.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-covered-err-delete-call-expression-private-no-reference.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-covered-err-delete-call-expression-privatename.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-covered-err-delete-member-expression-private-method-accessor-get.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-covered-err-delete-member-expression-private-method-accessor-set.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-covered-err-delete-member-expression-private-method-async-gen.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-covered-err-delete-member-expression-private-method-async.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-covered-err-delete-member-expression-private-method-gen.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-covered-err-delete-member-expression-private-method.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-covered-err-delete-member-expression-private-no-reference.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-covered-err-delete-member-expression-privatename.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-err-delete-call-expression-private-method-accessor-get.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-err-delete-call-expression-private-method-accessor-set.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-err-delete-call-expression-private-method-async-gen.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-err-delete-call-expression-private-method-async.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-err-delete-call-expression-private-method-gen.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-err-delete-call-expression-private-method.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-err-delete-call-expression-private-no-reference.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-err-delete-call-expression-privatename.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-err-delete-member-expression-private-method-accessor-get.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-err-delete-member-expression-private-method-accessor-set.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-err-delete-member-expression-private-method-async-gen.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-err-delete-member-expression-private-method-async.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-err-delete-member-expression-private-method-gen.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-err-delete-member-expression-private-method.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-err-delete-member-expression-private-no-reference.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-err-delete-member-expression-privatename.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-twice-covered-err-delete-call-expression-private-method-accessor-get.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-twice-covered-err-delete-call-expression-private-method-accessor-set.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-twice-covered-err-delete-call-expression-private-method-async-gen.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-twice-covered-err-delete-call-expression-private-method-async.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-twice-covered-err-delete-call-expression-private-method-gen.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-twice-covered-err-delete-call-expression-private-method.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-twice-covered-err-delete-call-expression-private-no-reference.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-twice-covered-err-delete-call-expression-privatename.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-twice-covered-err-delete-member-expression-private-method-accessor-get.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-twice-covered-err-delete-member-expression-private-method-accessor-set.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-twice-covered-err-delete-member-expression-private-method-async-gen.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-twice-covered-err-delete-member-expression-private-method-async.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-twice-covered-err-delete-member-expression-private-method-gen.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-twice-covered-err-delete-member-expression-private-method.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-twice-covered-err-delete-member-expression-private-no-reference.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-twice-covered-err-delete-member-expression-privatename.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/shell.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-class-body-ctor-duplicate.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-ctor-super-no-heritage.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-field-identifier-invalid-ues-error.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-field-identifier-invalid-zwj-error.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-field-identifier-invalid-zwnj-error.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-fields-same-line-error.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-private-environment-on-class-heritage-array-literal.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-private-environment-on-class-heritage-chained-usage.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-private-environment-on-class-heritage-function-expression.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-private-environment-on-class-heritage-obj-literal.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-private-environment-on-class-heritage-recursive.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-private-environment-on-class-heritage.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-private-field-on-object-destructuring.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-private-field-super-access.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatemeth-duplicate-async-gen.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatemeth-duplicate-async.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatemeth-duplicate-gen.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatemeth-duplicate-get-field.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatemeth-duplicate-get-get.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatemeth-duplicate-meth-field.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatemeth-duplicate-meth-get.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatemeth-duplicate-meth-meth.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatemeth-duplicate-meth-set.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatemeth-duplicate-meth-staticfield.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatemeth-duplicate-meth-staticmeth.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatemeth-duplicate-set-field.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatemeth-duplicate-set-set.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatename-constructor.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatename-error.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatename-identifier-invalid-ues.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatename-identifier-invalid-zwj-error.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatename-identifier-invalid-zwnj-error.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatename-in-computed-property-missing.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatename-whitespace-error-accessor-get-meth.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatename-whitespace-error-accessor-set-meth.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatename-whitespace-error-async-gen-meth.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatename-whitespace-error-async-meth.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatename-whitespace-error-call-expr.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatename-whitespace-error-field-init.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatename-whitespace-error-field.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatename-whitespace-error-gen-meth.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatename-whitespace-error-member-expr.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatename-whitespace-error-meth.case.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatename-whitespace-error-static-accessor-get-meth.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatename-whitespace-error-static-accessor-set-meth.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatename-whitespace-error-static-async-gen-meth.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatename-whitespace-error-static-async-meth.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatename-whitespace-error-static-field-init.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatename-whitespace-error-static-field.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatename-whitespace-error-static-gen-meth.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatename-whitespace-error-static-meth.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatenames-same-line-error.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-special-meth-contains-super-async-gen.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-special-meth-contains-super-async.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-special-meth-contains-super-gen.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-special-meth-contains-super-get.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-special-meth-contains-super-method.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-special-meth-contains-super-private-async-gen.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-special-meth-contains-super-private-async.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-special-meth-contains-super-private-gen.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-special-meth-contains-super-private-method.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-special-meth-contains-super-set.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-special-meth-ctor-async-gen.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-special-meth-ctor-async-meth.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-special-meth-ctor-gen.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-special-meth-ctor-get.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-special-meth-ctor-set.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-static-async-gen-meth-prototype.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-static-async-gen-meth-super.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-static-async-meth-prototype.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-static-async-meth-super.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-static-gen-meth-prototype.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-static-gen-meth-super.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-static-get-meth-prototype.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-static-get-meth-super.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-static-meth-prototype.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-static-meth-super.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-static-private-async-gen-meth-constructor.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-static-private-async-gen-meth-super.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-static-private-async-meth-constructor.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-static-private-async-meth-super.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-static-private-gen-meth-constructor.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-static-private-gen-meth-super.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-static-private-meth-constructor.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-static-private-meth-super.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-static-privatename-constructor.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-static-set-meth-prototype.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-static-set-meth-super.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/invalid-names/browser.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/invalid-names/field-init-call-expression-bad-reference.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/invalid-names/field-init-call-expression-this.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/invalid-names/field-init-fn-call-expression-bad-reference.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/invalid-names/field-init-fn-call-expression-this.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/invalid-names/field-init-fn-member-expression-bad-reference.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/invalid-names/field-init-fn-member-expression-this.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/invalid-names/field-init-member-expression-bad-reference.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/invalid-names/field-init-member-expression-this.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/invalid-names/fields-init-heritage-call-expression-bad-reference.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/invalid-names/fields-init-heritage-call-expression-this.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/invalid-names/fields-init-heritage-member-expression-bad-reference.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/invalid-names/fields-init-heritage-member-expression-this.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/invalid-names/method-call-expression-bad-reference.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/invalid-names/method-call-expression-this.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/invalid-names/method-fn-call-expression-bad-reference.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/invalid-names/method-fn-call-expression-this.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/invalid-names/method-fn-member-expression-bad-reference.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/invalid-names/method-fn-member-expression-this.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/invalid-names/method-heritage-call-expression-bad-reference.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/invalid-names/method-heritage-call-expression-this.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/invalid-names/method-heritage-member-expression-bad-reference.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/invalid-names/method-heritage-member-expression-this.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/invalid-names/method-member-expression-bad-reference.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/invalid-names/method-member-expression-this.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/invalid-names/method-outter-call-expression-bad-reference.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/invalid-names/method-outter-call-expression-this.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/invalid-names/method-outter-member-expression-bad-reference.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/invalid-names/method-outter-member-expression-this.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/invalid-names/shell.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/private-async-generator-cannot-escape-token.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/private-async-method-cannot-escape-token.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/private-call-exp-cannot-escape-token.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/private-field-cannot-escape-token.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/private-generator-cannot-escape-token.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/private-member-exp-cannot-escape-token.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/private-method-cannot-escape-token.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/shell.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/early-errors/super-private-access-invalid.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/shell.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/valid/browser.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/valid/grammar-class-body-ctor-no-heritage.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/valid/grammar-field-accessor.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/valid/grammar-field-classelementname-initializer-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/valid/grammar-field-classelementname-initializer.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/valid/grammar-field-identifier-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/valid/grammar-field-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/valid/grammar-fields-multi-line.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/valid/grammar-privatemeth-duplicate-get-set.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/valid/grammar-privatemeth-duplicate-meth-nestedclassmeth.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/valid/grammar-privatename-classelementname-initializer-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/valid/grammar-privatename-classelementname-initializer.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/valid/grammar-privatename-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/valid/grammar-privatename-no-initializer-with-method.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/valid/grammar-privatenames-multi-line.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/valid/grammar-special-prototype-accessor-meth-valid.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/valid/grammar-special-prototype-async-gen-meth-valid.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/valid/grammar-special-prototype-async-meth-valid.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/valid/grammar-special-prototype-gen-meth-valid.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/valid/grammar-special-prototype-meth-valid.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/valid/grammar-static-ctor-accessor-meth-valid.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/valid/grammar-static-ctor-async-gen-meth-valid.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/valid/grammar-static-ctor-async-meth-valid.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/valid/grammar-static-ctor-gen-meth-valid.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/valid/grammar-static-ctor-meth-valid.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/valid/grammar-static-private-async-gen-meth-prototype.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/valid/grammar-static-private-async-meth-prototype.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/valid/grammar-static-private-gen-meth-prototype.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/valid/grammar-static-private-meth-prototype.js create mode 100644 js/src/tests/test262/language/statements/class/elements/syntax/valid/shell.js create mode 100644 js/src/tests/test262/language/statements/class/elements/ternary-init-err-contains-arguments.js create mode 100644 js/src/tests/test262/language/statements/class/elements/ternary-init-err-contains-super.js create mode 100644 js/src/tests/test262/language/statements/class/elements/typeof-init-err-contains-arguments.js create mode 100644 js/src/tests/test262/language/statements/class/elements/typeof-init-err-contains-super.js create mode 100644 js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-computed-names.js create mode 100644 js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-computed-symbol-names.js create mode 100644 js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-grammar-privatename-identifier-semantics-stringvalue.js create mode 100644 js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-literal-names-asi.js create mode 100644 js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-literal-names.js create mode 100644 js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-private-field-usage.js create mode 100644 js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-private-method-getter-usage.js create mode 100644 js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-private-method-usage.js create mode 100644 js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-private-names.js create mode 100644 js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-rs-field-identifier-initializer.js create mode 100644 js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-rs-field-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-rs-private-getter-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-rs-private-getter.js create mode 100644 js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-rs-private-method-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-rs-private-method.js create mode 100644 js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-rs-private-setter-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-rs-private-setter.js create mode 100644 js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-rs-privatename-identifier-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-rs-privatename-identifier-initializer-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-rs-privatename-identifier-initializer.js create mode 100644 js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-rs-privatename-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-rs-static-async-generator-method-privatename-identifier-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-rs-static-async-generator-method-privatename-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-rs-static-async-method-privatename-identifier-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-rs-static-async-method-privatename-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-rs-static-generator-method-privatename-identifier-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-rs-static-generator-method-privatename-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-rs-static-method-privatename-identifier-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-rs-static-method-privatename-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-rs-static-privatename-identifier-alt-by-classname.js create mode 100644 js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-rs-static-privatename-identifier-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-rs-static-privatename-identifier-by-classname.js create mode 100644 js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-rs-static-privatename-identifier-initializer-alt-by-classname.js create mode 100644 js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-rs-static-privatename-identifier-initializer-alt.js create mode 100644 js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-rs-static-privatename-identifier-initializer.js create mode 100644 js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-rs-static-privatename-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-static-private-fields.js create mode 100644 js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-static-private-methods-with-fields.js create mode 100644 js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-static-private-methods.js create mode 100644 js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-string-literal-names.js create mode 100644 js/src/tests/test262/language/statements/class/gen-method-length-dflt.js create mode 100644 js/src/tests/test262/language/statements/class/gen-method-param-dflt-yield.js create mode 100644 js/src/tests/test262/language/statements/class/gen-method-static/array-destructuring-param-strict-body.js create mode 100644 js/src/tests/test262/language/statements/class/gen-method-static/browser.js create mode 100644 js/src/tests/test262/language/statements/class/gen-method-static/dflt-params-abrupt.js create mode 100644 js/src/tests/test262/language/statements/class/gen-method-static/dflt-params-arg-val-not-undefined.js create mode 100644 js/src/tests/test262/language/statements/class/gen-method-static/dflt-params-arg-val-undefined.js create mode 100644 js/src/tests/test262/language/statements/class/gen-method-static/dflt-params-duplicates.js create mode 100644 js/src/tests/test262/language/statements/class/gen-method-static/dflt-params-ref-later.js create mode 100644 js/src/tests/test262/language/statements/class/gen-method-static/dflt-params-ref-prior.js create mode 100644 js/src/tests/test262/language/statements/class/gen-method-static/dflt-params-ref-self.js create mode 100644 js/src/tests/test262/language/statements/class/gen-method-static/dflt-params-rest.js create mode 100644 js/src/tests/test262/language/statements/class/gen-method-static/dflt-params-trailing-comma.js create mode 100644 js/src/tests/test262/language/statements/class/gen-method-static/forbidden-ext/b1/browser.js create mode 100644 js/src/tests/test262/language/statements/class/gen-method-static/forbidden-ext/b1/cls-decl-gen-meth-static-forbidden-ext-direct-access-prop-arguments.js create mode 100644 js/src/tests/test262/language/statements/class/gen-method-static/forbidden-ext/b1/cls-decl-gen-meth-static-forbidden-ext-direct-access-prop-caller.js create mode 100644 js/src/tests/test262/language/statements/class/gen-method-static/forbidden-ext/b1/shell.js create mode 100644 js/src/tests/test262/language/statements/class/gen-method-static/forbidden-ext/b2/browser.js create mode 100644 js/src/tests/test262/language/statements/class/gen-method-static/forbidden-ext/b2/cls-decl-gen-meth-static-forbidden-ext-indirect-access-own-prop-caller-get.js create mode 100644 js/src/tests/test262/language/statements/class/gen-method-static/forbidden-ext/b2/cls-decl-gen-meth-static-forbidden-ext-indirect-access-own-prop-caller-value.js create mode 100644 js/src/tests/test262/language/statements/class/gen-method-static/forbidden-ext/b2/cls-decl-gen-meth-static-forbidden-ext-indirect-access-prop-caller.js create mode 100644 js/src/tests/test262/language/statements/class/gen-method-static/forbidden-ext/b2/shell.js create mode 100644 js/src/tests/test262/language/statements/class/gen-method-static/forbidden-ext/browser.js create mode 100644 js/src/tests/test262/language/statements/class/gen-method-static/forbidden-ext/shell.js create mode 100644 js/src/tests/test262/language/statements/class/gen-method-static/object-destructuring-param-strict-body.js create mode 100644 js/src/tests/test262/language/statements/class/gen-method-static/params-trailing-comma-multiple.js create mode 100644 js/src/tests/test262/language/statements/class/gen-method-static/params-trailing-comma-single.js create mode 100644 js/src/tests/test262/language/statements/class/gen-method-static/rest-param-strict-body.js create mode 100644 js/src/tests/test262/language/statements/class/gen-method-static/rest-params-trailing-comma-early-error.js create mode 100644 js/src/tests/test262/language/statements/class/gen-method-static/shell.js create mode 100644 js/src/tests/test262/language/statements/class/gen-method-static/yield-as-binding-identifier-escaped.js create mode 100644 js/src/tests/test262/language/statements/class/gen-method-static/yield-as-binding-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/gen-method-static/yield-as-identifier-reference-escaped.js create mode 100644 js/src/tests/test262/language/statements/class/gen-method-static/yield-as-identifier-reference.js create mode 100644 js/src/tests/test262/language/statements/class/gen-method-static/yield-as-label-identifier-escaped.js create mode 100644 js/src/tests/test262/language/statements/class/gen-method-static/yield-as-label-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/gen-method-static/yield-identifier-spread-strict-strict.js create mode 100644 js/src/tests/test262/language/statements/class/gen-method-static/yield-identifier-strict-strict.js create mode 100644 js/src/tests/test262/language/statements/class/gen-method-static/yield-spread-arr-multiple.js create mode 100644 js/src/tests/test262/language/statements/class/gen-method-static/yield-spread-arr-single.js create mode 100644 js/src/tests/test262/language/statements/class/gen-method-static/yield-spread-obj.js create mode 100644 js/src/tests/test262/language/statements/class/gen-method/array-destructuring-param-strict-body.js create mode 100644 js/src/tests/test262/language/statements/class/gen-method/browser.js create mode 100644 js/src/tests/test262/language/statements/class/gen-method/dflt-params-abrupt.js create mode 100644 js/src/tests/test262/language/statements/class/gen-method/dflt-params-arg-val-not-undefined.js create mode 100644 js/src/tests/test262/language/statements/class/gen-method/dflt-params-arg-val-undefined.js create mode 100644 js/src/tests/test262/language/statements/class/gen-method/dflt-params-duplicates.js create mode 100644 js/src/tests/test262/language/statements/class/gen-method/dflt-params-ref-later.js create mode 100644 js/src/tests/test262/language/statements/class/gen-method/dflt-params-ref-prior.js create mode 100644 js/src/tests/test262/language/statements/class/gen-method/dflt-params-ref-self.js create mode 100644 js/src/tests/test262/language/statements/class/gen-method/dflt-params-rest.js create mode 100644 js/src/tests/test262/language/statements/class/gen-method/dflt-params-trailing-comma.js create mode 100644 js/src/tests/test262/language/statements/class/gen-method/forbidden-ext/b1/browser.js create mode 100644 js/src/tests/test262/language/statements/class/gen-method/forbidden-ext/b1/cls-decl-gen-meth-forbidden-ext-direct-access-prop-arguments.js create mode 100644 js/src/tests/test262/language/statements/class/gen-method/forbidden-ext/b1/cls-decl-gen-meth-forbidden-ext-direct-access-prop-caller.js create mode 100644 js/src/tests/test262/language/statements/class/gen-method/forbidden-ext/b1/shell.js create mode 100644 js/src/tests/test262/language/statements/class/gen-method/forbidden-ext/b2/browser.js create mode 100644 js/src/tests/test262/language/statements/class/gen-method/forbidden-ext/b2/cls-decl-gen-meth-forbidden-ext-indirect-access-own-prop-caller-get.js create mode 100644 js/src/tests/test262/language/statements/class/gen-method/forbidden-ext/b2/cls-decl-gen-meth-forbidden-ext-indirect-access-own-prop-caller-value.js create mode 100644 js/src/tests/test262/language/statements/class/gen-method/forbidden-ext/b2/cls-decl-gen-meth-forbidden-ext-indirect-access-prop-caller.js create mode 100644 js/src/tests/test262/language/statements/class/gen-method/forbidden-ext/b2/shell.js create mode 100644 js/src/tests/test262/language/statements/class/gen-method/forbidden-ext/browser.js create mode 100644 js/src/tests/test262/language/statements/class/gen-method/forbidden-ext/shell.js create mode 100644 js/src/tests/test262/language/statements/class/gen-method/object-destructuring-param-strict-body.js create mode 100644 js/src/tests/test262/language/statements/class/gen-method/params-trailing-comma-multiple.js create mode 100644 js/src/tests/test262/language/statements/class/gen-method/params-trailing-comma-single.js create mode 100644 js/src/tests/test262/language/statements/class/gen-method/rest-param-strict-body.js create mode 100644 js/src/tests/test262/language/statements/class/gen-method/rest-params-trailing-comma-early-error.js create mode 100644 js/src/tests/test262/language/statements/class/gen-method/shell.js create mode 100644 js/src/tests/test262/language/statements/class/gen-method/yield-as-binding-identifier-escaped.js create mode 100644 js/src/tests/test262/language/statements/class/gen-method/yield-as-binding-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/gen-method/yield-as-identifier-reference-escaped.js create mode 100644 js/src/tests/test262/language/statements/class/gen-method/yield-as-identifier-reference.js create mode 100644 js/src/tests/test262/language/statements/class/gen-method/yield-as-label-identifier-escaped.js create mode 100644 js/src/tests/test262/language/statements/class/gen-method/yield-as-label-identifier.js create mode 100644 js/src/tests/test262/language/statements/class/gen-method/yield-identifier-spread-strict-strict.js create mode 100644 js/src/tests/test262/language/statements/class/gen-method/yield-identifier-strict-strict.js create mode 100644 js/src/tests/test262/language/statements/class/gen-method/yield-spread-arr-multiple.js create mode 100644 js/src/tests/test262/language/statements/class/gen-method/yield-spread-arr-single.js create mode 100644 js/src/tests/test262/language/statements/class/gen-method/yield-spread-obj.js create mode 100644 js/src/tests/test262/language/statements/class/getter-param-dflt.js create mode 100644 js/src/tests/test262/language/statements/class/ident-name-method-def-break-escaped.js create mode 100644 js/src/tests/test262/language/statements/class/ident-name-method-def-case-escaped.js create mode 100644 js/src/tests/test262/language/statements/class/ident-name-method-def-catch-escaped.js create mode 100644 js/src/tests/test262/language/statements/class/ident-name-method-def-class-escaped.js create mode 100644 js/src/tests/test262/language/statements/class/ident-name-method-def-const-escaped.js create mode 100644 js/src/tests/test262/language/statements/class/ident-name-method-def-continue-escaped.js create mode 100644 js/src/tests/test262/language/statements/class/ident-name-method-def-debugger-escaped.js create mode 100644 js/src/tests/test262/language/statements/class/ident-name-method-def-default-escaped-ext.js create mode 100644 js/src/tests/test262/language/statements/class/ident-name-method-def-default-escaped.js create mode 100644 js/src/tests/test262/language/statements/class/ident-name-method-def-default.js create mode 100644 js/src/tests/test262/language/statements/class/ident-name-method-def-delete-escaped.js create mode 100644 js/src/tests/test262/language/statements/class/ident-name-method-def-do-escaped.js create mode 100644 js/src/tests/test262/language/statements/class/ident-name-method-def-else-escaped.js create mode 100644 js/src/tests/test262/language/statements/class/ident-name-method-def-enum-escaped.js create mode 100644 js/src/tests/test262/language/statements/class/ident-name-method-def-export-escaped.js create mode 100644 js/src/tests/test262/language/statements/class/ident-name-method-def-extends-escaped-ext.js create mode 100644 js/src/tests/test262/language/statements/class/ident-name-method-def-extends-escaped.js create mode 100644 js/src/tests/test262/language/statements/class/ident-name-method-def-extends.js create mode 100644 js/src/tests/test262/language/statements/class/ident-name-method-def-finally-escaped.js create mode 100644 js/src/tests/test262/language/statements/class/ident-name-method-def-for-escaped.js create mode 100644 js/src/tests/test262/language/statements/class/ident-name-method-def-function-escaped.js create mode 100644 js/src/tests/test262/language/statements/class/ident-name-method-def-if-escaped.js create mode 100644 js/src/tests/test262/language/statements/class/ident-name-method-def-implements-escaped.js create mode 100644 js/src/tests/test262/language/statements/class/ident-name-method-def-import-escaped.js create mode 100644 js/src/tests/test262/language/statements/class/ident-name-method-def-in-escaped.js create mode 100644 js/src/tests/test262/language/statements/class/ident-name-method-def-instanceof-escaped.js create mode 100644 js/src/tests/test262/language/statements/class/ident-name-method-def-interface-escaped.js create mode 100644 js/src/tests/test262/language/statements/class/ident-name-method-def-let-escaped.js create mode 100644 js/src/tests/test262/language/statements/class/ident-name-method-def-new-escaped.js create mode 100644 js/src/tests/test262/language/statements/class/ident-name-method-def-package-escaped.js create mode 100644 js/src/tests/test262/language/statements/class/ident-name-method-def-private-escaped.js create mode 100644 js/src/tests/test262/language/statements/class/ident-name-method-def-protected-escaped.js create mode 100644 js/src/tests/test262/language/statements/class/ident-name-method-def-public-escaped.js create mode 100644 js/src/tests/test262/language/statements/class/ident-name-method-def-return-escaped.js create mode 100644 js/src/tests/test262/language/statements/class/ident-name-method-def-static-escaped.js create mode 100644 js/src/tests/test262/language/statements/class/ident-name-method-def-super-escaped.js create mode 100644 js/src/tests/test262/language/statements/class/ident-name-method-def-switch-escaped.js create mode 100644 js/src/tests/test262/language/statements/class/ident-name-method-def-this-escaped.js create mode 100644 js/src/tests/test262/language/statements/class/ident-name-method-def-throw-escaped.js create mode 100644 js/src/tests/test262/language/statements/class/ident-name-method-def-try-escaped.js create mode 100644 js/src/tests/test262/language/statements/class/ident-name-method-def-typeof-escaped.js create mode 100644 js/src/tests/test262/language/statements/class/ident-name-method-def-var-escaped.js create mode 100644 js/src/tests/test262/language/statements/class/ident-name-method-def-void-escaped.js create mode 100644 js/src/tests/test262/language/statements/class/ident-name-method-def-while-escaped.js create mode 100644 js/src/tests/test262/language/statements/class/ident-name-method-def-with-escaped.js create mode 100644 js/src/tests/test262/language/statements/class/method-length-dflt.js create mode 100644 js/src/tests/test262/language/statements/class/method-param-yield.js create mode 100644 js/src/tests/test262/language/statements/class/method-static/array-destructuring-param-strict-body.js create mode 100644 js/src/tests/test262/language/statements/class/method-static/browser.js create mode 100644 js/src/tests/test262/language/statements/class/method-static/dflt-params-abrupt.js create mode 100644 js/src/tests/test262/language/statements/class/method-static/dflt-params-arg-val-not-undefined.js create mode 100644 js/src/tests/test262/language/statements/class/method-static/dflt-params-arg-val-undefined.js create mode 100644 js/src/tests/test262/language/statements/class/method-static/dflt-params-duplicates.js create mode 100644 js/src/tests/test262/language/statements/class/method-static/dflt-params-ref-later.js create mode 100644 js/src/tests/test262/language/statements/class/method-static/dflt-params-ref-prior.js create mode 100644 js/src/tests/test262/language/statements/class/method-static/dflt-params-ref-self.js create mode 100644 js/src/tests/test262/language/statements/class/method-static/dflt-params-rest.js create mode 100644 js/src/tests/test262/language/statements/class/method-static/dflt-params-trailing-comma.js create mode 100644 js/src/tests/test262/language/statements/class/method-static/forbidden-ext/b1/browser.js create mode 100644 js/src/tests/test262/language/statements/class/method-static/forbidden-ext/b1/cls-decl-meth-static-forbidden-ext-direct-access-prop-arguments.js create mode 100644 js/src/tests/test262/language/statements/class/method-static/forbidden-ext/b1/cls-decl-meth-static-forbidden-ext-direct-access-prop-caller.js create mode 100644 js/src/tests/test262/language/statements/class/method-static/forbidden-ext/b1/shell.js create mode 100644 js/src/tests/test262/language/statements/class/method-static/forbidden-ext/b2/browser.js create mode 100644 js/src/tests/test262/language/statements/class/method-static/forbidden-ext/b2/cls-decl-meth-static-forbidden-ext-indirect-access-own-prop-caller-get.js create mode 100644 js/src/tests/test262/language/statements/class/method-static/forbidden-ext/b2/cls-decl-meth-static-forbidden-ext-indirect-access-own-prop-caller-value.js create mode 100644 js/src/tests/test262/language/statements/class/method-static/forbidden-ext/b2/cls-decl-meth-static-forbidden-ext-indirect-access-prop-caller.js create mode 100644 js/src/tests/test262/language/statements/class/method-static/forbidden-ext/b2/shell.js create mode 100644 js/src/tests/test262/language/statements/class/method-static/forbidden-ext/browser.js create mode 100644 js/src/tests/test262/language/statements/class/method-static/forbidden-ext/shell.js create mode 100644 js/src/tests/test262/language/statements/class/method-static/object-destructuring-param-strict-body.js create mode 100644 js/src/tests/test262/language/statements/class/method-static/params-trailing-comma-multiple.js create mode 100644 js/src/tests/test262/language/statements/class/method-static/params-trailing-comma-single.js create mode 100644 js/src/tests/test262/language/statements/class/method-static/rest-param-strict-body.js create mode 100644 js/src/tests/test262/language/statements/class/method-static/rest-params-trailing-comma-early-error.js create mode 100644 js/src/tests/test262/language/statements/class/method-static/shell.js create mode 100644 js/src/tests/test262/language/statements/class/method/array-destructuring-param-strict-body.js create mode 100644 js/src/tests/test262/language/statements/class/method/browser.js create mode 100644 js/src/tests/test262/language/statements/class/method/dflt-params-abrupt.js create mode 100644 js/src/tests/test262/language/statements/class/method/dflt-params-arg-val-not-undefined.js create mode 100644 js/src/tests/test262/language/statements/class/method/dflt-params-arg-val-undefined.js create mode 100644 js/src/tests/test262/language/statements/class/method/dflt-params-duplicates.js create mode 100644 js/src/tests/test262/language/statements/class/method/dflt-params-ref-later.js create mode 100644 js/src/tests/test262/language/statements/class/method/dflt-params-ref-prior.js create mode 100644 js/src/tests/test262/language/statements/class/method/dflt-params-ref-self.js create mode 100644 js/src/tests/test262/language/statements/class/method/dflt-params-rest.js create mode 100644 js/src/tests/test262/language/statements/class/method/dflt-params-trailing-comma.js create mode 100644 js/src/tests/test262/language/statements/class/method/forbidden-ext/b1/browser.js create mode 100644 js/src/tests/test262/language/statements/class/method/forbidden-ext/b1/cls-decl-meth-forbidden-ext-direct-access-prop-arguments.js create mode 100644 js/src/tests/test262/language/statements/class/method/forbidden-ext/b1/cls-decl-meth-forbidden-ext-direct-access-prop-caller.js create mode 100644 js/src/tests/test262/language/statements/class/method/forbidden-ext/b1/shell.js create mode 100644 js/src/tests/test262/language/statements/class/method/forbidden-ext/b2/browser.js create mode 100644 js/src/tests/test262/language/statements/class/method/forbidden-ext/b2/cls-decl-meth-forbidden-ext-indirect-access-own-prop-caller-get.js create mode 100644 js/src/tests/test262/language/statements/class/method/forbidden-ext/b2/cls-decl-meth-forbidden-ext-indirect-access-own-prop-caller-value.js create mode 100644 js/src/tests/test262/language/statements/class/method/forbidden-ext/b2/cls-decl-meth-forbidden-ext-indirect-access-prop-caller.js create mode 100644 js/src/tests/test262/language/statements/class/method/forbidden-ext/b2/shell.js create mode 100644 js/src/tests/test262/language/statements/class/method/forbidden-ext/browser.js create mode 100644 js/src/tests/test262/language/statements/class/method/forbidden-ext/shell.js create mode 100644 js/src/tests/test262/language/statements/class/method/object-destructuring-param-strict-body.js create mode 100644 js/src/tests/test262/language/statements/class/method/params-trailing-comma-multiple.js create mode 100644 js/src/tests/test262/language/statements/class/method/params-trailing-comma-single.js create mode 100644 js/src/tests/test262/language/statements/class/method/rest-param-strict-body.js create mode 100644 js/src/tests/test262/language/statements/class/method/rest-params-trailing-comma-early-error.js create mode 100644 js/src/tests/test262/language/statements/class/method/shell.js create mode 100644 js/src/tests/test262/language/statements/class/name-binding/basic.js create mode 100644 js/src/tests/test262/language/statements/class/name-binding/browser.js create mode 100644 js/src/tests/test262/language/statements/class/name-binding/const.js create mode 100644 js/src/tests/test262/language/statements/class/name-binding/expression.js create mode 100644 js/src/tests/test262/language/statements/class/name-binding/in-extends-expression-assigned.js create mode 100644 js/src/tests/test262/language/statements/class/name-binding/in-extends-expression-grouped.js create mode 100644 js/src/tests/test262/language/statements/class/name-binding/in-extends-expression.js create mode 100644 js/src/tests/test262/language/statements/class/name-binding/shell.js create mode 100644 js/src/tests/test262/language/statements/class/name.js create mode 100644 js/src/tests/test262/language/statements/class/params-dflt-gen-meth-args-unmapped.js create mode 100644 js/src/tests/test262/language/statements/class/params-dflt-gen-meth-ref-arguments.js create mode 100644 js/src/tests/test262/language/statements/class/params-dflt-gen-meth-static-args-unmapped.js create mode 100644 js/src/tests/test262/language/statements/class/params-dflt-gen-meth-static-ref-arguments.js create mode 100644 js/src/tests/test262/language/statements/class/params-dflt-meth-args-unmapped.js create mode 100644 js/src/tests/test262/language/statements/class/params-dflt-meth-ref-arguments.js create mode 100644 js/src/tests/test262/language/statements/class/params-dflt-meth-static-args-unmapped.js create mode 100644 js/src/tests/test262/language/statements/class/params-dflt-meth-static-ref-arguments.js create mode 100644 js/src/tests/test262/language/statements/class/poisoned-underscore-proto.js create mode 100644 js/src/tests/test262/language/statements/class/private-non-static-getter-static-setter-early-error.js create mode 100644 js/src/tests/test262/language/statements/class/private-non-static-setter-static-getter-early-error.js create mode 100644 js/src/tests/test262/language/statements/class/private-static-getter-non-static-setter-early-error.js create mode 100644 js/src/tests/test262/language/statements/class/private-static-setter-non-static-getter-early-error.js create mode 100644 js/src/tests/test262/language/statements/class/restricted-properties.js create mode 100644 js/src/tests/test262/language/statements/class/scope-gen-meth-paramsbody-var-close.js create mode 100644 js/src/tests/test262/language/statements/class/scope-gen-meth-paramsbody-var-open.js create mode 100644 js/src/tests/test262/language/statements/class/scope-meth-paramsbody-var-close.js create mode 100644 js/src/tests/test262/language/statements/class/scope-meth-paramsbody-var-open.js create mode 100644 js/src/tests/test262/language/statements/class/scope-name-lex-close.js create mode 100644 js/src/tests/test262/language/statements/class/scope-name-lex-open-heritage.js create mode 100644 js/src/tests/test262/language/statements/class/scope-name-lex-open-no-heritage.js create mode 100644 js/src/tests/test262/language/statements/class/scope-setter-paramsbody-var-close.js create mode 100644 js/src/tests/test262/language/statements/class/scope-setter-paramsbody-var-open.js create mode 100644 js/src/tests/test262/language/statements/class/scope-static-gen-meth-paramsbody-var-close.js create mode 100644 js/src/tests/test262/language/statements/class/scope-static-gen-meth-paramsbody-var-open.js create mode 100644 js/src/tests/test262/language/statements/class/scope-static-meth-paramsbody-var-close.js create mode 100644 js/src/tests/test262/language/statements/class/scope-static-meth-paramsbody-var-open.js create mode 100644 js/src/tests/test262/language/statements/class/scope-static-setter-paramsbody-var-close.js create mode 100644 js/src/tests/test262/language/statements/class/scope-static-setter-paramsbody-var-open.js create mode 100644 js/src/tests/test262/language/statements/class/setter-length-dflt.js create mode 100644 js/src/tests/test262/language/statements/class/shell.js create mode 100644 js/src/tests/test262/language/statements/class/static-classelementname-abrupt-completion.js create mode 100644 js/src/tests/test262/language/statements/class/static-gen-method-param-dflt-yield.js create mode 100644 js/src/tests/test262/language/statements/class/static-init-abrupt.js create mode 100644 js/src/tests/test262/language/statements/class/static-init-arguments-functions.js create mode 100644 js/src/tests/test262/language/statements/class/static-init-arguments-methods.js create mode 100644 js/src/tests/test262/language/statements/class/static-init-await-binding-invalid.js create mode 100644 js/src/tests/test262/language/statements/class/static-init-await-binding-valid.js create mode 100644 js/src/tests/test262/language/statements/class/static-init-expr-new-target.js create mode 100644 js/src/tests/test262/language/statements/class/static-init-expr-this.js create mode 100644 js/src/tests/test262/language/statements/class/static-init-invalid-arguments.js create mode 100644 js/src/tests/test262/language/statements/class/static-init-invalid-await.js create mode 100644 js/src/tests/test262/language/statements/class/static-init-invalid-label-dup.js create mode 100644 js/src/tests/test262/language/statements/class/static-init-invalid-lex-dup.js create mode 100644 js/src/tests/test262/language/statements/class/static-init-invalid-lex-var.js create mode 100644 js/src/tests/test262/language/statements/class/static-init-invalid-return.js create mode 100644 js/src/tests/test262/language/statements/class/static-init-invalid-super-call.js create mode 100644 js/src/tests/test262/language/statements/class/static-init-invalid-undefined-break-target.js create mode 100644 js/src/tests/test262/language/statements/class/static-init-invalid-undefined-continue-target.js create mode 100644 js/src/tests/test262/language/statements/class/static-init-invalid-yield.js create mode 100644 js/src/tests/test262/language/statements/class/static-init-scope-lex-close.js create mode 100644 js/src/tests/test262/language/statements/class/static-init-scope-lex-derived.js create mode 100644 js/src/tests/test262/language/statements/class/static-init-scope-lex-open.js create mode 100644 js/src/tests/test262/language/statements/class/static-init-scope-private.js create mode 100644 js/src/tests/test262/language/statements/class/static-init-scope-var-close.js create mode 100644 js/src/tests/test262/language/statements/class/static-init-scope-var-derived.js create mode 100644 js/src/tests/test262/language/statements/class/static-init-scope-var-open.js create mode 100644 js/src/tests/test262/language/statements/class/static-init-sequence.js create mode 100644 js/src/tests/test262/language/statements/class/static-init-statement-list-optional.js create mode 100644 js/src/tests/test262/language/statements/class/static-init-super-property.js create mode 100644 js/src/tests/test262/language/statements/class/static-method-gen-non-configurable-err.js create mode 100644 js/src/tests/test262/language/statements/class/static-method-length-dflt.js create mode 100644 js/src/tests/test262/language/statements/class/static-method-non-configurable-err.js create mode 100644 js/src/tests/test262/language/statements/class/static-method-param-yield.js create mode 100644 js/src/tests/test262/language/statements/class/strict-mode/arguments-callee.js create mode 100644 js/src/tests/test262/language/statements/class/strict-mode/browser.js create mode 100644 js/src/tests/test262/language/statements/class/strict-mode/shell.js create mode 100644 js/src/tests/test262/language/statements/class/strict-mode/with.js create mode 100644 js/src/tests/test262/language/statements/class/subclass-builtins/browser.js create mode 100644 js/src/tests/test262/language/statements/class/subclass-builtins/shell.js create mode 100644 js/src/tests/test262/language/statements/class/subclass-builtins/subclass-AggregateError.js create mode 100644 js/src/tests/test262/language/statements/class/subclass-builtins/subclass-Array.js create mode 100644 js/src/tests/test262/language/statements/class/subclass-builtins/subclass-ArrayBuffer.js create mode 100644 js/src/tests/test262/language/statements/class/subclass-builtins/subclass-BigInt64Array.js create mode 100644 js/src/tests/test262/language/statements/class/subclass-builtins/subclass-BigUint64Array.js create mode 100644 js/src/tests/test262/language/statements/class/subclass-builtins/subclass-Boolean.js create mode 100644 js/src/tests/test262/language/statements/class/subclass-builtins/subclass-DataView.js create mode 100644 js/src/tests/test262/language/statements/class/subclass-builtins/subclass-Date.js create mode 100644 js/src/tests/test262/language/statements/class/subclass-builtins/subclass-Error.js create mode 100644 js/src/tests/test262/language/statements/class/subclass-builtins/subclass-EvalError.js create mode 100644 js/src/tests/test262/language/statements/class/subclass-builtins/subclass-Float32Array.js create mode 100644 js/src/tests/test262/language/statements/class/subclass-builtins/subclass-Float64Array.js create mode 100644 js/src/tests/test262/language/statements/class/subclass-builtins/subclass-Function.js create mode 100644 js/src/tests/test262/language/statements/class/subclass-builtins/subclass-Int16Array.js create mode 100644 js/src/tests/test262/language/statements/class/subclass-builtins/subclass-Int32Array.js create mode 100644 js/src/tests/test262/language/statements/class/subclass-builtins/subclass-Int8Array.js create mode 100644 js/src/tests/test262/language/statements/class/subclass-builtins/subclass-Map.js create mode 100644 js/src/tests/test262/language/statements/class/subclass-builtins/subclass-Number.js create mode 100644 js/src/tests/test262/language/statements/class/subclass-builtins/subclass-Object.js create mode 100644 js/src/tests/test262/language/statements/class/subclass-builtins/subclass-Promise.js create mode 100644 js/src/tests/test262/language/statements/class/subclass-builtins/subclass-RangeError.js create mode 100644 js/src/tests/test262/language/statements/class/subclass-builtins/subclass-ReferenceError.js create mode 100644 js/src/tests/test262/language/statements/class/subclass-builtins/subclass-RegExp.js create mode 100644 js/src/tests/test262/language/statements/class/subclass-builtins/subclass-Set.js create mode 100644 js/src/tests/test262/language/statements/class/subclass-builtins/subclass-SharedArrayBuffer.js create mode 100644 js/src/tests/test262/language/statements/class/subclass-builtins/subclass-String.js create mode 100644 js/src/tests/test262/language/statements/class/subclass-builtins/subclass-SyntaxError.js create mode 100644 js/src/tests/test262/language/statements/class/subclass-builtins/subclass-TypeError.js create mode 100644 js/src/tests/test262/language/statements/class/subclass-builtins/subclass-URIError.js create mode 100644 js/src/tests/test262/language/statements/class/subclass-builtins/subclass-Uint16Array.js create mode 100644 js/src/tests/test262/language/statements/class/subclass-builtins/subclass-Uint32Array.js create mode 100644 js/src/tests/test262/language/statements/class/subclass-builtins/subclass-Uint8Array.js create mode 100644 js/src/tests/test262/language/statements/class/subclass-builtins/subclass-Uint8ClampedArray.js create mode 100644 js/src/tests/test262/language/statements/class/subclass-builtins/subclass-WeakMap.js create mode 100644 js/src/tests/test262/language/statements/class/subclass-builtins/subclass-WeakRef.js create mode 100644 js/src/tests/test262/language/statements/class/subclass-builtins/subclass-WeakSet.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/binding.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/browser.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/builtin-objects/Array/browser.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/builtin-objects/Array/contructor-calls-super-multiple-arguments.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/builtin-objects/Array/contructor-calls-super-single-argument.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/builtin-objects/Array/length.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/builtin-objects/Array/regular-subclassing.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/builtin-objects/Array/shell.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/builtin-objects/Array/super-must-be-called.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/builtin-objects/ArrayBuffer/browser.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/builtin-objects/ArrayBuffer/regular-subclassing.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/builtin-objects/ArrayBuffer/shell.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/builtin-objects/ArrayBuffer/super-must-be-called.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/builtin-objects/Boolean/browser.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/builtin-objects/Boolean/regular-subclassing.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/builtin-objects/Boolean/shell.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/builtin-objects/Boolean/super-must-be-called.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/builtin-objects/DataView/browser.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/builtin-objects/DataView/regular-subclassing.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/builtin-objects/DataView/shell.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/builtin-objects/DataView/super-must-be-called.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/builtin-objects/Date/browser.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/builtin-objects/Date/regular-subclassing.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/builtin-objects/Date/shell.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/builtin-objects/Date/super-must-be-called.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/builtin-objects/Error/browser.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/builtin-objects/Error/message-property-assignment.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/builtin-objects/Error/regular-subclassing.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/builtin-objects/Error/shell.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/builtin-objects/Error/super-must-be-called.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/builtin-objects/Function/browser.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/builtin-objects/Function/instance-length.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/builtin-objects/Function/instance-name.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/builtin-objects/Function/regular-subclassing.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/builtin-objects/Function/shell.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/builtin-objects/Function/super-must-be-called.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/builtin-objects/GeneratorFunction/browser.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/builtin-objects/GeneratorFunction/instance-length.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/builtin-objects/GeneratorFunction/instance-name.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/builtin-objects/GeneratorFunction/instance-prototype.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/builtin-objects/GeneratorFunction/regular-subclassing.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/builtin-objects/GeneratorFunction/shell.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/builtin-objects/GeneratorFunction/super-must-be-called.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/builtin-objects/Map/browser.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/builtin-objects/Map/regular-subclassing.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/builtin-objects/Map/shell.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/builtin-objects/Map/super-must-be-called.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/builtin-objects/NativeError/EvalError-message.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/builtin-objects/NativeError/EvalError-name.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/builtin-objects/NativeError/EvalError-super.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/builtin-objects/NativeError/RangeError-message.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/builtin-objects/NativeError/RangeError-name.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/builtin-objects/NativeError/RangeError-super.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/builtin-objects/NativeError/ReferenceError-message.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/builtin-objects/NativeError/ReferenceError-name.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/builtin-objects/NativeError/ReferenceError-super.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/builtin-objects/NativeError/SyntaxError-message.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/builtin-objects/NativeError/SyntaxError-name.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/builtin-objects/NativeError/SyntaxError-super.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/builtin-objects/NativeError/TypeError-message.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/builtin-objects/NativeError/TypeError-name.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/builtin-objects/NativeError/TypeError-super.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/builtin-objects/NativeError/URIError-message.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/builtin-objects/NativeError/URIError-name.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/builtin-objects/NativeError/URIError-super.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/builtin-objects/NativeError/browser.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/builtin-objects/NativeError/shell.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/builtin-objects/Number/browser.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/builtin-objects/Number/regular-subclassing.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/builtin-objects/Number/shell.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/builtin-objects/Number/super-must-be-called.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/builtin-objects/Object/browser.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/builtin-objects/Object/constructor-return-undefined-throws.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/builtin-objects/Object/constructor-returns-non-object.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/builtin-objects/Object/regular-subclassing.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/builtin-objects/Object/replacing-prototype.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/builtin-objects/Object/shell.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/builtin-objects/Promise/browser.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/builtin-objects/Promise/regular-subclassing.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/builtin-objects/Promise/shell.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/builtin-objects/Promise/super-must-be-called.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/builtin-objects/Proxy/browser.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/builtin-objects/Proxy/no-prototype-throws.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/builtin-objects/Proxy/shell.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/builtin-objects/RegExp/browser.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/builtin-objects/RegExp/lastIndex.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/builtin-objects/RegExp/regular-subclassing.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/builtin-objects/RegExp/shell.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/builtin-objects/RegExp/super-must-be-called.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/builtin-objects/Set/browser.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/builtin-objects/Set/regular-subclassing.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/builtin-objects/Set/shell.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/builtin-objects/Set/super-must-be-called.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/builtin-objects/String/browser.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/builtin-objects/String/length.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/builtin-objects/String/regular-subclassing.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/builtin-objects/String/shell.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/builtin-objects/String/super-must-be-called.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/builtin-objects/Symbol/browser.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/builtin-objects/Symbol/new-symbol-with-super-throws.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/builtin-objects/Symbol/shell.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/builtin-objects/Symbol/symbol-valid-as-extends-value.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/builtin-objects/TypedArray/browser.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/builtin-objects/TypedArray/regular-subclassing.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/builtin-objects/TypedArray/shell.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/builtin-objects/TypedArray/super-must-be-called.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/builtin-objects/WeakMap/browser.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/builtin-objects/WeakMap/regular-subclassing.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/builtin-objects/WeakMap/shell.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/builtin-objects/WeakMap/super-must-be-called.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/builtin-objects/WeakSet/browser.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/builtin-objects/WeakSet/regular-subclassing.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/builtin-objects/WeakSet/shell.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/builtin-objects/WeakSet/super-must-be-called.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/builtin-objects/browser.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/builtin-objects/shell.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/builtins.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/class-definition-evaluation-empty-constructor-heritage-present.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/class-definition-null-proto-contains-return-override.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/class-definition-null-proto-missing-return-override.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/class-definition-null-proto-super.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/class-definition-null-proto-this.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/class-definition-null-proto.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/class-definition-parent-proto-null.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/default-constructor-2.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/default-constructor-spread-override.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/default-constructor.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/derived-class-return-override-catch-finally-arrow.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/derived-class-return-override-catch-finally.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/derived-class-return-override-catch-super-arrow.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/derived-class-return-override-catch-super.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/derived-class-return-override-catch.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/derived-class-return-override-finally-super-arrow.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/derived-class-return-override-finally-super.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/derived-class-return-override-for-of-arrow.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/derived-class-return-override-for-of.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/derived-class-return-override-with-boolean.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/derived-class-return-override-with-empty.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/derived-class-return-override-with-null.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/derived-class-return-override-with-number.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/derived-class-return-override-with-object.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/derived-class-return-override-with-string.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/derived-class-return-override-with-symbol.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/derived-class-return-override-with-this.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/derived-class-return-override-with-undefined.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/shell.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/superclass-arrow-function.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/superclass-async-function.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/superclass-async-generator-function.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/superclass-bound-function.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/superclass-generator-function.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/superclass-prototype-setter-constructor.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/superclass-prototype-setter-method-override.js create mode 100644 js/src/tests/test262/language/statements/class/subclass/superclass-static-method-override.js create mode 100644 js/src/tests/test262/language/statements/class/super/browser.js create mode 100644 js/src/tests/test262/language/statements/class/super/in-constructor-superproperty-evaluation.js create mode 100644 js/src/tests/test262/language/statements/class/super/in-constructor.js create mode 100644 js/src/tests/test262/language/statements/class/super/in-getter.js create mode 100644 js/src/tests/test262/language/statements/class/super/in-methods.js create mode 100644 js/src/tests/test262/language/statements/class/super/in-setter.js create mode 100644 js/src/tests/test262/language/statements/class/super/in-static-getter.js create mode 100644 js/src/tests/test262/language/statements/class/super/in-static-methods.js create mode 100644 js/src/tests/test262/language/statements/class/super/in-static-setter.js create mode 100644 js/src/tests/test262/language/statements/class/super/shell.js create mode 100644 js/src/tests/test262/language/statements/class/syntax/browser.js create mode 100644 js/src/tests/test262/language/statements/class/syntax/class-body-has-direct-super-class-heritage.js create mode 100644 js/src/tests/test262/language/statements/class/syntax/class-body-method-definition-super-property.js create mode 100644 js/src/tests/test262/language/statements/class/syntax/class-declaration-binding-identifier-class-element-list.js create mode 100644 js/src/tests/test262/language/statements/class/syntax/class-declaration-computed-method-definition.js create mode 100644 js/src/tests/test262/language/statements/class/syntax/class-declaration-computed-method-generator-definition.js create mode 100644 js/src/tests/test262/language/statements/class/syntax/class-declaration-heritage-identifier-reference-class-element-list.js create mode 100644 js/src/tests/test262/language/statements/class/syntax/class-expression-binding-identifier-opt-class-element-list.js create mode 100644 js/src/tests/test262/language/statements/class/syntax/class-expression-heritage-identifier-reference.js create mode 100644 js/src/tests/test262/language/statements/class/syntax/class-expression.js create mode 100644 js/src/tests/test262/language/statements/class/syntax/class-method-propname-constructor.js create mode 100644 js/src/tests/test262/language/statements/class/syntax/early-errors/browser.js create mode 100644 js/src/tests/test262/language/statements/class/syntax/early-errors/class-definition-evaluation-block-duplicate-binding.js create mode 100644 js/src/tests/test262/language/statements/class/syntax/early-errors/class-definition-evaluation-scriptbody-duplicate-binding.js create mode 100644 js/src/tests/test262/language/statements/class/syntax/early-errors/shell.js create mode 100644 js/src/tests/test262/language/statements/class/syntax/escaped-static.js create mode 100644 js/src/tests/test262/language/statements/class/syntax/shell.js (limited to 'js/src/tests/test262/language/statements/class') diff --git a/js/src/tests/test262/language/statements/class/accessor-name-inst-computed-yield-expr.js b/js/src/tests/test262/language/statements/class/accessor-name-inst-computed-yield-expr.js new file mode 100644 index 0000000000..1ffff48bfd --- /dev/null +++ b/js/src/tests/test262/language/statements/class/accessor-name-inst-computed-yield-expr.js @@ -0,0 +1,45 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-object-initializer-runtime-semantics-evaluation +es6id: 12.2.6.8 +description: > + The `yield` keyword behaves as a YieldExpression within a generator function +info: | + [...] + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing PropertyDefinitionEvaluation + for m with arguments proto and false. + + ComputedPropertyName : [ AssignmentExpression ] + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let propName be ? GetValue(exprValue). + 3. Return ? ToPropertyKey(propName). +features: [generators] +---*/ + +var yieldSet, C, iter; +function* g() { + class C_ { + get [yield]() { return 'get yield'; } + set [yield](param) { yieldSet = param; } + } + + C = C_; +} + +iter = g(); + +iter.next(); +iter.next('first'); +iter.next('second'); + +assert.sameValue(C.prototype.first, 'get yield'); + +C.prototype.second = 'set yield'; + +assert.sameValue(yieldSet, 'set yield'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/accessor-name-inst/browser.js b/js/src/tests/test262/language/statements/class/accessor-name-inst/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/accessor-name-inst/computed-err-evaluation.js b/js/src/tests/test262/language/statements/class/accessor-name-inst/computed-err-evaluation.js new file mode 100644 index 0000000000..6b2789e7b7 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/accessor-name-inst/computed-err-evaluation.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/accessor-names/computed-err-evaluation.case +// - src/accessor-names/error/cls-decl-inst.template +/*--- +description: Abrupt completion when evaluating expression (Class declaration, instance method) +esid: sec-runtime-semantics-classdefinitionevaluation +features: [class] +flags: [generated] +info: | + [...] + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing PropertyDefinitionEvaluation + for m with arguments proto and false. + + + 12.2.6.7 Runtime Semantics: Evaluation + + ComputedPropertyName : [ AssignmentExpression ] + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let propName be ? GetValue(exprValue). +---*/ +var thrower = function() { + throw new Test262Error(); +}; + + +assert.throws(Test262Error, function() { + class C { + get [thrower()]() {} + } +}, '`get` accessor'); + +assert.throws(Test262Error, function() { + class C { + set [thrower()](_) {} + } +}, '`set` accessor'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/accessor-name-inst/computed-err-to-prop-key.js b/js/src/tests/test262/language/statements/class/accessor-name-inst/computed-err-to-prop-key.js new file mode 100644 index 0000000000..bad284dd3a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/accessor-name-inst/computed-err-to-prop-key.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/accessor-names/computed-err-to-prop-key.case +// - src/accessor-names/error/cls-decl-inst.template +/*--- +description: Abrupt completion when coercing to property key value (Class declaration, instance method) +esid: sec-runtime-semantics-classdefinitionevaluation +features: [class] +flags: [generated] +info: | + [...] + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing PropertyDefinitionEvaluation + for m with arguments proto and false. + + + 12.2.6.7 Runtime Semantics: Evaluation + + [...] + + ComputedPropertyName : [ AssignmentExpression ] + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let propName be ? GetValue(exprValue). + 3. Return ? ToPropertyKey(propName). + + 7.1.14 ToPropertyKey + + 1. Let key be ? ToPrimitive(argument, hint String). + + 7.1.1 ToPrimitive + + [...] + 7. Return ? OrdinaryToPrimitive(input, hint). + + 7.1.1.1 OrdinaryToPrimitive + + 5. For each name in methodNames in List order, do + [...] + 6. Throw a TypeError exception. +---*/ +var badKey = Object.create(null); + + +assert.throws(TypeError, function() { + class C { + get [badKey]() {} + } +}, '`get` accessor'); + +assert.throws(TypeError, function() { + class C { + set [badKey](_) {} + } +}, '`set` accessor'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/accessor-name-inst/computed-err-unresolvable.js b/js/src/tests/test262/language/statements/class/accessor-name-inst/computed-err-unresolvable.js new file mode 100644 index 0000000000..55e183a385 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/accessor-name-inst/computed-err-unresolvable.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/accessor-names/computed-err-unresolvable.case +// - src/accessor-names/error/cls-decl-inst.template +/*--- +description: Abrupt completion when resolving reference value (Class declaration, instance method) +esid: sec-runtime-semantics-classdefinitionevaluation +features: [class] +flags: [generated] +info: | + [...] + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing PropertyDefinitionEvaluation + for m with arguments proto and false. + + + 12.2.6.7 Runtime Semantics: Evaluation + + [...] + + ComputedPropertyName : [ AssignmentExpression ] + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let propName be ? GetValue(exprValue). +---*/ + +assert.throws(ReferenceError, function() { + class C { + get [test262unresolvable]() {} + } +}, '`get` accessor'); + +assert.throws(ReferenceError, function() { + class C { + set [test262unresolvable](_) {} + } +}, '`set` accessor'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/accessor-name-inst/computed.js b/js/src/tests/test262/language/statements/class/accessor-name-inst/computed.js new file mode 100644 index 0000000000..b11ca09cff --- /dev/null +++ b/js/src/tests/test262/language/statements/class/accessor-name-inst/computed.js @@ -0,0 +1,42 @@ +// This file was procedurally generated from the following sources: +// - src/accessor-names/computed.case +// - src/accessor-names/default/cls-decl-inst.template +/*--- +description: Computed values as accessor property names (AssignmentExpression) (Class declaration, instance method) +esid: sec-runtime-semantics-classdefinitionevaluation +features: [class] +flags: [generated] +info: | + [...] + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing PropertyDefinitionEvaluation + for m with arguments proto and false. + + + 12.2.6.7 Runtime Semantics: Evaluation + + [...] + + ComputedPropertyName : [ AssignmentExpression ] + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let propName be ? GetValue(exprValue). + 3. Return ? ToPropertyKey(propName). +---*/ +var _; + + +var stringSet; + +class C { + get [_ = 'str' + 'ing']() { return 'get string'; } + set [_ = 'str' + 'ing'](param) { stringSet = param; } +} + +assert.sameValue(C.prototype['string'], 'get string'); + +C.prototype['string'] = 'set string'; +assert.sameValue(stringSet, 'set string'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/accessor-name-inst/literal-numeric-binary.js b/js/src/tests/test262/language/statements/class/accessor-name-inst/literal-numeric-binary.js new file mode 100644 index 0000000000..1dd543dfbd --- /dev/null +++ b/js/src/tests/test262/language/statements/class/accessor-name-inst/literal-numeric-binary.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/accessor-names/literal-numeric-binary.case +// - src/accessor-names/default/cls-decl-inst.template +/*--- +description: Computed values as accessor property names (numeric literal in binary notation) (Class declaration, instance method) +esid: sec-runtime-semantics-classdefinitionevaluation +features: [class] +flags: [generated] +info: | + [...] + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing PropertyDefinitionEvaluation + for m with arguments proto and false. + + + 12.2.6.7 Runtime Semantics: Evaluation + + [...] + + ComputedPropertyName : [ AssignmentExpression ] + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let propName be ? GetValue(exprValue). + 3. Return ? ToPropertyKey(propName). +---*/ + +var stringSet; + +class C { + get 0b10() { return 'get string'; } + set 0b10(param) { stringSet = param; } +} + +assert.sameValue(C.prototype['2'], 'get string'); + +C.prototype['2'] = 'set string'; +assert.sameValue(stringSet, 'set string'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/accessor-name-inst/literal-numeric-exponent.js b/js/src/tests/test262/language/statements/class/accessor-name-inst/literal-numeric-exponent.js new file mode 100644 index 0000000000..f6bbea1eb1 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/accessor-name-inst/literal-numeric-exponent.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/accessor-names/literal-numeric-exponent.case +// - src/accessor-names/default/cls-decl-inst.template +/*--- +description: Computed values as accessor property names (numeric literal in exponent notation) (Class declaration, instance method) +esid: sec-runtime-semantics-classdefinitionevaluation +features: [class] +flags: [generated] +info: | + [...] + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing PropertyDefinitionEvaluation + for m with arguments proto and false. + + + 12.2.6.7 Runtime Semantics: Evaluation + + [...] + + ComputedPropertyName : [ AssignmentExpression ] + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let propName be ? GetValue(exprValue). + 3. Return ? ToPropertyKey(propName). +---*/ + +var stringSet; + +class C { + get 1E+9() { return 'get string'; } + set 1E+9(param) { stringSet = param; } +} + +assert.sameValue(C.prototype['1000000000'], 'get string'); + +C.prototype['1000000000'] = 'set string'; +assert.sameValue(stringSet, 'set string'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/accessor-name-inst/literal-numeric-hex.js b/js/src/tests/test262/language/statements/class/accessor-name-inst/literal-numeric-hex.js new file mode 100644 index 0000000000..7ab75e0fad --- /dev/null +++ b/js/src/tests/test262/language/statements/class/accessor-name-inst/literal-numeric-hex.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/accessor-names/literal-numeric-hex.case +// - src/accessor-names/default/cls-decl-inst.template +/*--- +description: Computed values as accessor property names (numeric literal in hexadecimal notation) (Class declaration, instance method) +esid: sec-runtime-semantics-classdefinitionevaluation +features: [class] +flags: [generated] +info: | + [...] + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing PropertyDefinitionEvaluation + for m with arguments proto and false. + + + 12.2.6.7 Runtime Semantics: Evaluation + + [...] + + ComputedPropertyName : [ AssignmentExpression ] + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let propName be ? GetValue(exprValue). + 3. Return ? ToPropertyKey(propName). +---*/ + +var stringSet; + +class C { + get 0x10() { return 'get string'; } + set 0x10(param) { stringSet = param; } +} + +assert.sameValue(C.prototype['16'], 'get string'); + +C.prototype['16'] = 'set string'; +assert.sameValue(stringSet, 'set string'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/accessor-name-inst/literal-numeric-leading-decimal.js b/js/src/tests/test262/language/statements/class/accessor-name-inst/literal-numeric-leading-decimal.js new file mode 100644 index 0000000000..c70cf03231 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/accessor-name-inst/literal-numeric-leading-decimal.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/accessor-names/literal-numeric-leading-decimal.case +// - src/accessor-names/default/cls-decl-inst.template +/*--- +description: Computed values as accessor property names (numeric literal with leading decimal point) (Class declaration, instance method) +esid: sec-runtime-semantics-classdefinitionevaluation +features: [class] +flags: [generated] +info: | + [...] + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing PropertyDefinitionEvaluation + for m with arguments proto and false. + + + 12.2.6.7 Runtime Semantics: Evaluation + + [...] + + ComputedPropertyName : [ AssignmentExpression ] + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let propName be ? GetValue(exprValue). + 3. Return ? ToPropertyKey(propName). +---*/ + +var stringSet; + +class C { + get .1() { return 'get string'; } + set .1(param) { stringSet = param; } +} + +assert.sameValue(C.prototype['0.1'], 'get string'); + +C.prototype['0.1'] = 'set string'; +assert.sameValue(stringSet, 'set string'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/accessor-name-inst/literal-numeric-non-canonical.js b/js/src/tests/test262/language/statements/class/accessor-name-inst/literal-numeric-non-canonical.js new file mode 100644 index 0000000000..69513c97d0 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/accessor-name-inst/literal-numeric-non-canonical.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/accessor-names/literal-numeric-non-canonical.case +// - src/accessor-names/default/cls-decl-inst.template +/*--- +description: Computed values as accessor property names (numeric literal with non-canonical representation) (Class declaration, instance method) +esid: sec-runtime-semantics-classdefinitionevaluation +features: [class] +flags: [generated] +info: | + [...] + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing PropertyDefinitionEvaluation + for m with arguments proto and false. + + + 12.2.6.7 Runtime Semantics: Evaluation + + [...] + + ComputedPropertyName : [ AssignmentExpression ] + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let propName be ? GetValue(exprValue). + 3. Return ? ToPropertyKey(propName). +---*/ + +var stringSet; + +class C { + get 0.0000001() { return 'get string'; } + set 0.0000001(param) { stringSet = param; } +} + +assert.sameValue(C.prototype['1e-7'], 'get string'); + +C.prototype['1e-7'] = 'set string'; +assert.sameValue(stringSet, 'set string'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/accessor-name-inst/literal-numeric-octal.js b/js/src/tests/test262/language/statements/class/accessor-name-inst/literal-numeric-octal.js new file mode 100644 index 0000000000..08eff48f90 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/accessor-name-inst/literal-numeric-octal.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/accessor-names/literal-numeric-octal.case +// - src/accessor-names/default/cls-decl-inst.template +/*--- +description: Computed values as accessor property names (numeric literal in octal notation) (Class declaration, instance method) +esid: sec-runtime-semantics-classdefinitionevaluation +features: [class] +flags: [generated] +info: | + [...] + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing PropertyDefinitionEvaluation + for m with arguments proto and false. + + + 12.2.6.7 Runtime Semantics: Evaluation + + [...] + + ComputedPropertyName : [ AssignmentExpression ] + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let propName be ? GetValue(exprValue). + 3. Return ? ToPropertyKey(propName). +---*/ + +var stringSet; + +class C { + get 0o10() { return 'get string'; } + set 0o10(param) { stringSet = param; } +} + +assert.sameValue(C.prototype['8'], 'get string'); + +C.prototype['8'] = 'set string'; +assert.sameValue(stringSet, 'set string'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/accessor-name-inst/literal-numeric-zero.js b/js/src/tests/test262/language/statements/class/accessor-name-inst/literal-numeric-zero.js new file mode 100644 index 0000000000..d062be1fcf --- /dev/null +++ b/js/src/tests/test262/language/statements/class/accessor-name-inst/literal-numeric-zero.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/accessor-names/literal-numeric-zero.case +// - src/accessor-names/default/cls-decl-inst.template +/*--- +description: Computed values as accessor property names (numeric literal zero) (Class declaration, instance method) +esid: sec-runtime-semantics-classdefinitionevaluation +features: [class] +flags: [generated] +info: | + [...] + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing PropertyDefinitionEvaluation + for m with arguments proto and false. + + + 12.2.6.7 Runtime Semantics: Evaluation + + [...] + + ComputedPropertyName : [ AssignmentExpression ] + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let propName be ? GetValue(exprValue). + 3. Return ? ToPropertyKey(propName). +---*/ + +var stringSet; + +class C { + get 0() { return 'get string'; } + set 0(param) { stringSet = param; } +} + +assert.sameValue(C.prototype['0'], 'get string'); + +C.prototype['0'] = 'set string'; +assert.sameValue(stringSet, 'set string'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/accessor-name-inst/literal-string-char-escape.js b/js/src/tests/test262/language/statements/class/accessor-name-inst/literal-string-char-escape.js new file mode 100644 index 0000000000..88960560e3 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/accessor-name-inst/literal-string-char-escape.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/accessor-names/literal-string-char-escape.case +// - src/accessor-names/default/cls-decl-inst.template +/*--- +description: Computed values as accessor property names (string literal containing a character escape sequence) (Class declaration, instance method) +esid: sec-runtime-semantics-classdefinitionevaluation +features: [class] +flags: [generated] +info: | + [...] + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing PropertyDefinitionEvaluation + for m with arguments proto and false. + + + 12.2.6.7 Runtime Semantics: Evaluation + + [...] + + ComputedPropertyName : [ AssignmentExpression ] + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let propName be ? GetValue(exprValue). + 3. Return ? ToPropertyKey(propName). +---*/ + +var stringSet; + +class C { + get 'character\tescape'() { return 'get string'; } + set 'character\tescape'(param) { stringSet = param; } +} + +assert.sameValue(C.prototype['character escape'], 'get string'); + +C.prototype['character escape'] = 'set string'; +assert.sameValue(stringSet, 'set string'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/accessor-name-inst/literal-string-default-escaped-ext.js b/js/src/tests/test262/language/statements/class/accessor-name-inst/literal-string-default-escaped-ext.js new file mode 100644 index 0000000000..68f36541d8 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/accessor-name-inst/literal-string-default-escaped-ext.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/accessor-names/literal-string-default-escaped-ext.case +// - src/accessor-names/default/cls-decl-inst.template +/*--- +description: Computed values as accessor property names (string literal 'default' w/ extended escape) (Class declaration, instance method) +esid: sec-runtime-semantics-classdefinitionevaluation +features: [class] +flags: [generated] +info: | + [...] + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing PropertyDefinitionEvaluation + for m with arguments proto and false. + + + 12.2.6.7 Runtime Semantics: Evaluation + + [...] + + ComputedPropertyName : [ AssignmentExpression ] + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let propName be ? GetValue(exprValue). + 3. Return ? ToPropertyKey(propName). +---*/ + +var stringSet; + +class C { + get 'def\u{61}ult'() { return 'get string'; } + set 'def\u{61}ult'(param) { stringSet = param; } +} + +assert.sameValue(C.prototype['default'], 'get string'); + +C.prototype['default'] = 'set string'; +assert.sameValue(stringSet, 'set string'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/accessor-name-inst/literal-string-default-escaped.js b/js/src/tests/test262/language/statements/class/accessor-name-inst/literal-string-default-escaped.js new file mode 100644 index 0000000000..e133e30efd --- /dev/null +++ b/js/src/tests/test262/language/statements/class/accessor-name-inst/literal-string-default-escaped.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/accessor-names/literal-string-default-escaped.case +// - src/accessor-names/default/cls-decl-inst.template +/*--- +description: Computed values as accessor property names (string literal 'default' escaped) (Class declaration, instance method) +esid: sec-runtime-semantics-classdefinitionevaluation +features: [class] +flags: [generated] +info: | + [...] + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing PropertyDefinitionEvaluation + for m with arguments proto and false. + + + 12.2.6.7 Runtime Semantics: Evaluation + + [...] + + ComputedPropertyName : [ AssignmentExpression ] + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let propName be ? GetValue(exprValue). + 3. Return ? ToPropertyKey(propName). +---*/ + +var stringSet; + +class C { + get 'def\u0061ult'() { return 'get string'; } + set 'def\u0061ult'(param) { stringSet = param; } +} + +assert.sameValue(C.prototype['default'], 'get string'); + +C.prototype['default'] = 'set string'; +assert.sameValue(stringSet, 'set string'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/accessor-name-inst/literal-string-default.js b/js/src/tests/test262/language/statements/class/accessor-name-inst/literal-string-default.js new file mode 100644 index 0000000000..152e02fb3c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/accessor-name-inst/literal-string-default.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/accessor-names/literal-string-default.case +// - src/accessor-names/default/cls-decl-inst.template +/*--- +description: Computed values as accessor property names (string literal 'default') (Class declaration, instance method) +esid: sec-runtime-semantics-classdefinitionevaluation +features: [class] +flags: [generated] +info: | + [...] + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing PropertyDefinitionEvaluation + for m with arguments proto and false. + + + 12.2.6.7 Runtime Semantics: Evaluation + + [...] + + ComputedPropertyName : [ AssignmentExpression ] + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let propName be ? GetValue(exprValue). + 3. Return ? ToPropertyKey(propName). +---*/ + +var stringSet; + +class C { + get 'default'() { return 'get string'; } + set 'default'(param) { stringSet = param; } +} + +assert.sameValue(C.prototype['default'], 'get string'); + +C.prototype['default'] = 'set string'; +assert.sameValue(stringSet, 'set string'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/accessor-name-inst/literal-string-double-quote.js b/js/src/tests/test262/language/statements/class/accessor-name-inst/literal-string-double-quote.js new file mode 100644 index 0000000000..6b1b5d8361 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/accessor-name-inst/literal-string-double-quote.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/accessor-names/literal-string-double-quote.case +// - src/accessor-names/default/cls-decl-inst.template +/*--- +description: Computed values as accessor property names (string literal using double quotes) (Class declaration, instance method) +esid: sec-runtime-semantics-classdefinitionevaluation +features: [class] +flags: [generated] +info: | + [...] + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing PropertyDefinitionEvaluation + for m with arguments proto and false. + + + 12.2.6.7 Runtime Semantics: Evaluation + + [...] + + ComputedPropertyName : [ AssignmentExpression ] + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let propName be ? GetValue(exprValue). + 3. Return ? ToPropertyKey(propName). +---*/ + +var stringSet; + +class C { + get "doubleQuote"() { return 'get string'; } + set "doubleQuote"(param) { stringSet = param; } +} + +assert.sameValue(C.prototype["doubleQuote"], 'get string'); + +C.prototype["doubleQuote"] = 'set string'; +assert.sameValue(stringSet, 'set string'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/accessor-name-inst/literal-string-empty.js b/js/src/tests/test262/language/statements/class/accessor-name-inst/literal-string-empty.js new file mode 100644 index 0000000000..fa579f4173 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/accessor-name-inst/literal-string-empty.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/accessor-names/literal-string-empty.case +// - src/accessor-names/default/cls-decl-inst.template +/*--- +description: Computed values as accessor property names (string literal, the empty string) (Class declaration, instance method) +esid: sec-runtime-semantics-classdefinitionevaluation +features: [class] +flags: [generated] +info: | + [...] + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing PropertyDefinitionEvaluation + for m with arguments proto and false. + + + 12.2.6.7 Runtime Semantics: Evaluation + + [...] + + ComputedPropertyName : [ AssignmentExpression ] + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let propName be ? GetValue(exprValue). + 3. Return ? ToPropertyKey(propName). +---*/ + +var stringSet; + +class C { + get ''() { return 'get string'; } + set ''(param) { stringSet = param; } +} + +assert.sameValue(C.prototype[''], 'get string'); + +C.prototype[''] = 'set string'; +assert.sameValue(stringSet, 'set string'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/accessor-name-inst/literal-string-hex-escape.js b/js/src/tests/test262/language/statements/class/accessor-name-inst/literal-string-hex-escape.js new file mode 100644 index 0000000000..37fa2404b8 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/accessor-name-inst/literal-string-hex-escape.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/accessor-names/literal-string-hex-escape.case +// - src/accessor-names/default/cls-decl-inst.template +/*--- +description: Computed values as accessor property names (string literal containing a hexadecimal escape sequence) (Class declaration, instance method) +esid: sec-runtime-semantics-classdefinitionevaluation +features: [class] +flags: [generated] +info: | + [...] + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing PropertyDefinitionEvaluation + for m with arguments proto and false. + + + 12.2.6.7 Runtime Semantics: Evaluation + + [...] + + ComputedPropertyName : [ AssignmentExpression ] + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let propName be ? GetValue(exprValue). + 3. Return ? ToPropertyKey(propName). +---*/ + +var stringSet; + +class C { + get 'hex\x45scape'() { return 'get string'; } + set 'hex\x45scape'(param) { stringSet = param; } +} + +assert.sameValue(C.prototype['hexEscape'], 'get string'); + +C.prototype['hexEscape'] = 'set string'; +assert.sameValue(stringSet, 'set string'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/accessor-name-inst/literal-string-line-continuation.js b/js/src/tests/test262/language/statements/class/accessor-name-inst/literal-string-line-continuation.js new file mode 100644 index 0000000000..6208971eb6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/accessor-name-inst/literal-string-line-continuation.js @@ -0,0 +1,42 @@ +// This file was procedurally generated from the following sources: +// - src/accessor-names/literal-string-line-continuation.case +// - src/accessor-names/default/cls-decl-inst.template +/*--- +description: Computed values as accessor property names (string literal containing LineContinuation) (Class declaration, instance method) +esid: sec-runtime-semantics-classdefinitionevaluation +features: [class] +flags: [generated] +info: | + [...] + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing PropertyDefinitionEvaluation + for m with arguments proto and false. + + + 12.2.6.7 Runtime Semantics: Evaluation + + [...] + + ComputedPropertyName : [ AssignmentExpression ] + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let propName be ? GetValue(exprValue). + 3. Return ? ToPropertyKey(propName). +---*/ + +var stringSet; + +class C { + get 'line\ +Continuation'() { return 'get string'; } + set 'line\ +Continuation'(param) { stringSet = param; } +} + +assert.sameValue(C.prototype['lineContinuation'], 'get string'); + +C.prototype['lineContinuation'] = 'set string'; +assert.sameValue(stringSet, 'set string'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/accessor-name-inst/literal-string-single-quote.js b/js/src/tests/test262/language/statements/class/accessor-name-inst/literal-string-single-quote.js new file mode 100644 index 0000000000..f6ef6c5fc6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/accessor-name-inst/literal-string-single-quote.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/accessor-names/literal-string-single-quote.case +// - src/accessor-names/default/cls-decl-inst.template +/*--- +description: Computed values as accessor property names (string literal using single quotes) (Class declaration, instance method) +esid: sec-runtime-semantics-classdefinitionevaluation +features: [class] +flags: [generated] +info: | + [...] + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing PropertyDefinitionEvaluation + for m with arguments proto and false. + + + 12.2.6.7 Runtime Semantics: Evaluation + + [...] + + ComputedPropertyName : [ AssignmentExpression ] + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let propName be ? GetValue(exprValue). + 3. Return ? ToPropertyKey(propName). +---*/ + +var stringSet; + +class C { + get 'singleQuote'() { return 'get string'; } + set 'singleQuote'(param) { stringSet = param; } +} + +assert.sameValue(C.prototype['singleQuote'], 'get string'); + +C.prototype['singleQuote'] = 'set string'; +assert.sameValue(stringSet, 'set string'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/accessor-name-inst/literal-string-unicode-escape.js b/js/src/tests/test262/language/statements/class/accessor-name-inst/literal-string-unicode-escape.js new file mode 100644 index 0000000000..d14a6d3d0d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/accessor-name-inst/literal-string-unicode-escape.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/accessor-names/literal-string-unicode-escape.case +// - src/accessor-names/default/cls-decl-inst.template +/*--- +description: Computed values as accessor property names (string literal containing a Unicode escape sequence) (Class declaration, instance method) +esid: sec-runtime-semantics-classdefinitionevaluation +features: [class] +flags: [generated] +info: | + [...] + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing PropertyDefinitionEvaluation + for m with arguments proto and false. + + + 12.2.6.7 Runtime Semantics: Evaluation + + [...] + + ComputedPropertyName : [ AssignmentExpression ] + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let propName be ? GetValue(exprValue). + 3. Return ? ToPropertyKey(propName). +---*/ + +var stringSet; + +class C { + get 'unicod\u{000065}Escape'() { return 'get string'; } + set 'unicod\u{000065}Escape'(param) { stringSet = param; } +} + +assert.sameValue(C.prototype['unicodeEscape'], 'get string'); + +C.prototype['unicodeEscape'] = 'set string'; +assert.sameValue(stringSet, 'set string'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/accessor-name-inst/shell.js b/js/src/tests/test262/language/statements/class/accessor-name-inst/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/accessor-name-static-computed-yield-expr.js b/js/src/tests/test262/language/statements/class/accessor-name-static-computed-yield-expr.js new file mode 100644 index 0000000000..1f42823f34 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/accessor-name-static-computed-yield-expr.js @@ -0,0 +1,47 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-object-initializer-runtime-semantics-evaluation +es6id: 12.2.6.8 +description: > + The `yield` keyword behaves as a YieldExpression within a generator function +info: | + [...] + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + [...] + b. Else, + a. Let status be the result of performing PropertyDefinitionEvaluation + for m with arguments F and false. + + ComputedPropertyName : [ AssignmentExpression ] + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let propName be ? GetValue(exprValue). + 3. Return ? ToPropertyKey(propName). +features: [generators] +---*/ + +var yieldSet, C, iter; +function* g() { + class C_ { + static get [yield]() { return 'get yield'; } + static set [yield](param) { yieldSet = param; } + } + + C = C_; +} + +iter = g(); + +iter.next(); +iter.next('first'); +iter.next('second'); + +assert.sameValue(C.first, 'get yield'); + +C.second = 'set yield'; + +assert.sameValue(yieldSet, 'set yield'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/accessor-name-static/browser.js b/js/src/tests/test262/language/statements/class/accessor-name-static/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/accessor-name-static/computed-err-evaluation.js b/js/src/tests/test262/language/statements/class/accessor-name-static/computed-err-evaluation.js new file mode 100644 index 0000000000..8541304f43 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/accessor-name-static/computed-err-evaluation.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/accessor-names/computed-err-evaluation.case +// - src/accessor-names/error/cls-decl-static.template +/*--- +description: Abrupt completion when evaluating expression (Class declaration, static method) +esid: sec-runtime-semantics-classdefinitionevaluation +features: [class] +flags: [generated] +info: | + [...] + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + [...] + b. Else, + a. Let status be the result of performing PropertyDefinitionEvaluation + for m with arguments F and false. + + + 12.2.6.7 Runtime Semantics: Evaluation + + ComputedPropertyName : [ AssignmentExpression ] + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let propName be ? GetValue(exprValue). +---*/ +var thrower = function() { + throw new Test262Error(); +}; + + +assert.throws(Test262Error, function() { + class C { + static get [thrower()]() {} + } +}, '`get` accessor'); + +assert.throws(Test262Error, function() { + class C { + static set [thrower()](_) {} + } +}, '`set` accessor'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/accessor-name-static/computed-err-to-prop-key.js b/js/src/tests/test262/language/statements/class/accessor-name-static/computed-err-to-prop-key.js new file mode 100644 index 0000000000..57e250e59c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/accessor-name-static/computed-err-to-prop-key.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/accessor-names/computed-err-to-prop-key.case +// - src/accessor-names/error/cls-decl-static.template +/*--- +description: Abrupt completion when coercing to property key value (Class declaration, static method) +esid: sec-runtime-semantics-classdefinitionevaluation +features: [class] +flags: [generated] +info: | + [...] + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + [...] + b. Else, + a. Let status be the result of performing PropertyDefinitionEvaluation + for m with arguments F and false. + + + 12.2.6.7 Runtime Semantics: Evaluation + + [...] + + ComputedPropertyName : [ AssignmentExpression ] + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let propName be ? GetValue(exprValue). + 3. Return ? ToPropertyKey(propName). + + 7.1.14 ToPropertyKey + + 1. Let key be ? ToPrimitive(argument, hint String). + + 7.1.1 ToPrimitive + + [...] + 7. Return ? OrdinaryToPrimitive(input, hint). + + 7.1.1.1 OrdinaryToPrimitive + + 5. For each name in methodNames in List order, do + [...] + 6. Throw a TypeError exception. +---*/ +var badKey = Object.create(null); + + +assert.throws(TypeError, function() { + class C { + static get [badKey]() {} + } +}, '`get` accessor'); + +assert.throws(TypeError, function() { + class C { + static set [badKey](_) {} + } +}, '`set` accessor'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/accessor-name-static/computed-err-unresolvable.js b/js/src/tests/test262/language/statements/class/accessor-name-static/computed-err-unresolvable.js new file mode 100644 index 0000000000..c049096333 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/accessor-name-static/computed-err-unresolvable.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/accessor-names/computed-err-unresolvable.case +// - src/accessor-names/error/cls-decl-static.template +/*--- +description: Abrupt completion when resolving reference value (Class declaration, static method) +esid: sec-runtime-semantics-classdefinitionevaluation +features: [class] +flags: [generated] +info: | + [...] + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + [...] + b. Else, + a. Let status be the result of performing PropertyDefinitionEvaluation + for m with arguments F and false. + + + 12.2.6.7 Runtime Semantics: Evaluation + + [...] + + ComputedPropertyName : [ AssignmentExpression ] + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let propName be ? GetValue(exprValue). +---*/ + +assert.throws(ReferenceError, function() { + class C { + static get [test262unresolvable]() {} + } +}, '`get` accessor'); + +assert.throws(ReferenceError, function() { + class C { + static set [test262unresolvable](_) {} + } +}, '`set` accessor'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/accessor-name-static/computed.js b/js/src/tests/test262/language/statements/class/accessor-name-static/computed.js new file mode 100644 index 0000000000..e8284e4c2c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/accessor-name-static/computed.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/accessor-names/computed.case +// - src/accessor-names/default/cls-decl-static.template +/*--- +description: Computed values as accessor property names (AssignmentExpression) (Class declaration, static method) +esid: sec-runtime-semantics-classdefinitionevaluation +features: [class] +flags: [generated] +info: | + [...] + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + [...] + b. Else, + a. Let status be the result of performing PropertyDefinitionEvaluation + for m with arguments F and false. + + + 12.2.6.7 Runtime Semantics: Evaluation + + [...] + + ComputedPropertyName : [ AssignmentExpression ] + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let propName be ? GetValue(exprValue). + 3. Return ? ToPropertyKey(propName). +---*/ +var _; + + +var stringSet; + +class C { + static get [_ = 'str' + 'ing']() { return 'get string'; } + static set [_ = 'str' + 'ing'](param) { stringSet = param; } +} + +assert.sameValue(C['string'], 'get string'); + +C['string'] = 'set string'; +assert.sameValue(stringSet, 'set string'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/accessor-name-static/literal-numeric-binary.js b/js/src/tests/test262/language/statements/class/accessor-name-static/literal-numeric-binary.js new file mode 100644 index 0000000000..eba3b2b1bb --- /dev/null +++ b/js/src/tests/test262/language/statements/class/accessor-name-static/literal-numeric-binary.js @@ -0,0 +1,42 @@ +// This file was procedurally generated from the following sources: +// - src/accessor-names/literal-numeric-binary.case +// - src/accessor-names/default/cls-decl-static.template +/*--- +description: Computed values as accessor property names (numeric literal in binary notation) (Class declaration, static method) +esid: sec-runtime-semantics-classdefinitionevaluation +features: [class] +flags: [generated] +info: | + [...] + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + [...] + b. Else, + a. Let status be the result of performing PropertyDefinitionEvaluation + for m with arguments F and false. + + + 12.2.6.7 Runtime Semantics: Evaluation + + [...] + + ComputedPropertyName : [ AssignmentExpression ] + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let propName be ? GetValue(exprValue). + 3. Return ? ToPropertyKey(propName). +---*/ + +var stringSet; + +class C { + static get 0b10() { return 'get string'; } + static set 0b10(param) { stringSet = param; } +} + +assert.sameValue(C['2'], 'get string'); + +C['2'] = 'set string'; +assert.sameValue(stringSet, 'set string'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/accessor-name-static/literal-numeric-exponent.js b/js/src/tests/test262/language/statements/class/accessor-name-static/literal-numeric-exponent.js new file mode 100644 index 0000000000..309c418790 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/accessor-name-static/literal-numeric-exponent.js @@ -0,0 +1,42 @@ +// This file was procedurally generated from the following sources: +// - src/accessor-names/literal-numeric-exponent.case +// - src/accessor-names/default/cls-decl-static.template +/*--- +description: Computed values as accessor property names (numeric literal in exponent notation) (Class declaration, static method) +esid: sec-runtime-semantics-classdefinitionevaluation +features: [class] +flags: [generated] +info: | + [...] + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + [...] + b. Else, + a. Let status be the result of performing PropertyDefinitionEvaluation + for m with arguments F and false. + + + 12.2.6.7 Runtime Semantics: Evaluation + + [...] + + ComputedPropertyName : [ AssignmentExpression ] + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let propName be ? GetValue(exprValue). + 3. Return ? ToPropertyKey(propName). +---*/ + +var stringSet; + +class C { + static get 1E+9() { return 'get string'; } + static set 1E+9(param) { stringSet = param; } +} + +assert.sameValue(C['1000000000'], 'get string'); + +C['1000000000'] = 'set string'; +assert.sameValue(stringSet, 'set string'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/accessor-name-static/literal-numeric-hex.js b/js/src/tests/test262/language/statements/class/accessor-name-static/literal-numeric-hex.js new file mode 100644 index 0000000000..aaeaa22988 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/accessor-name-static/literal-numeric-hex.js @@ -0,0 +1,42 @@ +// This file was procedurally generated from the following sources: +// - src/accessor-names/literal-numeric-hex.case +// - src/accessor-names/default/cls-decl-static.template +/*--- +description: Computed values as accessor property names (numeric literal in hexadecimal notation) (Class declaration, static method) +esid: sec-runtime-semantics-classdefinitionevaluation +features: [class] +flags: [generated] +info: | + [...] + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + [...] + b. Else, + a. Let status be the result of performing PropertyDefinitionEvaluation + for m with arguments F and false. + + + 12.2.6.7 Runtime Semantics: Evaluation + + [...] + + ComputedPropertyName : [ AssignmentExpression ] + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let propName be ? GetValue(exprValue). + 3. Return ? ToPropertyKey(propName). +---*/ + +var stringSet; + +class C { + static get 0x10() { return 'get string'; } + static set 0x10(param) { stringSet = param; } +} + +assert.sameValue(C['16'], 'get string'); + +C['16'] = 'set string'; +assert.sameValue(stringSet, 'set string'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/accessor-name-static/literal-numeric-leading-decimal.js b/js/src/tests/test262/language/statements/class/accessor-name-static/literal-numeric-leading-decimal.js new file mode 100644 index 0000000000..21cdddc9a4 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/accessor-name-static/literal-numeric-leading-decimal.js @@ -0,0 +1,42 @@ +// This file was procedurally generated from the following sources: +// - src/accessor-names/literal-numeric-leading-decimal.case +// - src/accessor-names/default/cls-decl-static.template +/*--- +description: Computed values as accessor property names (numeric literal with leading decimal point) (Class declaration, static method) +esid: sec-runtime-semantics-classdefinitionevaluation +features: [class] +flags: [generated] +info: | + [...] + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + [...] + b. Else, + a. Let status be the result of performing PropertyDefinitionEvaluation + for m with arguments F and false. + + + 12.2.6.7 Runtime Semantics: Evaluation + + [...] + + ComputedPropertyName : [ AssignmentExpression ] + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let propName be ? GetValue(exprValue). + 3. Return ? ToPropertyKey(propName). +---*/ + +var stringSet; + +class C { + static get .1() { return 'get string'; } + static set .1(param) { stringSet = param; } +} + +assert.sameValue(C['0.1'], 'get string'); + +C['0.1'] = 'set string'; +assert.sameValue(stringSet, 'set string'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/accessor-name-static/literal-numeric-non-canonical.js b/js/src/tests/test262/language/statements/class/accessor-name-static/literal-numeric-non-canonical.js new file mode 100644 index 0000000000..86d8f2fd6f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/accessor-name-static/literal-numeric-non-canonical.js @@ -0,0 +1,42 @@ +// This file was procedurally generated from the following sources: +// - src/accessor-names/literal-numeric-non-canonical.case +// - src/accessor-names/default/cls-decl-static.template +/*--- +description: Computed values as accessor property names (numeric literal with non-canonical representation) (Class declaration, static method) +esid: sec-runtime-semantics-classdefinitionevaluation +features: [class] +flags: [generated] +info: | + [...] + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + [...] + b. Else, + a. Let status be the result of performing PropertyDefinitionEvaluation + for m with arguments F and false. + + + 12.2.6.7 Runtime Semantics: Evaluation + + [...] + + ComputedPropertyName : [ AssignmentExpression ] + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let propName be ? GetValue(exprValue). + 3. Return ? ToPropertyKey(propName). +---*/ + +var stringSet; + +class C { + static get 0.0000001() { return 'get string'; } + static set 0.0000001(param) { stringSet = param; } +} + +assert.sameValue(C['1e-7'], 'get string'); + +C['1e-7'] = 'set string'; +assert.sameValue(stringSet, 'set string'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/accessor-name-static/literal-numeric-octal.js b/js/src/tests/test262/language/statements/class/accessor-name-static/literal-numeric-octal.js new file mode 100644 index 0000000000..fa8b4e0505 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/accessor-name-static/literal-numeric-octal.js @@ -0,0 +1,42 @@ +// This file was procedurally generated from the following sources: +// - src/accessor-names/literal-numeric-octal.case +// - src/accessor-names/default/cls-decl-static.template +/*--- +description: Computed values as accessor property names (numeric literal in octal notation) (Class declaration, static method) +esid: sec-runtime-semantics-classdefinitionevaluation +features: [class] +flags: [generated] +info: | + [...] + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + [...] + b. Else, + a. Let status be the result of performing PropertyDefinitionEvaluation + for m with arguments F and false. + + + 12.2.6.7 Runtime Semantics: Evaluation + + [...] + + ComputedPropertyName : [ AssignmentExpression ] + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let propName be ? GetValue(exprValue). + 3. Return ? ToPropertyKey(propName). +---*/ + +var stringSet; + +class C { + static get 0o10() { return 'get string'; } + static set 0o10(param) { stringSet = param; } +} + +assert.sameValue(C['8'], 'get string'); + +C['8'] = 'set string'; +assert.sameValue(stringSet, 'set string'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/accessor-name-static/literal-numeric-zero.js b/js/src/tests/test262/language/statements/class/accessor-name-static/literal-numeric-zero.js new file mode 100644 index 0000000000..18dfed2a88 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/accessor-name-static/literal-numeric-zero.js @@ -0,0 +1,42 @@ +// This file was procedurally generated from the following sources: +// - src/accessor-names/literal-numeric-zero.case +// - src/accessor-names/default/cls-decl-static.template +/*--- +description: Computed values as accessor property names (numeric literal zero) (Class declaration, static method) +esid: sec-runtime-semantics-classdefinitionevaluation +features: [class] +flags: [generated] +info: | + [...] + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + [...] + b. Else, + a. Let status be the result of performing PropertyDefinitionEvaluation + for m with arguments F and false. + + + 12.2.6.7 Runtime Semantics: Evaluation + + [...] + + ComputedPropertyName : [ AssignmentExpression ] + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let propName be ? GetValue(exprValue). + 3. Return ? ToPropertyKey(propName). +---*/ + +var stringSet; + +class C { + static get 0() { return 'get string'; } + static set 0(param) { stringSet = param; } +} + +assert.sameValue(C['0'], 'get string'); + +C['0'] = 'set string'; +assert.sameValue(stringSet, 'set string'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/accessor-name-static/literal-string-char-escape.js b/js/src/tests/test262/language/statements/class/accessor-name-static/literal-string-char-escape.js new file mode 100644 index 0000000000..30687691d0 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/accessor-name-static/literal-string-char-escape.js @@ -0,0 +1,42 @@ +// This file was procedurally generated from the following sources: +// - src/accessor-names/literal-string-char-escape.case +// - src/accessor-names/default/cls-decl-static.template +/*--- +description: Computed values as accessor property names (string literal containing a character escape sequence) (Class declaration, static method) +esid: sec-runtime-semantics-classdefinitionevaluation +features: [class] +flags: [generated] +info: | + [...] + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + [...] + b. Else, + a. Let status be the result of performing PropertyDefinitionEvaluation + for m with arguments F and false. + + + 12.2.6.7 Runtime Semantics: Evaluation + + [...] + + ComputedPropertyName : [ AssignmentExpression ] + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let propName be ? GetValue(exprValue). + 3. Return ? ToPropertyKey(propName). +---*/ + +var stringSet; + +class C { + static get 'character\tescape'() { return 'get string'; } + static set 'character\tescape'(param) { stringSet = param; } +} + +assert.sameValue(C['character escape'], 'get string'); + +C['character escape'] = 'set string'; +assert.sameValue(stringSet, 'set string'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/accessor-name-static/literal-string-default-escaped-ext.js b/js/src/tests/test262/language/statements/class/accessor-name-static/literal-string-default-escaped-ext.js new file mode 100644 index 0000000000..3c04d8426d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/accessor-name-static/literal-string-default-escaped-ext.js @@ -0,0 +1,42 @@ +// This file was procedurally generated from the following sources: +// - src/accessor-names/literal-string-default-escaped-ext.case +// - src/accessor-names/default/cls-decl-static.template +/*--- +description: Computed values as accessor property names (string literal 'default' w/ extended escape) (Class declaration, static method) +esid: sec-runtime-semantics-classdefinitionevaluation +features: [class] +flags: [generated] +info: | + [...] + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + [...] + b. Else, + a. Let status be the result of performing PropertyDefinitionEvaluation + for m with arguments F and false. + + + 12.2.6.7 Runtime Semantics: Evaluation + + [...] + + ComputedPropertyName : [ AssignmentExpression ] + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let propName be ? GetValue(exprValue). + 3. Return ? ToPropertyKey(propName). +---*/ + +var stringSet; + +class C { + static get 'def\u{61}ult'() { return 'get string'; } + static set 'def\u{61}ult'(param) { stringSet = param; } +} + +assert.sameValue(C['default'], 'get string'); + +C['default'] = 'set string'; +assert.sameValue(stringSet, 'set string'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/accessor-name-static/literal-string-default-escaped.js b/js/src/tests/test262/language/statements/class/accessor-name-static/literal-string-default-escaped.js new file mode 100644 index 0000000000..64d6bdf455 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/accessor-name-static/literal-string-default-escaped.js @@ -0,0 +1,42 @@ +// This file was procedurally generated from the following sources: +// - src/accessor-names/literal-string-default-escaped.case +// - src/accessor-names/default/cls-decl-static.template +/*--- +description: Computed values as accessor property names (string literal 'default' escaped) (Class declaration, static method) +esid: sec-runtime-semantics-classdefinitionevaluation +features: [class] +flags: [generated] +info: | + [...] + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + [...] + b. Else, + a. Let status be the result of performing PropertyDefinitionEvaluation + for m with arguments F and false. + + + 12.2.6.7 Runtime Semantics: Evaluation + + [...] + + ComputedPropertyName : [ AssignmentExpression ] + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let propName be ? GetValue(exprValue). + 3. Return ? ToPropertyKey(propName). +---*/ + +var stringSet; + +class C { + static get 'def\u0061ult'() { return 'get string'; } + static set 'def\u0061ult'(param) { stringSet = param; } +} + +assert.sameValue(C['default'], 'get string'); + +C['default'] = 'set string'; +assert.sameValue(stringSet, 'set string'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/accessor-name-static/literal-string-default.js b/js/src/tests/test262/language/statements/class/accessor-name-static/literal-string-default.js new file mode 100644 index 0000000000..88f60739e8 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/accessor-name-static/literal-string-default.js @@ -0,0 +1,42 @@ +// This file was procedurally generated from the following sources: +// - src/accessor-names/literal-string-default.case +// - src/accessor-names/default/cls-decl-static.template +/*--- +description: Computed values as accessor property names (string literal 'default') (Class declaration, static method) +esid: sec-runtime-semantics-classdefinitionevaluation +features: [class] +flags: [generated] +info: | + [...] + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + [...] + b. Else, + a. Let status be the result of performing PropertyDefinitionEvaluation + for m with arguments F and false. + + + 12.2.6.7 Runtime Semantics: Evaluation + + [...] + + ComputedPropertyName : [ AssignmentExpression ] + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let propName be ? GetValue(exprValue). + 3. Return ? ToPropertyKey(propName). +---*/ + +var stringSet; + +class C { + static get 'default'() { return 'get string'; } + static set 'default'(param) { stringSet = param; } +} + +assert.sameValue(C['default'], 'get string'); + +C['default'] = 'set string'; +assert.sameValue(stringSet, 'set string'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/accessor-name-static/literal-string-double-quote.js b/js/src/tests/test262/language/statements/class/accessor-name-static/literal-string-double-quote.js new file mode 100644 index 0000000000..b7ec6e0e8b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/accessor-name-static/literal-string-double-quote.js @@ -0,0 +1,42 @@ +// This file was procedurally generated from the following sources: +// - src/accessor-names/literal-string-double-quote.case +// - src/accessor-names/default/cls-decl-static.template +/*--- +description: Computed values as accessor property names (string literal using double quotes) (Class declaration, static method) +esid: sec-runtime-semantics-classdefinitionevaluation +features: [class] +flags: [generated] +info: | + [...] + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + [...] + b. Else, + a. Let status be the result of performing PropertyDefinitionEvaluation + for m with arguments F and false. + + + 12.2.6.7 Runtime Semantics: Evaluation + + [...] + + ComputedPropertyName : [ AssignmentExpression ] + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let propName be ? GetValue(exprValue). + 3. Return ? ToPropertyKey(propName). +---*/ + +var stringSet; + +class C { + static get "doubleQuote"() { return 'get string'; } + static set "doubleQuote"(param) { stringSet = param; } +} + +assert.sameValue(C["doubleQuote"], 'get string'); + +C["doubleQuote"] = 'set string'; +assert.sameValue(stringSet, 'set string'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/accessor-name-static/literal-string-empty.js b/js/src/tests/test262/language/statements/class/accessor-name-static/literal-string-empty.js new file mode 100644 index 0000000000..ed7767d1df --- /dev/null +++ b/js/src/tests/test262/language/statements/class/accessor-name-static/literal-string-empty.js @@ -0,0 +1,42 @@ +// This file was procedurally generated from the following sources: +// - src/accessor-names/literal-string-empty.case +// - src/accessor-names/default/cls-decl-static.template +/*--- +description: Computed values as accessor property names (string literal, the empty string) (Class declaration, static method) +esid: sec-runtime-semantics-classdefinitionevaluation +features: [class] +flags: [generated] +info: | + [...] + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + [...] + b. Else, + a. Let status be the result of performing PropertyDefinitionEvaluation + for m with arguments F and false. + + + 12.2.6.7 Runtime Semantics: Evaluation + + [...] + + ComputedPropertyName : [ AssignmentExpression ] + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let propName be ? GetValue(exprValue). + 3. Return ? ToPropertyKey(propName). +---*/ + +var stringSet; + +class C { + static get ''() { return 'get string'; } + static set ''(param) { stringSet = param; } +} + +assert.sameValue(C[''], 'get string'); + +C[''] = 'set string'; +assert.sameValue(stringSet, 'set string'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/accessor-name-static/literal-string-hex-escape.js b/js/src/tests/test262/language/statements/class/accessor-name-static/literal-string-hex-escape.js new file mode 100644 index 0000000000..215a665e56 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/accessor-name-static/literal-string-hex-escape.js @@ -0,0 +1,42 @@ +// This file was procedurally generated from the following sources: +// - src/accessor-names/literal-string-hex-escape.case +// - src/accessor-names/default/cls-decl-static.template +/*--- +description: Computed values as accessor property names (string literal containing a hexadecimal escape sequence) (Class declaration, static method) +esid: sec-runtime-semantics-classdefinitionevaluation +features: [class] +flags: [generated] +info: | + [...] + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + [...] + b. Else, + a. Let status be the result of performing PropertyDefinitionEvaluation + for m with arguments F and false. + + + 12.2.6.7 Runtime Semantics: Evaluation + + [...] + + ComputedPropertyName : [ AssignmentExpression ] + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let propName be ? GetValue(exprValue). + 3. Return ? ToPropertyKey(propName). +---*/ + +var stringSet; + +class C { + static get 'hex\x45scape'() { return 'get string'; } + static set 'hex\x45scape'(param) { stringSet = param; } +} + +assert.sameValue(C['hexEscape'], 'get string'); + +C['hexEscape'] = 'set string'; +assert.sameValue(stringSet, 'set string'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/accessor-name-static/literal-string-line-continuation.js b/js/src/tests/test262/language/statements/class/accessor-name-static/literal-string-line-continuation.js new file mode 100644 index 0000000000..367e8f4c3c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/accessor-name-static/literal-string-line-continuation.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/accessor-names/literal-string-line-continuation.case +// - src/accessor-names/default/cls-decl-static.template +/*--- +description: Computed values as accessor property names (string literal containing LineContinuation) (Class declaration, static method) +esid: sec-runtime-semantics-classdefinitionevaluation +features: [class] +flags: [generated] +info: | + [...] + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + [...] + b. Else, + a. Let status be the result of performing PropertyDefinitionEvaluation + for m with arguments F and false. + + + 12.2.6.7 Runtime Semantics: Evaluation + + [...] + + ComputedPropertyName : [ AssignmentExpression ] + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let propName be ? GetValue(exprValue). + 3. Return ? ToPropertyKey(propName). +---*/ + +var stringSet; + +class C { + static get 'line\ +Continuation'() { return 'get string'; } + static set 'line\ +Continuation'(param) { stringSet = param; } +} + +assert.sameValue(C['lineContinuation'], 'get string'); + +C['lineContinuation'] = 'set string'; +assert.sameValue(stringSet, 'set string'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/accessor-name-static/literal-string-single-quote.js b/js/src/tests/test262/language/statements/class/accessor-name-static/literal-string-single-quote.js new file mode 100644 index 0000000000..f0c2272add --- /dev/null +++ b/js/src/tests/test262/language/statements/class/accessor-name-static/literal-string-single-quote.js @@ -0,0 +1,42 @@ +// This file was procedurally generated from the following sources: +// - src/accessor-names/literal-string-single-quote.case +// - src/accessor-names/default/cls-decl-static.template +/*--- +description: Computed values as accessor property names (string literal using single quotes) (Class declaration, static method) +esid: sec-runtime-semantics-classdefinitionevaluation +features: [class] +flags: [generated] +info: | + [...] + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + [...] + b. Else, + a. Let status be the result of performing PropertyDefinitionEvaluation + for m with arguments F and false. + + + 12.2.6.7 Runtime Semantics: Evaluation + + [...] + + ComputedPropertyName : [ AssignmentExpression ] + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let propName be ? GetValue(exprValue). + 3. Return ? ToPropertyKey(propName). +---*/ + +var stringSet; + +class C { + static get 'singleQuote'() { return 'get string'; } + static set 'singleQuote'(param) { stringSet = param; } +} + +assert.sameValue(C['singleQuote'], 'get string'); + +C['singleQuote'] = 'set string'; +assert.sameValue(stringSet, 'set string'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/accessor-name-static/literal-string-unicode-escape.js b/js/src/tests/test262/language/statements/class/accessor-name-static/literal-string-unicode-escape.js new file mode 100644 index 0000000000..a428e5ba96 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/accessor-name-static/literal-string-unicode-escape.js @@ -0,0 +1,42 @@ +// This file was procedurally generated from the following sources: +// - src/accessor-names/literal-string-unicode-escape.case +// - src/accessor-names/default/cls-decl-static.template +/*--- +description: Computed values as accessor property names (string literal containing a Unicode escape sequence) (Class declaration, static method) +esid: sec-runtime-semantics-classdefinitionevaluation +features: [class] +flags: [generated] +info: | + [...] + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + [...] + b. Else, + a. Let status be the result of performing PropertyDefinitionEvaluation + for m with arguments F and false. + + + 12.2.6.7 Runtime Semantics: Evaluation + + [...] + + ComputedPropertyName : [ AssignmentExpression ] + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let propName be ? GetValue(exprValue). + 3. Return ? ToPropertyKey(propName). +---*/ + +var stringSet; + +class C { + static get 'unicod\u{000065}Escape'() { return 'get string'; } + static set 'unicod\u{000065}Escape'(param) { stringSet = param; } +} + +assert.sameValue(C['unicodeEscape'], 'get string'); + +C['unicodeEscape'] = 'set string'; +assert.sameValue(stringSet, 'set string'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/accessor-name-static/shell.js b/js/src/tests/test262/language/statements/class/accessor-name-static/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/arguments/access.js b/js/src/tests/test262/language/statements/class/arguments/access.js new file mode 100644 index 0000000000..24cd6a15b4 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/arguments/access.js @@ -0,0 +1,56 @@ +// Copyright (C) 2014 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.5 +description: > + class arguments access +---*/ +var constructCounts = { + base: 0, + subclass: 0, + subclass2: 0 +}; + +class Base { + constructor() { + constructCounts.base++; + assert.sameValue(arguments.length, 2, "The value of `arguments.length` is `2`"); + assert.sameValue(arguments[0], 1, "The value of `arguments[0]` is `1`"); + assert.sameValue(arguments[1], 2, "The value of `arguments[1]` is `2`"); + } +} + +var b = new Base(1, 2); + +class Subclass extends Base { + constructor() { + constructCounts.subclass++; + assert.sameValue(arguments.length, 2, "The value of `arguments.length` is `2`"); + assert.sameValue(arguments[0], 3, "The value of `arguments[0]` is `3`"); + assert.sameValue(arguments[1], 4, "The value of `arguments[1]` is `4`"); + super(1, 2); + } +} + +var s = new Subclass(3, 4); +assert.sameValue(Subclass.length, 0, "The value of `Subclass.length` is `0`, because there are 0 formal parameters"); + +class Subclass2 extends Base { + constructor(x, y) { + constructCounts.subclass2++; + assert.sameValue(arguments.length, 2, "The value of `arguments.length` is `2`"); + assert.sameValue(arguments[0], 3, "The value of `arguments[0]` is `3`"); + assert.sameValue(arguments[1], 4, "The value of `arguments[1]` is `4`"); + super(1, 2); + } +} + +var s2 = new Subclass2(3, 4); +assert.sameValue(Subclass2.length, 2, "The value of `Subclass2.length` is `2`, because there are 2 formal parameters"); + + +assert.sameValue(constructCounts.base, 3, "The value of `constructCounts.base` is `3`"); +assert.sameValue(constructCounts.subclass, 1, "The value of `constructCounts.subclass` is `1`"); +assert.sameValue(constructCounts.subclass2, 1, "The value of `constructCounts.subclass2` is `1`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/arguments/browser.js b/js/src/tests/test262/language/statements/class/arguments/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/arguments/default-constructor.js b/js/src/tests/test262/language/statements/class/arguments/default-constructor.js new file mode 100644 index 0000000000..f30ec66b5a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/arguments/default-constructor.js @@ -0,0 +1,32 @@ +// Copyright (C) 2014 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.5 +description: > + class default constructor arguments +---*/ +var args, that; +class Base { + constructor() { + that = this; + args = arguments; + } +} +class Derived extends Base {} + +new Derived; +assert.sameValue(args.length, 0, "The value of `args.length` is `0`"); + +new Derived(0, 1, 2); +assert.sameValue(args.length, 3, "The value of `args.length` is `3`"); +assert.sameValue( + that instanceof Derived, + true, + "The result of `that instanceof Derived` is `true`" +); + +var arr = new Array(100); +var obj = {}; +assert.throws(TypeError, function() {Derived.apply(obj, arr);}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/arguments/shell.js b/js/src/tests/test262/language/statements/class/arguments/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/async-gen-meth-escaped-async.js b/js/src/tests/test262/language/statements/class/async-gen-meth-escaped-async.js new file mode 100644 index 0000000000..247290d7a8 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-meth-escaped-async.js @@ -0,0 +1,27 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-grammar-notation +description: > + The `async` contextual keyword must not contain Unicode escape sequences. +info: | + Terminal symbols are shown + in fixed width font, both in the productions of the grammars and throughout this + specification whenever the text directly refers to such a terminal symbol. These + are to appear in a script exactly as written. All terminal symbol code points + specified in this way are to be understood as the appropriate Unicode code points + from the Basic Latin range, as opposed to any similar-looking code points from + other Unicode ranges. +negative: + phase: parse + type: SyntaxError +features: [async-iteration] +---*/ + +$DONOTEVALUATE(); + +class C { + \u0061sync* m(){} +}; diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/array-destructuring-param-strict-body.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/array-destructuring-param-strict-body.js new file mode 100644 index 0000000000..949ef653e7 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/array-destructuring-param-strict-body.js @@ -0,0 +1,138 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/function-forms/array-destructuring-param-strict-body.case +// - src/function-forms/syntax/cls-decl-async-gen-meth-static.template +/*--- +description: ArrayBindingPattern and Use Strict Directive are not allowed to coexist for the same function. (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [rest-parameters, async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.4 Static Semantics: IsSimpleParameterList + + BindingElement : BindingPattern + + 1. Return false. + + 14.1.2 Static Semantics: Early Errors + + FunctionDeclaration : function BindingIdentifier ( FormalParameters ) { FunctionBody } + FunctionDeclaration : function ( FormalParameters ) { FunctionBody } + FunctionExpression : function BindingIdentifier ( FormalParameters ) { FunctionBody } + + - It is a Syntax Error if ContainsUseStrict of FunctionBody is true and + IsSimpleParameterList of FormalParameters is false. + + 14.2.1 Static Semantics: Early Errors + + ArrowFunction : ArrowParameters => ConciseBody + + - It is a Syntax Error if ContainsUseStrict of ConciseBody is true and + IsSimpleParameterList of ArrowParameters is false. + + 14.3.1 Static Semantics: Early Errors + + MethodDefinition : PropertyName ( UniqueFormalParameters ) { FunctionBody } + + - It is a Syntax Error if ContainsUseStrict of FunctionBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + MethodDefinition : set PropertyName ( PropertySetParameterList ) { FunctionBody } + + - It is a Syntax Error if ContainsUseStrict of FunctionBody is true and + IsSimpleParameterList of PropertySetParameterList is false. + + 14.4.1 Static Semantics: Early Errors + + GeneratorMethod : * PropertyName ( UniqueFormalParameters ) { GeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of GeneratorBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + GeneratorDeclaration : function * BindingIdentifier ( FormalParameters ) { GeneratorBody } + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + GeneratorExpression : function * BindingIdentifier ( FormalParameters ) { GeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of GeneratorBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + 14.5.1 Static Semantics: Early Errors + + AsyncGeneratorMethod : async * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncGeneratorBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + AsyncGeneratorDeclaration : async function * BindingIdentifier ( FormalParameters ) { AsyncGeneratorBody } + AsyncGeneratorDeclaration : async function * ( FormalParameters ) { AsyncGeneratorBody } + AsyncGeneratorExpression : async function * BindingIdentifier ( FormalParameters ) { AsyncGeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncGeneratorBody is true and + IsSimpleParameterList of FormalParameters is false. + + 14.7.1 Static Semantics: Early Errors + + AsyncMethod : async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncFunctionBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + AsyncFunctionDeclaration : async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody } + AsyncFunctionDeclaration : async function ( FormalParameters ) { AsyncFunctionBody } + AsyncFunctionExpression : async function ( FormalParameters ) { AsyncFunctionBody } + AsyncFunctionExpression : async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncFunctionBody is true and + IsSimpleParameterList of FormalParameters is false. + + 14.8.1 Static Semantics: Early Errors + + AsyncArrowFunction : CoverCallExpressionAndAsyncArrowHead => AsyncConciseBody + + - It is a Syntax Error if ContainsUseStrict of AsyncConciseBody is true and + IsSimpleParameterList of CoverCallExpressionAndAsyncArrowHead is false. + +---*/ +$DONOTEVALUATE(); + + +class C { + static async *method([element]) { + "use strict"; + } +} diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/await-as-binding-identifier-escaped.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/await-as-binding-identifier-escaped.js new file mode 100644 index 0000000000..c1aa9803dc --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/await-as-binding-identifier-escaped.js @@ -0,0 +1,37 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/async-generators/await-as-binding-identifier-escaped.case +// - src/async-generators/syntax/async-class-decl-static-method.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as a binding identifier. (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + BindingIdentifier : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +$DONOTEVALUATE(); + + +class C { static async *gen() { + var \u0061wait; +}} diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/await-as-binding-identifier.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/await-as-binding-identifier.js new file mode 100644 index 0000000000..d7f1e1cfba --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/await-as-binding-identifier.js @@ -0,0 +1,37 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/async-generators/await-as-binding-identifier.case +// - src/async-generators/syntax/async-class-decl-static-method.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as a binding identifier. (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + BindingIdentifier : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +$DONOTEVALUATE(); + + +class C { static async *gen() { + var await; +}} diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/await-as-identifier-reference-escaped.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/await-as-identifier-reference-escaped.js new file mode 100644 index 0000000000..808d003b1d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/await-as-identifier-reference-escaped.js @@ -0,0 +1,37 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/async-generators/await-as-identifier-reference-escaped.case +// - src/async-generators/syntax/async-class-decl-static-method.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as an identifier reference. (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + IdentifierReference : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +$DONOTEVALUATE(); + + +class C { static async *gen() { + void \u0061wait; +}} diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/await-as-identifier-reference.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/await-as-identifier-reference.js new file mode 100644 index 0000000000..0a231fb8ee --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/await-as-identifier-reference.js @@ -0,0 +1,37 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/async-generators/await-as-identifier-reference.case +// - src/async-generators/syntax/async-class-decl-static-method.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as an identifier reference. (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + IdentifierReference : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +$DONOTEVALUATE(); + + +class C { static async *gen() { + void await; +}} diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/await-as-label-identifier-escaped.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/await-as-label-identifier-escaped.js new file mode 100644 index 0000000000..3cc2db647d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/await-as-label-identifier-escaped.js @@ -0,0 +1,37 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/async-generators/await-as-label-identifier-escaped.case +// - src/async-generators/syntax/async-class-decl-static-method.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as a label identifier. (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + LabelIdentifier : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +$DONOTEVALUATE(); + + +class C { static async *gen() { + \u0061wait: ; +}} diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/await-as-label-identifier.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/await-as-label-identifier.js new file mode 100644 index 0000000000..c511ce78db --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/await-as-label-identifier.js @@ -0,0 +1,37 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/async-generators/await-as-label-identifier.case +// - src/async-generators/syntax/async-class-decl-static-method.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as a label identifier. (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + LabelIdentifier : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +$DONOTEVALUATE(); + + +class C { static async *gen() { + await: ; +}} diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/browser.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/dflt-params-abrupt.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/dflt-params-abrupt.js new file mode 100644 index 0000000000..81e14dc50e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/dflt-params-abrupt.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-abrupt.case +// - src/function-forms/error/cls-decl-async-gen-meth-static.template +/*--- +description: Abrupt completion returned by evaluation of initializer (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [default-parameters, async-iteration] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. + +---*/ + + +var callCount = 0; +class C { + static async *method(_ = (function() { throw new Test262Error(); }())) { + + callCount = callCount + 1; + } +} + +assert.throws(Test262Error, function() { + C.method(); +}); + +assert.sameValue(callCount, 0, 'method body not evaluated'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/dflt-params-arg-val-not-undefined.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/dflt-params-arg-val-not-undefined.js new file mode 100644 index 0000000000..49010f9797 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/dflt-params-arg-val-not-undefined.js @@ -0,0 +1,92 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-arg-val-not-undefined.case +// - src/function-forms/default/cls-decl-async-gen-meth-static.template +/*--- +description: Use of initializer when argument value is not `undefined` (static class declaration async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [default-parameters, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + [...] + 23. Let iteratorRecord be Record {[[Iterator]]: + CreateListIterator(argumentsList), [[Done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + a. Perform ? IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + +---*/ +var obj = {}; +var falseCount = 0; +var stringCount = 0; +var nanCount = 0; +var zeroCount = 0; +var nullCount = 0; +var objCount = 0; + + +var callCount = 0; +class C { + static async *method(aFalse = falseCount +=1, aString = stringCount += 1, aNaN = nanCount += 1, a0 = zeroCount += 1, aNull = nullCount += 1, aObj = objCount +=1) { + assert.sameValue(aFalse, false); + assert.sameValue(aString, ''); + assert.sameValue(aNaN, NaN); + assert.sameValue(a0, 0); + assert.sameValue(aNull, null); + assert.sameValue(aObj, obj); + callCount = callCount + 1; + } +} + +// Stores a reference `ref` for case evaluation +var ref = C.method; + +ref(false, '', NaN, 0, null, obj).next().then(() => { + assert.sameValue(callCount, 1, 'method invoked exactly once'); +}).then($DONE, $DONE); + +assert.sameValue(falseCount, 0, 'initializer not evaluated: false'); +assert.sameValue(stringCount, 0, 'initializer not evaluated: string'); +assert.sameValue(nanCount, 0, 'initializer not evaluated: NaN'); +assert.sameValue(zeroCount, 0, 'initializer not evaluated: 0'); +assert.sameValue(nullCount, 0, 'initializer not evaluated: null'); +assert.sameValue(objCount, 0, 'initializer not evaluated: object'); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/dflt-params-arg-val-undefined.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/dflt-params-arg-val-undefined.js new file mode 100644 index 0000000000..608b9cb883 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/dflt-params-arg-val-undefined.js @@ -0,0 +1,75 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-arg-val-undefined.case +// - src/function-forms/default/cls-decl-async-gen-meth-static.template +/*--- +description: Use of initializer when argument value is `undefined` (static class declaration async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [default-parameters, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + [...] + 23. Let iteratorRecord be Record {[[Iterator]]: + CreateListIterator(argumentsList), [[Done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + a. Perform ? IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + +---*/ + + +var callCount = 0; +class C { + static async *method(fromLiteral = 23, fromExpr = 45, fromHole = 99) { + assert.sameValue(fromLiteral, 23); + assert.sameValue(fromExpr, 45); + assert.sameValue(fromHole, 99); + callCount = callCount + 1; + } +} + +// Stores a reference `ref` for case evaluation +var ref = C.method; + +ref(undefined, void 0).next().then(() => { + assert.sameValue(callCount, 1, 'method invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/dflt-params-duplicates.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/dflt-params-duplicates.js new file mode 100644 index 0000000000..9b7901cd65 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/dflt-params-duplicates.js @@ -0,0 +1,67 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-duplicates.case +// - src/function-forms/syntax/cls-decl-async-gen-meth-static.template +/*--- +description: It is a Syntax Error if BoundNames of FormalParameters contains any duplicate elements. (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [default-parameters, async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 14.1.2 Static Semantics: Early Errors + + StrictFormalParameters : FormalParameters + + - It is a Syntax Error if BoundNames of FormalParameters contains any + duplicate elements. + + FormalParameters : FormalParameterList + + - It is a Syntax Error if IsSimpleParameterList of FormalParameterList is + false and BoundNames of FormalParameterList contains any duplicate + elements. + +---*/ +$DONOTEVALUATE(); + + +class C { + static async *method(x = 0, x) { + + } +} diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/dflt-params-ref-later.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/dflt-params-ref-later.js new file mode 100644 index 0000000000..30fc7fa7c1 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/dflt-params-ref-later.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-ref-later.case +// - src/function-forms/error/cls-decl-async-gen-meth-static.template +/*--- +description: Referencing a parameter that occurs later in the ParameterList (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [default-parameters, async-iteration] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. + +---*/ +var x = 0; + + +var callCount = 0; +class C { + static async *method(x = y, y) { + + callCount = callCount + 1; + } +} + +assert.throws(ReferenceError, function() { + C.method(); +}); + +assert.sameValue(callCount, 0, 'method body not evaluated'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/dflt-params-ref-prior.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/dflt-params-ref-prior.js new file mode 100644 index 0000000000..daf60509b5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/dflt-params-ref-prior.js @@ -0,0 +1,72 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-ref-prior.case +// - src/function-forms/default/cls-decl-async-gen-meth-static.template +/*--- +description: Referencing a parameter that occurs earlier in the ParameterList (static class declaration async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [default-parameters, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. + +---*/ +var x = 0; + + +var callCount = 0; +class C { + static async *method(x, y = x, z = y) { + assert.sameValue(x, 3, 'first argument value'); + assert.sameValue(y, 3, 'second argument value'); + assert.sameValue(z, 3, 'third argument value'); + callCount = callCount + 1; + } +} + +// Stores a reference `ref` for case evaluation +var ref = C.method; + +ref(3).next().then(() => { + assert.sameValue(callCount, 1, 'method invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/dflt-params-ref-self.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/dflt-params-ref-self.js new file mode 100644 index 0000000000..9f2bc4dfdb --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/dflt-params-ref-self.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-ref-self.case +// - src/function-forms/error/cls-decl-async-gen-meth-static.template +/*--- +description: Referencing a parameter from within its own initializer (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [default-parameters, async-iteration] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. + +---*/ +var x = 0; + + +var callCount = 0; +class C { + static async *method(x = x) { + + callCount = callCount + 1; + } +} + +assert.throws(ReferenceError, function() { + C.method(); +}); + +assert.sameValue(callCount, 0, 'method body not evaluated'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/dflt-params-rest.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/dflt-params-rest.js new file mode 100644 index 0000000000..5e6b021d1c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/dflt-params-rest.js @@ -0,0 +1,71 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-rest.case +// - src/function-forms/syntax/cls-decl-async-gen-meth-static.template +/*--- +description: RestParameter does not support an initializer (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [default-parameters, async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 14.1 Function Definitions + + Syntax + + FunctionRestParameter[Yield] : + + BindingRestElement[?Yield] + + 13.3.3 Destructuring Binding Patterns + + Syntax + + BindingRestElement[Yield] : + + ...BindingIdentifier[?Yield] + ...BindingPattern[?Yield] + +---*/ +$DONOTEVALUATE(); + + +class C { + static async *method(...x = []) { + + } +} diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/dflt-params-trailing-comma.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/dflt-params-trailing-comma.js new file mode 100644 index 0000000000..16ae5a99e9 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/dflt-params-trailing-comma.js @@ -0,0 +1,67 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-trailing-comma.case +// - src/function-forms/default/cls-decl-async-gen-meth-static.template +/*--- +description: A trailing comma should not increase the respective length, using default parameters (static class declaration async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + Trailing comma in the parameters list + + 14.1 Function Definitions + + FormalParameters[Yield, Await] : FormalParameterList[?Yield, ?Await] , +---*/ + + +var callCount = 0; +class C { + static async *method(a, b = 39,) { + assert.sameValue(a, 42); + assert.sameValue(b, 39); + callCount = callCount + 1; + } +} + +// Stores a reference `ref` for case evaluation +var ref = C.method; + +ref(42, undefined, 1).next().then(() => { + assert.sameValue(callCount, 1, 'method invoked exactly once'); +}).then($DONE, $DONE); + +assert.sameValue(ref.length, 1, 'length is properly set'); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/forbidden-ext/b1/browser.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/forbidden-ext/b1/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/forbidden-ext/b1/cls-decl-async-gen-meth-static-forbidden-ext-direct-access-prop-arguments.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/forbidden-ext/b1/cls-decl-async-gen-meth-static-forbidden-ext-direct-access-prop-arguments.js new file mode 100644 index 0000000000..ccf94751ad --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/forbidden-ext/b1/cls-decl-async-gen-meth-static-forbidden-ext-direct-access-prop-arguments.js @@ -0,0 +1,39 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/function-forms/forbidden-ext-direct-access-prop-arguments.case +// - src/function-forms/forbidden-extensions/bullet-one/cls-decl-async-gen-meth-static.template +/*--- +description: Forbidden extension, f.arguments (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [arrow-function, async-functions, async-iteration, class] +flags: [generated, noStrict, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + + ECMAScript function objects defined using syntactic constructors in strict mode code must + not be created with own properties named "caller" or "arguments". Such own properties also + must not be created for function objects defined using an ArrowFunction, MethodDefinition, + GeneratorDeclaration, GeneratorExpression, AsyncGeneratorDeclaration, AsyncGeneratorExpression, + ClassDeclaration, ClassExpression, AsyncFunctionDeclaration, AsyncFunctionExpression, or + AsyncArrowFunction regardless of whether the definition is contained in strict mode code. + Built-in functions, strict functions created using the Function constructor, generator functions + created using the Generator constructor, async functions created using the AsyncFunction + constructor, and functions created using the bind method also must not be created with such own + properties. + +---*/ + + +var callCount = 0; +class C { + static async *method() { + assert.sameValue(this.method.hasOwnProperty("arguments"), false); + callCount++; + } +} + +C.method().next() + .then(() => { + assert.sameValue(callCount, 1, 'function body evaluated'); + }, $DONE).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/forbidden-ext/b1/cls-decl-async-gen-meth-static-forbidden-ext-direct-access-prop-caller.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/forbidden-ext/b1/cls-decl-async-gen-meth-static-forbidden-ext-direct-access-prop-caller.js new file mode 100644 index 0000000000..8e4893e5cc --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/forbidden-ext/b1/cls-decl-async-gen-meth-static-forbidden-ext-direct-access-prop-caller.js @@ -0,0 +1,39 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/function-forms/forbidden-ext-direct-access-prop-caller.case +// - src/function-forms/forbidden-extensions/bullet-one/cls-decl-async-gen-meth-static.template +/*--- +description: Forbidden extension, o.caller (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [arrow-function, async-functions, async-iteration, class] +flags: [generated, noStrict, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + + ECMAScript function objects defined using syntactic constructors in strict mode code must + not be created with own properties named "caller" or "arguments". Such own properties also + must not be created for function objects defined using an ArrowFunction, MethodDefinition, + GeneratorDeclaration, GeneratorExpression, AsyncGeneratorDeclaration, AsyncGeneratorExpression, + ClassDeclaration, ClassExpression, AsyncFunctionDeclaration, AsyncFunctionExpression, or + AsyncArrowFunction regardless of whether the definition is contained in strict mode code. + Built-in functions, strict functions created using the Function constructor, generator functions + created using the Generator constructor, async functions created using the AsyncFunction + constructor, and functions created using the bind method also must not be created with such own + properties. + +---*/ + + +var callCount = 0; +class C { + static async *method() { + assert.sameValue(this.method.hasOwnProperty("caller"), false); + callCount++; + } +} + +C.method().next() + .then(() => { + assert.sameValue(callCount, 1, 'function body evaluated'); + }, $DONE).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/forbidden-ext/b1/shell.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/forbidden-ext/b1/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/forbidden-ext/b2/browser.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/forbidden-ext/b2/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/forbidden-ext/b2/cls-decl-async-gen-meth-static-forbidden-ext-indirect-access-own-prop-caller-get.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/forbidden-ext/b2/cls-decl-async-gen-meth-static-forbidden-ext-indirect-access-own-prop-caller-get.js new file mode 100644 index 0000000000..4071306341 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/forbidden-ext/b2/cls-decl-async-gen-meth-static-forbidden-ext-indirect-access-own-prop-caller-get.js @@ -0,0 +1,65 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/function-forms/forbidden-ext-indirect-access-own-prop-caller-get.case +// - src/function-forms/forbidden-extensions/bullet-two/cls-decl-async-gen-meth-static.template +/*--- +description: Forbidden extension, o.caller (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [arrow-function, async-functions, async-iteration, class] +flags: [generated, noStrict, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + + If an implementation extends any function object with an own property named "caller" the value of + that property, as observed using [[Get]] or [[GetOwnProperty]], must not be a strict function + object. If it is an accessor property, the function that is the value of the property's [[Get]] + attribute must never return a strict function when called. + +---*/ +var CALLER_OWN_PROPERTY_DOES_NOT_EXIST = Symbol(); +function inner() { + // This property may exist, but is forbidden from having a value that is a strict function object + return inner.hasOwnProperty("caller") + ? inner.caller + : CALLER_OWN_PROPERTY_DOES_NOT_EXIST; +} + + +var callCount = 0; +class C { + static async *method() { + /* implicit strict */ + // This and the following conditional value is set in the test's .case file. + // For every test that has a "true" value here, there is a + // corresponding test that has a "false" value here. + // They are generated from two different case files, which use + let descriptor = Object.getOwnPropertyDescriptor(inner, "caller"); + if (descriptor && descriptor.configurable && true) { + Object.defineProperty(inner, "caller", {get(){return 1}}); + } + var result = inner(); + if (descriptor && descriptor.configurable && true) { + assert.sameValue(result, 1, 'If this test defined an own "caller" property on the inner function, then it should be accessible and should return the value it was set to.'); + } + + // "CALLER_OWN_PROPERTY_DOES_NOT_EXIST" is from + // forbidden-ext-indirect-access-prop-caller.case + // + // If the function object "inner" has an own property + // named "caller", then its value will be returned. + // + // If the function object "inner" DOES NOT have an + // own property named "caller", then the symbol + // CALLER_OWN_PROPERTY_DOES_NOT_EXIST will be returned. + if (result !== CALLER_OWN_PROPERTY_DOES_NOT_EXIST) { + assert.notSameValue(result, this.method); + } + callCount++; + } +} + +C.method().next() + .then(() => { + assert.sameValue(callCount, 1, 'function body evaluated'); + }, $DONE).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/forbidden-ext/b2/cls-decl-async-gen-meth-static-forbidden-ext-indirect-access-own-prop-caller-value.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/forbidden-ext/b2/cls-decl-async-gen-meth-static-forbidden-ext-indirect-access-own-prop-caller-value.js new file mode 100644 index 0000000000..7c47646f0c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/forbidden-ext/b2/cls-decl-async-gen-meth-static-forbidden-ext-indirect-access-own-prop-caller-value.js @@ -0,0 +1,65 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/function-forms/forbidden-ext-indirect-access-own-prop-caller-value.case +// - src/function-forms/forbidden-extensions/bullet-two/cls-decl-async-gen-meth-static.template +/*--- +description: Forbidden extension, o.caller (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [arrow-function, async-functions, async-iteration, class] +flags: [generated, noStrict, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + + If an implementation extends any function object with an own property named "caller" the value of + that property, as observed using [[Get]] or [[GetOwnProperty]], must not be a strict function + object. If it is an accessor property, the function that is the value of the property's [[Get]] + attribute must never return a strict function when called. + +---*/ +var CALLER_OWN_PROPERTY_DOES_NOT_EXIST = Symbol(); +function inner() { + // This property may exist, but is forbidden from having a value that is a strict function object + return inner.hasOwnProperty("caller") + ? inner.caller + : CALLER_OWN_PROPERTY_DOES_NOT_EXIST; +} + + +var callCount = 0; +class C { + static async *method() { + /* implicit strict */ + // This and the following conditional value is set in the test's .case file. + // For every test that has a "true" value here, there is a + // corresponding test that has a "false" value here. + // They are generated from two different case files, which use + let descriptor = Object.getOwnPropertyDescriptor(inner, "caller"); + if (descriptor && descriptor.configurable && true) { + Object.defineProperty(inner, "caller", {value: 1}); + } + var result = inner(); + if (descriptor && descriptor.configurable && true) { + assert.sameValue(result, 1, 'If this test defined an own "caller" property on the inner function, then it should be accessible and should return the value it was set to.'); + } + + // "CALLER_OWN_PROPERTY_DOES_NOT_EXIST" is from + // forbidden-ext-indirect-access-prop-caller.case + // + // If the function object "inner" has an own property + // named "caller", then its value will be returned. + // + // If the function object "inner" DOES NOT have an + // own property named "caller", then the symbol + // CALLER_OWN_PROPERTY_DOES_NOT_EXIST will be returned. + if (result !== CALLER_OWN_PROPERTY_DOES_NOT_EXIST) { + assert.notSameValue(result, this.method); + } + callCount++; + } +} + +C.method().next() + .then(() => { + assert.sameValue(callCount, 1, 'function body evaluated'); + }, $DONE).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/forbidden-ext/b2/cls-decl-async-gen-meth-static-forbidden-ext-indirect-access-prop-caller.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/forbidden-ext/b2/cls-decl-async-gen-meth-static-forbidden-ext-indirect-access-prop-caller.js new file mode 100644 index 0000000000..c845f26f16 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/forbidden-ext/b2/cls-decl-async-gen-meth-static-forbidden-ext-indirect-access-prop-caller.js @@ -0,0 +1,65 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/function-forms/forbidden-ext-indirect-access-prop-caller.case +// - src/function-forms/forbidden-extensions/bullet-two/cls-decl-async-gen-meth-static.template +/*--- +description: Forbidden extension, o.caller (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [arrow-function, async-functions, async-iteration, class] +flags: [generated, noStrict, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + + If an implementation extends any function object with an own property named "caller" the value of + that property, as observed using [[Get]] or [[GetOwnProperty]], must not be a strict function + object. If it is an accessor property, the function that is the value of the property's [[Get]] + attribute must never return a strict function when called. + +---*/ +var CALLER_OWN_PROPERTY_DOES_NOT_EXIST = Symbol(); +function inner() { + // This property may exist, but is forbidden from having a value that is a strict function object + return inner.hasOwnProperty("caller") + ? inner.caller + : CALLER_OWN_PROPERTY_DOES_NOT_EXIST; +} + + +var callCount = 0; +class C { + static async *method() { + /* implicit strict */ + // This and the following conditional value is set in the test's .case file. + // For every test that has a "true" value here, there is a + // corresponding test that has a "false" value here. + // They are generated from two different case files, which use + let descriptor = Object.getOwnPropertyDescriptor(inner, "caller"); + if (descriptor && descriptor.configurable && false) { + Object.defineProperty(inner, "caller", {}); + } + var result = inner(); + if (descriptor && descriptor.configurable && false) { + assert.sameValue(result, 1, 'If this test defined an own "caller" property on the inner function, then it should be accessible and should return the value it was set to.'); + } + + // "CALLER_OWN_PROPERTY_DOES_NOT_EXIST" is from + // forbidden-ext-indirect-access-prop-caller.case + // + // If the function object "inner" has an own property + // named "caller", then its value will be returned. + // + // If the function object "inner" DOES NOT have an + // own property named "caller", then the symbol + // CALLER_OWN_PROPERTY_DOES_NOT_EXIST will be returned. + if (result !== CALLER_OWN_PROPERTY_DOES_NOT_EXIST) { + assert.notSameValue(result, this.method); + } + callCount++; + } +} + +C.method().next() + .then(() => { + assert.sameValue(callCount, 1, 'function body evaluated'); + }, $DONE).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/forbidden-ext/b2/shell.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/forbidden-ext/b2/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/forbidden-ext/browser.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/forbidden-ext/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/forbidden-ext/shell.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/forbidden-ext/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/object-destructuring-param-strict-body.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/object-destructuring-param-strict-body.js new file mode 100644 index 0000000000..0669b18670 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/object-destructuring-param-strict-body.js @@ -0,0 +1,138 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/function-forms/object-destructuring-param-strict-body.case +// - src/function-forms/syntax/cls-decl-async-gen-meth-static.template +/*--- +description: ObjectBindingPattern and Use Strict Directive are not allowed to coexist for the same function. (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [rest-parameters, async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.4 Static Semantics: IsSimpleParameterList + + BindingElement : BindingPattern + + 1. Return false. + + 14.1.2 Static Semantics: Early Errors + + FunctionDeclaration : function BindingIdentifier ( FormalParameters ) { FunctionBody } + FunctionDeclaration : function ( FormalParameters ) { FunctionBody } + FunctionExpression : function BindingIdentifier ( FormalParameters ) { FunctionBody } + + - It is a Syntax Error if ContainsUseStrict of FunctionBody is true and + IsSimpleParameterList of FormalParameters is false. + + 14.2.1 Static Semantics: Early Errors + + ArrowFunction : ArrowParameters => ConciseBody + + - It is a Syntax Error if ContainsUseStrict of ConciseBody is true and + IsSimpleParameterList of ArrowParameters is false. + + 14.3.1 Static Semantics: Early Errors + + MethodDefinition : PropertyName ( UniqueFormalParameters ) { FunctionBody } + + - It is a Syntax Error if ContainsUseStrict of FunctionBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + MethodDefinition : set PropertyName ( PropertySetParameterList ) { FunctionBody } + + - It is a Syntax Error if ContainsUseStrict of FunctionBody is true and + IsSimpleParameterList of PropertySetParameterList is false. + + 14.4.1 Static Semantics: Early Errors + + GeneratorMethod : * PropertyName ( UniqueFormalParameters ) { GeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of GeneratorBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + GeneratorDeclaration : function * BindingIdentifier ( FormalParameters ) { GeneratorBody } + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + GeneratorExpression : function * BindingIdentifier ( FormalParameters ) { GeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of GeneratorBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + 14.5.1 Static Semantics: Early Errors + + AsyncGeneratorMethod : async * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncGeneratorBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + AsyncGeneratorDeclaration : async function * BindingIdentifier ( FormalParameters ) { AsyncGeneratorBody } + AsyncGeneratorDeclaration : async function * ( FormalParameters ) { AsyncGeneratorBody } + AsyncGeneratorExpression : async function * BindingIdentifier ( FormalParameters ) { AsyncGeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncGeneratorBody is true and + IsSimpleParameterList of FormalParameters is false. + + 14.7.1 Static Semantics: Early Errors + + AsyncMethod : async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncFunctionBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + AsyncFunctionDeclaration : async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody } + AsyncFunctionDeclaration : async function ( FormalParameters ) { AsyncFunctionBody } + AsyncFunctionExpression : async function ( FormalParameters ) { AsyncFunctionBody } + AsyncFunctionExpression : async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncFunctionBody is true and + IsSimpleParameterList of FormalParameters is false. + + 14.8.1 Static Semantics: Early Errors + + AsyncArrowFunction : CoverCallExpressionAndAsyncArrowHead => AsyncConciseBody + + - It is a Syntax Error if ContainsUseStrict of AsyncConciseBody is true and + IsSimpleParameterList of CoverCallExpressionAndAsyncArrowHead is false. + +---*/ +$DONOTEVALUATE(); + + +class C { + static async *method({property}) { + "use strict"; + } +} diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/params-trailing-comma-multiple.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/params-trailing-comma-multiple.js new file mode 100644 index 0000000000..5ac5a17650 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/params-trailing-comma-multiple.js @@ -0,0 +1,67 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/function-forms/params-trailing-comma-multiple.case +// - src/function-forms/default/cls-decl-async-gen-meth-static.template +/*--- +description: A trailing comma should not increase the respective length, using multiple parameters (static class declaration async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + Trailing comma in the parameters list + + 14.1 Function Definitions + + FormalParameters[Yield, Await] : FormalParameterList[?Yield, ?Await] , +---*/ + + +var callCount = 0; +class C { + static async *method(a, b,) { + assert.sameValue(a, 42); + assert.sameValue(b, 39); + callCount = callCount + 1; + } +} + +// Stores a reference `ref` for case evaluation +var ref = C.method; + +ref(42, 39, 1).next().then(() => { + assert.sameValue(callCount, 1, 'method invoked exactly once'); +}).then($DONE, $DONE); + +assert.sameValue(ref.length, 2, 'length is properly set'); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/params-trailing-comma-single.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/params-trailing-comma-single.js new file mode 100644 index 0000000000..ce92295b3d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/params-trailing-comma-single.js @@ -0,0 +1,66 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/function-forms/params-trailing-comma-single.case +// - src/function-forms/default/cls-decl-async-gen-meth-static.template +/*--- +description: A trailing comma should not increase the respective length, using a single parameter (static class declaration async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + Trailing comma in the parameters list + + 14.1 Function Definitions + + FormalParameters[Yield, Await] : FormalParameterList[?Yield, ?Await] , +---*/ + + +var callCount = 0; +class C { + static async *method(a,) { + assert.sameValue(a, 42); + callCount = callCount + 1; + } +} + +// Stores a reference `ref` for case evaluation +var ref = C.method; + +ref(42, 39).next().then(() => { + assert.sameValue(callCount, 1, 'method invoked exactly once'); +}).then($DONE, $DONE); + +assert.sameValue(ref.length, 1, 'length is properly set'); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/rest-param-strict-body.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/rest-param-strict-body.js new file mode 100644 index 0000000000..6f77dcec53 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/rest-param-strict-body.js @@ -0,0 +1,138 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/function-forms/rest-param-strict-body.case +// - src/function-forms/syntax/cls-decl-async-gen-meth-static.template +/*--- +description: RestParameter and Use Strict Directive are not allowed to coexist for the same function. (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [rest-parameters, async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 14.1.13 Static Semantics: IsSimpleParameterList + + FormalParameters : FormalParameterList , FunctionRestParameter + + 1. Return false. + + 14.1.2 Static Semantics: Early Errors + + FunctionDeclaration : function BindingIdentifier ( FormalParameters ) { FunctionBody } + FunctionDeclaration : function ( FormalParameters ) { FunctionBody } + FunctionExpression : function BindingIdentifier ( FormalParameters ) { FunctionBody } + + - It is a Syntax Error if ContainsUseStrict of FunctionBody is true and + IsSimpleParameterList of FormalParameters is false. + + 14.2.1 Static Semantics: Early Errors + + ArrowFunction : ArrowParameters => ConciseBody + + - It is a Syntax Error if ContainsUseStrict of ConciseBody is true and + IsSimpleParameterList of ArrowParameters is false. + + 14.3.1 Static Semantics: Early Errors + + MethodDefinition : PropertyName ( UniqueFormalParameters ) { FunctionBody } + + - It is a Syntax Error if ContainsUseStrict of FunctionBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + MethodDefinition : set PropertyName ( PropertySetParameterList ) { FunctionBody } + + - It is a Syntax Error if ContainsUseStrict of FunctionBody is true and + IsSimpleParameterList of PropertySetParameterList is false. + + 14.4.1 Static Semantics: Early Errors + + GeneratorMethod : * PropertyName ( UniqueFormalParameters ) { GeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of GeneratorBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + GeneratorDeclaration : function * BindingIdentifier ( FormalParameters ) { GeneratorBody } + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + GeneratorExpression : function * BindingIdentifier ( FormalParameters ) { GeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of GeneratorBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + 14.5.1 Static Semantics: Early Errors + + AsyncGeneratorMethod : async * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncGeneratorBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + AsyncGeneratorDeclaration : async function * BindingIdentifier ( FormalParameters ) { AsyncGeneratorBody } + AsyncGeneratorDeclaration : async function * ( FormalParameters ) { AsyncGeneratorBody } + AsyncGeneratorExpression : async function * BindingIdentifier ( FormalParameters ) { AsyncGeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncGeneratorBody is true and + IsSimpleParameterList of FormalParameters is false. + + 14.7.1 Static Semantics: Early Errors + + AsyncMethod : async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncFunctionBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + AsyncFunctionDeclaration : async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody } + AsyncFunctionDeclaration : async function ( FormalParameters ) { AsyncFunctionBody } + AsyncFunctionExpression : async function ( FormalParameters ) { AsyncFunctionBody } + AsyncFunctionExpression : async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncFunctionBody is true and + IsSimpleParameterList of FormalParameters is false. + + 14.8.1 Static Semantics: Early Errors + + AsyncArrowFunction : CoverCallExpressionAndAsyncArrowHead => AsyncConciseBody + + - It is a Syntax Error if ContainsUseStrict of AsyncConciseBody is true and + IsSimpleParameterList of CoverCallExpressionAndAsyncArrowHead is false. + +---*/ +$DONOTEVALUATE(); + + +class C { + static async *method(a,...rest) { + "use strict"; + } +} diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/rest-params-trailing-comma-early-error.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/rest-params-trailing-comma-early-error.js new file mode 100644 index 0000000000..cbc14b1619 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/rest-params-trailing-comma-early-error.js @@ -0,0 +1,64 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/function-forms/rest-params-trailing-comma-early-error.case +// - src/function-forms/syntax/cls-decl-async-gen-meth-static.template +/*--- +description: It's a syntax error if a FunctionRestParameter is followed by a trailing comma (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + Trailing comma in the parameters list + + 14.1 Function Definitions + + FormalParameters[Yield, Await] : + [empty] + FunctionRestParameter[?Yield, ?Await] + FormalParameterList[?Yield, ?Await] + FormalParameterList[?Yield, ?Await] , + FormalParameterList[?Yield, ?Await] , FunctionRestParameter[?Yield, ?Await] +---*/ +$DONOTEVALUATE(); + + +class C { + static async *method(...a,) { + + } +} diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/shell.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-as-binding-identifier-escaped.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-as-binding-identifier-escaped.js new file mode 100644 index 0000000000..04f56c8bd7 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-as-binding-identifier-escaped.js @@ -0,0 +1,37 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-as-binding-identifier-escaped.case +// - src/async-generators/syntax/async-class-decl-static-method.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as a binding identifier. (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + BindingIdentifier : Identifier + + It is a Syntax Error if this production has a [Yield] parameter and + StringValue of Identifier is "yield". + +---*/ +$DONOTEVALUATE(); + + +class C { static async *gen() { + var yi\u0065ld; +}} diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-as-binding-identifier.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-as-binding-identifier.js new file mode 100644 index 0000000000..f3b028e636 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-as-binding-identifier.js @@ -0,0 +1,37 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-as-binding-identifier.case +// - src/async-generators/syntax/async-class-decl-static-method.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as a binding identifier. (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + BindingIdentifier : Identifier + + It is a Syntax Error if this production has a [Yield] parameter and + StringValue of Identifier is "yield". + +---*/ +$DONOTEVALUATE(); + + +class C { static async *gen() { + var yield; +}} diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-as-identifier-reference-escaped.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-as-identifier-reference-escaped.js new file mode 100644 index 0000000000..61bb80ffeb --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-as-identifier-reference-escaped.js @@ -0,0 +1,37 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-as-identifier-reference-escaped.case +// - src/async-generators/syntax/async-class-decl-static-method.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as an identifier reference. (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + IdentifierReference : Identifier + + It is a Syntax Error if this production has a [Yield] parameter and + StringValue of Identifier is "yield". + +---*/ +$DONOTEVALUATE(); + + +class C { static async *gen() { + void yi\u0065ld; +}} diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-as-identifier-reference.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-as-identifier-reference.js new file mode 100644 index 0000000000..3e6df8cc98 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-as-identifier-reference.js @@ -0,0 +1,37 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-as-identifier-reference.case +// - src/async-generators/syntax/async-class-decl-static-method.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as an identifier reference. (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + IdentifierReference : Identifier + + It is a Syntax Error if this production has a [Yield] parameter and + StringValue of Identifier is "yield". + +---*/ +$DONOTEVALUATE(); + + +class C { static async *gen() { + void yield; +}} diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-as-label-identifier-escaped.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-as-label-identifier-escaped.js new file mode 100644 index 0000000000..ed8c94e6ff --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-as-label-identifier-escaped.js @@ -0,0 +1,37 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-as-label-identifier-escaped.case +// - src/async-generators/syntax/async-class-decl-static-method.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as a label identifier. (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + LabelIdentifier : Identifier + + It is a Syntax Error if this production has a [Yield] parameter and + StringValue of Identifier is "yield". + +---*/ +$DONOTEVALUATE(); + + +class C { static async *gen() { + yi\u0065ld: ; +}} diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-as-label-identifier.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-as-label-identifier.js new file mode 100644 index 0000000000..58f5930948 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-as-label-identifier.js @@ -0,0 +1,37 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-as-label-identifier.case +// - src/async-generators/syntax/async-class-decl-static-method.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as a label identifier. (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + LabelIdentifier : Identifier + + It is a Syntax Error if this production has a [Yield] parameter and + StringValue of Identifier is "yield". + +---*/ +$DONOTEVALUATE(); + + +class C { static async *gen() { + yield: ; +}} diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-identifier-spread-strict-strict.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-identifier-spread-strict-strict.js new file mode 100644 index 0000000000..de3f96587b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-identifier-spread-strict-strict.js @@ -0,0 +1,55 @@ +// |reftest| error:SyntaxError +'use strict'; +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-identifier-spread-strict.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: It's an early error if the AssignmentExpression is a function body with yield as an identifier in strict mode. (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [object-spread, async-iteration] +flags: [generated, onlyStrict] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + Spread Properties + + PropertyDefinition[Yield]: + (...) + ...AssignmentExpression[In, ?Yield] + +---*/ +$DONOTEVALUATE(); + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + return { + ...(function() { + var yield; + throw new Test262Error(); + }()), + } +}} + +var gen = C.gen; + +var iter = gen(); + + + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-identifier-strict-strict.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-identifier-strict-strict.js new file mode 100644 index 0000000000..7ef3a6f717 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-identifier-strict-strict.js @@ -0,0 +1,46 @@ +// |reftest| error:SyntaxError +'use strict'; +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-identifier-strict.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: It's an early error if the generator body has another function body with yield as an identifier in strict mode. (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration] +flags: [generated, onlyStrict] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + +---*/ +$DONOTEVALUATE(); + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + (function() { + var yield; + throw new Test262Error(); + }()) +}} + +var gen = C.gen; + +var iter = gen(); + + + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-promise-reject-next-catch.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-promise-reject-next-catch.js new file mode 100644 index 0000000000..2c9fde7744 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-promise-reject-next-catch.js @@ -0,0 +1,51 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-promise-reject-next-catch.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: yield Promise.reject(value) is treated as throw value (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + +---*/ +let error = new Error(); + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + yield Promise.reject(error); + yield "unreachable"; +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error("Promise incorrectly resolved."); +}).catch(rejectValue => { + // yield Promise.reject(error); + assert.sameValue(rejectValue, error); + + iter.next().then(({done, value}) => { + // iter is closed now. + assert.sameValue(done, true, "The value of IteratorResult.done is `true`"); + assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`"); + }).then($DONE, $DONE); +}); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-promise-reject-next-for-await-of-async-iterator.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-promise-reject-next-for-await-of-async-iterator.js new file mode 100644 index 0000000000..347dfc59cb --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-promise-reject-next-for-await-of-async-iterator.js @@ -0,0 +1,57 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-promise-reject-next-for-await-of-async-iterator.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: yield * [Promise.reject(value)] is treated as throw value (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + +---*/ +let error = new Error(); +async function * readFile() { + yield Promise.reject(error); + yield "unreachable"; +} + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + for await (let line of readFile()) { + yield line; + } +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error("Promise incorrectly resolved."); +}, rejectValue => { + + // yield Promise.reject(error); + assert.sameValue(rejectValue, error); + + iter.next().then(({done, value}) => { + // iter is closed now. + assert.sameValue(done, true, "The value of IteratorResult.done is `true`"); + assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`"); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-promise-reject-next-for-await-of-sync-iterator.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-promise-reject-next-for-await-of-sync-iterator.js new file mode 100644 index 0000000000..09cbb76b40 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-promise-reject-next-for-await-of-sync-iterator.js @@ -0,0 +1,56 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-promise-reject-next-for-await-of-sync-iterator.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: yield Promise.reject(value) in for-await-of is treated as throw value (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + +---*/ +let error = new Error(); +let iterable = [ + Promise.reject(error), + "unreachable" +]; + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + for await (let value of iterable) { + yield value; + } +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error("Promise incorrectly resolved."); +}, rejectValue => { + // yield Promise.reject(error); + assert.sameValue(rejectValue, error); + + iter.next().then(({done, value}) => { + // iter is closed now. + assert.sameValue(done, true, "The value of IteratorResult.done is `true`"); + assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`"); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-promise-reject-next-yield-star-async-iterator.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-promise-reject-next-yield-star-async-iterator.js new file mode 100644 index 0000000000..bd83eced36 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-promise-reject-next-yield-star-async-iterator.js @@ -0,0 +1,55 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-promise-reject-next-yield-star-async-iterator.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: yield * (async iterator) is treated as throw value (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + +---*/ +let error = new Error(); +async function * readFile() { + yield Promise.reject(error); + yield "unreachable"; +} + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + yield * readFile(); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error("Promise incorrectly resolved."); +}, rejectValue => { + // yield Promise.reject(error); + assert.sameValue(rejectValue, error); + + iter.next().then(({done, value}) => { + // iter is closed now. + assert.sameValue(done, true, "The value of IteratorResult.done is `true`"); + assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`"); + }).then($DONE, $DONE); +}, $DONE).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-promise-reject-next-yield-star-sync-iterator.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-promise-reject-next-yield-star-sync-iterator.js new file mode 100644 index 0000000000..e081278277 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-promise-reject-next-yield-star-sync-iterator.js @@ -0,0 +1,54 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-promise-reject-next-yield-star-sync-iterator.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: yield * (async iterator) is treated as throw value (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + +---*/ +let error = new Error(); +let iterable = [ + Promise.reject(error), + "unreachable" +]; + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + yield * iterable; +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error("Promise incorrectly resolved."); +}, rejectValue => { + // yield Promise.reject(error); + assert.sameValue(rejectValue, error); + + iter.next().then(({done, value}) => { + // iter is closed now. + assert.sameValue(done, true, "The value of IteratorResult.done is `true`"); + assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`"); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-promise-reject-next.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-promise-reject-next.js new file mode 100644 index 0000000000..e3cd184f98 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-promise-reject-next.js @@ -0,0 +1,51 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-promise-reject-next.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: yield Promise.reject(value) is treated as throw value (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + +---*/ +let error = new Error(); + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + yield Promise.reject(error); + yield "unreachable"; +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error("Promise incorrectly resolved."); +}, rejectValue => { + // yield Promise.reject(error); + assert.sameValue(rejectValue, error); + + iter.next().then(({done, value}) => { + // iter is closed now. + assert.sameValue(done, true, "The value of IteratorResult.done is `true`"); + assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`"); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-spread-arr-multiple.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-spread-arr-multiple.js new file mode 100644 index 0000000000..a45a13e0bd --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-spread-arr-multiple.js @@ -0,0 +1,57 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-spread-arr-multiple.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: Use yield value in a array spread position (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration] +flags: [generated, async] +includes: [compareArray.js] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + Array Initializer + + SpreadElement[Yield, Await]: + ...AssignmentExpression[+In, ?Yield, ?Await] + +---*/ +var arr = ['a', 'b', 'c']; +var item; + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + yield [...yield yield]; +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next(false); +item = iter.next(['a', 'b', 'c']); + +item.then(({ done, value }) => { + item = iter.next(value); + + item.then(({ done, value }) => { + assert.compareArray(value, arr); + assert.sameValue(done, false); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-spread-arr-single.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-spread-arr-single.js new file mode 100644 index 0000000000..21f3704f58 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-spread-arr-single.js @@ -0,0 +1,56 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-spread-arr-single.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: Use yield value in a array spread position (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + Array Initializer + + SpreadElement[Yield, Await]: + ...AssignmentExpression[+In, ?Yield, ?Await] + +---*/ +var arr = ['a', 'b', 'c']; + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + yield [...yield]; +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next(false); +var item = iter.next(arr); + +item.then(({ done, value }) => { + assert.notSameValue(value, arr, 'value is a new array'); + assert(Array.isArray(value), 'value is an Array exotic object'); + assert.sameValue(value.length, 3) + assert.sameValue(value[0], 'a'); + assert.sameValue(value[1], 'b'); + assert.sameValue(value[2], 'c'); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-spread-obj.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-spread-obj.js new file mode 100644 index 0000000000..dc5be5b91e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-spread-obj.js @@ -0,0 +1,59 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-spread-obj.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: Use yield value in a object spread position (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [object-spread, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + Spread Properties + + PropertyDefinition[Yield]: + (...) + ...AssignmentExpression[In, ?Yield] + +---*/ + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + yield { + ...yield, + y: 1, + ...yield yield, + }; +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next(); +iter.next({ x: 42 }); +iter.next({ x: 'lol' }); +var item = iter.next({ y: 39 }); + +item.then(({ done, value }) => { + assert.sameValue(value.x, 42); + assert.sameValue(value.y, 39); + assert.sameValue(Object.keys(value).length, 2); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-async-next.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-async-next.js new file mode 100644 index 0000000000..05ee32010d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-async-next.js @@ -0,0 +1,226 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-async-next.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: Execution order for yield* with async iterator and next() (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, async-iteration, Symbol.asyncIterator] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + +---*/ +var log = []; +var obj = { + get [Symbol.iterator]() { + log.push({ name: "get [Symbol.iterator]" }); + }, + get [Symbol.asyncIterator]() { + log.push({ + name: "get [Symbol.asyncIterator]", + thisValue: this + }); + return function() { + log.push({ + name: "call [Symbol.asyncIterator]", + thisValue: this, + args: [...arguments] + }); + var nextCount = 0; + return { + name: "asyncIterator", + get next() { + log.push({ + name: "get next", + thisValue: this + }); + return function() { + log.push({ + name: "call next", + thisValue: this, + args: [...arguments] + }); + + nextCount++; + if (nextCount == 1) { + return { + name: "next-promise-1", + get then() { + log.push({ + name: "get next then (1)", + thisValue: this + }); + return function(resolve) { + log.push({ + name: "call next then (1)", + thisValue: this, + args: [...arguments] + }); + + resolve({ + name: "next-result-1", + get value() { + log.push({ + name: "get next value (1)", + thisValue: this + }); + return "next-value-1"; + }, + get done() { + log.push({ + name: "get next done (1)", + thisValue: this + }); + return false; + } + }); + }; + } + }; + } + + return { + name: "next-promise-2", + get then() { + log.push({ + name: "get next then (2)", + thisValue: this + }); + return function(resolve) { + log.push({ + name: "call next then (2)", + thisValue: this, + args: [...arguments] + }); + + resolve({ + name: "next-result-2", + get value() { + log.push({ + name: "get next value (2)", + thisValue: this + }); + return "next-value-2"; + }, + get done() { + log.push({ + name: "get next done (2)", + thisValue: this + }); + return true; + } + }); + }; + } + }; + }; + } + }; + }; + } +}; + + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + log.push({ name: "before yield*" }); + var v = yield* obj; + log.push({ + name: "after yield*", + value: v + }); + return "return-value"; + +}} + +var gen = C.gen; + +var iter = gen(); + +assert.sameValue(log.length, 0, "log.length"); + +iter.next("next-arg-1").then(v => { + assert.sameValue(log[0].name, "before yield*"); + + assert.sameValue(log[1].name, "get [Symbol.asyncIterator]"); + assert.sameValue(log[1].thisValue, obj, "get [Symbol.asyncIterator] thisValue"); + + assert.sameValue(log[2].name, "call [Symbol.asyncIterator]"); + assert.sameValue(log[2].thisValue, obj, "[Symbol.asyncIterator] thisValue"); + assert.sameValue(log[2].args.length, 0, "[Symbol.asyncIterator] args.length"); + + assert.sameValue(log[3].name, "get next"); + assert.sameValue(log[3].thisValue.name, "asyncIterator", "get next thisValue"); + + assert.sameValue(log[4].name, "call next"); + assert.sameValue(log[4].thisValue.name, "asyncIterator", "next thisValue"); + assert.sameValue(log[4].args.length, 1, "next args.length"); + assert.sameValue(log[4].args[0], undefined, "next args[0]"); + + assert.sameValue(log[5].name, "get next then (1)"); + assert.sameValue(log[5].thisValue.name, "next-promise-1", "get next then thisValue"); + + assert.sameValue(log[6].name, "call next then (1)"); + assert.sameValue(log[6].thisValue.name, "next-promise-1", "next then thisValue"); + assert.sameValue(log[6].args.length, 2, "next then args.length"); + assert.sameValue(typeof log[6].args[0], "function", "next then args[0]"); + assert.sameValue(typeof log[6].args[1], "function", "next then args[1]"); + + assert.sameValue(log[7].name, "get next done (1)"); + assert.sameValue(log[7].thisValue.name, "next-result-1", "get next done thisValue"); + + assert.sameValue(log[8].name, "get next value (1)"); + assert.sameValue(log[8].thisValue.name, "next-result-1", "get next value thisValue"); + + assert.sameValue(v.value, "next-value-1"); + assert.sameValue(v.done, false); + + assert.sameValue(log.length, 9, "log.length"); + + iter.next("next-arg-2").then(v => { + assert.sameValue(log[9].name, "call next"); + assert.sameValue(log[9].thisValue.name, "asyncIterator", "next thisValue"); + assert.sameValue(log[9].args.length, 1, "next args.length"); + assert.sameValue(log[9].args[0], "next-arg-2", "next args[0]"); + + assert.sameValue(log[10].name, "get next then (2)"); + assert.sameValue(log[10].thisValue.name, "next-promise-2", "get next then thisValue"); + + assert.sameValue(log[11].name, "call next then (2)"); + assert.sameValue(log[11].thisValue.name, "next-promise-2", "next then thisValue"); + assert.sameValue(log[11].args.length, 2, "next then args.length"); + assert.sameValue(typeof log[11].args[0], "function", "next then args[0]"); + assert.sameValue(typeof log[11].args[1], "function", "next then args[1]"); + + assert.sameValue(log[12].name, "get next done (2)"); + assert.sameValue(log[12].thisValue.name, "next-result-2", "get next done thisValue"); + + assert.sameValue(log[13].name, "get next value (2)"); + assert.sameValue(log[13].thisValue.name, "next-result-2", "get next value thisValue"); + + assert.sameValue(log[14].name, "after yield*"); + assert.sameValue(log[14].value, "next-value-2"); + + assert.sameValue(v.value, "return-value"); + assert.sameValue(v.done, true); + + assert.sameValue(log.length, 15, "log.length"); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-async-return.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-async-return.js new file mode 100644 index 0000000000..4b3cc6a36d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-async-return.js @@ -0,0 +1,242 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-async-return.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: execution order for yield* with async iterator and return() (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration, Symbol.asyncIterator] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + ... + 6. Repeat + ... + c. Else, + i. Assert: received.[[Type]] is return. + ii. Let return be ? GetMethod(iterator, "return"). + iii. If return is undefined, return Completion(received). + iv. Let innerReturnResult be ? Call(return, iterator, « received.[[Value]] »). + v. If generatorKind is async, then set innerReturnResult to ? Await(innerReturnResult). + ... + vii. Let done be ? IteratorComplete(innerReturnResult). + viii. If done is true, then + 1. Let value be ? IteratorValue(innerReturnResult). + 2. If generatorKind is async, then set value to ? Await(value). + 3. Return Completion{[[Type]]: return, [[Value]]: value, [[Target]]: empty}. + ix. If generatorKind is async, then let received be AsyncGeneratorYield(? IteratorValue(innerResult)). + ... + + AsyncGeneratorYield ( value ) + ... + 8. Return ! AsyncGeneratorResolve(generator, value, false). + ... + +---*/ +var log = []; +var obj = { + [Symbol.asyncIterator]() { + var returnCount = 0; + return { + name: 'asyncIterator', + get next() { + log.push({ name: "get next" }); + return function() { + return { + value: "next-value-1", + done: false + }; + }; + }, + get return() { + log.push({ + name: "get return", + thisValue: this + }); + return function() { + log.push({ + name: "call return", + thisValue: this, + args: [...arguments] + }); + + returnCount++; + if (returnCount == 1) { + return { + name: "return-promise-1", + get then() { + log.push({ + name: "get return then (1)", + thisValue: this + }); + return function(resolve) { + log.push({ + name: "call return then (1)", + thisValue: this, + args: [...arguments] + }); + + resolve({ + name: "return-result-1", + get value() { + log.push({ + name: "get return value (1)", + thisValue: this + }); + return "return-value-1"; + }, + get done() { + log.push({ + name: "get return done (1)", + thisValue: this + }); + return false; + } + }); + }; + } + }; + } + + return { + name: "return-promise-2", + get then() { + log.push({ + name: "get return then (2)", + thisValue: this + }); + return function(resolve) { + log.push({ + name: "call return then (2)", + thisValue: this, + args: [...arguments] + }); + + resolve({ + name: "return-result-2", + get value() { + log.push({ + name: "get return value (2)", + thisValue: this + }); + return "return-value-2"; + }, + get done() { + log.push({ + name: "get return done (2)", + thisValue: this + }); + return true; + } + }); + }; + } + }; + }; + } + }; + } +}; + + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + log.push({ name: "before yield*" }); + yield* obj; + +}} + +var gen = C.gen; + +var iter = gen(); + +assert.sameValue(log.length, 0, "log.length"); + +iter.next().then(v => { + assert.sameValue(log[0].name, "before yield*"); + + assert.sameValue(log[1].name, "get next"); + + assert.sameValue(v.value, "next-value-1"); + assert.sameValue(v.done, false); + + assert.sameValue(log.length, 2, "log.length"); + + iter.return("return-arg-1").then(v => { + assert.sameValue(log[2].name, "get return"); + assert.sameValue(log[2].thisValue.name, "asyncIterator", "get return thisValue"); + + assert.sameValue(log[3].name, "call return"); + assert.sameValue(log[3].thisValue.name, "asyncIterator", "return thisValue"); + assert.sameValue(log[3].args.length, 1, "return args.length"); + assert.sameValue(log[3].args[0], "return-arg-1", "return args[0]"); + + assert.sameValue(log[4].name, "get return then (1)"); + assert.sameValue(log[4].thisValue.name, "return-promise-1", "get return then thisValue"); + + assert.sameValue(log[5].name, "call return then (1)"); + assert.sameValue(log[5].thisValue.name, "return-promise-1", "return then thisValue"); + assert.sameValue(log[5].args.length, 2, "return then args.length"); + assert.sameValue(typeof log[5].args[0], "function", "return then args[0]"); + assert.sameValue(typeof log[5].args[1], "function", "return then args[1]"); + + assert.sameValue(log[6].name, "get return done (1)"); + assert.sameValue(log[6].thisValue.name, "return-result-1", "get return done thisValue"); + + assert.sameValue(log[7].name, "get return value (1)"); + assert.sameValue(log[7].thisValue.name, "return-result-1", "get return value thisValue"); + + assert.sameValue(v.value, "return-value-1"); + assert.sameValue(v.done, false); + + assert.sameValue(log.length, 8, "log.length"); + + iter.return("return-arg-2").then(v => { + assert.sameValue(log[8].name, "get return"); + assert.sameValue(log[8].thisValue.name, "asyncIterator", "get return thisValue"); + + assert.sameValue(log[9].name, "call return"); + assert.sameValue(log[9].thisValue.name, "asyncIterator", "return thisValue"); + assert.sameValue(log[9].args.length, 1, "return args.length"); + assert.sameValue(log[9].args[0], "return-arg-2", "return args[0]"); + + assert.sameValue(log[10].name, "get return then (2)"); + assert.sameValue(log[10].thisValue.name, "return-promise-2", "get return then thisValue"); + + assert.sameValue(log[11].name, "call return then (2)"); + assert.sameValue(log[11].thisValue.name, "return-promise-2", "return then thisValue"); + assert.sameValue(log[11].args.length, 2, "return then args.length"); + assert.sameValue(typeof log[11].args[0], "function", "return then args[0]"); + assert.sameValue(typeof log[11].args[1], "function", "return then args[1]"); + + assert.sameValue(log[12].name, "get return done (2)"); + assert.sameValue(log[12].thisValue.name, "return-result-2", "get return done thisValue"); + + assert.sameValue(log[13].name, "get return value (2)"); + assert.sameValue(log[13].thisValue.name, "return-result-2", "get return value thisValue"); + + assert.sameValue(v.value, "return-value-2"); + assert.sameValue(v.done, true); + + assert.sameValue(log.length, 14, "log.length"); + }).then($DONE, $DONE); + }).catch($DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-async-throw.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-async-throw.js new file mode 100644 index 0000000000..15c8c04084 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-async-throw.js @@ -0,0 +1,250 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-async-throw.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: execution order for yield* with async iterator and throw() (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration, Symbol.asyncIterator] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + ... + 6. Repeat + ... + b. Else if received.[[Type]] is throw, then + i. Let throw be ? GetMethod(iterator, "throw"). + ii. If throw is not undefined, then + 1. Let innerResult be ? Call(throw, iterator, « received.[[Value]] »). + 2. If generatorKind is async, then set innerResult to ? Await(innerResult). + ... + 5. Let done be ? IteratorComplete(innerResult). + 6. If done is true, then + a. Let resultValue be Return ? IteratorValue(innerResult). + b. If generatorKind is async, then set resultValue to ? Await(resultValue). + c. Return resultValue. + 7. If generatorKind is async, then let received be AsyncGeneratorYield(? IteratorValue(innerResult)). + ... + + AsyncGeneratorYield ( value ) + + ... + 8. Return ! AsyncGeneratorResolve(generator, value, false). + ... + +---*/ +var log = []; +var obj = { + [Symbol.asyncIterator]() { + var throwCount = 0; + return { + name: "asyncIterator", + get next() { + log.push({ name: "get next" }); + return function() { + return { + value: "next-value-1", + done: false + }; + }; + }, + get throw() { + log.push({ + name: "get throw", + thisValue: this + }); + return function() { + log.push({ + name: "call throw", + thisValue: this, + args: [...arguments] + }); + + throwCount++; + if (throwCount == 1) { + return { + name: "throw-promise-1", + get then() { + log.push({ + name: "get throw then (1)", + thisValue: this + }); + return function(resolve) { + log.push({ + name: "call throw then (1)", + thisValue: this, + args: [...arguments] + }); + + resolve({ + name: "throw-result-1", + get value() { + log.push({ + name: "get throw value (1)", + thisValue: this + }); + return "throw-value-1"; + }, + get done() { + log.push({ + name: "get throw done (1)", + thisValue: this + }); + return false; + } + }); + }; + } + }; + } + + return { + name: "throw-promise-2", + get then() { + log.push({ + name: "get throw then (2)", + thisValue: this + }); + return function(resolve) { + log.push({ + name: "call throw then (2)", + thisValue: this, + args: [...arguments] + }); + + resolve({ + name: "throw-result-2", + get value() { + log.push({ + name: "get throw value (2)", + thisValue: this + }); + return "throw-value-2"; + }, + get done() { + log.push({ + name: "get throw done (2)", + thisValue: this + }); + return true; + } + }); + }; + } + }; + }; + } + }; + } +}; + + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + log.push({ name: "before yield*" }); + var v = yield* obj; + log.push({ + name: "after yield*", + value: v + }); + return "return-value"; + +}} + +var gen = C.gen; + +var iter = gen(); + +assert.sameValue(log.length, 0, "log.length"); + +iter.next().then(v => { + assert.sameValue(log[0].name, "before yield*"); + + assert.sameValue(log[1].name, "get next"); + + assert.sameValue(v.value, "next-value-1"); + assert.sameValue(v.done, false); + + assert.sameValue(log.length, 2, "log.length"); + + iter.throw("throw-arg-1").then(v => { + assert.sameValue(log[2].name, "get throw"); + assert.sameValue(log[2].thisValue.name, "asyncIterator", "get throw thisValue"); + + assert.sameValue(log[3].name, "call throw"); + assert.sameValue(log[3].thisValue.name, "asyncIterator", "throw thisValue"); + assert.sameValue(log[3].args.length, 1, "throw args.length"); + assert.sameValue(log[3].args[0], "throw-arg-1", "throw args[0]"); + + assert.sameValue(log[4].name, "get throw then (1)"); + assert.sameValue(log[4].thisValue.name, "throw-promise-1", "get throw thisValue"); + + assert.sameValue(log[5].name, "call throw then (1)"); + assert.sameValue(log[5].thisValue.name, "throw-promise-1", "throw thisValue"); + assert.sameValue(log[5].args.length, 2, "throw then args.length"); + assert.sameValue(typeof log[5].args[0], "function", "throw then args[0]"); + assert.sameValue(typeof log[5].args[1], "function", "throw then args[1]"); + + assert.sameValue(log[6].name, "get throw done (1)"); + assert.sameValue(log[6].thisValue.name, "throw-result-1", "get throw done thisValue"); + + assert.sameValue(log[7].name, "get throw value (1)"); + assert.sameValue(log[7].thisValue.name, "throw-result-1", "get throw value thisValue"); + + assert.sameValue(v.value, "throw-value-1"); + assert.sameValue(v.done, false); + + assert.sameValue(log.length, 8, "log.length"); + + iter.throw("throw-arg-2").then(v => { + assert.sameValue(log[8].name, "get throw"); + assert.sameValue(log[8].thisValue.name, "asyncIterator", "get throw thisValue"); + + assert.sameValue(log[9].name, "call throw"); + assert.sameValue(log[9].thisValue.name, "asyncIterator", "throw thisValue"); + assert.sameValue(log[9].args.length, 1, "throw args.length"); + assert.sameValue(log[9].args[0], "throw-arg-2", "throw args[0]"); + + assert.sameValue(log[10].name, "get throw then (2)"); + assert.sameValue(log[10].thisValue.name, "throw-promise-2", "get throw thisValue"); + + assert.sameValue(log[11].name, "call throw then (2)"); + assert.sameValue(log[11].thisValue.name, "throw-promise-2", "throw thisValue"); + assert.sameValue(log[11].args.length, 2, "throw then args.length"); + assert.sameValue(typeof log[11].args[0], "function", "throw then args[0]"); + assert.sameValue(typeof log[11].args[1], "function", "throw then args[1]"); + + assert.sameValue(log[12].name, "get throw done (2)"); + assert.sameValue(log[12].thisValue.name, "throw-result-2", "get throw done thisValue"); + + assert.sameValue(log[13].name, "get throw value (2)"); + assert.sameValue(log[13].thisValue.name, "throw-result-2", "get throw value thisValue"); + + assert.sameValue(log[14].name, "after yield*"); + assert.sameValue(log[14].value, "throw-value-2"); + + assert.sameValue(v.value, "return-value"); + assert.sameValue(v.done, true); + + assert.sameValue(log.length, 15, "log.length"); + }).then($DONE, $DONE); + }).catch($DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-expr-abrupt.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-expr-abrupt.js new file mode 100644 index 0000000000..6389d5345b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-expr-abrupt.js @@ -0,0 +1,61 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-expr-abrupt.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: Abrupt completion while getting yield* operand (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + ... + +---*/ +var obj = {}; +var abrupt = function() { + throw obj; +}; + + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + yield* abrupt(); + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, obj, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-async-get-abrupt.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-async-get-abrupt.js new file mode 100644 index 0000000000..48307a3ce3 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-async-get-abrupt.js @@ -0,0 +1,81 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-get-abrupt.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: Abrupt completion while getting [Symbol.asyncIterator] (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + get [Symbol.asyncIterator]() { + throw reason; + } +}; + + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-async-not-callable-boolean-throw.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-async-not-callable-boolean-throw.js new file mode 100644 index 0000000000..3403913eaa --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-async-not-callable-boolean-throw.js @@ -0,0 +1,80 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-not-callable-boolean-throw.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: Throws a TypeError on a non-callable [Symbol.asyncIterator] (boolean) (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + 3. If func is either undefined or null, return undefined. + 4. If IsCallable(func) is false, throw a TypeError exception. + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]: false +}; + + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-async-not-callable-number-throw.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-async-not-callable-number-throw.js new file mode 100644 index 0000000000..979a5d2798 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-async-not-callable-number-throw.js @@ -0,0 +1,80 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-not-callable-number-throw.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: Throws a TypeError on a non-callable [Symbol.asyncIterator] (number) (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + 3. If func is either undefined or null, return undefined. + 4. If IsCallable(func) is false, throw a TypeError exception. + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]: 0 +}; + + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-async-not-callable-object-throw.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-async-not-callable-object-throw.js new file mode 100644 index 0000000000..37be5fcdf5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-async-not-callable-object-throw.js @@ -0,0 +1,80 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-not-callable-object-throw.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: Throws a TypeError on a non-callable [Symbol.asyncIterator] (object) (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + 3. If func is either undefined or null, return undefined. + 4. If IsCallable(func) is false, throw a TypeError exception. + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]: {} +}; + + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-async-not-callable-string-throw.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-async-not-callable-string-throw.js new file mode 100644 index 0000000000..c536648457 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-async-not-callable-string-throw.js @@ -0,0 +1,80 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-not-callable-string-throw.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: Throws a TypeError on a non-callable [Symbol.asyncIterator] (string) (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + 3. If func is either undefined or null, return undefined. + 4. If IsCallable(func) is false, throw a TypeError exception. + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]: '' +}; + + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-async-not-callable-symbol-throw.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-async-not-callable-symbol-throw.js new file mode 100644 index 0000000000..6acc648eb0 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-async-not-callable-symbol-throw.js @@ -0,0 +1,80 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-not-callable-symbol-throw.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: Throws a TypeError on a non-callable [Symbol.asyncIterator] (symbol) (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + 3. If func is either undefined or null, return undefined. + 4. If IsCallable(func) is false, throw a TypeError exception. + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]: Symbol.asyncIterator +}; + + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-async-null-sync-get-abrupt.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-async-null-sync-get-abrupt.js new file mode 100644 index 0000000000..37e1fe413e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-async-null-sync-get-abrupt.js @@ -0,0 +1,86 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-null-sync-get-abrupt.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: Abrupt completion while getting @@iterator after null @@asyncIterator (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + b. If method is undefined, + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + ... + +---*/ +var calls = 0; +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw reason; + }, + get [Symbol.asyncIterator]() { + calls += 1; + return null; + } +}; + + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, 'reject reason'); + assert.sameValue(calls, 1); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-async-returns-abrupt.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-async-returns-abrupt.js new file mode 100644 index 0000000000..17bd7eeed7 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-async-returns-abrupt.js @@ -0,0 +1,77 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-returns-abrupt.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: Abrupt completion while calling [Symbol.asyncIterator] (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + 6. Let iterator be ? Call(method, obj). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + throw reason; + } +}; + + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-async-returns-boolean-throw.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-async-returns-boolean-throw.js new file mode 100644 index 0000000000..6d73237afe --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-async-returns-boolean-throw.js @@ -0,0 +1,77 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-returns-boolean-throw.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: Non object returned by [Symbol.asyncIterator]() - boolean (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + 6. Let iterator be ? Call(method, obj). + 7. If Type(iterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return true; + } +}; + + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-async-returns-null-throw.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-async-returns-null-throw.js new file mode 100644 index 0000000000..eab29d7628 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-async-returns-null-throw.js @@ -0,0 +1,77 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-returns-null-throw.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: Non object returned by [Symbol.asyncIterator]() - null (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + 6. Let iterator be ? Call(method, obj). + 7. If Type(iterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return null; + } +}; + + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-async-returns-number-throw.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-async-returns-number-throw.js new file mode 100644 index 0000000000..2affab6fed --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-async-returns-number-throw.js @@ -0,0 +1,77 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-returns-number-throw.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: Non object returned by [Symbol.asyncIterator]() - number (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + 6. Let iterator be ? Call(method, obj). + 7. If Type(iterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return 42; + } +}; + + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-async-returns-string-throw.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-async-returns-string-throw.js new file mode 100644 index 0000000000..6fb7db7086 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-async-returns-string-throw.js @@ -0,0 +1,77 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-returns-string-throw.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: Non object returned by [Symbol.asyncIterator]() - string (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + 6. Let iterator be ? Call(method, obj). + 7. If Type(iterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return '42'; + } +}; + + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-async-returns-symbol-throw.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-async-returns-symbol-throw.js new file mode 100644 index 0000000000..e2d4c6438d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-async-returns-symbol-throw.js @@ -0,0 +1,77 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-returns-symbol-throw.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: Non object returned by [Symbol.asyncIterator]() - symbol (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + 6. Let iterator be ? Call(method, obj). + 7. If Type(iterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return Symbol.asyncIterator; + } +}; + + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-async-returns-undefined-throw.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-async-returns-undefined-throw.js new file mode 100644 index 0000000000..0271cdef4c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-async-returns-undefined-throw.js @@ -0,0 +1,77 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-returns-undefined-throw.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: Non object returned by [Symbol.asyncIterator]() - undefined (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + 6. Let iterator be ? Call(method, obj). + 7. If Type(iterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return undefined; + } +}; + + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-async-undefined-sync-get-abrupt.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-async-undefined-sync-get-abrupt.js new file mode 100644 index 0000000000..82f09b446e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-async-undefined-sync-get-abrupt.js @@ -0,0 +1,86 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-undefined-sync-get-abrupt.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: Abrupt completion while getting @@iterator after undefined @@asyncIterator (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + b. If method is undefined, + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + ... + +---*/ +var calls = 0; +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw reason; + }, + get [Symbol.asyncIterator]() { + calls += 1; + return undefined; + } +}; + + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, 'reject reason'); + assert.sameValue(calls, 1); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-sync-get-abrupt.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-sync-get-abrupt.js new file mode 100644 index 0000000000..33d910c1a1 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-sync-get-abrupt.js @@ -0,0 +1,80 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-get-abrupt.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: Abrupt completion while getting [Symbol.iterator] (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + b. If method is undefined, + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw reason; + } +}; + + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-sync-not-callable-boolean-throw.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-sync-not-callable-boolean-throw.js new file mode 100644 index 0000000000..256bfc66e4 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-sync-not-callable-boolean-throw.js @@ -0,0 +1,79 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-not-callable-boolean-throw.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: Throws a TypeError on a non-callable [Symbol.iterator] (boolean) (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + b. If method is undefined, + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + ... + 4. If IsCallable(func) is false, throw a TypeError exception. + ... + +---*/ +var obj = { + [Symbol.iterator]: false +}; + + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-sync-not-callable-number-throw.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-sync-not-callable-number-throw.js new file mode 100644 index 0000000000..ab6f71205f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-sync-not-callable-number-throw.js @@ -0,0 +1,79 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-not-callable-number-throw.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: Throws a TypeError on a non-callable [Symbol.iterator] (number) (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + b. If method is undefined, + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + ... + 4. If IsCallable(func) is false, throw a TypeError exception. + ... + +---*/ +var obj = { + [Symbol.iterator]: 0 +}; + + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-sync-not-callable-object-throw.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-sync-not-callable-object-throw.js new file mode 100644 index 0000000000..ff0f0108f8 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-sync-not-callable-object-throw.js @@ -0,0 +1,79 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-not-callable-object-throw.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: Throws a TypeError on a non-callable [Symbol.iterator] (object) (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + b. If method is undefined, + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + ... + 4. If IsCallable(func) is false, throw a TypeError exception. + ... + +---*/ +var obj = { + [Symbol.iterator]: {} +}; + + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-sync-not-callable-string-throw.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-sync-not-callable-string-throw.js new file mode 100644 index 0000000000..eabfeae9d4 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-sync-not-callable-string-throw.js @@ -0,0 +1,79 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-not-callable-string-throw.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: Throws a TypeError on a non-callable [Symbol.iterator] (string) (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + b. If method is undefined, + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + ... + 4. If IsCallable(func) is false, throw a TypeError exception. + ... + +---*/ +var obj = { + [Symbol.iterator]: '' +}; + + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-sync-not-callable-symbol-throw.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-sync-not-callable-symbol-throw.js new file mode 100644 index 0000000000..387dd91524 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-sync-not-callable-symbol-throw.js @@ -0,0 +1,79 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-not-callable-symbol-throw.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: Throws a TypeError on a non-callable [Symbol.iterator] (symbol) (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + b. If method is undefined, + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + ... + 4. If IsCallable(func) is false, throw a TypeError exception. + ... + +---*/ +var obj = { + [Symbol.iterator]: Symbol.iterator +}; + + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-sync-returns-abrupt.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-sync-returns-abrupt.js new file mode 100644 index 0000000000..8ebcd59b6b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-sync-returns-abrupt.js @@ -0,0 +1,74 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-returns-abrupt.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: Abrupt completion while calling [Symbol.iterator] (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ii. Let syncIterator be ? Call(syncMethod, obj). + ... + +---*/ +var reason = {}; +var obj = { + [Symbol.iterator]() { + throw reason; + } +}; + + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-sync-returns-boolean-throw.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-sync-returns-boolean-throw.js new file mode 100644 index 0000000000..fc863e3bfc --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-sync-returns-boolean-throw.js @@ -0,0 +1,79 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-returns-boolean-throw.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: Non object returned by [Symbol.iterator]() - boolean (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ii. Let syncIterator be ? Call(syncMethod, obj). + iii. Return ? CreateAsyncFromSyncIterator(syncIterator). + ... + + CreateAsyncFromSyncIterator(syncIterator) + + 1. If Type(syncIterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + [Symbol.iterator]() { + return true; + } +}; + + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-sync-returns-null-throw.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-sync-returns-null-throw.js new file mode 100644 index 0000000000..b5d48b88ca --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-sync-returns-null-throw.js @@ -0,0 +1,79 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-returns-null-throw.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: Non object returned by [Symbol.iterator]() - null (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ii. Let syncIterator be ? Call(syncMethod, obj). + iii. Return ? CreateAsyncFromSyncIterator(syncIterator). + ... + + CreateAsyncFromSyncIterator(syncIterator) + + 1. If Type(syncIterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + [Symbol.iterator]() { + return null; + } +}; + + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-sync-returns-number-throw.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-sync-returns-number-throw.js new file mode 100644 index 0000000000..cdc15f4b09 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-sync-returns-number-throw.js @@ -0,0 +1,79 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-returns-number-throw.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: Non object returned by [Symbol.iterator]() - number (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ii. Let syncIterator be ? Call(syncMethod, obj). + iii. Return ? CreateAsyncFromSyncIterator(syncIterator). + ... + + CreateAsyncFromSyncIterator(syncIterator) + + 1. If Type(syncIterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + [Symbol.iterator]() { + return 0; + } +}; + + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-sync-returns-string-throw.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-sync-returns-string-throw.js new file mode 100644 index 0000000000..9370a13561 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-sync-returns-string-throw.js @@ -0,0 +1,79 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-returns-string-throw.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: Non object returned by [Symbol.iterator]() - string (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ii. Let syncIterator be ? Call(syncMethod, obj). + iii. Return ? CreateAsyncFromSyncIterator(syncIterator). + ... + + CreateAsyncFromSyncIterator(syncIterator) + + 1. If Type(syncIterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + [Symbol.iterator]() { + return ''; + } +}; + + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-sync-returns-symbol-throw.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-sync-returns-symbol-throw.js new file mode 100644 index 0000000000..e04e09b272 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-sync-returns-symbol-throw.js @@ -0,0 +1,79 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-returns-symbol-throw.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: Non object returned by [Symbol.iterator]() - symbol (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ii. Let syncIterator be ? Call(syncMethod, obj). + iii. Return ? CreateAsyncFromSyncIterator(syncIterator). + ... + + CreateAsyncFromSyncIterator(syncIterator) + + 1. If Type(syncIterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + [Symbol.iterator]() { + return Symbol.iterator; + } +}; + + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-sync-returns-undefined-throw.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-sync-returns-undefined-throw.js new file mode 100644 index 0000000000..afdf0ef493 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-getiter-sync-returns-undefined-throw.js @@ -0,0 +1,79 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-returns-undefined-throw.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: Non object returned by [Symbol.iterator]() - undefined (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ii. Let syncIterator be ? Call(syncMethod, obj). + iii. Return ? CreateAsyncFromSyncIterator(syncIterator). + ... + + CreateAsyncFromSyncIterator(syncIterator) + + 1. If Type(syncIterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + [Symbol.iterator]() { + return undefined; + } +}; + + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-call-done-get-abrupt.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-call-done-get-abrupt.js new file mode 100644 index 0000000000..c601d51199 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-call-done-get-abrupt.js @@ -0,0 +1,80 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-call-done-get-abrupt.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: Abrupt completion while getting done (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + v. Let done be ? IteratorComplete(innerResult). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + get done() { + throw reason; + } + }; + } + }; + } +}; + + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-call-returns-abrupt.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-call-returns-abrupt.js new file mode 100644 index 0000000000..1a6db5d8a8 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-call-returns-abrupt.js @@ -0,0 +1,72 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-call-returns-abrupt.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: Abrupt completion while calling next (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + throw reason; + } + }; + } +}; + + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-call-value-get-abrupt.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-call-value-get-abrupt.js new file mode 100644 index 0000000000..0b5990c744 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-call-value-get-abrupt.js @@ -0,0 +1,82 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-call-value-get-abrupt.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: Abrupt completion while getting value (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + vi. If done is true, then + 1. Return ? IteratorValue(innerResult). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + done: true, + get value() { + throw reason; + } + }; + } + }; + } +}; + + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-get-abrupt.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-get-abrupt.js new file mode 100644 index 0000000000..d27e07f33b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-get-abrupt.js @@ -0,0 +1,72 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-get-abrupt.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: Abrupt completion while getting next (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + get next() { + throw reason; + } + }; + } +}; + + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-non-object-ignores-then.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-non-object-ignores-then.js new file mode 100644 index 0000000000..53a7eff8e1 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-non-object-ignores-then.js @@ -0,0 +1,92 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-non-object-ignores-then.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: If next() value is not-object, do not access respective then property (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + +---*/ +Number.prototype.then = function() { + throw new Test262Error('Number#then should not be used'); +}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return 42; + } + }; + } +}; + + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, 'TypeError'); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-not-callable-boolean-throw.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-not-callable-boolean-throw.js new file mode 100644 index 0000000000..d6bcf220ec --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-not-callable-boolean-throw.js @@ -0,0 +1,69 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-boolean-throw.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: Not-callable next value in a yield star position - boolean (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: true + }; + } +}; + + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-not-callable-null-throw.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-not-callable-null-throw.js new file mode 100644 index 0000000000..b2c8f1e8a6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-not-callable-null-throw.js @@ -0,0 +1,69 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-null-throw.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: Not-callable next value in a yield star position - null (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: null + }; + } +}; + + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-not-callable-number-throw.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-not-callable-number-throw.js new file mode 100644 index 0000000000..dbbf208489 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-not-callable-number-throw.js @@ -0,0 +1,69 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-number-throw.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: Not-callable next value in a yield star position - number (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: 42 + }; + } +}; + + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-not-callable-object-throw.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-not-callable-object-throw.js new file mode 100644 index 0000000000..298c964de5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-not-callable-object-throw.js @@ -0,0 +1,69 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-object-throw.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: Not-callable next value in a yield star position - object (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: {} + }; + } +}; + + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-not-callable-string-throw.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-not-callable-string-throw.js new file mode 100644 index 0000000000..9ebbf19402 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-not-callable-string-throw.js @@ -0,0 +1,69 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-string-throw.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: Not-callable next value in a yield star position - string (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: '' + }; + } +}; + + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-not-callable-symbol-throw.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-not-callable-symbol-throw.js new file mode 100644 index 0000000000..b61aeb91d5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-not-callable-symbol-throw.js @@ -0,0 +1,69 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-symbol-throw.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: Not-callable next value in a yield star position - symbol (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: Symbol('oi') + }; + } +}; + + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-not-callable-undefined-throw.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-not-callable-undefined-throw.js new file mode 100644 index 0000000000..74031fa546 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-not-callable-undefined-throw.js @@ -0,0 +1,69 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-undefined-throw.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: Not-callable next value in a yield star position - undefined (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: undefined + }; + } +}; + + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-then-get-abrupt.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-then-get-abrupt.js new file mode 100644 index 0000000000..573faffd03 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-then-get-abrupt.js @@ -0,0 +1,96 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-get-abrupt.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: Return abrupt after getting next().then (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 8. Let then be Get(resolution, "then"). + ... + 10. Get thenAction be then.[[Value]]. + ... + 12. Perform EnqueueJob("PromiseJobs", PromiseResolveThenableJob, « promise, + resolution, thenAction »). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + get then() { + throw reason; + } + }; + } + }; + } +}; + + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, 'reject reason'); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-then-non-callable-boolean-fulfillpromise.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-then-non-callable-boolean-fulfillpromise.js new file mode 100644 index 0000000000..05c76f2658 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-then-non-callable-boolean-fulfillpromise.js @@ -0,0 +1,90 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-boolean-fulfillpromise.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: FulfillPromise if next().then is not-callable (boolean) (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: true, + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-then-non-callable-null-fulfillpromise.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-then-non-callable-null-fulfillpromise.js new file mode 100644 index 0000000000..c789fadca3 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-then-non-callable-null-fulfillpromise.js @@ -0,0 +1,90 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-null-fulfillpromise.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: FulfillPromise if next().then is not-callable (null) (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: null, + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-then-non-callable-number-fulfillpromise.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-then-non-callable-number-fulfillpromise.js new file mode 100644 index 0000000000..ef1ebee1d6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-then-non-callable-number-fulfillpromise.js @@ -0,0 +1,90 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-number-fulfillpromise.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: FulfillPromise if next().then is not-callable (number) (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: 39, + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-then-non-callable-object-fulfillpromise.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-then-non-callable-object-fulfillpromise.js new file mode 100644 index 0000000000..f56613fafe --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-then-non-callable-object-fulfillpromise.js @@ -0,0 +1,90 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-object-fulfillpromise.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: FulfillPromise if next().then is not-callable (object) (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: {}, + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-then-non-callable-string-fulfillpromise.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-then-non-callable-string-fulfillpromise.js new file mode 100644 index 0000000000..5d9ee1aaa1 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-then-non-callable-string-fulfillpromise.js @@ -0,0 +1,90 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-string-fulfillpromise.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: FulfillPromise if next().then is not-callable (string) (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: '', + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-then-non-callable-symbol-fulfillpromise.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-then-non-callable-symbol-fulfillpromise.js new file mode 100644 index 0000000000..baf92f8f13 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-then-non-callable-symbol-fulfillpromise.js @@ -0,0 +1,90 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-symbol-fulfillpromise.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: FulfillPromise if next().then is not-callable (symbol) (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: Symbol('oi'), + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-then-non-callable-undefined-fulfillpromise.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-then-non-callable-undefined-fulfillpromise.js new file mode 100644 index 0000000000..db0df04520 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-then-non-callable-undefined-fulfillpromise.js @@ -0,0 +1,90 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-undefined-fulfillpromise.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: FulfillPromise if next().then is not-callable (undefined) (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: undefined, + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-then-returns-abrupt.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-then-returns-abrupt.js new file mode 100644 index 0000000000..92987f9a33 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-next-then-returns-abrupt.js @@ -0,0 +1,96 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-returns-abrupt.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: Return abrupt after calling next().then (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 8. Let then be Get(resolution, "then"). + ... + 10. Get thenAction be then.[[Value]]. + ... + 12. Perform EnqueueJob("PromiseJobs", PromiseResolveThenableJob, « promise, + resolution, thenAction »). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then() { + throw reason; + } + }; + } + }; + } +}; + + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, 'reject reason'); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-sync-next.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-sync-next.js new file mode 100644 index 0000000000..b6bb6ad955 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-sync-next.js @@ -0,0 +1,229 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-sync-next.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: execution order for yield* with sync iterator and next() (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, async-iteration, Symbol.asyncIterator] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + ... + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + 5. Let received be NormalCompletion(undefined). + 6. Repeat + a. If received.[[Type]] is normal, then + i. Let innerResult be ? IteratorNext(iterator, received.[[Value]]). + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + v. Let done be ? IteratorComplete(innerResult). + vi. If done is true, then + 1. Return ? IteratorValue(innerResult). + vii. Let received be GeneratorYield(innerResult). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + b. If method is undefined, + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ii. Let syncIterator be ? Call(syncMethod, obj). + iii. Return ? CreateAsyncFromSyncIterator(syncIterator). + ... + + %AsyncFromSyncIteratorPrototype%.next ( value ) + + ... + 5. Let nextResult be IteratorNext(syncIterator, value). + ... + 7. Let nextValue be IteratorValue(nextResult). + ... + 9. Let nextDone be IteratorComplete(nextResult). + ... + 12. Perform ! Call(valueWrapperCapability.[[Resolve]], undefined, + « nextValue »). + ... + 14. Set onFulfilled.[[Done]] to nextDone. + 15. Perform ! PerformPromiseThen(valueWrapperCapability.[[Promise]], + onFulfilled, undefined, promiseCapability). + ... + + Async Iterator Value Unwrap Functions + + 1. Return ! CreateIterResultObject(value, F.[[Done]]). + +---*/ +var log = []; +var obj = { + get [Symbol.iterator]() { + log.push({ + name: "get [Symbol.iterator]", + thisValue: this + }); + return function() { + log.push({ + name: "call [Symbol.iterator]", + thisValue: this, + args: [...arguments] + }); + var nextCount = 0; + return { + name: "syncIterator", + get next() { + log.push({ + name: "get next", + thisValue: this + }); + return function() { + log.push({ + name: "call next", + thisValue: this, + args: [...arguments] + }); + + nextCount++; + if (nextCount == 1) { + return { + name: "next-result-1", + get value() { + log.push({ + name: "get next value (1)", + thisValue: this + }); + return "next-value-1"; + }, + get done() { + log.push({ + name: "get next done (1)", + thisValue: this + }); + return false; + } + }; + } + + return { + name: "next-result-2", + get value() { + log.push({ + name: "get next value (2)", + thisValue: this + }); + return "next-value-2"; + }, + get done() { + log.push({ + name: "get next done (2)", + thisValue: this + }); + return true; + } + }; + }; + } + }; + }; + }, + get [Symbol.asyncIterator]() { + log.push({ name: "get [Symbol.asyncIterator]" }); + return null; + } +}; + + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + log.push({ name: "before yield*" }); + var v = yield* obj; + log.push({ + name: "after yield*", + value: v + }); + return "return-value"; + +}} + +var gen = C.gen; + +var iter = gen(); + +assert.sameValue(log.length, 0, "log.length"); + +iter.next("next-arg-1").then(v => { + assert.sameValue(log[0].name, "before yield*"); + + assert.sameValue(log[1].name, "get [Symbol.asyncIterator]"); + + assert.sameValue(log[2].name, "get [Symbol.iterator]"); + assert.sameValue(log[2].thisValue, obj, "get [Symbol.iterator] thisValue"); + + assert.sameValue(log[3].name, "call [Symbol.iterator]"); + assert.sameValue(log[3].thisValue, obj, "[Symbol.iterator] thisValue"); + assert.sameValue(log[3].args.length, 0, "[Symbol.iterator] args.length"); + + assert.sameValue(log[4].name, "get next"); + assert.sameValue(log[4].thisValue.name, "syncIterator", "get next thisValue"); + + assert.sameValue(log[5].name, "call next"); + assert.sameValue(log[5].thisValue.name, "syncIterator", "next thisValue"); + assert.sameValue(log[5].args.length, 1, "next args.length"); + assert.sameValue(log[5].args[0], undefined, "next args[0]"); + + assert.sameValue(log[6].name, "get next done (1)"); + assert.sameValue(log[6].thisValue.name, "next-result-1", "get next done thisValue"); + + assert.sameValue(log[7].name, "get next value (1)"); + assert.sameValue(log[7].thisValue.name, "next-result-1", "get next value thisValue"); + + assert.sameValue(v.value, "next-value-1"); + assert.sameValue(v.done, false); + + assert.sameValue(log.length, 8, "log.length"); + + iter.next("next-arg-2").then(v => { + assert.sameValue(log[8].name, "call next"); + assert.sameValue(log[8].thisValue.name, "syncIterator", "next thisValue"); + assert.sameValue(log[8].args.length, 1, "next args.length"); + assert.sameValue(log[8].args[0], "next-arg-2", "next args[0]"); + + assert.sameValue(log[9].name, "get next done (2)"); + assert.sameValue(log[9].thisValue.name, "next-result-2", "get next done thisValue"); + + assert.sameValue(log[10].name, "get next value (2)"); + assert.sameValue(log[10].thisValue.name, "next-result-2", "get next value thisValue"); + + assert.sameValue(log[11].name, "after yield*"); + assert.sameValue(log[11].value, "next-value-2"); + + assert.sameValue(v.value, "return-value"); + assert.sameValue(v.done, true); + + assert.sameValue(log.length, 12, "log.length"); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-sync-return.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-sync-return.js new file mode 100644 index 0000000000..f83ce21dd5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-sync-return.js @@ -0,0 +1,204 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-sync-return.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: execution order for yield* with sync iterator and return() (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, async-iteration, Symbol.asyncIterator] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + ... + 6. Repeat + ... + c. Else, + i. Assert: received.[[Type]] is return. + ii. Let return be ? GetMethod(iterator, "return"). + iii. If return is undefined, return Completion(received). + iv. Let innerReturnResult be ? Call(return, iterator, + « received.[[Value]] »). + v. If generatorKind is async, then set innerReturnResult to + ? Await(innerReturnResult). + ... + vii. Let done be ? IteratorComplete(innerReturnResult). + viii. If done is true, then + 1. Let value be ? IteratorValue(innerReturnResult). + 2. Return Completion{[[Type]]: return, [[Value]]: value, + [[Target]]: empty}. + ix. Let received be GeneratorYield(innerResult). + + %AsyncFromSyncIteratorPrototype%.return ( value ) + + 5. Let return be GetMethod(syncIterator, "return"). + ... + ... + 8. Let returnResult be Call(return, syncIterator, « value »). + ... + 11. Let returnValue be IteratorValue(returnResult). + .. + 13. Let returnDone be IteratorComplete(returnResult). + ... + 16. Perform ! Call(valueWrapperCapability.[[Resolve]], undefined, « returnValue »). + ... + 18. Set onFulfilled.[[Done]] to returnDone. + 19. Perform ! PerformPromiseThen(valueWrapperCapability.[[Promise]], + onFulfilled, undefined, promiseCapability). + ... + +---*/ +var log = []; +var obj = { + [Symbol.iterator]() { + var returnCount = 0; + return { + name: "syncIterator", + get next() { + log.push({ name: "get next" }); + return function() { + return { + value: "next-value-1", + done: false + }; + }; + }, + get return() { + log.push({ + name: "get return", + thisValue: this + }); + return function() { + log.push({ + name: "call return", + thisValue: this, + args: [...arguments] + }); + + returnCount++; + if (returnCount == 1) { + return { + name: "return-result-1", + get value() { + log.push({ + name: "get return value (1)", + thisValue: this + }); + return "return-value-1"; + }, + get done() { + log.push({ + name: "get return done (1)", + thisValue: this + }); + return false; + } + }; + } + + return { + name: "return-result-2", + get value() { + log.push({ + name: "get return value (2)", + thisValue: this + }); + return "return-value-2"; + }, + get done() { + log.push({ + name: "get return done (2)", + thisValue: this + }); + return true; + } + }; + }; + } + }; + } +}; + + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + log.push({ name: "before yield*" }); + yield* obj; + +}} + +var gen = C.gen; + +var iter = gen(); + +assert.sameValue(log.length, 0, "log.length"); + +iter.next().then(v => { + assert.sameValue(log[0].name, "before yield*"); + + assert.sameValue(log[1].name, "get next"); + + assert.sameValue(v.value, "next-value-1"); + assert.sameValue(v.done, false); + + assert.sameValue(log.length, 2, "log.length"); + + iter.return("return-arg-1").then(v => { + assert.sameValue(log[2].name, "get return"); + assert.sameValue(log[2].thisValue.name, "syncIterator", "get return thisValue"); + + assert.sameValue(log[3].name, "call return"); + assert.sameValue(log[3].thisValue.name, "syncIterator", "return thisValue"); + assert.sameValue(log[3].args.length, 1, "return args.length"); + assert.sameValue(log[3].args[0], "return-arg-1", "return args[0]"); + + assert.sameValue(log[4].name, "get return done (1)"); + assert.sameValue(log[4].thisValue.name, "return-result-1", "get return done thisValue"); + + assert.sameValue(log[5].name, "get return value (1)"); + assert.sameValue(log[5].thisValue.name, "return-result-1", "get return value thisValue"); + + assert.sameValue(v.value, "return-value-1"); + assert.sameValue(v.done, false); + + assert.sameValue(log.length, 6, "log.length"); + + iter.return().then(v => { + assert.sameValue(log[6].name, "get return"); + assert.sameValue(log[6].thisValue.name, "syncIterator", "get return thisValue"); + + assert.sameValue(log[7].name, "call return"); + assert.sameValue(log[7].thisValue.name, "syncIterator", "get return thisValue"); + assert.sameValue(log[7].args.length, 1, "return args.length"); + assert.sameValue(log[7].args[0], undefined, "return args[0]"); + + assert.sameValue(log[8].name, "get return done (2)"); + assert.sameValue(log[8].thisValue.name, "return-result-2", "get return done thisValue"); + + assert.sameValue(log[9].name, "get return value (2)"); + assert.sameValue(log[9].thisValue.name, "return-result-2", "get return value thisValue"); + + assert.sameValue(v.value, "return-value-2"); + assert.sameValue(v.done, true); + + assert.sameValue(log.length, 10, "log.length"); + }).then($DONE, $DONE); + }).catch($DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-sync-throw.js b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-sync-throw.js new file mode 100644 index 0000000000..6924d9f8e6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method-static/yield-star-sync-throw.js @@ -0,0 +1,210 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-sync-throw.case +// - src/async-generators/default/async-class-decl-static-method.template +/*--- +description: execution order for yield* with sync iterator and throw() (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + ... + 6. Repeat + ... + b. Else if received.[[Type]] is throw, then + i. Let throw be ? GetMethod(iterator, "throw"). + ii. If throw is not undefined, then + 1. Let innerResult be ? Call(throw, iterator, « received.[[Value]] »). + 2. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + 5. Let done be ? IteratorComplete(innerResult). + 6. If done is true, then + a. Return ? IteratorValue(innerResult). + 7. Let received be GeneratorYield(innerResult). + ... + + %AsyncFromSyncIteratorPrototype%.throw ( value ) + + ... + 5. Let throw be GetMethod(syncIterator, "throw"). + ... + 8. Let throwResult be Call(throw, syncIterator, « value »). + ... + 11. Let throwValue be IteratorValue(throwResult). + ... + 13. Let throwDone be IteratorComplete(throwResult). + ... + 16. Perform ! Call(valueWrapperCapability.[[Resolve]], undefined, + « throwValue »). + ... + 18. Set onFulfilled.[[Done]] to throwDone. + 19. Perform ! PerformPromiseThen(valueWrapperCapability.[[Promise]], + onFulfilled, undefined, promiseCapability). + ... + +---*/ +var log = []; +var obj = { + [Symbol.iterator]() { + var throwCount = 0; + return { + name: "syncIterator", + get next() { + log.push({ name: "get next" }); + return function() { + return { + value: "next-value-1", + done: false + }; + }; + }, + get throw() { + log.push({ + name: "get throw", + thisValue: this + }); + return function() { + log.push({ + name: "call throw", + thisValue: this, + args: [...arguments] + }); + + throwCount++; + if (throwCount == 1) { + return { + name: "throw-result-1", + get value() { + log.push({ + name: "get throw value (1)", + thisValue: this + }); + return "throw-value-1"; + }, + get done() { + log.push({ + name: "get throw done (1)", + thisValue: this + }); + return false; + } + }; + } + + return { + name: "throw-result-2", + get value() { + log.push({ + name: "get throw value (2)", + thisValue: this + }); + return "throw-value-2"; + }, + get done() { + log.push({ + name: "get throw done (2)", + thisValue: this + }); + return true; + } + }; + }; + } + }; + } +}; + + + +var callCount = 0; + +class C { static async *gen() { + callCount += 1; + log.push({ name: "before yield*" }); + var v = yield* obj; + log.push({ + name: "after yield*", + value: v + }); + return "return-value"; + +}} + +var gen = C.gen; + +var iter = gen(); + +assert.sameValue(log.length, 0, "log.length"); + +iter.next().then(v => { + assert.sameValue(log[0].name, "before yield*"); + + assert.sameValue(log[1].name, "get next"); + + assert.sameValue(v.value, "next-value-1"); + assert.sameValue(v.done, false); + + assert.sameValue(log.length, 2, "log.length"); + + iter.throw("throw-arg-1").then(v => { + assert.sameValue(log[2].name, "get throw"); + assert.sameValue(log[2].thisValue.name, "syncIterator", "get throw thisValue"); + + assert.sameValue(log[3].name, "call throw"); + assert.sameValue(log[3].thisValue.name, "syncIterator", "throw thisValue"); + assert.sameValue(log[3].args.length, 1, "throw args.length"); + assert.sameValue(log[3].args[0], "throw-arg-1", "throw args[0]"); + + assert.sameValue(log[4].name, "get throw done (1)"); + assert.sameValue(log[4].thisValue.name, "throw-result-1", "get throw done thisValue"); + + assert.sameValue(log[5].name, "get throw value (1)"); + assert.sameValue(log[5].thisValue.name, "throw-result-1", "get throw value thisValue"); + + assert.sameValue(v.value, "throw-value-1"); + assert.sameValue(v.done, false); + + assert.sameValue(log.length, 6, "log.length"); + + iter.throw().then(v => { + assert.sameValue(log[6].name, "get throw"); + assert.sameValue(log[6].thisValue.name, "syncIterator", "get throw thisValue"); + + assert.sameValue(log[7].name, "call throw"); + assert.sameValue(log[7].thisValue.name, "syncIterator", "throw thisValue"); + assert.sameValue(log[7].args.length, 1, "throw args.length"); + assert.sameValue(log[7].args[0], undefined, "throw args[0]"); + + assert.sameValue(log[8].name, "get throw done (2)"); + assert.sameValue(log[8].thisValue.name, "throw-result-2", "get throw done thisValue"); + + assert.sameValue(log[9].name, "get throw value (2)"); + assert.sameValue(log[9].thisValue.name, "throw-result-2", "get throw value thisValue"); + + assert.sameValue(log[10].name, "after yield*"); + assert.sameValue(log[10].value, "throw-value-2"); + + assert.sameValue(v.value, "return-value"); + assert.sameValue(v.done, true); + + assert.sameValue(log.length, 11, "log.length"); + }).then($DONE, $DONE); + }).catch($DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method/array-destructuring-param-strict-body.js b/js/src/tests/test262/language/statements/class/async-gen-method/array-destructuring-param-strict-body.js new file mode 100644 index 0000000000..afe29a17e6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method/array-destructuring-param-strict-body.js @@ -0,0 +1,137 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/function-forms/array-destructuring-param-strict-body.case +// - src/function-forms/syntax/cls-decl-async-gen-meth.template +/*--- +description: ArrayBindingPattern and Use Strict Directive are not allowed to coexist for the same function. (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [rest-parameters, async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.4 Static Semantics: IsSimpleParameterList + + BindingElement : BindingPattern + + 1. Return false. + + 14.1.2 Static Semantics: Early Errors + + FunctionDeclaration : function BindingIdentifier ( FormalParameters ) { FunctionBody } + FunctionDeclaration : function ( FormalParameters ) { FunctionBody } + FunctionExpression : function BindingIdentifier ( FormalParameters ) { FunctionBody } + + - It is a Syntax Error if ContainsUseStrict of FunctionBody is true and + IsSimpleParameterList of FormalParameters is false. + + 14.2.1 Static Semantics: Early Errors + + ArrowFunction : ArrowParameters => ConciseBody + + - It is a Syntax Error if ContainsUseStrict of ConciseBody is true and + IsSimpleParameterList of ArrowParameters is false. + + 14.3.1 Static Semantics: Early Errors + + MethodDefinition : PropertyName ( UniqueFormalParameters ) { FunctionBody } + + - It is a Syntax Error if ContainsUseStrict of FunctionBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + MethodDefinition : set PropertyName ( PropertySetParameterList ) { FunctionBody } + + - It is a Syntax Error if ContainsUseStrict of FunctionBody is true and + IsSimpleParameterList of PropertySetParameterList is false. + + 14.4.1 Static Semantics: Early Errors + + GeneratorMethod : * PropertyName ( UniqueFormalParameters ) { GeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of GeneratorBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + GeneratorDeclaration : function * BindingIdentifier ( FormalParameters ) { GeneratorBody } + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + GeneratorExpression : function * BindingIdentifier ( FormalParameters ) { GeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of GeneratorBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + 14.5.1 Static Semantics: Early Errors + + AsyncGeneratorMethod : async * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncGeneratorBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + AsyncGeneratorDeclaration : async function * BindingIdentifier ( FormalParameters ) { AsyncGeneratorBody } + AsyncGeneratorDeclaration : async function * ( FormalParameters ) { AsyncGeneratorBody } + AsyncGeneratorExpression : async function * BindingIdentifier ( FormalParameters ) { AsyncGeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncGeneratorBody is true and + IsSimpleParameterList of FormalParameters is false. + + 14.7.1 Static Semantics: Early Errors + + AsyncMethod : async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncFunctionBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + AsyncFunctionDeclaration : async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody } + AsyncFunctionDeclaration : async function ( FormalParameters ) { AsyncFunctionBody } + AsyncFunctionExpression : async function ( FormalParameters ) { AsyncFunctionBody } + AsyncFunctionExpression : async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncFunctionBody is true and + IsSimpleParameterList of FormalParameters is false. + + 14.8.1 Static Semantics: Early Errors + + AsyncArrowFunction : CoverCallExpressionAndAsyncArrowHead => AsyncConciseBody + + - It is a Syntax Error if ContainsUseStrict of AsyncConciseBody is true and + IsSimpleParameterList of CoverCallExpressionAndAsyncArrowHead is false. + +---*/ +$DONOTEVALUATE(); + +class C { + async *method([element]) { + "use strict"; + } +} diff --git a/js/src/tests/test262/language/statements/class/async-gen-method/await-as-binding-identifier-escaped.js b/js/src/tests/test262/language/statements/class/async-gen-method/await-as-binding-identifier-escaped.js new file mode 100644 index 0000000000..c769ed5e60 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method/await-as-binding-identifier-escaped.js @@ -0,0 +1,37 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/async-generators/await-as-binding-identifier-escaped.case +// - src/async-generators/syntax/async-class-decl-method.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as a binding identifier. (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + BindingIdentifier : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +$DONOTEVALUATE(); + + +class C { async *gen() { + var \u0061wait; +}} diff --git a/js/src/tests/test262/language/statements/class/async-gen-method/await-as-binding-identifier.js b/js/src/tests/test262/language/statements/class/async-gen-method/await-as-binding-identifier.js new file mode 100644 index 0000000000..b8da3a80d8 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method/await-as-binding-identifier.js @@ -0,0 +1,37 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/async-generators/await-as-binding-identifier.case +// - src/async-generators/syntax/async-class-decl-method.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as a binding identifier. (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + BindingIdentifier : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +$DONOTEVALUATE(); + + +class C { async *gen() { + var await; +}} diff --git a/js/src/tests/test262/language/statements/class/async-gen-method/await-as-identifier-reference-escaped.js b/js/src/tests/test262/language/statements/class/async-gen-method/await-as-identifier-reference-escaped.js new file mode 100644 index 0000000000..8bbc5763e4 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method/await-as-identifier-reference-escaped.js @@ -0,0 +1,37 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/async-generators/await-as-identifier-reference-escaped.case +// - src/async-generators/syntax/async-class-decl-method.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as an identifier reference. (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + IdentifierReference : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +$DONOTEVALUATE(); + + +class C { async *gen() { + void \u0061wait; +}} diff --git a/js/src/tests/test262/language/statements/class/async-gen-method/await-as-identifier-reference.js b/js/src/tests/test262/language/statements/class/async-gen-method/await-as-identifier-reference.js new file mode 100644 index 0000000000..c941d9c970 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method/await-as-identifier-reference.js @@ -0,0 +1,37 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/async-generators/await-as-identifier-reference.case +// - src/async-generators/syntax/async-class-decl-method.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as an identifier reference. (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + IdentifierReference : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +$DONOTEVALUATE(); + + +class C { async *gen() { + void await; +}} diff --git a/js/src/tests/test262/language/statements/class/async-gen-method/await-as-label-identifier-escaped.js b/js/src/tests/test262/language/statements/class/async-gen-method/await-as-label-identifier-escaped.js new file mode 100644 index 0000000000..a80f495432 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method/await-as-label-identifier-escaped.js @@ -0,0 +1,37 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/async-generators/await-as-label-identifier-escaped.case +// - src/async-generators/syntax/async-class-decl-method.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as a label identifier. (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + LabelIdentifier : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +$DONOTEVALUATE(); + + +class C { async *gen() { + \u0061wait: ; +}} diff --git a/js/src/tests/test262/language/statements/class/async-gen-method/await-as-label-identifier.js b/js/src/tests/test262/language/statements/class/async-gen-method/await-as-label-identifier.js new file mode 100644 index 0000000000..f7dd596937 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method/await-as-label-identifier.js @@ -0,0 +1,37 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/async-generators/await-as-label-identifier.case +// - src/async-generators/syntax/async-class-decl-method.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as a label identifier. (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + LabelIdentifier : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +$DONOTEVALUATE(); + + +class C { async *gen() { + await: ; +}} diff --git a/js/src/tests/test262/language/statements/class/async-gen-method/browser.js b/js/src/tests/test262/language/statements/class/async-gen-method/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/async-gen-method/dflt-params-abrupt.js b/js/src/tests/test262/language/statements/class/async-gen-method/dflt-params-abrupt.js new file mode 100644 index 0000000000..d1bcfa11ed --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method/dflt-params-abrupt.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-abrupt.case +// - src/function-forms/error/cls-decl-async-gen-meth.template +/*--- +description: Abrupt completion returned by evaluation of initializer (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [default-parameters, async-iteration] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. + +---*/ + +var callCount = 0; +class C { + async *method(_ = (function() { throw new Test262Error(); }())) { + + callCount = callCount + 1; + } +} + +assert.throws(Test262Error, function() { + C.prototype.method(); +}); +assert.sameValue(callCount, 0, 'method body not evaluated'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method/dflt-params-arg-val-not-undefined.js b/js/src/tests/test262/language/statements/class/async-gen-method/dflt-params-arg-val-not-undefined.js new file mode 100644 index 0000000000..ee15d9a365 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method/dflt-params-arg-val-not-undefined.js @@ -0,0 +1,91 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-arg-val-not-undefined.case +// - src/function-forms/default/cls-decl-async-gen-meth.template +/*--- +description: Use of initializer when argument value is not `undefined` (class declaration async generator method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [default-parameters, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + [...] + 23. Let iteratorRecord be Record {[[Iterator]]: + CreateListIterator(argumentsList), [[Done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + a. Perform ? IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + +---*/ +var obj = {}; +var falseCount = 0; +var stringCount = 0; +var nanCount = 0; +var zeroCount = 0; +var nullCount = 0; +var objCount = 0; + +var callCount = 0; +class C { + async *method(aFalse = falseCount +=1, aString = stringCount += 1, aNaN = nanCount += 1, a0 = zeroCount += 1, aNull = nullCount += 1, aObj = objCount +=1) { + assert.sameValue(aFalse, false); + assert.sameValue(aString, ''); + assert.sameValue(aNaN, NaN); + assert.sameValue(a0, 0); + assert.sameValue(aNull, null); + assert.sameValue(aObj, obj); + callCount = callCount + 1; + } +} + +// Stores a reference `ref` for case evaluation +var ref = C.prototype.method; + +ref(false, '', NaN, 0, null, obj).next().then(() => { + assert.sameValue(callCount, 1, 'method invoked exactly once'); +}).then($DONE, $DONE); + +assert.sameValue(falseCount, 0, 'initializer not evaluated: false'); +assert.sameValue(stringCount, 0, 'initializer not evaluated: string'); +assert.sameValue(nanCount, 0, 'initializer not evaluated: NaN'); +assert.sameValue(zeroCount, 0, 'initializer not evaluated: 0'); +assert.sameValue(nullCount, 0, 'initializer not evaluated: null'); +assert.sameValue(objCount, 0, 'initializer not evaluated: object'); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method/dflt-params-arg-val-undefined.js b/js/src/tests/test262/language/statements/class/async-gen-method/dflt-params-arg-val-undefined.js new file mode 100644 index 0000000000..711588c5a7 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method/dflt-params-arg-val-undefined.js @@ -0,0 +1,74 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-arg-val-undefined.case +// - src/function-forms/default/cls-decl-async-gen-meth.template +/*--- +description: Use of initializer when argument value is `undefined` (class declaration async generator method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [default-parameters, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + [...] + 23. Let iteratorRecord be Record {[[Iterator]]: + CreateListIterator(argumentsList), [[Done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + a. Perform ? IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + +---*/ + +var callCount = 0; +class C { + async *method(fromLiteral = 23, fromExpr = 45, fromHole = 99) { + assert.sameValue(fromLiteral, 23); + assert.sameValue(fromExpr, 45); + assert.sameValue(fromHole, 99); + callCount = callCount + 1; + } +} + +// Stores a reference `ref` for case evaluation +var ref = C.prototype.method; + +ref(undefined, void 0).next().then(() => { + assert.sameValue(callCount, 1, 'method invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method/dflt-params-duplicates.js b/js/src/tests/test262/language/statements/class/async-gen-method/dflt-params-duplicates.js new file mode 100644 index 0000000000..0f0499f102 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method/dflt-params-duplicates.js @@ -0,0 +1,66 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-duplicates.case +// - src/function-forms/syntax/cls-decl-async-gen-meth.template +/*--- +description: It is a Syntax Error if BoundNames of FormalParameters contains any duplicate elements. (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [default-parameters, async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 14.1.2 Static Semantics: Early Errors + + StrictFormalParameters : FormalParameters + + - It is a Syntax Error if BoundNames of FormalParameters contains any + duplicate elements. + + FormalParameters : FormalParameterList + + - It is a Syntax Error if IsSimpleParameterList of FormalParameterList is + false and BoundNames of FormalParameterList contains any duplicate + elements. + +---*/ +$DONOTEVALUATE(); + +class C { + async *method(x = 0, x) { + + } +} diff --git a/js/src/tests/test262/language/statements/class/async-gen-method/dflt-params-ref-later.js b/js/src/tests/test262/language/statements/class/async-gen-method/dflt-params-ref-later.js new file mode 100644 index 0000000000..934b90117e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method/dflt-params-ref-later.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-ref-later.case +// - src/function-forms/error/cls-decl-async-gen-meth.template +/*--- +description: Referencing a parameter that occurs later in the ParameterList (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [default-parameters, async-iteration] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. + +---*/ +var x = 0; + +var callCount = 0; +class C { + async *method(x = y, y) { + + callCount = callCount + 1; + } +} + +assert.throws(ReferenceError, function() { + C.prototype.method(); +}); +assert.sameValue(callCount, 0, 'method body not evaluated'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method/dflt-params-ref-prior.js b/js/src/tests/test262/language/statements/class/async-gen-method/dflt-params-ref-prior.js new file mode 100644 index 0000000000..f8d6fdb234 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method/dflt-params-ref-prior.js @@ -0,0 +1,71 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-ref-prior.case +// - src/function-forms/default/cls-decl-async-gen-meth.template +/*--- +description: Referencing a parameter that occurs earlier in the ParameterList (class declaration async generator method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [default-parameters, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. + +---*/ +var x = 0; + +var callCount = 0; +class C { + async *method(x, y = x, z = y) { + assert.sameValue(x, 3, 'first argument value'); + assert.sameValue(y, 3, 'second argument value'); + assert.sameValue(z, 3, 'third argument value'); + callCount = callCount + 1; + } +} + +// Stores a reference `ref` for case evaluation +var ref = C.prototype.method; + +ref(3).next().then(() => { + assert.sameValue(callCount, 1, 'method invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method/dflt-params-ref-self.js b/js/src/tests/test262/language/statements/class/async-gen-method/dflt-params-ref-self.js new file mode 100644 index 0000000000..233d3c84b0 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method/dflt-params-ref-self.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-ref-self.case +// - src/function-forms/error/cls-decl-async-gen-meth.template +/*--- +description: Referencing a parameter from within its own initializer (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [default-parameters, async-iteration] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. + +---*/ +var x = 0; + +var callCount = 0; +class C { + async *method(x = x) { + + callCount = callCount + 1; + } +} + +assert.throws(ReferenceError, function() { + C.prototype.method(); +}); +assert.sameValue(callCount, 0, 'method body not evaluated'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method/dflt-params-rest.js b/js/src/tests/test262/language/statements/class/async-gen-method/dflt-params-rest.js new file mode 100644 index 0000000000..11481afb99 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method/dflt-params-rest.js @@ -0,0 +1,70 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-rest.case +// - src/function-forms/syntax/cls-decl-async-gen-meth.template +/*--- +description: RestParameter does not support an initializer (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [default-parameters, async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 14.1 Function Definitions + + Syntax + + FunctionRestParameter[Yield] : + + BindingRestElement[?Yield] + + 13.3.3 Destructuring Binding Patterns + + Syntax + + BindingRestElement[Yield] : + + ...BindingIdentifier[?Yield] + ...BindingPattern[?Yield] + +---*/ +$DONOTEVALUATE(); + +class C { + async *method(...x = []) { + + } +} diff --git a/js/src/tests/test262/language/statements/class/async-gen-method/dflt-params-trailing-comma.js b/js/src/tests/test262/language/statements/class/async-gen-method/dflt-params-trailing-comma.js new file mode 100644 index 0000000000..a156db4c70 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method/dflt-params-trailing-comma.js @@ -0,0 +1,66 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-trailing-comma.case +// - src/function-forms/default/cls-decl-async-gen-meth.template +/*--- +description: A trailing comma should not increase the respective length, using default parameters (class declaration async generator method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + Trailing comma in the parameters list + + 14.1 Function Definitions + + FormalParameters[Yield, Await] : FormalParameterList[?Yield, ?Await] , +---*/ + +var callCount = 0; +class C { + async *method(a, b = 39,) { + assert.sameValue(a, 42); + assert.sameValue(b, 39); + callCount = callCount + 1; + } +} + +// Stores a reference `ref` for case evaluation +var ref = C.prototype.method; + +ref(42, undefined, 1).next().then(() => { + assert.sameValue(callCount, 1, 'method invoked exactly once'); +}).then($DONE, $DONE); + +assert.sameValue(ref.length, 1, 'length is properly set'); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method/forbidden-ext/b1/browser.js b/js/src/tests/test262/language/statements/class/async-gen-method/forbidden-ext/b1/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/async-gen-method/forbidden-ext/b1/cls-decl-async-gen-meth-forbidden-ext-direct-access-prop-arguments.js b/js/src/tests/test262/language/statements/class/async-gen-method/forbidden-ext/b1/cls-decl-async-gen-meth-forbidden-ext-direct-access-prop-arguments.js new file mode 100644 index 0000000000..25bfc4645e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method/forbidden-ext/b1/cls-decl-async-gen-meth-forbidden-ext-direct-access-prop-arguments.js @@ -0,0 +1,38 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/function-forms/forbidden-ext-direct-access-prop-arguments.case +// - src/function-forms/forbidden-extensions/bullet-one/cls-decl-async-gen-meth.template +/*--- +description: Forbidden extension, f.arguments (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [arrow-function, async-functions, async-iteration, class, generators] +flags: [generated, noStrict, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + + ECMAScript function objects defined using syntactic constructors in strict mode code must + not be created with own properties named "caller" or "arguments". Such own properties also + must not be created for function objects defined using an ArrowFunction, MethodDefinition, + GeneratorDeclaration, GeneratorExpression, AsyncGeneratorDeclaration, AsyncGeneratorExpression, + ClassDeclaration, ClassExpression, AsyncFunctionDeclaration, AsyncFunctionExpression, or + AsyncArrowFunction regardless of whether the definition is contained in strict mode code. + Built-in functions, strict functions created using the Function constructor, generator functions + created using the Generator constructor, async functions created using the AsyncFunction + constructor, and functions created using the bind method also must not be created with such own + properties. + +---*/ + +var callCount = 0; +class C { + async *method() { + assert.sameValue(this.method.hasOwnProperty("arguments"), false); + callCount++; + } +} + +C.prototype.method().next() + .then(() => { + assert.sameValue(callCount, 1, 'function body evaluated'); + }, $DONE).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method/forbidden-ext/b1/cls-decl-async-gen-meth-forbidden-ext-direct-access-prop-caller.js b/js/src/tests/test262/language/statements/class/async-gen-method/forbidden-ext/b1/cls-decl-async-gen-meth-forbidden-ext-direct-access-prop-caller.js new file mode 100644 index 0000000000..87675f55e5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method/forbidden-ext/b1/cls-decl-async-gen-meth-forbidden-ext-direct-access-prop-caller.js @@ -0,0 +1,38 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/function-forms/forbidden-ext-direct-access-prop-caller.case +// - src/function-forms/forbidden-extensions/bullet-one/cls-decl-async-gen-meth.template +/*--- +description: Forbidden extension, o.caller (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [arrow-function, async-functions, async-iteration, class, generators] +flags: [generated, noStrict, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + + ECMAScript function objects defined using syntactic constructors in strict mode code must + not be created with own properties named "caller" or "arguments". Such own properties also + must not be created for function objects defined using an ArrowFunction, MethodDefinition, + GeneratorDeclaration, GeneratorExpression, AsyncGeneratorDeclaration, AsyncGeneratorExpression, + ClassDeclaration, ClassExpression, AsyncFunctionDeclaration, AsyncFunctionExpression, or + AsyncArrowFunction regardless of whether the definition is contained in strict mode code. + Built-in functions, strict functions created using the Function constructor, generator functions + created using the Generator constructor, async functions created using the AsyncFunction + constructor, and functions created using the bind method also must not be created with such own + properties. + +---*/ + +var callCount = 0; +class C { + async *method() { + assert.sameValue(this.method.hasOwnProperty("caller"), false); + callCount++; + } +} + +C.prototype.method().next() + .then(() => { + assert.sameValue(callCount, 1, 'function body evaluated'); + }, $DONE).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method/forbidden-ext/b1/shell.js b/js/src/tests/test262/language/statements/class/async-gen-method/forbidden-ext/b1/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/async-gen-method/forbidden-ext/b2/browser.js b/js/src/tests/test262/language/statements/class/async-gen-method/forbidden-ext/b2/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/async-gen-method/forbidden-ext/b2/cls-decl-async-gen-meth-forbidden-ext-indirect-access-own-prop-caller-get.js b/js/src/tests/test262/language/statements/class/async-gen-method/forbidden-ext/b2/cls-decl-async-gen-meth-forbidden-ext-indirect-access-own-prop-caller-get.js new file mode 100644 index 0000000000..1ee1d902c6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method/forbidden-ext/b2/cls-decl-async-gen-meth-forbidden-ext-indirect-access-own-prop-caller-get.js @@ -0,0 +1,64 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/function-forms/forbidden-ext-indirect-access-own-prop-caller-get.case +// - src/function-forms/forbidden-extensions/bullet-two/cls-decl-async-gen-meth.template +/*--- +description: Forbidden extension, o.caller (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [arrow-function, async-functions, async-iteration, class] +flags: [generated, noStrict, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + + If an implementation extends any function object with an own property named "caller" the value of + that property, as observed using [[Get]] or [[GetOwnProperty]], must not be a strict function + object. If it is an accessor property, the function that is the value of the property's [[Get]] + attribute must never return a strict function when called. + +---*/ +var CALLER_OWN_PROPERTY_DOES_NOT_EXIST = Symbol(); +function inner() { + // This property may exist, but is forbidden from having a value that is a strict function object + return inner.hasOwnProperty("caller") + ? inner.caller + : CALLER_OWN_PROPERTY_DOES_NOT_EXIST; +} + +var callCount = 0; +class C { + async *method() { + /* implicit strict */ + // This and the following conditional value is set in the test's .case file. + // For every test that has a "true" value here, there is a + // corresponding test that has a "false" value here. + // They are generated from two different case files, which use + let descriptor = Object.getOwnPropertyDescriptor(inner, "caller"); + if (descriptor && descriptor.configurable && true) { + Object.defineProperty(inner, "caller", {get(){return 1}}); + } + var result = inner(); + if (descriptor && descriptor.configurable && true) { + assert.sameValue(result, 1, 'If this test defined an own "caller" property on the inner function, then it should be accessible and should return the value it was set to.'); + } + + // "CALLER_OWN_PROPERTY_DOES_NOT_EXIST" is from + // forbidden-ext-indirect-access-prop-caller.case + // + // If the function object "inner" has an own property + // named "caller", then its value will be returned. + // + // If the function object "inner" DOES NOT have an + // own property named "caller", then the symbol + // CALLER_OWN_PROPERTY_DOES_NOT_EXIST will be returned. + if (result !== CALLER_OWN_PROPERTY_DOES_NOT_EXIST) { + assert.notSameValue(result, this.method); + } + callCount++; + } +} + +C.prototype.method().next() + .then(() => { + assert.sameValue(callCount, 1, 'function body evaluated'); + }, $DONE).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method/forbidden-ext/b2/cls-decl-async-gen-meth-forbidden-ext-indirect-access-own-prop-caller-value.js b/js/src/tests/test262/language/statements/class/async-gen-method/forbidden-ext/b2/cls-decl-async-gen-meth-forbidden-ext-indirect-access-own-prop-caller-value.js new file mode 100644 index 0000000000..1cc848438f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method/forbidden-ext/b2/cls-decl-async-gen-meth-forbidden-ext-indirect-access-own-prop-caller-value.js @@ -0,0 +1,64 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/function-forms/forbidden-ext-indirect-access-own-prop-caller-value.case +// - src/function-forms/forbidden-extensions/bullet-two/cls-decl-async-gen-meth.template +/*--- +description: Forbidden extension, o.caller (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [arrow-function, async-functions, async-iteration, class] +flags: [generated, noStrict, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + + If an implementation extends any function object with an own property named "caller" the value of + that property, as observed using [[Get]] or [[GetOwnProperty]], must not be a strict function + object. If it is an accessor property, the function that is the value of the property's [[Get]] + attribute must never return a strict function when called. + +---*/ +var CALLER_OWN_PROPERTY_DOES_NOT_EXIST = Symbol(); +function inner() { + // This property may exist, but is forbidden from having a value that is a strict function object + return inner.hasOwnProperty("caller") + ? inner.caller + : CALLER_OWN_PROPERTY_DOES_NOT_EXIST; +} + +var callCount = 0; +class C { + async *method() { + /* implicit strict */ + // This and the following conditional value is set in the test's .case file. + // For every test that has a "true" value here, there is a + // corresponding test that has a "false" value here. + // They are generated from two different case files, which use + let descriptor = Object.getOwnPropertyDescriptor(inner, "caller"); + if (descriptor && descriptor.configurable && true) { + Object.defineProperty(inner, "caller", {value: 1}); + } + var result = inner(); + if (descriptor && descriptor.configurable && true) { + assert.sameValue(result, 1, 'If this test defined an own "caller" property on the inner function, then it should be accessible and should return the value it was set to.'); + } + + // "CALLER_OWN_PROPERTY_DOES_NOT_EXIST" is from + // forbidden-ext-indirect-access-prop-caller.case + // + // If the function object "inner" has an own property + // named "caller", then its value will be returned. + // + // If the function object "inner" DOES NOT have an + // own property named "caller", then the symbol + // CALLER_OWN_PROPERTY_DOES_NOT_EXIST will be returned. + if (result !== CALLER_OWN_PROPERTY_DOES_NOT_EXIST) { + assert.notSameValue(result, this.method); + } + callCount++; + } +} + +C.prototype.method().next() + .then(() => { + assert.sameValue(callCount, 1, 'function body evaluated'); + }, $DONE).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method/forbidden-ext/b2/cls-decl-async-gen-meth-forbidden-ext-indirect-access-prop-caller.js b/js/src/tests/test262/language/statements/class/async-gen-method/forbidden-ext/b2/cls-decl-async-gen-meth-forbidden-ext-indirect-access-prop-caller.js new file mode 100644 index 0000000000..f1c8cb25fb --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method/forbidden-ext/b2/cls-decl-async-gen-meth-forbidden-ext-indirect-access-prop-caller.js @@ -0,0 +1,64 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/function-forms/forbidden-ext-indirect-access-prop-caller.case +// - src/function-forms/forbidden-extensions/bullet-two/cls-decl-async-gen-meth.template +/*--- +description: Forbidden extension, o.caller (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [arrow-function, async-functions, async-iteration, class] +flags: [generated, noStrict, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + + If an implementation extends any function object with an own property named "caller" the value of + that property, as observed using [[Get]] or [[GetOwnProperty]], must not be a strict function + object. If it is an accessor property, the function that is the value of the property's [[Get]] + attribute must never return a strict function when called. + +---*/ +var CALLER_OWN_PROPERTY_DOES_NOT_EXIST = Symbol(); +function inner() { + // This property may exist, but is forbidden from having a value that is a strict function object + return inner.hasOwnProperty("caller") + ? inner.caller + : CALLER_OWN_PROPERTY_DOES_NOT_EXIST; +} + +var callCount = 0; +class C { + async *method() { + /* implicit strict */ + // This and the following conditional value is set in the test's .case file. + // For every test that has a "true" value here, there is a + // corresponding test that has a "false" value here. + // They are generated from two different case files, which use + let descriptor = Object.getOwnPropertyDescriptor(inner, "caller"); + if (descriptor && descriptor.configurable && false) { + Object.defineProperty(inner, "caller", {}); + } + var result = inner(); + if (descriptor && descriptor.configurable && false) { + assert.sameValue(result, 1, 'If this test defined an own "caller" property on the inner function, then it should be accessible and should return the value it was set to.'); + } + + // "CALLER_OWN_PROPERTY_DOES_NOT_EXIST" is from + // forbidden-ext-indirect-access-prop-caller.case + // + // If the function object "inner" has an own property + // named "caller", then its value will be returned. + // + // If the function object "inner" DOES NOT have an + // own property named "caller", then the symbol + // CALLER_OWN_PROPERTY_DOES_NOT_EXIST will be returned. + if (result !== CALLER_OWN_PROPERTY_DOES_NOT_EXIST) { + assert.notSameValue(result, this.method); + } + callCount++; + } +} + +C.prototype.method().next() + .then(() => { + assert.sameValue(callCount, 1, 'function body evaluated'); + }, $DONE).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method/forbidden-ext/b2/shell.js b/js/src/tests/test262/language/statements/class/async-gen-method/forbidden-ext/b2/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/async-gen-method/forbidden-ext/browser.js b/js/src/tests/test262/language/statements/class/async-gen-method/forbidden-ext/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/async-gen-method/forbidden-ext/shell.js b/js/src/tests/test262/language/statements/class/async-gen-method/forbidden-ext/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/async-gen-method/object-destructuring-param-strict-body.js b/js/src/tests/test262/language/statements/class/async-gen-method/object-destructuring-param-strict-body.js new file mode 100644 index 0000000000..12171b4e5e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method/object-destructuring-param-strict-body.js @@ -0,0 +1,137 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/function-forms/object-destructuring-param-strict-body.case +// - src/function-forms/syntax/cls-decl-async-gen-meth.template +/*--- +description: ObjectBindingPattern and Use Strict Directive are not allowed to coexist for the same function. (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [rest-parameters, async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.4 Static Semantics: IsSimpleParameterList + + BindingElement : BindingPattern + + 1. Return false. + + 14.1.2 Static Semantics: Early Errors + + FunctionDeclaration : function BindingIdentifier ( FormalParameters ) { FunctionBody } + FunctionDeclaration : function ( FormalParameters ) { FunctionBody } + FunctionExpression : function BindingIdentifier ( FormalParameters ) { FunctionBody } + + - It is a Syntax Error if ContainsUseStrict of FunctionBody is true and + IsSimpleParameterList of FormalParameters is false. + + 14.2.1 Static Semantics: Early Errors + + ArrowFunction : ArrowParameters => ConciseBody + + - It is a Syntax Error if ContainsUseStrict of ConciseBody is true and + IsSimpleParameterList of ArrowParameters is false. + + 14.3.1 Static Semantics: Early Errors + + MethodDefinition : PropertyName ( UniqueFormalParameters ) { FunctionBody } + + - It is a Syntax Error if ContainsUseStrict of FunctionBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + MethodDefinition : set PropertyName ( PropertySetParameterList ) { FunctionBody } + + - It is a Syntax Error if ContainsUseStrict of FunctionBody is true and + IsSimpleParameterList of PropertySetParameterList is false. + + 14.4.1 Static Semantics: Early Errors + + GeneratorMethod : * PropertyName ( UniqueFormalParameters ) { GeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of GeneratorBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + GeneratorDeclaration : function * BindingIdentifier ( FormalParameters ) { GeneratorBody } + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + GeneratorExpression : function * BindingIdentifier ( FormalParameters ) { GeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of GeneratorBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + 14.5.1 Static Semantics: Early Errors + + AsyncGeneratorMethod : async * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncGeneratorBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + AsyncGeneratorDeclaration : async function * BindingIdentifier ( FormalParameters ) { AsyncGeneratorBody } + AsyncGeneratorDeclaration : async function * ( FormalParameters ) { AsyncGeneratorBody } + AsyncGeneratorExpression : async function * BindingIdentifier ( FormalParameters ) { AsyncGeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncGeneratorBody is true and + IsSimpleParameterList of FormalParameters is false. + + 14.7.1 Static Semantics: Early Errors + + AsyncMethod : async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncFunctionBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + AsyncFunctionDeclaration : async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody } + AsyncFunctionDeclaration : async function ( FormalParameters ) { AsyncFunctionBody } + AsyncFunctionExpression : async function ( FormalParameters ) { AsyncFunctionBody } + AsyncFunctionExpression : async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncFunctionBody is true and + IsSimpleParameterList of FormalParameters is false. + + 14.8.1 Static Semantics: Early Errors + + AsyncArrowFunction : CoverCallExpressionAndAsyncArrowHead => AsyncConciseBody + + - It is a Syntax Error if ContainsUseStrict of AsyncConciseBody is true and + IsSimpleParameterList of CoverCallExpressionAndAsyncArrowHead is false. + +---*/ +$DONOTEVALUATE(); + +class C { + async *method({property}) { + "use strict"; + } +} diff --git a/js/src/tests/test262/language/statements/class/async-gen-method/params-trailing-comma-multiple.js b/js/src/tests/test262/language/statements/class/async-gen-method/params-trailing-comma-multiple.js new file mode 100644 index 0000000000..e86210f4f1 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method/params-trailing-comma-multiple.js @@ -0,0 +1,66 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/function-forms/params-trailing-comma-multiple.case +// - src/function-forms/default/cls-decl-async-gen-meth.template +/*--- +description: A trailing comma should not increase the respective length, using multiple parameters (class declaration async generator method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + Trailing comma in the parameters list + + 14.1 Function Definitions + + FormalParameters[Yield, Await] : FormalParameterList[?Yield, ?Await] , +---*/ + +var callCount = 0; +class C { + async *method(a, b,) { + assert.sameValue(a, 42); + assert.sameValue(b, 39); + callCount = callCount + 1; + } +} + +// Stores a reference `ref` for case evaluation +var ref = C.prototype.method; + +ref(42, 39, 1).next().then(() => { + assert.sameValue(callCount, 1, 'method invoked exactly once'); +}).then($DONE, $DONE); + +assert.sameValue(ref.length, 2, 'length is properly set'); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method/params-trailing-comma-single.js b/js/src/tests/test262/language/statements/class/async-gen-method/params-trailing-comma-single.js new file mode 100644 index 0000000000..a84e93b285 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method/params-trailing-comma-single.js @@ -0,0 +1,65 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/function-forms/params-trailing-comma-single.case +// - src/function-forms/default/cls-decl-async-gen-meth.template +/*--- +description: A trailing comma should not increase the respective length, using a single parameter (class declaration async generator method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + Trailing comma in the parameters list + + 14.1 Function Definitions + + FormalParameters[Yield, Await] : FormalParameterList[?Yield, ?Await] , +---*/ + +var callCount = 0; +class C { + async *method(a,) { + assert.sameValue(a, 42); + callCount = callCount + 1; + } +} + +// Stores a reference `ref` for case evaluation +var ref = C.prototype.method; + +ref(42, 39).next().then(() => { + assert.sameValue(callCount, 1, 'method invoked exactly once'); +}).then($DONE, $DONE); + +assert.sameValue(ref.length, 1, 'length is properly set'); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method/rest-param-strict-body.js b/js/src/tests/test262/language/statements/class/async-gen-method/rest-param-strict-body.js new file mode 100644 index 0000000000..93b4172858 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method/rest-param-strict-body.js @@ -0,0 +1,137 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/function-forms/rest-param-strict-body.case +// - src/function-forms/syntax/cls-decl-async-gen-meth.template +/*--- +description: RestParameter and Use Strict Directive are not allowed to coexist for the same function. (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [rest-parameters, async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 14.1.13 Static Semantics: IsSimpleParameterList + + FormalParameters : FormalParameterList , FunctionRestParameter + + 1. Return false. + + 14.1.2 Static Semantics: Early Errors + + FunctionDeclaration : function BindingIdentifier ( FormalParameters ) { FunctionBody } + FunctionDeclaration : function ( FormalParameters ) { FunctionBody } + FunctionExpression : function BindingIdentifier ( FormalParameters ) { FunctionBody } + + - It is a Syntax Error if ContainsUseStrict of FunctionBody is true and + IsSimpleParameterList of FormalParameters is false. + + 14.2.1 Static Semantics: Early Errors + + ArrowFunction : ArrowParameters => ConciseBody + + - It is a Syntax Error if ContainsUseStrict of ConciseBody is true and + IsSimpleParameterList of ArrowParameters is false. + + 14.3.1 Static Semantics: Early Errors + + MethodDefinition : PropertyName ( UniqueFormalParameters ) { FunctionBody } + + - It is a Syntax Error if ContainsUseStrict of FunctionBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + MethodDefinition : set PropertyName ( PropertySetParameterList ) { FunctionBody } + + - It is a Syntax Error if ContainsUseStrict of FunctionBody is true and + IsSimpleParameterList of PropertySetParameterList is false. + + 14.4.1 Static Semantics: Early Errors + + GeneratorMethod : * PropertyName ( UniqueFormalParameters ) { GeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of GeneratorBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + GeneratorDeclaration : function * BindingIdentifier ( FormalParameters ) { GeneratorBody } + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + GeneratorExpression : function * BindingIdentifier ( FormalParameters ) { GeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of GeneratorBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + 14.5.1 Static Semantics: Early Errors + + AsyncGeneratorMethod : async * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncGeneratorBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + AsyncGeneratorDeclaration : async function * BindingIdentifier ( FormalParameters ) { AsyncGeneratorBody } + AsyncGeneratorDeclaration : async function * ( FormalParameters ) { AsyncGeneratorBody } + AsyncGeneratorExpression : async function * BindingIdentifier ( FormalParameters ) { AsyncGeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncGeneratorBody is true and + IsSimpleParameterList of FormalParameters is false. + + 14.7.1 Static Semantics: Early Errors + + AsyncMethod : async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncFunctionBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + AsyncFunctionDeclaration : async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody } + AsyncFunctionDeclaration : async function ( FormalParameters ) { AsyncFunctionBody } + AsyncFunctionExpression : async function ( FormalParameters ) { AsyncFunctionBody } + AsyncFunctionExpression : async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncFunctionBody is true and + IsSimpleParameterList of FormalParameters is false. + + 14.8.1 Static Semantics: Early Errors + + AsyncArrowFunction : CoverCallExpressionAndAsyncArrowHead => AsyncConciseBody + + - It is a Syntax Error if ContainsUseStrict of AsyncConciseBody is true and + IsSimpleParameterList of CoverCallExpressionAndAsyncArrowHead is false. + +---*/ +$DONOTEVALUATE(); + +class C { + async *method(a,...rest) { + "use strict"; + } +} diff --git a/js/src/tests/test262/language/statements/class/async-gen-method/rest-params-trailing-comma-early-error.js b/js/src/tests/test262/language/statements/class/async-gen-method/rest-params-trailing-comma-early-error.js new file mode 100644 index 0000000000..ac3e44e824 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method/rest-params-trailing-comma-early-error.js @@ -0,0 +1,63 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/function-forms/rest-params-trailing-comma-early-error.case +// - src/function-forms/syntax/cls-decl-async-gen-meth.template +/*--- +description: It's a syntax error if a FunctionRestParameter is followed by a trailing comma (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + Trailing comma in the parameters list + + 14.1 Function Definitions + + FormalParameters[Yield, Await] : + [empty] + FunctionRestParameter[?Yield, ?Await] + FormalParameterList[?Yield, ?Await] + FormalParameterList[?Yield, ?Await] , + FormalParameterList[?Yield, ?Await] , FunctionRestParameter[?Yield, ?Await] +---*/ +$DONOTEVALUATE(); + +class C { + async *method(...a,) { + + } +} diff --git a/js/src/tests/test262/language/statements/class/async-gen-method/shell.js b/js/src/tests/test262/language/statements/class/async-gen-method/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/async-gen-method/yield-as-binding-identifier-escaped.js b/js/src/tests/test262/language/statements/class/async-gen-method/yield-as-binding-identifier-escaped.js new file mode 100644 index 0000000000..c516f6d840 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method/yield-as-binding-identifier-escaped.js @@ -0,0 +1,37 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-as-binding-identifier-escaped.case +// - src/async-generators/syntax/async-class-decl-method.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as a binding identifier. (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + BindingIdentifier : Identifier + + It is a Syntax Error if this production has a [Yield] parameter and + StringValue of Identifier is "yield". + +---*/ +$DONOTEVALUATE(); + + +class C { async *gen() { + var yi\u0065ld; +}} diff --git a/js/src/tests/test262/language/statements/class/async-gen-method/yield-as-binding-identifier.js b/js/src/tests/test262/language/statements/class/async-gen-method/yield-as-binding-identifier.js new file mode 100644 index 0000000000..e0ee916ba1 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method/yield-as-binding-identifier.js @@ -0,0 +1,37 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-as-binding-identifier.case +// - src/async-generators/syntax/async-class-decl-method.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as a binding identifier. (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + BindingIdentifier : Identifier + + It is a Syntax Error if this production has a [Yield] parameter and + StringValue of Identifier is "yield". + +---*/ +$DONOTEVALUATE(); + + +class C { async *gen() { + var yield; +}} diff --git a/js/src/tests/test262/language/statements/class/async-gen-method/yield-as-identifier-reference-escaped.js b/js/src/tests/test262/language/statements/class/async-gen-method/yield-as-identifier-reference-escaped.js new file mode 100644 index 0000000000..1280b4655f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method/yield-as-identifier-reference-escaped.js @@ -0,0 +1,37 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-as-identifier-reference-escaped.case +// - src/async-generators/syntax/async-class-decl-method.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as an identifier reference. (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + IdentifierReference : Identifier + + It is a Syntax Error if this production has a [Yield] parameter and + StringValue of Identifier is "yield". + +---*/ +$DONOTEVALUATE(); + + +class C { async *gen() { + void yi\u0065ld; +}} diff --git a/js/src/tests/test262/language/statements/class/async-gen-method/yield-as-identifier-reference.js b/js/src/tests/test262/language/statements/class/async-gen-method/yield-as-identifier-reference.js new file mode 100644 index 0000000000..6fe5770f86 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method/yield-as-identifier-reference.js @@ -0,0 +1,37 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-as-identifier-reference.case +// - src/async-generators/syntax/async-class-decl-method.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as an identifier reference. (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + IdentifierReference : Identifier + + It is a Syntax Error if this production has a [Yield] parameter and + StringValue of Identifier is "yield". + +---*/ +$DONOTEVALUATE(); + + +class C { async *gen() { + void yield; +}} diff --git a/js/src/tests/test262/language/statements/class/async-gen-method/yield-as-label-identifier-escaped.js b/js/src/tests/test262/language/statements/class/async-gen-method/yield-as-label-identifier-escaped.js new file mode 100644 index 0000000000..5bdce639e2 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method/yield-as-label-identifier-escaped.js @@ -0,0 +1,37 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-as-label-identifier-escaped.case +// - src/async-generators/syntax/async-class-decl-method.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as a label identifier. (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + LabelIdentifier : Identifier + + It is a Syntax Error if this production has a [Yield] parameter and + StringValue of Identifier is "yield". + +---*/ +$DONOTEVALUATE(); + + +class C { async *gen() { + yi\u0065ld: ; +}} diff --git a/js/src/tests/test262/language/statements/class/async-gen-method/yield-as-label-identifier.js b/js/src/tests/test262/language/statements/class/async-gen-method/yield-as-label-identifier.js new file mode 100644 index 0000000000..ce338ce1b8 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method/yield-as-label-identifier.js @@ -0,0 +1,37 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-as-label-identifier.case +// - src/async-generators/syntax/async-class-decl-method.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as a label identifier. (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + LabelIdentifier : Identifier + + It is a Syntax Error if this production has a [Yield] parameter and + StringValue of Identifier is "yield". + +---*/ +$DONOTEVALUATE(); + + +class C { async *gen() { + yield: ; +}} diff --git a/js/src/tests/test262/language/statements/class/async-gen-method/yield-identifier-spread-strict-strict.js b/js/src/tests/test262/language/statements/class/async-gen-method/yield-identifier-spread-strict-strict.js new file mode 100644 index 0000000000..635f0c848c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method/yield-identifier-spread-strict-strict.js @@ -0,0 +1,55 @@ +// |reftest| error:SyntaxError +'use strict'; +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-identifier-spread-strict.case +// - src/async-generators/default/async-class-decl-method.template +/*--- +description: It's an early error if the AssignmentExpression is a function body with yield as an identifier in strict mode. (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [object-spread, async-iteration] +flags: [generated, onlyStrict] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + Spread Properties + + PropertyDefinition[Yield]: + (...) + ...AssignmentExpression[In, ?Yield] + +---*/ +$DONOTEVALUATE(); + + +var callCount = 0; + +class C { async *gen() { + callCount += 1; + return { + ...(function() { + var yield; + throw new Test262Error(); + }()), + } +}} + +var gen = C.prototype.gen; + +var iter = gen(); + + + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method/yield-identifier-strict-strict.js b/js/src/tests/test262/language/statements/class/async-gen-method/yield-identifier-strict-strict.js new file mode 100644 index 0000000000..8fd9382ede --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method/yield-identifier-strict-strict.js @@ -0,0 +1,46 @@ +// |reftest| error:SyntaxError +'use strict'; +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-identifier-strict.case +// - src/async-generators/default/async-class-decl-method.template +/*--- +description: It's an early error if the generator body has another function body with yield as an identifier in strict mode. (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration] +flags: [generated, onlyStrict] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + +---*/ +$DONOTEVALUATE(); + + +var callCount = 0; + +class C { async *gen() { + callCount += 1; + (function() { + var yield; + throw new Test262Error(); + }()) +}} + +var gen = C.prototype.gen; + +var iter = gen(); + + + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method/yield-promise-reject-next-catch.js b/js/src/tests/test262/language/statements/class/async-gen-method/yield-promise-reject-next-catch.js new file mode 100644 index 0000000000..64f693bd72 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method/yield-promise-reject-next-catch.js @@ -0,0 +1,51 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-promise-reject-next-catch.case +// - src/async-generators/default/async-class-decl-method.template +/*--- +description: yield Promise.reject(value) is treated as throw value (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + +---*/ +let error = new Error(); + + +var callCount = 0; + +class C { async *gen() { + callCount += 1; + yield Promise.reject(error); + yield "unreachable"; +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error("Promise incorrectly resolved."); +}).catch(rejectValue => { + // yield Promise.reject(error); + assert.sameValue(rejectValue, error); + + iter.next().then(({done, value}) => { + // iter is closed now. + assert.sameValue(done, true, "The value of IteratorResult.done is `true`"); + assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`"); + }).then($DONE, $DONE); +}); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method/yield-promise-reject-next-for-await-of-async-iterator.js b/js/src/tests/test262/language/statements/class/async-gen-method/yield-promise-reject-next-for-await-of-async-iterator.js new file mode 100644 index 0000000000..83ecb6da04 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method/yield-promise-reject-next-for-await-of-async-iterator.js @@ -0,0 +1,57 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-promise-reject-next-for-await-of-async-iterator.case +// - src/async-generators/default/async-class-decl-method.template +/*--- +description: yield * [Promise.reject(value)] is treated as throw value (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + +---*/ +let error = new Error(); +async function * readFile() { + yield Promise.reject(error); + yield "unreachable"; +} + + +var callCount = 0; + +class C { async *gen() { + callCount += 1; + for await (let line of readFile()) { + yield line; + } +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error("Promise incorrectly resolved."); +}, rejectValue => { + + // yield Promise.reject(error); + assert.sameValue(rejectValue, error); + + iter.next().then(({done, value}) => { + // iter is closed now. + assert.sameValue(done, true, "The value of IteratorResult.done is `true`"); + assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`"); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method/yield-promise-reject-next-for-await-of-sync-iterator.js b/js/src/tests/test262/language/statements/class/async-gen-method/yield-promise-reject-next-for-await-of-sync-iterator.js new file mode 100644 index 0000000000..45989ca753 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method/yield-promise-reject-next-for-await-of-sync-iterator.js @@ -0,0 +1,56 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-promise-reject-next-for-await-of-sync-iterator.case +// - src/async-generators/default/async-class-decl-method.template +/*--- +description: yield Promise.reject(value) in for-await-of is treated as throw value (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + +---*/ +let error = new Error(); +let iterable = [ + Promise.reject(error), + "unreachable" +]; + + +var callCount = 0; + +class C { async *gen() { + callCount += 1; + for await (let value of iterable) { + yield value; + } +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error("Promise incorrectly resolved."); +}, rejectValue => { + // yield Promise.reject(error); + assert.sameValue(rejectValue, error); + + iter.next().then(({done, value}) => { + // iter is closed now. + assert.sameValue(done, true, "The value of IteratorResult.done is `true`"); + assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`"); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method/yield-promise-reject-next-yield-star-async-iterator.js b/js/src/tests/test262/language/statements/class/async-gen-method/yield-promise-reject-next-yield-star-async-iterator.js new file mode 100644 index 0000000000..e7d1b5dbe7 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method/yield-promise-reject-next-yield-star-async-iterator.js @@ -0,0 +1,55 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-promise-reject-next-yield-star-async-iterator.case +// - src/async-generators/default/async-class-decl-method.template +/*--- +description: yield * (async iterator) is treated as throw value (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + +---*/ +let error = new Error(); +async function * readFile() { + yield Promise.reject(error); + yield "unreachable"; +} + + +var callCount = 0; + +class C { async *gen() { + callCount += 1; + yield * readFile(); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error("Promise incorrectly resolved."); +}, rejectValue => { + // yield Promise.reject(error); + assert.sameValue(rejectValue, error); + + iter.next().then(({done, value}) => { + // iter is closed now. + assert.sameValue(done, true, "The value of IteratorResult.done is `true`"); + assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`"); + }).then($DONE, $DONE); +}, $DONE).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method/yield-promise-reject-next-yield-star-sync-iterator.js b/js/src/tests/test262/language/statements/class/async-gen-method/yield-promise-reject-next-yield-star-sync-iterator.js new file mode 100644 index 0000000000..f6614c70fe --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method/yield-promise-reject-next-yield-star-sync-iterator.js @@ -0,0 +1,54 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-promise-reject-next-yield-star-sync-iterator.case +// - src/async-generators/default/async-class-decl-method.template +/*--- +description: yield * (async iterator) is treated as throw value (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + +---*/ +let error = new Error(); +let iterable = [ + Promise.reject(error), + "unreachable" +]; + + +var callCount = 0; + +class C { async *gen() { + callCount += 1; + yield * iterable; +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error("Promise incorrectly resolved."); +}, rejectValue => { + // yield Promise.reject(error); + assert.sameValue(rejectValue, error); + + iter.next().then(({done, value}) => { + // iter is closed now. + assert.sameValue(done, true, "The value of IteratorResult.done is `true`"); + assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`"); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method/yield-promise-reject-next.js b/js/src/tests/test262/language/statements/class/async-gen-method/yield-promise-reject-next.js new file mode 100644 index 0000000000..6d10c0e0d0 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method/yield-promise-reject-next.js @@ -0,0 +1,51 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-promise-reject-next.case +// - src/async-generators/default/async-class-decl-method.template +/*--- +description: yield Promise.reject(value) is treated as throw value (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + +---*/ +let error = new Error(); + + +var callCount = 0; + +class C { async *gen() { + callCount += 1; + yield Promise.reject(error); + yield "unreachable"; +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error("Promise incorrectly resolved."); +}, rejectValue => { + // yield Promise.reject(error); + assert.sameValue(rejectValue, error); + + iter.next().then(({done, value}) => { + // iter is closed now. + assert.sameValue(done, true, "The value of IteratorResult.done is `true`"); + assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`"); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method/yield-spread-arr-multiple.js b/js/src/tests/test262/language/statements/class/async-gen-method/yield-spread-arr-multiple.js new file mode 100644 index 0000000000..1396fedca9 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method/yield-spread-arr-multiple.js @@ -0,0 +1,57 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-spread-arr-multiple.case +// - src/async-generators/default/async-class-decl-method.template +/*--- +description: Use yield value in a array spread position (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration] +flags: [generated, async] +includes: [compareArray.js] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + Array Initializer + + SpreadElement[Yield, Await]: + ...AssignmentExpression[+In, ?Yield, ?Await] + +---*/ +var arr = ['a', 'b', 'c']; +var item; + + +var callCount = 0; + +class C { async *gen() { + callCount += 1; + yield [...yield yield]; +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next(false); +item = iter.next(['a', 'b', 'c']); + +item.then(({ done, value }) => { + item = iter.next(value); + + item.then(({ done, value }) => { + assert.compareArray(value, arr); + assert.sameValue(done, false); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method/yield-spread-arr-single.js b/js/src/tests/test262/language/statements/class/async-gen-method/yield-spread-arr-single.js new file mode 100644 index 0000000000..55b7f0855a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method/yield-spread-arr-single.js @@ -0,0 +1,56 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-spread-arr-single.case +// - src/async-generators/default/async-class-decl-method.template +/*--- +description: Use yield value in a array spread position (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + Array Initializer + + SpreadElement[Yield, Await]: + ...AssignmentExpression[+In, ?Yield, ?Await] + +---*/ +var arr = ['a', 'b', 'c']; + + +var callCount = 0; + +class C { async *gen() { + callCount += 1; + yield [...yield]; +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next(false); +var item = iter.next(arr); + +item.then(({ done, value }) => { + assert.notSameValue(value, arr, 'value is a new array'); + assert(Array.isArray(value), 'value is an Array exotic object'); + assert.sameValue(value.length, 3) + assert.sameValue(value[0], 'a'); + assert.sameValue(value[1], 'b'); + assert.sameValue(value[2], 'c'); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method/yield-spread-obj.js b/js/src/tests/test262/language/statements/class/async-gen-method/yield-spread-obj.js new file mode 100644 index 0000000000..0e00dd9637 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method/yield-spread-obj.js @@ -0,0 +1,59 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-spread-obj.case +// - src/async-generators/default/async-class-decl-method.template +/*--- +description: Use yield value in a object spread position (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [object-spread, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + Spread Properties + + PropertyDefinition[Yield]: + (...) + ...AssignmentExpression[In, ?Yield] + +---*/ + + +var callCount = 0; + +class C { async *gen() { + callCount += 1; + yield { + ...yield, + y: 1, + ...yield yield, + }; +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next(); +iter.next({ x: 42 }); +iter.next({ x: 'lol' }); +var item = iter.next({ y: 39 }); + +item.then(({ done, value }) => { + assert.sameValue(value.x, 42); + assert.sameValue(value.y, 39); + assert.sameValue(Object.keys(value).length, 2); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-async-next.js b/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-async-next.js new file mode 100644 index 0000000000..84ecde54f8 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-async-next.js @@ -0,0 +1,226 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-async-next.case +// - src/async-generators/default/async-class-decl-method.template +/*--- +description: Execution order for yield* with async iterator and next() (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, async-iteration, Symbol.asyncIterator] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + +---*/ +var log = []; +var obj = { + get [Symbol.iterator]() { + log.push({ name: "get [Symbol.iterator]" }); + }, + get [Symbol.asyncIterator]() { + log.push({ + name: "get [Symbol.asyncIterator]", + thisValue: this + }); + return function() { + log.push({ + name: "call [Symbol.asyncIterator]", + thisValue: this, + args: [...arguments] + }); + var nextCount = 0; + return { + name: "asyncIterator", + get next() { + log.push({ + name: "get next", + thisValue: this + }); + return function() { + log.push({ + name: "call next", + thisValue: this, + args: [...arguments] + }); + + nextCount++; + if (nextCount == 1) { + return { + name: "next-promise-1", + get then() { + log.push({ + name: "get next then (1)", + thisValue: this + }); + return function(resolve) { + log.push({ + name: "call next then (1)", + thisValue: this, + args: [...arguments] + }); + + resolve({ + name: "next-result-1", + get value() { + log.push({ + name: "get next value (1)", + thisValue: this + }); + return "next-value-1"; + }, + get done() { + log.push({ + name: "get next done (1)", + thisValue: this + }); + return false; + } + }); + }; + } + }; + } + + return { + name: "next-promise-2", + get then() { + log.push({ + name: "get next then (2)", + thisValue: this + }); + return function(resolve) { + log.push({ + name: "call next then (2)", + thisValue: this, + args: [...arguments] + }); + + resolve({ + name: "next-result-2", + get value() { + log.push({ + name: "get next value (2)", + thisValue: this + }); + return "next-value-2"; + }, + get done() { + log.push({ + name: "get next done (2)", + thisValue: this + }); + return true; + } + }); + }; + } + }; + }; + } + }; + }; + } +}; + + + +var callCount = 0; + +class C { async *gen() { + callCount += 1; + log.push({ name: "before yield*" }); + var v = yield* obj; + log.push({ + name: "after yield*", + value: v + }); + return "return-value"; + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +assert.sameValue(log.length, 0, "log.length"); + +iter.next("next-arg-1").then(v => { + assert.sameValue(log[0].name, "before yield*"); + + assert.sameValue(log[1].name, "get [Symbol.asyncIterator]"); + assert.sameValue(log[1].thisValue, obj, "get [Symbol.asyncIterator] thisValue"); + + assert.sameValue(log[2].name, "call [Symbol.asyncIterator]"); + assert.sameValue(log[2].thisValue, obj, "[Symbol.asyncIterator] thisValue"); + assert.sameValue(log[2].args.length, 0, "[Symbol.asyncIterator] args.length"); + + assert.sameValue(log[3].name, "get next"); + assert.sameValue(log[3].thisValue.name, "asyncIterator", "get next thisValue"); + + assert.sameValue(log[4].name, "call next"); + assert.sameValue(log[4].thisValue.name, "asyncIterator", "next thisValue"); + assert.sameValue(log[4].args.length, 1, "next args.length"); + assert.sameValue(log[4].args[0], undefined, "next args[0]"); + + assert.sameValue(log[5].name, "get next then (1)"); + assert.sameValue(log[5].thisValue.name, "next-promise-1", "get next then thisValue"); + + assert.sameValue(log[6].name, "call next then (1)"); + assert.sameValue(log[6].thisValue.name, "next-promise-1", "next then thisValue"); + assert.sameValue(log[6].args.length, 2, "next then args.length"); + assert.sameValue(typeof log[6].args[0], "function", "next then args[0]"); + assert.sameValue(typeof log[6].args[1], "function", "next then args[1]"); + + assert.sameValue(log[7].name, "get next done (1)"); + assert.sameValue(log[7].thisValue.name, "next-result-1", "get next done thisValue"); + + assert.sameValue(log[8].name, "get next value (1)"); + assert.sameValue(log[8].thisValue.name, "next-result-1", "get next value thisValue"); + + assert.sameValue(v.value, "next-value-1"); + assert.sameValue(v.done, false); + + assert.sameValue(log.length, 9, "log.length"); + + iter.next("next-arg-2").then(v => { + assert.sameValue(log[9].name, "call next"); + assert.sameValue(log[9].thisValue.name, "asyncIterator", "next thisValue"); + assert.sameValue(log[9].args.length, 1, "next args.length"); + assert.sameValue(log[9].args[0], "next-arg-2", "next args[0]"); + + assert.sameValue(log[10].name, "get next then (2)"); + assert.sameValue(log[10].thisValue.name, "next-promise-2", "get next then thisValue"); + + assert.sameValue(log[11].name, "call next then (2)"); + assert.sameValue(log[11].thisValue.name, "next-promise-2", "next then thisValue"); + assert.sameValue(log[11].args.length, 2, "next then args.length"); + assert.sameValue(typeof log[11].args[0], "function", "next then args[0]"); + assert.sameValue(typeof log[11].args[1], "function", "next then args[1]"); + + assert.sameValue(log[12].name, "get next done (2)"); + assert.sameValue(log[12].thisValue.name, "next-result-2", "get next done thisValue"); + + assert.sameValue(log[13].name, "get next value (2)"); + assert.sameValue(log[13].thisValue.name, "next-result-2", "get next value thisValue"); + + assert.sameValue(log[14].name, "after yield*"); + assert.sameValue(log[14].value, "next-value-2"); + + assert.sameValue(v.value, "return-value"); + assert.sameValue(v.done, true); + + assert.sameValue(log.length, 15, "log.length"); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-async-return.js b/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-async-return.js new file mode 100644 index 0000000000..f006307f4a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-async-return.js @@ -0,0 +1,242 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-async-return.case +// - src/async-generators/default/async-class-decl-method.template +/*--- +description: execution order for yield* with async iterator and return() (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration, Symbol.asyncIterator] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + ... + 6. Repeat + ... + c. Else, + i. Assert: received.[[Type]] is return. + ii. Let return be ? GetMethod(iterator, "return"). + iii. If return is undefined, return Completion(received). + iv. Let innerReturnResult be ? Call(return, iterator, « received.[[Value]] »). + v. If generatorKind is async, then set innerReturnResult to ? Await(innerReturnResult). + ... + vii. Let done be ? IteratorComplete(innerReturnResult). + viii. If done is true, then + 1. Let value be ? IteratorValue(innerReturnResult). + 2. If generatorKind is async, then set value to ? Await(value). + 3. Return Completion{[[Type]]: return, [[Value]]: value, [[Target]]: empty}. + ix. If generatorKind is async, then let received be AsyncGeneratorYield(? IteratorValue(innerResult)). + ... + + AsyncGeneratorYield ( value ) + ... + 8. Return ! AsyncGeneratorResolve(generator, value, false). + ... + +---*/ +var log = []; +var obj = { + [Symbol.asyncIterator]() { + var returnCount = 0; + return { + name: 'asyncIterator', + get next() { + log.push({ name: "get next" }); + return function() { + return { + value: "next-value-1", + done: false + }; + }; + }, + get return() { + log.push({ + name: "get return", + thisValue: this + }); + return function() { + log.push({ + name: "call return", + thisValue: this, + args: [...arguments] + }); + + returnCount++; + if (returnCount == 1) { + return { + name: "return-promise-1", + get then() { + log.push({ + name: "get return then (1)", + thisValue: this + }); + return function(resolve) { + log.push({ + name: "call return then (1)", + thisValue: this, + args: [...arguments] + }); + + resolve({ + name: "return-result-1", + get value() { + log.push({ + name: "get return value (1)", + thisValue: this + }); + return "return-value-1"; + }, + get done() { + log.push({ + name: "get return done (1)", + thisValue: this + }); + return false; + } + }); + }; + } + }; + } + + return { + name: "return-promise-2", + get then() { + log.push({ + name: "get return then (2)", + thisValue: this + }); + return function(resolve) { + log.push({ + name: "call return then (2)", + thisValue: this, + args: [...arguments] + }); + + resolve({ + name: "return-result-2", + get value() { + log.push({ + name: "get return value (2)", + thisValue: this + }); + return "return-value-2"; + }, + get done() { + log.push({ + name: "get return done (2)", + thisValue: this + }); + return true; + } + }); + }; + } + }; + }; + } + }; + } +}; + + + +var callCount = 0; + +class C { async *gen() { + callCount += 1; + log.push({ name: "before yield*" }); + yield* obj; + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +assert.sameValue(log.length, 0, "log.length"); + +iter.next().then(v => { + assert.sameValue(log[0].name, "before yield*"); + + assert.sameValue(log[1].name, "get next"); + + assert.sameValue(v.value, "next-value-1"); + assert.sameValue(v.done, false); + + assert.sameValue(log.length, 2, "log.length"); + + iter.return("return-arg-1").then(v => { + assert.sameValue(log[2].name, "get return"); + assert.sameValue(log[2].thisValue.name, "asyncIterator", "get return thisValue"); + + assert.sameValue(log[3].name, "call return"); + assert.sameValue(log[3].thisValue.name, "asyncIterator", "return thisValue"); + assert.sameValue(log[3].args.length, 1, "return args.length"); + assert.sameValue(log[3].args[0], "return-arg-1", "return args[0]"); + + assert.sameValue(log[4].name, "get return then (1)"); + assert.sameValue(log[4].thisValue.name, "return-promise-1", "get return then thisValue"); + + assert.sameValue(log[5].name, "call return then (1)"); + assert.sameValue(log[5].thisValue.name, "return-promise-1", "return then thisValue"); + assert.sameValue(log[5].args.length, 2, "return then args.length"); + assert.sameValue(typeof log[5].args[0], "function", "return then args[0]"); + assert.sameValue(typeof log[5].args[1], "function", "return then args[1]"); + + assert.sameValue(log[6].name, "get return done (1)"); + assert.sameValue(log[6].thisValue.name, "return-result-1", "get return done thisValue"); + + assert.sameValue(log[7].name, "get return value (1)"); + assert.sameValue(log[7].thisValue.name, "return-result-1", "get return value thisValue"); + + assert.sameValue(v.value, "return-value-1"); + assert.sameValue(v.done, false); + + assert.sameValue(log.length, 8, "log.length"); + + iter.return("return-arg-2").then(v => { + assert.sameValue(log[8].name, "get return"); + assert.sameValue(log[8].thisValue.name, "asyncIterator", "get return thisValue"); + + assert.sameValue(log[9].name, "call return"); + assert.sameValue(log[9].thisValue.name, "asyncIterator", "return thisValue"); + assert.sameValue(log[9].args.length, 1, "return args.length"); + assert.sameValue(log[9].args[0], "return-arg-2", "return args[0]"); + + assert.sameValue(log[10].name, "get return then (2)"); + assert.sameValue(log[10].thisValue.name, "return-promise-2", "get return then thisValue"); + + assert.sameValue(log[11].name, "call return then (2)"); + assert.sameValue(log[11].thisValue.name, "return-promise-2", "return then thisValue"); + assert.sameValue(log[11].args.length, 2, "return then args.length"); + assert.sameValue(typeof log[11].args[0], "function", "return then args[0]"); + assert.sameValue(typeof log[11].args[1], "function", "return then args[1]"); + + assert.sameValue(log[12].name, "get return done (2)"); + assert.sameValue(log[12].thisValue.name, "return-result-2", "get return done thisValue"); + + assert.sameValue(log[13].name, "get return value (2)"); + assert.sameValue(log[13].thisValue.name, "return-result-2", "get return value thisValue"); + + assert.sameValue(v.value, "return-value-2"); + assert.sameValue(v.done, true); + + assert.sameValue(log.length, 14, "log.length"); + }).then($DONE, $DONE); + }).catch($DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-async-throw.js b/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-async-throw.js new file mode 100644 index 0000000000..b7af5893bd --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-async-throw.js @@ -0,0 +1,250 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-async-throw.case +// - src/async-generators/default/async-class-decl-method.template +/*--- +description: execution order for yield* with async iterator and throw() (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration, Symbol.asyncIterator] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + ... + 6. Repeat + ... + b. Else if received.[[Type]] is throw, then + i. Let throw be ? GetMethod(iterator, "throw"). + ii. If throw is not undefined, then + 1. Let innerResult be ? Call(throw, iterator, « received.[[Value]] »). + 2. If generatorKind is async, then set innerResult to ? Await(innerResult). + ... + 5. Let done be ? IteratorComplete(innerResult). + 6. If done is true, then + a. Let resultValue be Return ? IteratorValue(innerResult). + b. If generatorKind is async, then set resultValue to ? Await(resultValue). + c. Return resultValue. + 7. If generatorKind is async, then let received be AsyncGeneratorYield(? IteratorValue(innerResult)). + ... + + AsyncGeneratorYield ( value ) + + ... + 8. Return ! AsyncGeneratorResolve(generator, value, false). + ... + +---*/ +var log = []; +var obj = { + [Symbol.asyncIterator]() { + var throwCount = 0; + return { + name: "asyncIterator", + get next() { + log.push({ name: "get next" }); + return function() { + return { + value: "next-value-1", + done: false + }; + }; + }, + get throw() { + log.push({ + name: "get throw", + thisValue: this + }); + return function() { + log.push({ + name: "call throw", + thisValue: this, + args: [...arguments] + }); + + throwCount++; + if (throwCount == 1) { + return { + name: "throw-promise-1", + get then() { + log.push({ + name: "get throw then (1)", + thisValue: this + }); + return function(resolve) { + log.push({ + name: "call throw then (1)", + thisValue: this, + args: [...arguments] + }); + + resolve({ + name: "throw-result-1", + get value() { + log.push({ + name: "get throw value (1)", + thisValue: this + }); + return "throw-value-1"; + }, + get done() { + log.push({ + name: "get throw done (1)", + thisValue: this + }); + return false; + } + }); + }; + } + }; + } + + return { + name: "throw-promise-2", + get then() { + log.push({ + name: "get throw then (2)", + thisValue: this + }); + return function(resolve) { + log.push({ + name: "call throw then (2)", + thisValue: this, + args: [...arguments] + }); + + resolve({ + name: "throw-result-2", + get value() { + log.push({ + name: "get throw value (2)", + thisValue: this + }); + return "throw-value-2"; + }, + get done() { + log.push({ + name: "get throw done (2)", + thisValue: this + }); + return true; + } + }); + }; + } + }; + }; + } + }; + } +}; + + + +var callCount = 0; + +class C { async *gen() { + callCount += 1; + log.push({ name: "before yield*" }); + var v = yield* obj; + log.push({ + name: "after yield*", + value: v + }); + return "return-value"; + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +assert.sameValue(log.length, 0, "log.length"); + +iter.next().then(v => { + assert.sameValue(log[0].name, "before yield*"); + + assert.sameValue(log[1].name, "get next"); + + assert.sameValue(v.value, "next-value-1"); + assert.sameValue(v.done, false); + + assert.sameValue(log.length, 2, "log.length"); + + iter.throw("throw-arg-1").then(v => { + assert.sameValue(log[2].name, "get throw"); + assert.sameValue(log[2].thisValue.name, "asyncIterator", "get throw thisValue"); + + assert.sameValue(log[3].name, "call throw"); + assert.sameValue(log[3].thisValue.name, "asyncIterator", "throw thisValue"); + assert.sameValue(log[3].args.length, 1, "throw args.length"); + assert.sameValue(log[3].args[0], "throw-arg-1", "throw args[0]"); + + assert.sameValue(log[4].name, "get throw then (1)"); + assert.sameValue(log[4].thisValue.name, "throw-promise-1", "get throw thisValue"); + + assert.sameValue(log[5].name, "call throw then (1)"); + assert.sameValue(log[5].thisValue.name, "throw-promise-1", "throw thisValue"); + assert.sameValue(log[5].args.length, 2, "throw then args.length"); + assert.sameValue(typeof log[5].args[0], "function", "throw then args[0]"); + assert.sameValue(typeof log[5].args[1], "function", "throw then args[1]"); + + assert.sameValue(log[6].name, "get throw done (1)"); + assert.sameValue(log[6].thisValue.name, "throw-result-1", "get throw done thisValue"); + + assert.sameValue(log[7].name, "get throw value (1)"); + assert.sameValue(log[7].thisValue.name, "throw-result-1", "get throw value thisValue"); + + assert.sameValue(v.value, "throw-value-1"); + assert.sameValue(v.done, false); + + assert.sameValue(log.length, 8, "log.length"); + + iter.throw("throw-arg-2").then(v => { + assert.sameValue(log[8].name, "get throw"); + assert.sameValue(log[8].thisValue.name, "asyncIterator", "get throw thisValue"); + + assert.sameValue(log[9].name, "call throw"); + assert.sameValue(log[9].thisValue.name, "asyncIterator", "throw thisValue"); + assert.sameValue(log[9].args.length, 1, "throw args.length"); + assert.sameValue(log[9].args[0], "throw-arg-2", "throw args[0]"); + + assert.sameValue(log[10].name, "get throw then (2)"); + assert.sameValue(log[10].thisValue.name, "throw-promise-2", "get throw thisValue"); + + assert.sameValue(log[11].name, "call throw then (2)"); + assert.sameValue(log[11].thisValue.name, "throw-promise-2", "throw thisValue"); + assert.sameValue(log[11].args.length, 2, "throw then args.length"); + assert.sameValue(typeof log[11].args[0], "function", "throw then args[0]"); + assert.sameValue(typeof log[11].args[1], "function", "throw then args[1]"); + + assert.sameValue(log[12].name, "get throw done (2)"); + assert.sameValue(log[12].thisValue.name, "throw-result-2", "get throw done thisValue"); + + assert.sameValue(log[13].name, "get throw value (2)"); + assert.sameValue(log[13].thisValue.name, "throw-result-2", "get throw value thisValue"); + + assert.sameValue(log[14].name, "after yield*"); + assert.sameValue(log[14].value, "throw-value-2"); + + assert.sameValue(v.value, "return-value"); + assert.sameValue(v.done, true); + + assert.sameValue(log.length, 15, "log.length"); + }).then($DONE, $DONE); + }).catch($DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-expr-abrupt.js b/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-expr-abrupt.js new file mode 100644 index 0000000000..9fa5fa10eb --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-expr-abrupt.js @@ -0,0 +1,61 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-expr-abrupt.case +// - src/async-generators/default/async-class-decl-method.template +/*--- +description: Abrupt completion while getting yield* operand (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + ... + +---*/ +var obj = {}; +var abrupt = function() { + throw obj; +}; + + + +var callCount = 0; + +class C { async *gen() { + callCount += 1; + yield* abrupt(); + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, obj, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-getiter-async-get-abrupt.js b/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-getiter-async-get-abrupt.js new file mode 100644 index 0000000000..e3e4865196 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-getiter-async-get-abrupt.js @@ -0,0 +1,81 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-get-abrupt.case +// - src/async-generators/default/async-class-decl-method.template +/*--- +description: Abrupt completion while getting [Symbol.asyncIterator] (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + get [Symbol.asyncIterator]() { + throw reason; + } +}; + + + +var callCount = 0; + +class C { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-getiter-async-not-callable-boolean-throw.js b/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-getiter-async-not-callable-boolean-throw.js new file mode 100644 index 0000000000..ee931b78bf --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-getiter-async-not-callable-boolean-throw.js @@ -0,0 +1,80 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-not-callable-boolean-throw.case +// - src/async-generators/default/async-class-decl-method.template +/*--- +description: Throws a TypeError on a non-callable [Symbol.asyncIterator] (boolean) (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + 3. If func is either undefined or null, return undefined. + 4. If IsCallable(func) is false, throw a TypeError exception. + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]: false +}; + + + +var callCount = 0; + +class C { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-getiter-async-not-callable-number-throw.js b/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-getiter-async-not-callable-number-throw.js new file mode 100644 index 0000000000..02cef73682 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-getiter-async-not-callable-number-throw.js @@ -0,0 +1,80 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-not-callable-number-throw.case +// - src/async-generators/default/async-class-decl-method.template +/*--- +description: Throws a TypeError on a non-callable [Symbol.asyncIterator] (number) (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + 3. If func is either undefined or null, return undefined. + 4. If IsCallable(func) is false, throw a TypeError exception. + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]: 0 +}; + + + +var callCount = 0; + +class C { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-getiter-async-not-callable-object-throw.js b/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-getiter-async-not-callable-object-throw.js new file mode 100644 index 0000000000..7394078578 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-getiter-async-not-callable-object-throw.js @@ -0,0 +1,80 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-not-callable-object-throw.case +// - src/async-generators/default/async-class-decl-method.template +/*--- +description: Throws a TypeError on a non-callable [Symbol.asyncIterator] (object) (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + 3. If func is either undefined or null, return undefined. + 4. If IsCallable(func) is false, throw a TypeError exception. + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]: {} +}; + + + +var callCount = 0; + +class C { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-getiter-async-not-callable-string-throw.js b/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-getiter-async-not-callable-string-throw.js new file mode 100644 index 0000000000..f672cfd0bc --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-getiter-async-not-callable-string-throw.js @@ -0,0 +1,80 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-not-callable-string-throw.case +// - src/async-generators/default/async-class-decl-method.template +/*--- +description: Throws a TypeError on a non-callable [Symbol.asyncIterator] (string) (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + 3. If func is either undefined or null, return undefined. + 4. If IsCallable(func) is false, throw a TypeError exception. + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]: '' +}; + + + +var callCount = 0; + +class C { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-getiter-async-not-callable-symbol-throw.js b/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-getiter-async-not-callable-symbol-throw.js new file mode 100644 index 0000000000..c0fd63751f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-getiter-async-not-callable-symbol-throw.js @@ -0,0 +1,80 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-not-callable-symbol-throw.case +// - src/async-generators/default/async-class-decl-method.template +/*--- +description: Throws a TypeError on a non-callable [Symbol.asyncIterator] (symbol) (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + 3. If func is either undefined or null, return undefined. + 4. If IsCallable(func) is false, throw a TypeError exception. + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]: Symbol.asyncIterator +}; + + + +var callCount = 0; + +class C { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-getiter-async-null-sync-get-abrupt.js b/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-getiter-async-null-sync-get-abrupt.js new file mode 100644 index 0000000000..87e5dd619b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-getiter-async-null-sync-get-abrupt.js @@ -0,0 +1,86 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-null-sync-get-abrupt.case +// - src/async-generators/default/async-class-decl-method.template +/*--- +description: Abrupt completion while getting @@iterator after null @@asyncIterator (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + b. If method is undefined, + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + ... + +---*/ +var calls = 0; +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw reason; + }, + get [Symbol.asyncIterator]() { + calls += 1; + return null; + } +}; + + + +var callCount = 0; + +class C { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, 'reject reason'); + assert.sameValue(calls, 1); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-getiter-async-returns-abrupt.js b/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-getiter-async-returns-abrupt.js new file mode 100644 index 0000000000..0ba984c4de --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-getiter-async-returns-abrupt.js @@ -0,0 +1,77 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-returns-abrupt.case +// - src/async-generators/default/async-class-decl-method.template +/*--- +description: Abrupt completion while calling [Symbol.asyncIterator] (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + 6. Let iterator be ? Call(method, obj). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + throw reason; + } +}; + + + +var callCount = 0; + +class C { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-getiter-async-returns-boolean-throw.js b/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-getiter-async-returns-boolean-throw.js new file mode 100644 index 0000000000..35f08fbfd5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-getiter-async-returns-boolean-throw.js @@ -0,0 +1,77 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-returns-boolean-throw.case +// - src/async-generators/default/async-class-decl-method.template +/*--- +description: Non object returned by [Symbol.asyncIterator]() - boolean (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + 6. Let iterator be ? Call(method, obj). + 7. If Type(iterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return true; + } +}; + + + +var callCount = 0; + +class C { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-getiter-async-returns-null-throw.js b/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-getiter-async-returns-null-throw.js new file mode 100644 index 0000000000..46e9d344df --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-getiter-async-returns-null-throw.js @@ -0,0 +1,77 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-returns-null-throw.case +// - src/async-generators/default/async-class-decl-method.template +/*--- +description: Non object returned by [Symbol.asyncIterator]() - null (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + 6. Let iterator be ? Call(method, obj). + 7. If Type(iterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return null; + } +}; + + + +var callCount = 0; + +class C { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-getiter-async-returns-number-throw.js b/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-getiter-async-returns-number-throw.js new file mode 100644 index 0000000000..a92c451abd --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-getiter-async-returns-number-throw.js @@ -0,0 +1,77 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-returns-number-throw.case +// - src/async-generators/default/async-class-decl-method.template +/*--- +description: Non object returned by [Symbol.asyncIterator]() - number (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + 6. Let iterator be ? Call(method, obj). + 7. If Type(iterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return 42; + } +}; + + + +var callCount = 0; + +class C { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-getiter-async-returns-string-throw.js b/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-getiter-async-returns-string-throw.js new file mode 100644 index 0000000000..f6ff86e9c3 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-getiter-async-returns-string-throw.js @@ -0,0 +1,77 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-returns-string-throw.case +// - src/async-generators/default/async-class-decl-method.template +/*--- +description: Non object returned by [Symbol.asyncIterator]() - string (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + 6. Let iterator be ? Call(method, obj). + 7. If Type(iterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return '42'; + } +}; + + + +var callCount = 0; + +class C { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-getiter-async-returns-symbol-throw.js b/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-getiter-async-returns-symbol-throw.js new file mode 100644 index 0000000000..6d3abc9a26 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-getiter-async-returns-symbol-throw.js @@ -0,0 +1,77 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-returns-symbol-throw.case +// - src/async-generators/default/async-class-decl-method.template +/*--- +description: Non object returned by [Symbol.asyncIterator]() - symbol (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + 6. Let iterator be ? Call(method, obj). + 7. If Type(iterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return Symbol.asyncIterator; + } +}; + + + +var callCount = 0; + +class C { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-getiter-async-returns-undefined-throw.js b/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-getiter-async-returns-undefined-throw.js new file mode 100644 index 0000000000..3f821ab7e7 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-getiter-async-returns-undefined-throw.js @@ -0,0 +1,77 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-returns-undefined-throw.case +// - src/async-generators/default/async-class-decl-method.template +/*--- +description: Non object returned by [Symbol.asyncIterator]() - undefined (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + 6. Let iterator be ? Call(method, obj). + 7. If Type(iterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return undefined; + } +}; + + + +var callCount = 0; + +class C { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-getiter-async-undefined-sync-get-abrupt.js b/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-getiter-async-undefined-sync-get-abrupt.js new file mode 100644 index 0000000000..39524b5304 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-getiter-async-undefined-sync-get-abrupt.js @@ -0,0 +1,86 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-undefined-sync-get-abrupt.case +// - src/async-generators/default/async-class-decl-method.template +/*--- +description: Abrupt completion while getting @@iterator after undefined @@asyncIterator (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + b. If method is undefined, + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + ... + +---*/ +var calls = 0; +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw reason; + }, + get [Symbol.asyncIterator]() { + calls += 1; + return undefined; + } +}; + + + +var callCount = 0; + +class C { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, 'reject reason'); + assert.sameValue(calls, 1); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-getiter-sync-get-abrupt.js b/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-getiter-sync-get-abrupt.js new file mode 100644 index 0000000000..d0b336e722 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-getiter-sync-get-abrupt.js @@ -0,0 +1,80 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-get-abrupt.case +// - src/async-generators/default/async-class-decl-method.template +/*--- +description: Abrupt completion while getting [Symbol.iterator] (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + b. If method is undefined, + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw reason; + } +}; + + + +var callCount = 0; + +class C { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-getiter-sync-not-callable-boolean-throw.js b/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-getiter-sync-not-callable-boolean-throw.js new file mode 100644 index 0000000000..6f44d3ee98 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-getiter-sync-not-callable-boolean-throw.js @@ -0,0 +1,79 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-not-callable-boolean-throw.case +// - src/async-generators/default/async-class-decl-method.template +/*--- +description: Throws a TypeError on a non-callable [Symbol.iterator] (boolean) (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + b. If method is undefined, + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + ... + 4. If IsCallable(func) is false, throw a TypeError exception. + ... + +---*/ +var obj = { + [Symbol.iterator]: false +}; + + + +var callCount = 0; + +class C { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-getiter-sync-not-callable-number-throw.js b/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-getiter-sync-not-callable-number-throw.js new file mode 100644 index 0000000000..3fb3df0fa8 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-getiter-sync-not-callable-number-throw.js @@ -0,0 +1,79 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-not-callable-number-throw.case +// - src/async-generators/default/async-class-decl-method.template +/*--- +description: Throws a TypeError on a non-callable [Symbol.iterator] (number) (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + b. If method is undefined, + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + ... + 4. If IsCallable(func) is false, throw a TypeError exception. + ... + +---*/ +var obj = { + [Symbol.iterator]: 0 +}; + + + +var callCount = 0; + +class C { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-getiter-sync-not-callable-object-throw.js b/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-getiter-sync-not-callable-object-throw.js new file mode 100644 index 0000000000..4dcf06dc35 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-getiter-sync-not-callable-object-throw.js @@ -0,0 +1,79 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-not-callable-object-throw.case +// - src/async-generators/default/async-class-decl-method.template +/*--- +description: Throws a TypeError on a non-callable [Symbol.iterator] (object) (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + b. If method is undefined, + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + ... + 4. If IsCallable(func) is false, throw a TypeError exception. + ... + +---*/ +var obj = { + [Symbol.iterator]: {} +}; + + + +var callCount = 0; + +class C { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-getiter-sync-not-callable-string-throw.js b/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-getiter-sync-not-callable-string-throw.js new file mode 100644 index 0000000000..ae77bebeaa --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-getiter-sync-not-callable-string-throw.js @@ -0,0 +1,79 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-not-callable-string-throw.case +// - src/async-generators/default/async-class-decl-method.template +/*--- +description: Throws a TypeError on a non-callable [Symbol.iterator] (string) (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + b. If method is undefined, + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + ... + 4. If IsCallable(func) is false, throw a TypeError exception. + ... + +---*/ +var obj = { + [Symbol.iterator]: '' +}; + + + +var callCount = 0; + +class C { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-getiter-sync-not-callable-symbol-throw.js b/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-getiter-sync-not-callable-symbol-throw.js new file mode 100644 index 0000000000..af6649ac1c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-getiter-sync-not-callable-symbol-throw.js @@ -0,0 +1,79 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-not-callable-symbol-throw.case +// - src/async-generators/default/async-class-decl-method.template +/*--- +description: Throws a TypeError on a non-callable [Symbol.iterator] (symbol) (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + b. If method is undefined, + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + ... + 4. If IsCallable(func) is false, throw a TypeError exception. + ... + +---*/ +var obj = { + [Symbol.iterator]: Symbol.iterator +}; + + + +var callCount = 0; + +class C { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-getiter-sync-returns-abrupt.js b/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-getiter-sync-returns-abrupt.js new file mode 100644 index 0000000000..c7c1894a08 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-getiter-sync-returns-abrupt.js @@ -0,0 +1,74 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-returns-abrupt.case +// - src/async-generators/default/async-class-decl-method.template +/*--- +description: Abrupt completion while calling [Symbol.iterator] (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ii. Let syncIterator be ? Call(syncMethod, obj). + ... + +---*/ +var reason = {}; +var obj = { + [Symbol.iterator]() { + throw reason; + } +}; + + + +var callCount = 0; + +class C { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-getiter-sync-returns-boolean-throw.js b/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-getiter-sync-returns-boolean-throw.js new file mode 100644 index 0000000000..116f08fe59 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-getiter-sync-returns-boolean-throw.js @@ -0,0 +1,79 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-returns-boolean-throw.case +// - src/async-generators/default/async-class-decl-method.template +/*--- +description: Non object returned by [Symbol.iterator]() - boolean (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ii. Let syncIterator be ? Call(syncMethod, obj). + iii. Return ? CreateAsyncFromSyncIterator(syncIterator). + ... + + CreateAsyncFromSyncIterator(syncIterator) + + 1. If Type(syncIterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + [Symbol.iterator]() { + return true; + } +}; + + + +var callCount = 0; + +class C { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-getiter-sync-returns-null-throw.js b/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-getiter-sync-returns-null-throw.js new file mode 100644 index 0000000000..7471f6b535 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-getiter-sync-returns-null-throw.js @@ -0,0 +1,79 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-returns-null-throw.case +// - src/async-generators/default/async-class-decl-method.template +/*--- +description: Non object returned by [Symbol.iterator]() - null (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ii. Let syncIterator be ? Call(syncMethod, obj). + iii. Return ? CreateAsyncFromSyncIterator(syncIterator). + ... + + CreateAsyncFromSyncIterator(syncIterator) + + 1. If Type(syncIterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + [Symbol.iterator]() { + return null; + } +}; + + + +var callCount = 0; + +class C { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-getiter-sync-returns-number-throw.js b/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-getiter-sync-returns-number-throw.js new file mode 100644 index 0000000000..cf39a2c8c4 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-getiter-sync-returns-number-throw.js @@ -0,0 +1,79 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-returns-number-throw.case +// - src/async-generators/default/async-class-decl-method.template +/*--- +description: Non object returned by [Symbol.iterator]() - number (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ii. Let syncIterator be ? Call(syncMethod, obj). + iii. Return ? CreateAsyncFromSyncIterator(syncIterator). + ... + + CreateAsyncFromSyncIterator(syncIterator) + + 1. If Type(syncIterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + [Symbol.iterator]() { + return 0; + } +}; + + + +var callCount = 0; + +class C { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-getiter-sync-returns-string-throw.js b/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-getiter-sync-returns-string-throw.js new file mode 100644 index 0000000000..5bd0727fef --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-getiter-sync-returns-string-throw.js @@ -0,0 +1,79 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-returns-string-throw.case +// - src/async-generators/default/async-class-decl-method.template +/*--- +description: Non object returned by [Symbol.iterator]() - string (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ii. Let syncIterator be ? Call(syncMethod, obj). + iii. Return ? CreateAsyncFromSyncIterator(syncIterator). + ... + + CreateAsyncFromSyncIterator(syncIterator) + + 1. If Type(syncIterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + [Symbol.iterator]() { + return ''; + } +}; + + + +var callCount = 0; + +class C { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-getiter-sync-returns-symbol-throw.js b/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-getiter-sync-returns-symbol-throw.js new file mode 100644 index 0000000000..9943d01a31 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-getiter-sync-returns-symbol-throw.js @@ -0,0 +1,79 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-returns-symbol-throw.case +// - src/async-generators/default/async-class-decl-method.template +/*--- +description: Non object returned by [Symbol.iterator]() - symbol (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ii. Let syncIterator be ? Call(syncMethod, obj). + iii. Return ? CreateAsyncFromSyncIterator(syncIterator). + ... + + CreateAsyncFromSyncIterator(syncIterator) + + 1. If Type(syncIterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + [Symbol.iterator]() { + return Symbol.iterator; + } +}; + + + +var callCount = 0; + +class C { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-getiter-sync-returns-undefined-throw.js b/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-getiter-sync-returns-undefined-throw.js new file mode 100644 index 0000000000..316be8f17e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-getiter-sync-returns-undefined-throw.js @@ -0,0 +1,79 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-returns-undefined-throw.case +// - src/async-generators/default/async-class-decl-method.template +/*--- +description: Non object returned by [Symbol.iterator]() - undefined (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ii. Let syncIterator be ? Call(syncMethod, obj). + iii. Return ? CreateAsyncFromSyncIterator(syncIterator). + ... + + CreateAsyncFromSyncIterator(syncIterator) + + 1. If Type(syncIterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + [Symbol.iterator]() { + return undefined; + } +}; + + + +var callCount = 0; + +class C { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-next-call-done-get-abrupt.js b/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-next-call-done-get-abrupt.js new file mode 100644 index 0000000000..c3789c2873 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-next-call-done-get-abrupt.js @@ -0,0 +1,80 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-call-done-get-abrupt.case +// - src/async-generators/default/async-class-decl-method.template +/*--- +description: Abrupt completion while getting done (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + v. Let done be ? IteratorComplete(innerResult). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + get done() { + throw reason; + } + }; + } + }; + } +}; + + + +var callCount = 0; + +class C { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-next-call-returns-abrupt.js b/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-next-call-returns-abrupt.js new file mode 100644 index 0000000000..5018bbb2be --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-next-call-returns-abrupt.js @@ -0,0 +1,72 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-call-returns-abrupt.case +// - src/async-generators/default/async-class-decl-method.template +/*--- +description: Abrupt completion while calling next (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + throw reason; + } + }; + } +}; + + + +var callCount = 0; + +class C { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-next-call-value-get-abrupt.js b/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-next-call-value-get-abrupt.js new file mode 100644 index 0000000000..e5c8b1b039 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-next-call-value-get-abrupt.js @@ -0,0 +1,82 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-call-value-get-abrupt.case +// - src/async-generators/default/async-class-decl-method.template +/*--- +description: Abrupt completion while getting value (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + vi. If done is true, then + 1. Return ? IteratorValue(innerResult). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + done: true, + get value() { + throw reason; + } + }; + } + }; + } +}; + + + +var callCount = 0; + +class C { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-next-get-abrupt.js b/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-next-get-abrupt.js new file mode 100644 index 0000000000..2fb2a77100 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-next-get-abrupt.js @@ -0,0 +1,72 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-get-abrupt.case +// - src/async-generators/default/async-class-decl-method.template +/*--- +description: Abrupt completion while getting next (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + get next() { + throw reason; + } + }; + } +}; + + + +var callCount = 0; + +class C { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-next-non-object-ignores-then.js b/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-next-non-object-ignores-then.js new file mode 100644 index 0000000000..0e47083f23 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-next-non-object-ignores-then.js @@ -0,0 +1,92 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-non-object-ignores-then.case +// - src/async-generators/default/async-class-decl-method.template +/*--- +description: If next() value is not-object, do not access respective then property (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + +---*/ +Number.prototype.then = function() { + throw new Test262Error('Number#then should not be used'); +}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return 42; + } + }; + } +}; + + + +var callCount = 0; + +class C { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, 'TypeError'); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-next-not-callable-boolean-throw.js b/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-next-not-callable-boolean-throw.js new file mode 100644 index 0000000000..40dfa0aa49 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-next-not-callable-boolean-throw.js @@ -0,0 +1,69 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-boolean-throw.case +// - src/async-generators/default/async-class-decl-method.template +/*--- +description: Not-callable next value in a yield star position - boolean (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: true + }; + } +}; + + + +var callCount = 0; + +class C { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-next-not-callable-null-throw.js b/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-next-not-callable-null-throw.js new file mode 100644 index 0000000000..f24943e9ca --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-next-not-callable-null-throw.js @@ -0,0 +1,69 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-null-throw.case +// - src/async-generators/default/async-class-decl-method.template +/*--- +description: Not-callable next value in a yield star position - null (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: null + }; + } +}; + + + +var callCount = 0; + +class C { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-next-not-callable-number-throw.js b/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-next-not-callable-number-throw.js new file mode 100644 index 0000000000..64a27fae1e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-next-not-callable-number-throw.js @@ -0,0 +1,69 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-number-throw.case +// - src/async-generators/default/async-class-decl-method.template +/*--- +description: Not-callable next value in a yield star position - number (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: 42 + }; + } +}; + + + +var callCount = 0; + +class C { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-next-not-callable-object-throw.js b/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-next-not-callable-object-throw.js new file mode 100644 index 0000000000..a1ef33d2bf --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-next-not-callable-object-throw.js @@ -0,0 +1,69 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-object-throw.case +// - src/async-generators/default/async-class-decl-method.template +/*--- +description: Not-callable next value in a yield star position - object (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: {} + }; + } +}; + + + +var callCount = 0; + +class C { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-next-not-callable-string-throw.js b/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-next-not-callable-string-throw.js new file mode 100644 index 0000000000..be3c40ec57 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-next-not-callable-string-throw.js @@ -0,0 +1,69 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-string-throw.case +// - src/async-generators/default/async-class-decl-method.template +/*--- +description: Not-callable next value in a yield star position - string (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: '' + }; + } +}; + + + +var callCount = 0; + +class C { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-next-not-callable-symbol-throw.js b/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-next-not-callable-symbol-throw.js new file mode 100644 index 0000000000..8d5c129490 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-next-not-callable-symbol-throw.js @@ -0,0 +1,69 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-symbol-throw.case +// - src/async-generators/default/async-class-decl-method.template +/*--- +description: Not-callable next value in a yield star position - symbol (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: Symbol('oi') + }; + } +}; + + + +var callCount = 0; + +class C { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-next-not-callable-undefined-throw.js b/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-next-not-callable-undefined-throw.js new file mode 100644 index 0000000000..0a755d6f73 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-next-not-callable-undefined-throw.js @@ -0,0 +1,69 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-undefined-throw.case +// - src/async-generators/default/async-class-decl-method.template +/*--- +description: Not-callable next value in a yield star position - undefined (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: undefined + }; + } +}; + + + +var callCount = 0; + +class C { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-next-then-get-abrupt.js b/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-next-then-get-abrupt.js new file mode 100644 index 0000000000..c233ce580a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-next-then-get-abrupt.js @@ -0,0 +1,96 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-get-abrupt.case +// - src/async-generators/default/async-class-decl-method.template +/*--- +description: Return abrupt after getting next().then (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 8. Let then be Get(resolution, "then"). + ... + 10. Get thenAction be then.[[Value]]. + ... + 12. Perform EnqueueJob("PromiseJobs", PromiseResolveThenableJob, « promise, + resolution, thenAction »). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + get then() { + throw reason; + } + }; + } + }; + } +}; + + + +var callCount = 0; + +class C { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, 'reject reason'); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-next-then-non-callable-boolean-fulfillpromise.js b/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-next-then-non-callable-boolean-fulfillpromise.js new file mode 100644 index 0000000000..d9086dcba6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-next-then-non-callable-boolean-fulfillpromise.js @@ -0,0 +1,90 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-boolean-fulfillpromise.case +// - src/async-generators/default/async-class-decl-method.template +/*--- +description: FulfillPromise if next().then is not-callable (boolean) (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: true, + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +class C { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-next-then-non-callable-null-fulfillpromise.js b/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-next-then-non-callable-null-fulfillpromise.js new file mode 100644 index 0000000000..e1fa7fde10 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-next-then-non-callable-null-fulfillpromise.js @@ -0,0 +1,90 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-null-fulfillpromise.case +// - src/async-generators/default/async-class-decl-method.template +/*--- +description: FulfillPromise if next().then is not-callable (null) (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: null, + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +class C { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-next-then-non-callable-number-fulfillpromise.js b/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-next-then-non-callable-number-fulfillpromise.js new file mode 100644 index 0000000000..c1d0811a23 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-next-then-non-callable-number-fulfillpromise.js @@ -0,0 +1,90 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-number-fulfillpromise.case +// - src/async-generators/default/async-class-decl-method.template +/*--- +description: FulfillPromise if next().then is not-callable (number) (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: 39, + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +class C { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-next-then-non-callable-object-fulfillpromise.js b/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-next-then-non-callable-object-fulfillpromise.js new file mode 100644 index 0000000000..71d346bc80 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-next-then-non-callable-object-fulfillpromise.js @@ -0,0 +1,90 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-object-fulfillpromise.case +// - src/async-generators/default/async-class-decl-method.template +/*--- +description: FulfillPromise if next().then is not-callable (object) (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: {}, + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +class C { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-next-then-non-callable-string-fulfillpromise.js b/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-next-then-non-callable-string-fulfillpromise.js new file mode 100644 index 0000000000..d957d8af7b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-next-then-non-callable-string-fulfillpromise.js @@ -0,0 +1,90 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-string-fulfillpromise.case +// - src/async-generators/default/async-class-decl-method.template +/*--- +description: FulfillPromise if next().then is not-callable (string) (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: '', + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +class C { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-next-then-non-callable-symbol-fulfillpromise.js b/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-next-then-non-callable-symbol-fulfillpromise.js new file mode 100644 index 0000000000..339c5f09f3 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-next-then-non-callable-symbol-fulfillpromise.js @@ -0,0 +1,90 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-symbol-fulfillpromise.case +// - src/async-generators/default/async-class-decl-method.template +/*--- +description: FulfillPromise if next().then is not-callable (symbol) (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: Symbol('oi'), + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +class C { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-next-then-non-callable-undefined-fulfillpromise.js b/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-next-then-non-callable-undefined-fulfillpromise.js new file mode 100644 index 0000000000..4153342a2f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-next-then-non-callable-undefined-fulfillpromise.js @@ -0,0 +1,90 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-undefined-fulfillpromise.case +// - src/async-generators/default/async-class-decl-method.template +/*--- +description: FulfillPromise if next().then is not-callable (undefined) (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: undefined, + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +class C { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-next-then-returns-abrupt.js b/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-next-then-returns-abrupt.js new file mode 100644 index 0000000000..a8c6fa6699 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-next-then-returns-abrupt.js @@ -0,0 +1,96 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-returns-abrupt.case +// - src/async-generators/default/async-class-decl-method.template +/*--- +description: Return abrupt after calling next().then (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 8. Let then be Get(resolution, "then"). + ... + 10. Get thenAction be then.[[Value]]. + ... + 12. Perform EnqueueJob("PromiseJobs", PromiseResolveThenableJob, « promise, + resolution, thenAction »). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then() { + throw reason; + } + }; + } + }; + } +}; + + + +var callCount = 0; + +class C { async *gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, 'reject reason'); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-sync-next.js b/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-sync-next.js new file mode 100644 index 0000000000..8f5fc9702e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-sync-next.js @@ -0,0 +1,229 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-sync-next.case +// - src/async-generators/default/async-class-decl-method.template +/*--- +description: execution order for yield* with sync iterator and next() (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, async-iteration, Symbol.asyncIterator] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + ... + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + 5. Let received be NormalCompletion(undefined). + 6. Repeat + a. If received.[[Type]] is normal, then + i. Let innerResult be ? IteratorNext(iterator, received.[[Value]]). + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + v. Let done be ? IteratorComplete(innerResult). + vi. If done is true, then + 1. Return ? IteratorValue(innerResult). + vii. Let received be GeneratorYield(innerResult). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + b. If method is undefined, + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ii. Let syncIterator be ? Call(syncMethod, obj). + iii. Return ? CreateAsyncFromSyncIterator(syncIterator). + ... + + %AsyncFromSyncIteratorPrototype%.next ( value ) + + ... + 5. Let nextResult be IteratorNext(syncIterator, value). + ... + 7. Let nextValue be IteratorValue(nextResult). + ... + 9. Let nextDone be IteratorComplete(nextResult). + ... + 12. Perform ! Call(valueWrapperCapability.[[Resolve]], undefined, + « nextValue »). + ... + 14. Set onFulfilled.[[Done]] to nextDone. + 15. Perform ! PerformPromiseThen(valueWrapperCapability.[[Promise]], + onFulfilled, undefined, promiseCapability). + ... + + Async Iterator Value Unwrap Functions + + 1. Return ! CreateIterResultObject(value, F.[[Done]]). + +---*/ +var log = []; +var obj = { + get [Symbol.iterator]() { + log.push({ + name: "get [Symbol.iterator]", + thisValue: this + }); + return function() { + log.push({ + name: "call [Symbol.iterator]", + thisValue: this, + args: [...arguments] + }); + var nextCount = 0; + return { + name: "syncIterator", + get next() { + log.push({ + name: "get next", + thisValue: this + }); + return function() { + log.push({ + name: "call next", + thisValue: this, + args: [...arguments] + }); + + nextCount++; + if (nextCount == 1) { + return { + name: "next-result-1", + get value() { + log.push({ + name: "get next value (1)", + thisValue: this + }); + return "next-value-1"; + }, + get done() { + log.push({ + name: "get next done (1)", + thisValue: this + }); + return false; + } + }; + } + + return { + name: "next-result-2", + get value() { + log.push({ + name: "get next value (2)", + thisValue: this + }); + return "next-value-2"; + }, + get done() { + log.push({ + name: "get next done (2)", + thisValue: this + }); + return true; + } + }; + }; + } + }; + }; + }, + get [Symbol.asyncIterator]() { + log.push({ name: "get [Symbol.asyncIterator]" }); + return null; + } +}; + + + +var callCount = 0; + +class C { async *gen() { + callCount += 1; + log.push({ name: "before yield*" }); + var v = yield* obj; + log.push({ + name: "after yield*", + value: v + }); + return "return-value"; + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +assert.sameValue(log.length, 0, "log.length"); + +iter.next("next-arg-1").then(v => { + assert.sameValue(log[0].name, "before yield*"); + + assert.sameValue(log[1].name, "get [Symbol.asyncIterator]"); + + assert.sameValue(log[2].name, "get [Symbol.iterator]"); + assert.sameValue(log[2].thisValue, obj, "get [Symbol.iterator] thisValue"); + + assert.sameValue(log[3].name, "call [Symbol.iterator]"); + assert.sameValue(log[3].thisValue, obj, "[Symbol.iterator] thisValue"); + assert.sameValue(log[3].args.length, 0, "[Symbol.iterator] args.length"); + + assert.sameValue(log[4].name, "get next"); + assert.sameValue(log[4].thisValue.name, "syncIterator", "get next thisValue"); + + assert.sameValue(log[5].name, "call next"); + assert.sameValue(log[5].thisValue.name, "syncIterator", "next thisValue"); + assert.sameValue(log[5].args.length, 1, "next args.length"); + assert.sameValue(log[5].args[0], undefined, "next args[0]"); + + assert.sameValue(log[6].name, "get next done (1)"); + assert.sameValue(log[6].thisValue.name, "next-result-1", "get next done thisValue"); + + assert.sameValue(log[7].name, "get next value (1)"); + assert.sameValue(log[7].thisValue.name, "next-result-1", "get next value thisValue"); + + assert.sameValue(v.value, "next-value-1"); + assert.sameValue(v.done, false); + + assert.sameValue(log.length, 8, "log.length"); + + iter.next("next-arg-2").then(v => { + assert.sameValue(log[8].name, "call next"); + assert.sameValue(log[8].thisValue.name, "syncIterator", "next thisValue"); + assert.sameValue(log[8].args.length, 1, "next args.length"); + assert.sameValue(log[8].args[0], "next-arg-2", "next args[0]"); + + assert.sameValue(log[9].name, "get next done (2)"); + assert.sameValue(log[9].thisValue.name, "next-result-2", "get next done thisValue"); + + assert.sameValue(log[10].name, "get next value (2)"); + assert.sameValue(log[10].thisValue.name, "next-result-2", "get next value thisValue"); + + assert.sameValue(log[11].name, "after yield*"); + assert.sameValue(log[11].value, "next-value-2"); + + assert.sameValue(v.value, "return-value"); + assert.sameValue(v.done, true); + + assert.sameValue(log.length, 12, "log.length"); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-sync-return.js b/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-sync-return.js new file mode 100644 index 0000000000..707b4d6f5a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-sync-return.js @@ -0,0 +1,204 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-sync-return.case +// - src/async-generators/default/async-class-decl-method.template +/*--- +description: execution order for yield* with sync iterator and return() (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, async-iteration, Symbol.asyncIterator] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + ... + 6. Repeat + ... + c. Else, + i. Assert: received.[[Type]] is return. + ii. Let return be ? GetMethod(iterator, "return"). + iii. If return is undefined, return Completion(received). + iv. Let innerReturnResult be ? Call(return, iterator, + « received.[[Value]] »). + v. If generatorKind is async, then set innerReturnResult to + ? Await(innerReturnResult). + ... + vii. Let done be ? IteratorComplete(innerReturnResult). + viii. If done is true, then + 1. Let value be ? IteratorValue(innerReturnResult). + 2. Return Completion{[[Type]]: return, [[Value]]: value, + [[Target]]: empty}. + ix. Let received be GeneratorYield(innerResult). + + %AsyncFromSyncIteratorPrototype%.return ( value ) + + 5. Let return be GetMethod(syncIterator, "return"). + ... + ... + 8. Let returnResult be Call(return, syncIterator, « value »). + ... + 11. Let returnValue be IteratorValue(returnResult). + .. + 13. Let returnDone be IteratorComplete(returnResult). + ... + 16. Perform ! Call(valueWrapperCapability.[[Resolve]], undefined, « returnValue »). + ... + 18. Set onFulfilled.[[Done]] to returnDone. + 19. Perform ! PerformPromiseThen(valueWrapperCapability.[[Promise]], + onFulfilled, undefined, promiseCapability). + ... + +---*/ +var log = []; +var obj = { + [Symbol.iterator]() { + var returnCount = 0; + return { + name: "syncIterator", + get next() { + log.push({ name: "get next" }); + return function() { + return { + value: "next-value-1", + done: false + }; + }; + }, + get return() { + log.push({ + name: "get return", + thisValue: this + }); + return function() { + log.push({ + name: "call return", + thisValue: this, + args: [...arguments] + }); + + returnCount++; + if (returnCount == 1) { + return { + name: "return-result-1", + get value() { + log.push({ + name: "get return value (1)", + thisValue: this + }); + return "return-value-1"; + }, + get done() { + log.push({ + name: "get return done (1)", + thisValue: this + }); + return false; + } + }; + } + + return { + name: "return-result-2", + get value() { + log.push({ + name: "get return value (2)", + thisValue: this + }); + return "return-value-2"; + }, + get done() { + log.push({ + name: "get return done (2)", + thisValue: this + }); + return true; + } + }; + }; + } + }; + } +}; + + + +var callCount = 0; + +class C { async *gen() { + callCount += 1; + log.push({ name: "before yield*" }); + yield* obj; + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +assert.sameValue(log.length, 0, "log.length"); + +iter.next().then(v => { + assert.sameValue(log[0].name, "before yield*"); + + assert.sameValue(log[1].name, "get next"); + + assert.sameValue(v.value, "next-value-1"); + assert.sameValue(v.done, false); + + assert.sameValue(log.length, 2, "log.length"); + + iter.return("return-arg-1").then(v => { + assert.sameValue(log[2].name, "get return"); + assert.sameValue(log[2].thisValue.name, "syncIterator", "get return thisValue"); + + assert.sameValue(log[3].name, "call return"); + assert.sameValue(log[3].thisValue.name, "syncIterator", "return thisValue"); + assert.sameValue(log[3].args.length, 1, "return args.length"); + assert.sameValue(log[3].args[0], "return-arg-1", "return args[0]"); + + assert.sameValue(log[4].name, "get return done (1)"); + assert.sameValue(log[4].thisValue.name, "return-result-1", "get return done thisValue"); + + assert.sameValue(log[5].name, "get return value (1)"); + assert.sameValue(log[5].thisValue.name, "return-result-1", "get return value thisValue"); + + assert.sameValue(v.value, "return-value-1"); + assert.sameValue(v.done, false); + + assert.sameValue(log.length, 6, "log.length"); + + iter.return().then(v => { + assert.sameValue(log[6].name, "get return"); + assert.sameValue(log[6].thisValue.name, "syncIterator", "get return thisValue"); + + assert.sameValue(log[7].name, "call return"); + assert.sameValue(log[7].thisValue.name, "syncIterator", "get return thisValue"); + assert.sameValue(log[7].args.length, 1, "return args.length"); + assert.sameValue(log[7].args[0], undefined, "return args[0]"); + + assert.sameValue(log[8].name, "get return done (2)"); + assert.sameValue(log[8].thisValue.name, "return-result-2", "get return done thisValue"); + + assert.sameValue(log[9].name, "get return value (2)"); + assert.sameValue(log[9].thisValue.name, "return-result-2", "get return value thisValue"); + + assert.sameValue(v.value, "return-value-2"); + assert.sameValue(v.done, true); + + assert.sameValue(log.length, 10, "log.length"); + }).then($DONE, $DONE); + }).catch($DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-sync-throw.js b/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-sync-throw.js new file mode 100644 index 0000000000..4721201d4d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-gen-method/yield-star-sync-throw.js @@ -0,0 +1,210 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-sync-throw.case +// - src/async-generators/default/async-class-decl-method.template +/*--- +description: execution order for yield* with sync iterator and throw() (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [Symbol.iterator, async-iteration] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + ... + 6. Repeat + ... + b. Else if received.[[Type]] is throw, then + i. Let throw be ? GetMethod(iterator, "throw"). + ii. If throw is not undefined, then + 1. Let innerResult be ? Call(throw, iterator, « received.[[Value]] »). + 2. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + 5. Let done be ? IteratorComplete(innerResult). + 6. If done is true, then + a. Return ? IteratorValue(innerResult). + 7. Let received be GeneratorYield(innerResult). + ... + + %AsyncFromSyncIteratorPrototype%.throw ( value ) + + ... + 5. Let throw be GetMethod(syncIterator, "throw"). + ... + 8. Let throwResult be Call(throw, syncIterator, « value »). + ... + 11. Let throwValue be IteratorValue(throwResult). + ... + 13. Let throwDone be IteratorComplete(throwResult). + ... + 16. Perform ! Call(valueWrapperCapability.[[Resolve]], undefined, + « throwValue »). + ... + 18. Set onFulfilled.[[Done]] to throwDone. + 19. Perform ! PerformPromiseThen(valueWrapperCapability.[[Promise]], + onFulfilled, undefined, promiseCapability). + ... + +---*/ +var log = []; +var obj = { + [Symbol.iterator]() { + var throwCount = 0; + return { + name: "syncIterator", + get next() { + log.push({ name: "get next" }); + return function() { + return { + value: "next-value-1", + done: false + }; + }; + }, + get throw() { + log.push({ + name: "get throw", + thisValue: this + }); + return function() { + log.push({ + name: "call throw", + thisValue: this, + args: [...arguments] + }); + + throwCount++; + if (throwCount == 1) { + return { + name: "throw-result-1", + get value() { + log.push({ + name: "get throw value (1)", + thisValue: this + }); + return "throw-value-1"; + }, + get done() { + log.push({ + name: "get throw done (1)", + thisValue: this + }); + return false; + } + }; + } + + return { + name: "throw-result-2", + get value() { + log.push({ + name: "get throw value (2)", + thisValue: this + }); + return "throw-value-2"; + }, + get done() { + log.push({ + name: "get throw done (2)", + thisValue: this + }); + return true; + } + }; + }; + } + }; + } +}; + + + +var callCount = 0; + +class C { async *gen() { + callCount += 1; + log.push({ name: "before yield*" }); + var v = yield* obj; + log.push({ + name: "after yield*", + value: v + }); + return "return-value"; + +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +assert.sameValue(log.length, 0, "log.length"); + +iter.next().then(v => { + assert.sameValue(log[0].name, "before yield*"); + + assert.sameValue(log[1].name, "get next"); + + assert.sameValue(v.value, "next-value-1"); + assert.sameValue(v.done, false); + + assert.sameValue(log.length, 2, "log.length"); + + iter.throw("throw-arg-1").then(v => { + assert.sameValue(log[2].name, "get throw"); + assert.sameValue(log[2].thisValue.name, "syncIterator", "get throw thisValue"); + + assert.sameValue(log[3].name, "call throw"); + assert.sameValue(log[3].thisValue.name, "syncIterator", "throw thisValue"); + assert.sameValue(log[3].args.length, 1, "throw args.length"); + assert.sameValue(log[3].args[0], "throw-arg-1", "throw args[0]"); + + assert.sameValue(log[4].name, "get throw done (1)"); + assert.sameValue(log[4].thisValue.name, "throw-result-1", "get throw done thisValue"); + + assert.sameValue(log[5].name, "get throw value (1)"); + assert.sameValue(log[5].thisValue.name, "throw-result-1", "get throw value thisValue"); + + assert.sameValue(v.value, "throw-value-1"); + assert.sameValue(v.done, false); + + assert.sameValue(log.length, 6, "log.length"); + + iter.throw().then(v => { + assert.sameValue(log[6].name, "get throw"); + assert.sameValue(log[6].thisValue.name, "syncIterator", "get throw thisValue"); + + assert.sameValue(log[7].name, "call throw"); + assert.sameValue(log[7].thisValue.name, "syncIterator", "throw thisValue"); + assert.sameValue(log[7].args.length, 1, "throw args.length"); + assert.sameValue(log[7].args[0], undefined, "throw args[0]"); + + assert.sameValue(log[8].name, "get throw done (2)"); + assert.sameValue(log[8].thisValue.name, "throw-result-2", "get throw done thisValue"); + + assert.sameValue(log[9].name, "get throw value (2)"); + assert.sameValue(log[9].thisValue.name, "throw-result-2", "get throw value thisValue"); + + assert.sameValue(log[10].name, "after yield*"); + assert.sameValue(log[10].value, "throw-value-2"); + + assert.sameValue(v.value, "return-value"); + assert.sameValue(v.done, true); + + assert.sameValue(log.length, 11, "log.length"); + }).then($DONE, $DONE); + }).catch($DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/async-meth-escaped-async.js b/js/src/tests/test262/language/statements/class/async-meth-escaped-async.js new file mode 100644 index 0000000000..55b5bc1790 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-meth-escaped-async.js @@ -0,0 +1,27 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-grammar-notation +description: > + The `async` contextual keyword must not contain Unicode escape sequences. +info: | + Terminal symbols are shown + in fixed width font, both in the productions of the grammars and throughout this + specification whenever the text directly refers to such a terminal symbol. These + are to appear in a script exactly as written. All terminal symbol code points + specified in this way are to be understood as the appropriate Unicode code points + from the Basic Latin range, as opposed to any similar-looking code points from + other Unicode ranges. +negative: + phase: parse + type: SyntaxError +features: [async-functions] +---*/ + +$DONOTEVALUATE(); + +class C { + \u0061sync m(){} +}; diff --git a/js/src/tests/test262/language/statements/class/async-method-static/array-destructuring-param-strict-body.js b/js/src/tests/test262/language/statements/class/async-method-static/array-destructuring-param-strict-body.js new file mode 100644 index 0000000000..3f3fcca036 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-method-static/array-destructuring-param-strict-body.js @@ -0,0 +1,135 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/function-forms/array-destructuring-param-strict-body.case +// - src/function-forms/syntax/cls-decl-async-meth-static.template +/*--- +description: ArrayBindingPattern and Use Strict Directive are not allowed to coexist for the same function. (static class declaration async method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [rest-parameters] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncMethod : async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncMethod is strict mode code, let strict be true. Otherwise + let strict be false. + 4. Let scope be the LexicalEnvironment of the running execution context. + 5. Let closure be ! AsyncFunctionCreate(Method, UniqueFormalParameters, AsyncFunctionBody, + scope, strict). + [...] + + 13.3.3.4 Static Semantics: IsSimpleParameterList + + BindingElement : BindingPattern + + 1. Return false. + + 14.1.2 Static Semantics: Early Errors + + FunctionDeclaration : function BindingIdentifier ( FormalParameters ) { FunctionBody } + FunctionDeclaration : function ( FormalParameters ) { FunctionBody } + FunctionExpression : function BindingIdentifier ( FormalParameters ) { FunctionBody } + + - It is a Syntax Error if ContainsUseStrict of FunctionBody is true and + IsSimpleParameterList of FormalParameters is false. + + 14.2.1 Static Semantics: Early Errors + + ArrowFunction : ArrowParameters => ConciseBody + + - It is a Syntax Error if ContainsUseStrict of ConciseBody is true and + IsSimpleParameterList of ArrowParameters is false. + + 14.3.1 Static Semantics: Early Errors + + MethodDefinition : PropertyName ( UniqueFormalParameters ) { FunctionBody } + + - It is a Syntax Error if ContainsUseStrict of FunctionBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + MethodDefinition : set PropertyName ( PropertySetParameterList ) { FunctionBody } + + - It is a Syntax Error if ContainsUseStrict of FunctionBody is true and + IsSimpleParameterList of PropertySetParameterList is false. + + 14.4.1 Static Semantics: Early Errors + + GeneratorMethod : * PropertyName ( UniqueFormalParameters ) { GeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of GeneratorBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + GeneratorDeclaration : function * BindingIdentifier ( FormalParameters ) { GeneratorBody } + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + GeneratorExpression : function * BindingIdentifier ( FormalParameters ) { GeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of GeneratorBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + 14.5.1 Static Semantics: Early Errors + + AsyncGeneratorMethod : async * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncGeneratorBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + AsyncGeneratorDeclaration : async function * BindingIdentifier ( FormalParameters ) { AsyncGeneratorBody } + AsyncGeneratorDeclaration : async function * ( FormalParameters ) { AsyncGeneratorBody } + AsyncGeneratorExpression : async function * BindingIdentifier ( FormalParameters ) { AsyncGeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncGeneratorBody is true and + IsSimpleParameterList of FormalParameters is false. + + 14.7.1 Static Semantics: Early Errors + + AsyncMethod : async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncFunctionBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + AsyncFunctionDeclaration : async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody } + AsyncFunctionDeclaration : async function ( FormalParameters ) { AsyncFunctionBody } + AsyncFunctionExpression : async function ( FormalParameters ) { AsyncFunctionBody } + AsyncFunctionExpression : async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncFunctionBody is true and + IsSimpleParameterList of FormalParameters is false. + + 14.8.1 Static Semantics: Early Errors + + AsyncArrowFunction : CoverCallExpressionAndAsyncArrowHead => AsyncConciseBody + + - It is a Syntax Error if ContainsUseStrict of AsyncConciseBody is true and + IsSimpleParameterList of CoverCallExpressionAndAsyncArrowHead is false. + +---*/ +$DONOTEVALUATE(); + + +class C { + static async method([element]) { + "use strict"; + } +} diff --git a/js/src/tests/test262/language/statements/class/async-method-static/await-as-binding-identifier-escaped.js b/js/src/tests/test262/language/statements/class/async-method-static/await-as-binding-identifier-escaped.js new file mode 100644 index 0000000000..c4764c5a6f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-method-static/await-as-binding-identifier-escaped.js @@ -0,0 +1,40 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/async-functions/await-as-binding-identifier-escaped.case +// - src/async-functions/syntax/async-class-decl-static-method.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as a binding identifier. (Static async method as a ClassDeclaration element) +esid: prod-AsyncMethod +features: [async-functions] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncMethod + + Async Function Definitions + + AsyncMethod : + async [no LineTerminator here] PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + + BindingIdentifier : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +$DONOTEVALUATE(); + + +class C { + static async method() { + var \u0061wait; + } +} + diff --git a/js/src/tests/test262/language/statements/class/async-method-static/await-as-binding-identifier.js b/js/src/tests/test262/language/statements/class/async-method-static/await-as-binding-identifier.js new file mode 100644 index 0000000000..9e1d40d72d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-method-static/await-as-binding-identifier.js @@ -0,0 +1,40 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/async-functions/await-as-binding-identifier.case +// - src/async-functions/syntax/async-class-decl-static-method.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as a binding identifier. (Static async method as a ClassDeclaration element) +esid: prod-AsyncMethod +features: [async-functions] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncMethod + + Async Function Definitions + + AsyncMethod : + async [no LineTerminator here] PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + + BindingIdentifier : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +$DONOTEVALUATE(); + + +class C { + static async method() { + var await; + } +} + diff --git a/js/src/tests/test262/language/statements/class/async-method-static/await-as-identifier-reference-escaped.js b/js/src/tests/test262/language/statements/class/async-method-static/await-as-identifier-reference-escaped.js new file mode 100644 index 0000000000..c345544674 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-method-static/await-as-identifier-reference-escaped.js @@ -0,0 +1,40 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/async-functions/await-as-identifier-reference-escaped.case +// - src/async-functions/syntax/async-class-decl-static-method.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as an identifier reference. (Static async method as a ClassDeclaration element) +esid: prod-AsyncMethod +features: [async-functions] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncMethod + + Async Function Definitions + + AsyncMethod : + async [no LineTerminator here] PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + + IdentifierReference : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +$DONOTEVALUATE(); + + +class C { + static async method() { + void \u0061wait; + } +} + diff --git a/js/src/tests/test262/language/statements/class/async-method-static/await-as-identifier-reference.js b/js/src/tests/test262/language/statements/class/async-method-static/await-as-identifier-reference.js new file mode 100644 index 0000000000..208b4624ee --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-method-static/await-as-identifier-reference.js @@ -0,0 +1,40 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/async-functions/await-as-identifier-reference.case +// - src/async-functions/syntax/async-class-decl-static-method.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as an identifier reference. (Static async method as a ClassDeclaration element) +esid: prod-AsyncMethod +features: [async-functions] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncMethod + + Async Function Definitions + + AsyncMethod : + async [no LineTerminator here] PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + + IdentifierReference : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +$DONOTEVALUATE(); + + +class C { + static async method() { + void await; + } +} + diff --git a/js/src/tests/test262/language/statements/class/async-method-static/await-as-label-identifier-escaped.js b/js/src/tests/test262/language/statements/class/async-method-static/await-as-label-identifier-escaped.js new file mode 100644 index 0000000000..b3ebdadd40 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-method-static/await-as-label-identifier-escaped.js @@ -0,0 +1,40 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/async-functions/await-as-label-identifier-escaped.case +// - src/async-functions/syntax/async-class-decl-static-method.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as a label identifier. (Static async method as a ClassDeclaration element) +esid: prod-AsyncMethod +features: [async-functions] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncMethod + + Async Function Definitions + + AsyncMethod : + async [no LineTerminator here] PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + + LabelIdentifier : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +$DONOTEVALUATE(); + + +class C { + static async method() { + \u0061wait: ; + } +} + diff --git a/js/src/tests/test262/language/statements/class/async-method-static/await-as-label-identifier.js b/js/src/tests/test262/language/statements/class/async-method-static/await-as-label-identifier.js new file mode 100644 index 0000000000..93610ded3d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-method-static/await-as-label-identifier.js @@ -0,0 +1,40 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/async-functions/await-as-label-identifier.case +// - src/async-functions/syntax/async-class-decl-static-method.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as a label identifier. (Static async method as a ClassDeclaration element) +esid: prod-AsyncMethod +features: [async-functions] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncMethod + + Async Function Definitions + + AsyncMethod : + async [no LineTerminator here] PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + + LabelIdentifier : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +$DONOTEVALUATE(); + + +class C { + static async method() { + await: ; + } +} + diff --git a/js/src/tests/test262/language/statements/class/async-method-static/browser.js b/js/src/tests/test262/language/statements/class/async-method-static/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/async-method-static/dflt-params-abrupt.js b/js/src/tests/test262/language/statements/class/async-method-static/dflt-params-abrupt.js new file mode 100644 index 0000000000..432afbeed3 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-method-static/dflt-params-abrupt.js @@ -0,0 +1,69 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-abrupt.case +// - src/function-forms/error/cls-decl-async-meth-static.template +/*--- +description: Abrupt completion returned by evaluation of initializer (static class declaration async method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [default-parameters, async-functions] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncMethod : async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncMethod is strict mode code, let strict be true. Otherwise + let strict be false. + 4. Let scope be the LexicalEnvironment of the running execution context. + 5. Let closure be ! AsyncFunctionCreate(Method, UniqueFormalParameters, AsyncFunctionBody, + scope, strict). + [...] + + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. + +---*/ + + +var callCount = 0; +class C { + static async method(_ = (function() { throw new Test262Error(); }())) { + + callCount = callCount + 1; + } +} + +C.method() + .then(_ => { + throw new Test262Error('function should not be resolved'); + }, error => assert.sameValue(error.constructor, Test262Error)) + .then(() => { + assert.sameValue(callCount, 0, 'function body is not evaluated'); + }, $DONE) + .then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/async-method-static/dflt-params-arg-val-not-undefined.js b/js/src/tests/test262/language/statements/class/async-method-static/dflt-params-arg-val-not-undefined.js new file mode 100644 index 0000000000..ace02e7cb4 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-method-static/dflt-params-arg-val-not-undefined.js @@ -0,0 +1,90 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-arg-val-not-undefined.case +// - src/function-forms/default/cls-decl-async-meth-static.template +/*--- +description: Use of initializer when argument value is not `undefined` (static class declaration async method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [default-parameters, async-functions] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncMethod : async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncMethod is strict mode code, let strict be true. Otherwise + let strict be false. + 4. Let scope be the LexicalEnvironment of the running execution context. + 5. Let closure be ! AsyncFunctionCreate(Method, UniqueFormalParameters, AsyncFunctionBody, + scope, strict). + [...] + + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + [...] + 23. Let iteratorRecord be Record {[[Iterator]]: + CreateListIterator(argumentsList), [[Done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + a. Perform ? IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + +---*/ +var obj = {}; +var falseCount = 0; +var stringCount = 0; +var nanCount = 0; +var zeroCount = 0; +var nullCount = 0; +var objCount = 0; + + +var callCount = 0; +class C { + static async method(aFalse = falseCount +=1, aString = stringCount += 1, aNaN = nanCount += 1, a0 = zeroCount += 1, aNull = nullCount += 1, aObj = objCount +=1) { + assert.sameValue(aFalse, false); + assert.sameValue(aString, ''); + assert.sameValue(aNaN, NaN); + assert.sameValue(a0, 0); + assert.sameValue(aNull, null); + assert.sameValue(aObj, obj); + callCount = callCount + 1; + } +} + +// Stores a reference `ref` for case evaluation +var ref = C.method; + +ref(false, '', NaN, 0, null, obj).then(() => { + assert.sameValue(callCount, 1, 'method invoked exactly once'); +}).then($DONE, $DONE); + +assert.sameValue(falseCount, 0, 'initializer not evaluated: false'); +assert.sameValue(stringCount, 0, 'initializer not evaluated: string'); +assert.sameValue(nanCount, 0, 'initializer not evaluated: NaN'); +assert.sameValue(zeroCount, 0, 'initializer not evaluated: 0'); +assert.sameValue(nullCount, 0, 'initializer not evaluated: null'); +assert.sameValue(objCount, 0, 'initializer not evaluated: object'); diff --git a/js/src/tests/test262/language/statements/class/async-method-static/dflt-params-arg-val-undefined.js b/js/src/tests/test262/language/statements/class/async-method-static/dflt-params-arg-val-undefined.js new file mode 100644 index 0000000000..50a0547e03 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-method-static/dflt-params-arg-val-undefined.js @@ -0,0 +1,73 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-arg-val-undefined.case +// - src/function-forms/default/cls-decl-async-meth-static.template +/*--- +description: Use of initializer when argument value is `undefined` (static class declaration async method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [default-parameters, async-functions] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncMethod : async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncMethod is strict mode code, let strict be true. Otherwise + let strict be false. + 4. Let scope be the LexicalEnvironment of the running execution context. + 5. Let closure be ! AsyncFunctionCreate(Method, UniqueFormalParameters, AsyncFunctionBody, + scope, strict). + [...] + + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + [...] + 23. Let iteratorRecord be Record {[[Iterator]]: + CreateListIterator(argumentsList), [[Done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + a. Perform ? IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + +---*/ + + +var callCount = 0; +class C { + static async method(fromLiteral = 23, fromExpr = 45, fromHole = 99) { + assert.sameValue(fromLiteral, 23); + assert.sameValue(fromExpr, 45); + assert.sameValue(fromHole, 99); + callCount = callCount + 1; + } +} + +// Stores a reference `ref` for case evaluation +var ref = C.method; + +ref(undefined, void 0).then(() => { + assert.sameValue(callCount, 1, 'method invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/async-method-static/dflt-params-duplicates.js b/js/src/tests/test262/language/statements/class/async-method-static/dflt-params-duplicates.js new file mode 100644 index 0000000000..1aa5b503e5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-method-static/dflt-params-duplicates.js @@ -0,0 +1,64 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-duplicates.case +// - src/function-forms/syntax/cls-decl-async-meth-static.template +/*--- +description: It is a Syntax Error if BoundNames of FormalParameters contains any duplicate elements. (static class declaration async method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [default-parameters] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncMethod : async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncMethod is strict mode code, let strict be true. Otherwise + let strict be false. + 4. Let scope be the LexicalEnvironment of the running execution context. + 5. Let closure be ! AsyncFunctionCreate(Method, UniqueFormalParameters, AsyncFunctionBody, + scope, strict). + [...] + + 14.1.2 Static Semantics: Early Errors + + StrictFormalParameters : FormalParameters + + - It is a Syntax Error if BoundNames of FormalParameters contains any + duplicate elements. + + FormalParameters : FormalParameterList + + - It is a Syntax Error if IsSimpleParameterList of FormalParameterList is + false and BoundNames of FormalParameterList contains any duplicate + elements. + +---*/ +$DONOTEVALUATE(); + + +class C { + static async method(x = 0, x) { + + } +} diff --git a/js/src/tests/test262/language/statements/class/async-method-static/dflt-params-ref-later.js b/js/src/tests/test262/language/statements/class/async-method-static/dflt-params-ref-later.js new file mode 100644 index 0000000000..f2f225fad3 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-method-static/dflt-params-ref-later.js @@ -0,0 +1,70 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-ref-later.case +// - src/function-forms/error/cls-decl-async-meth-static.template +/*--- +description: Referencing a parameter that occurs later in the ParameterList (static class declaration async method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [default-parameters, async-functions] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncMethod : async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncMethod is strict mode code, let strict be true. Otherwise + let strict be false. + 4. Let scope be the LexicalEnvironment of the running execution context. + 5. Let closure be ! AsyncFunctionCreate(Method, UniqueFormalParameters, AsyncFunctionBody, + scope, strict). + [...] + + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. + +---*/ +var x = 0; + + +var callCount = 0; +class C { + static async method(x = y, y) { + + callCount = callCount + 1; + } +} + +C.method() + .then(_ => { + throw new Test262Error('function should not be resolved'); + }, error => assert.sameValue(error.constructor, ReferenceError)) + .then(() => { + assert.sameValue(callCount, 0, 'function body is not evaluated'); + }, $DONE) + .then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/async-method-static/dflt-params-ref-prior.js b/js/src/tests/test262/language/statements/class/async-method-static/dflt-params-ref-prior.js new file mode 100644 index 0000000000..e66cf5a357 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-method-static/dflt-params-ref-prior.js @@ -0,0 +1,70 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-ref-prior.case +// - src/function-forms/default/cls-decl-async-meth-static.template +/*--- +description: Referencing a parameter that occurs earlier in the ParameterList (static class declaration async method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [default-parameters, async-functions] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncMethod : async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncMethod is strict mode code, let strict be true. Otherwise + let strict be false. + 4. Let scope be the LexicalEnvironment of the running execution context. + 5. Let closure be ! AsyncFunctionCreate(Method, UniqueFormalParameters, AsyncFunctionBody, + scope, strict). + [...] + + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. + +---*/ +var x = 0; + + +var callCount = 0; +class C { + static async method(x, y = x, z = y) { + assert.sameValue(x, 3, 'first argument value'); + assert.sameValue(y, 3, 'second argument value'); + assert.sameValue(z, 3, 'third argument value'); + callCount = callCount + 1; + } +} + +// Stores a reference `ref` for case evaluation +var ref = C.method; + +ref(3).then(() => { + assert.sameValue(callCount, 1, 'method invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/async-method-static/dflt-params-ref-self.js b/js/src/tests/test262/language/statements/class/async-method-static/dflt-params-ref-self.js new file mode 100644 index 0000000000..a38fd6dc54 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-method-static/dflt-params-ref-self.js @@ -0,0 +1,70 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-ref-self.case +// - src/function-forms/error/cls-decl-async-meth-static.template +/*--- +description: Referencing a parameter from within its own initializer (static class declaration async method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [default-parameters, async-functions] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncMethod : async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncMethod is strict mode code, let strict be true. Otherwise + let strict be false. + 4. Let scope be the LexicalEnvironment of the running execution context. + 5. Let closure be ! AsyncFunctionCreate(Method, UniqueFormalParameters, AsyncFunctionBody, + scope, strict). + [...] + + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. + +---*/ +var x = 0; + + +var callCount = 0; +class C { + static async method(x = x) { + + callCount = callCount + 1; + } +} + +C.method() + .then(_ => { + throw new Test262Error('function should not be resolved'); + }, error => assert.sameValue(error.constructor, ReferenceError)) + .then(() => { + assert.sameValue(callCount, 0, 'function body is not evaluated'); + }, $DONE) + .then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/async-method-static/dflt-params-rest.js b/js/src/tests/test262/language/statements/class/async-method-static/dflt-params-rest.js new file mode 100644 index 0000000000..126f505a86 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-method-static/dflt-params-rest.js @@ -0,0 +1,68 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-rest.case +// - src/function-forms/syntax/cls-decl-async-meth-static.template +/*--- +description: RestParameter does not support an initializer (static class declaration async method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [default-parameters] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncMethod : async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncMethod is strict mode code, let strict be true. Otherwise + let strict be false. + 4. Let scope be the LexicalEnvironment of the running execution context. + 5. Let closure be ! AsyncFunctionCreate(Method, UniqueFormalParameters, AsyncFunctionBody, + scope, strict). + [...] + + 14.1 Function Definitions + + Syntax + + FunctionRestParameter[Yield] : + + BindingRestElement[?Yield] + + 13.3.3 Destructuring Binding Patterns + + Syntax + + BindingRestElement[Yield] : + + ...BindingIdentifier[?Yield] + ...BindingPattern[?Yield] + +---*/ +$DONOTEVALUATE(); + + +class C { + static async method(...x = []) { + + } +} diff --git a/js/src/tests/test262/language/statements/class/async-method-static/dflt-params-trailing-comma.js b/js/src/tests/test262/language/statements/class/async-method-static/dflt-params-trailing-comma.js new file mode 100644 index 0000000000..005f2fcc09 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-method-static/dflt-params-trailing-comma.js @@ -0,0 +1,65 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-trailing-comma.case +// - src/function-forms/default/cls-decl-async-meth-static.template +/*--- +description: A trailing comma should not increase the respective length, using default parameters (static class declaration async method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-functions] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncMethod : async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncMethod is strict mode code, let strict be true. Otherwise + let strict be false. + 4. Let scope be the LexicalEnvironment of the running execution context. + 5. Let closure be ! AsyncFunctionCreate(Method, UniqueFormalParameters, AsyncFunctionBody, + scope, strict). + [...] + + + Trailing comma in the parameters list + + 14.1 Function Definitions + + FormalParameters[Yield, Await] : FormalParameterList[?Yield, ?Await] , +---*/ + + +var callCount = 0; +class C { + static async method(a, b = 39,) { + assert.sameValue(a, 42); + assert.sameValue(b, 39); + callCount = callCount + 1; + } +} + +// Stores a reference `ref` for case evaluation +var ref = C.method; + +ref(42, undefined, 1).then(() => { + assert.sameValue(callCount, 1, 'method invoked exactly once'); +}).then($DONE, $DONE); + +assert.sameValue(ref.length, 1, 'length is properly set'); diff --git a/js/src/tests/test262/language/statements/class/async-method-static/forbidden-ext/b1/browser.js b/js/src/tests/test262/language/statements/class/async-method-static/forbidden-ext/b1/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/async-method-static/forbidden-ext/b1/cls-decl-async-meth-static-forbidden-ext-direct-access-prop-arguments.js b/js/src/tests/test262/language/statements/class/async-method-static/forbidden-ext/b1/cls-decl-async-meth-static-forbidden-ext-direct-access-prop-arguments.js new file mode 100644 index 0000000000..c619167177 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-method-static/forbidden-ext/b1/cls-decl-async-meth-static-forbidden-ext-direct-access-prop-arguments.js @@ -0,0 +1,39 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/function-forms/forbidden-ext-direct-access-prop-arguments.case +// - src/function-forms/forbidden-extensions/bullet-one/cls-decl-async-meth-static.template +/*--- +description: Forbidden extension, f.arguments (static class declaration async method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [arrow-function, async-functions, async-iteration, class] +flags: [generated, noStrict, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + + ECMAScript function objects defined using syntactic constructors in strict mode code must + not be created with own properties named "caller" or "arguments". Such own properties also + must not be created for function objects defined using an ArrowFunction, MethodDefinition, + GeneratorDeclaration, GeneratorExpression, AsyncGeneratorDeclaration, AsyncGeneratorExpression, + ClassDeclaration, ClassExpression, AsyncFunctionDeclaration, AsyncFunctionExpression, or + AsyncArrowFunction regardless of whether the definition is contained in strict mode code. + Built-in functions, strict functions created using the Function constructor, generator functions + created using the Generator constructor, async functions created using the AsyncFunction + constructor, and functions created using the bind method also must not be created with such own + properties. + +---*/ + + +var callCount = 0; +class C { + static async method() { + assert.sameValue(this.method.hasOwnProperty("arguments"), false); + callCount++; + } +} + +C.method() + .then(() => { + assert.sameValue(callCount, 1, 'function body evaluated'); + }, $DONE).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/async-method-static/forbidden-ext/b1/cls-decl-async-meth-static-forbidden-ext-direct-access-prop-caller.js b/js/src/tests/test262/language/statements/class/async-method-static/forbidden-ext/b1/cls-decl-async-meth-static-forbidden-ext-direct-access-prop-caller.js new file mode 100644 index 0000000000..6424d9cf31 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-method-static/forbidden-ext/b1/cls-decl-async-meth-static-forbidden-ext-direct-access-prop-caller.js @@ -0,0 +1,39 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/function-forms/forbidden-ext-direct-access-prop-caller.case +// - src/function-forms/forbidden-extensions/bullet-one/cls-decl-async-meth-static.template +/*--- +description: Forbidden extension, o.caller (static class declaration async method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [arrow-function, async-functions, async-iteration, class] +flags: [generated, noStrict, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + + ECMAScript function objects defined using syntactic constructors in strict mode code must + not be created with own properties named "caller" or "arguments". Such own properties also + must not be created for function objects defined using an ArrowFunction, MethodDefinition, + GeneratorDeclaration, GeneratorExpression, AsyncGeneratorDeclaration, AsyncGeneratorExpression, + ClassDeclaration, ClassExpression, AsyncFunctionDeclaration, AsyncFunctionExpression, or + AsyncArrowFunction regardless of whether the definition is contained in strict mode code. + Built-in functions, strict functions created using the Function constructor, generator functions + created using the Generator constructor, async functions created using the AsyncFunction + constructor, and functions created using the bind method also must not be created with such own + properties. + +---*/ + + +var callCount = 0; +class C { + static async method() { + assert.sameValue(this.method.hasOwnProperty("caller"), false); + callCount++; + } +} + +C.method() + .then(() => { + assert.sameValue(callCount, 1, 'function body evaluated'); + }, $DONE).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/async-method-static/forbidden-ext/b1/shell.js b/js/src/tests/test262/language/statements/class/async-method-static/forbidden-ext/b1/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/async-method-static/forbidden-ext/b2/browser.js b/js/src/tests/test262/language/statements/class/async-method-static/forbidden-ext/b2/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/async-method-static/forbidden-ext/b2/cls-decl-async-meth-static-forbidden-ext-indirect-access-own-prop-caller-get.js b/js/src/tests/test262/language/statements/class/async-method-static/forbidden-ext/b2/cls-decl-async-meth-static-forbidden-ext-indirect-access-own-prop-caller-get.js new file mode 100644 index 0000000000..ba4b0c81c7 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-method-static/forbidden-ext/b2/cls-decl-async-meth-static-forbidden-ext-indirect-access-own-prop-caller-get.js @@ -0,0 +1,65 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/function-forms/forbidden-ext-indirect-access-own-prop-caller-get.case +// - src/function-forms/forbidden-extensions/bullet-two/cls-decl-async-meth-static.template +/*--- +description: Forbidden extension, o.caller (static class declaration async method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [arrow-function, async-functions, class] +flags: [generated, noStrict, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + + If an implementation extends any function object with an own property named "caller" the value of + that property, as observed using [[Get]] or [[GetOwnProperty]], must not be a strict function + object. If it is an accessor property, the function that is the value of the property's [[Get]] + attribute must never return a strict function when called. + +---*/ +var CALLER_OWN_PROPERTY_DOES_NOT_EXIST = Symbol(); +function inner() { + // This property may exist, but is forbidden from having a value that is a strict function object + return inner.hasOwnProperty("caller") + ? inner.caller + : CALLER_OWN_PROPERTY_DOES_NOT_EXIST; +} + + +var callCount = 0; +class C { + static async method() { + /* implicit strict */ + // This and the following conditional value is set in the test's .case file. + // For every test that has a "true" value here, there is a + // corresponding test that has a "false" value here. + // They are generated from two different case files, which use + let descriptor = Object.getOwnPropertyDescriptor(inner, "caller"); + if (descriptor && descriptor.configurable && true) { + Object.defineProperty(inner, "caller", {get(){return 1}}); + } + var result = inner(); + if (descriptor && descriptor.configurable && true) { + assert.sameValue(result, 1, 'If this test defined an own "caller" property on the inner function, then it should be accessible and should return the value it was set to.'); + } + + // "CALLER_OWN_PROPERTY_DOES_NOT_EXIST" is from + // forbidden-ext-indirect-access-prop-caller.case + // + // If the function object "inner" has an own property + // named "caller", then its value will be returned. + // + // If the function object "inner" DOES NOT have an + // own property named "caller", then the symbol + // CALLER_OWN_PROPERTY_DOES_NOT_EXIST will be returned. + if (result !== CALLER_OWN_PROPERTY_DOES_NOT_EXIST) { + assert.notSameValue(result, this.method); + } + callCount++; + } +} + +C.method() + .then(() => { + assert.sameValue(callCount, 1, 'function body evaluated'); + }, $DONE).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/async-method-static/forbidden-ext/b2/cls-decl-async-meth-static-forbidden-ext-indirect-access-own-prop-caller-value.js b/js/src/tests/test262/language/statements/class/async-method-static/forbidden-ext/b2/cls-decl-async-meth-static-forbidden-ext-indirect-access-own-prop-caller-value.js new file mode 100644 index 0000000000..328536d3ba --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-method-static/forbidden-ext/b2/cls-decl-async-meth-static-forbidden-ext-indirect-access-own-prop-caller-value.js @@ -0,0 +1,65 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/function-forms/forbidden-ext-indirect-access-own-prop-caller-value.case +// - src/function-forms/forbidden-extensions/bullet-two/cls-decl-async-meth-static.template +/*--- +description: Forbidden extension, o.caller (static class declaration async method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [arrow-function, async-functions, class] +flags: [generated, noStrict, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + + If an implementation extends any function object with an own property named "caller" the value of + that property, as observed using [[Get]] or [[GetOwnProperty]], must not be a strict function + object. If it is an accessor property, the function that is the value of the property's [[Get]] + attribute must never return a strict function when called. + +---*/ +var CALLER_OWN_PROPERTY_DOES_NOT_EXIST = Symbol(); +function inner() { + // This property may exist, but is forbidden from having a value that is a strict function object + return inner.hasOwnProperty("caller") + ? inner.caller + : CALLER_OWN_PROPERTY_DOES_NOT_EXIST; +} + + +var callCount = 0; +class C { + static async method() { + /* implicit strict */ + // This and the following conditional value is set in the test's .case file. + // For every test that has a "true" value here, there is a + // corresponding test that has a "false" value here. + // They are generated from two different case files, which use + let descriptor = Object.getOwnPropertyDescriptor(inner, "caller"); + if (descriptor && descriptor.configurable && true) { + Object.defineProperty(inner, "caller", {value: 1}); + } + var result = inner(); + if (descriptor && descriptor.configurable && true) { + assert.sameValue(result, 1, 'If this test defined an own "caller" property on the inner function, then it should be accessible and should return the value it was set to.'); + } + + // "CALLER_OWN_PROPERTY_DOES_NOT_EXIST" is from + // forbidden-ext-indirect-access-prop-caller.case + // + // If the function object "inner" has an own property + // named "caller", then its value will be returned. + // + // If the function object "inner" DOES NOT have an + // own property named "caller", then the symbol + // CALLER_OWN_PROPERTY_DOES_NOT_EXIST will be returned. + if (result !== CALLER_OWN_PROPERTY_DOES_NOT_EXIST) { + assert.notSameValue(result, this.method); + } + callCount++; + } +} + +C.method() + .then(() => { + assert.sameValue(callCount, 1, 'function body evaluated'); + }, $DONE).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/async-method-static/forbidden-ext/b2/cls-decl-async-meth-static-forbidden-ext-indirect-access-prop-caller.js b/js/src/tests/test262/language/statements/class/async-method-static/forbidden-ext/b2/cls-decl-async-meth-static-forbidden-ext-indirect-access-prop-caller.js new file mode 100644 index 0000000000..94bb78a47a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-method-static/forbidden-ext/b2/cls-decl-async-meth-static-forbidden-ext-indirect-access-prop-caller.js @@ -0,0 +1,65 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/function-forms/forbidden-ext-indirect-access-prop-caller.case +// - src/function-forms/forbidden-extensions/bullet-two/cls-decl-async-meth-static.template +/*--- +description: Forbidden extension, o.caller (static class declaration async method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [arrow-function, async-functions, class] +flags: [generated, noStrict, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + + If an implementation extends any function object with an own property named "caller" the value of + that property, as observed using [[Get]] or [[GetOwnProperty]], must not be a strict function + object. If it is an accessor property, the function that is the value of the property's [[Get]] + attribute must never return a strict function when called. + +---*/ +var CALLER_OWN_PROPERTY_DOES_NOT_EXIST = Symbol(); +function inner() { + // This property may exist, but is forbidden from having a value that is a strict function object + return inner.hasOwnProperty("caller") + ? inner.caller + : CALLER_OWN_PROPERTY_DOES_NOT_EXIST; +} + + +var callCount = 0; +class C { + static async method() { + /* implicit strict */ + // This and the following conditional value is set in the test's .case file. + // For every test that has a "true" value here, there is a + // corresponding test that has a "false" value here. + // They are generated from two different case files, which use + let descriptor = Object.getOwnPropertyDescriptor(inner, "caller"); + if (descriptor && descriptor.configurable && false) { + Object.defineProperty(inner, "caller", {}); + } + var result = inner(); + if (descriptor && descriptor.configurable && false) { + assert.sameValue(result, 1, 'If this test defined an own "caller" property on the inner function, then it should be accessible and should return the value it was set to.'); + } + + // "CALLER_OWN_PROPERTY_DOES_NOT_EXIST" is from + // forbidden-ext-indirect-access-prop-caller.case + // + // If the function object "inner" has an own property + // named "caller", then its value will be returned. + // + // If the function object "inner" DOES NOT have an + // own property named "caller", then the symbol + // CALLER_OWN_PROPERTY_DOES_NOT_EXIST will be returned. + if (result !== CALLER_OWN_PROPERTY_DOES_NOT_EXIST) { + assert.notSameValue(result, this.method); + } + callCount++; + } +} + +C.method() + .then(() => { + assert.sameValue(callCount, 1, 'function body evaluated'); + }, $DONE).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/async-method-static/forbidden-ext/b2/shell.js b/js/src/tests/test262/language/statements/class/async-method-static/forbidden-ext/b2/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/async-method-static/forbidden-ext/browser.js b/js/src/tests/test262/language/statements/class/async-method-static/forbidden-ext/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/async-method-static/forbidden-ext/shell.js b/js/src/tests/test262/language/statements/class/async-method-static/forbidden-ext/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/async-method-static/object-destructuring-param-strict-body.js b/js/src/tests/test262/language/statements/class/async-method-static/object-destructuring-param-strict-body.js new file mode 100644 index 0000000000..981b36d107 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-method-static/object-destructuring-param-strict-body.js @@ -0,0 +1,135 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/function-forms/object-destructuring-param-strict-body.case +// - src/function-forms/syntax/cls-decl-async-meth-static.template +/*--- +description: ObjectBindingPattern and Use Strict Directive are not allowed to coexist for the same function. (static class declaration async method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [rest-parameters] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncMethod : async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncMethod is strict mode code, let strict be true. Otherwise + let strict be false. + 4. Let scope be the LexicalEnvironment of the running execution context. + 5. Let closure be ! AsyncFunctionCreate(Method, UniqueFormalParameters, AsyncFunctionBody, + scope, strict). + [...] + + 13.3.3.4 Static Semantics: IsSimpleParameterList + + BindingElement : BindingPattern + + 1. Return false. + + 14.1.2 Static Semantics: Early Errors + + FunctionDeclaration : function BindingIdentifier ( FormalParameters ) { FunctionBody } + FunctionDeclaration : function ( FormalParameters ) { FunctionBody } + FunctionExpression : function BindingIdentifier ( FormalParameters ) { FunctionBody } + + - It is a Syntax Error if ContainsUseStrict of FunctionBody is true and + IsSimpleParameterList of FormalParameters is false. + + 14.2.1 Static Semantics: Early Errors + + ArrowFunction : ArrowParameters => ConciseBody + + - It is a Syntax Error if ContainsUseStrict of ConciseBody is true and + IsSimpleParameterList of ArrowParameters is false. + + 14.3.1 Static Semantics: Early Errors + + MethodDefinition : PropertyName ( UniqueFormalParameters ) { FunctionBody } + + - It is a Syntax Error if ContainsUseStrict of FunctionBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + MethodDefinition : set PropertyName ( PropertySetParameterList ) { FunctionBody } + + - It is a Syntax Error if ContainsUseStrict of FunctionBody is true and + IsSimpleParameterList of PropertySetParameterList is false. + + 14.4.1 Static Semantics: Early Errors + + GeneratorMethod : * PropertyName ( UniqueFormalParameters ) { GeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of GeneratorBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + GeneratorDeclaration : function * BindingIdentifier ( FormalParameters ) { GeneratorBody } + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + GeneratorExpression : function * BindingIdentifier ( FormalParameters ) { GeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of GeneratorBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + 14.5.1 Static Semantics: Early Errors + + AsyncGeneratorMethod : async * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncGeneratorBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + AsyncGeneratorDeclaration : async function * BindingIdentifier ( FormalParameters ) { AsyncGeneratorBody } + AsyncGeneratorDeclaration : async function * ( FormalParameters ) { AsyncGeneratorBody } + AsyncGeneratorExpression : async function * BindingIdentifier ( FormalParameters ) { AsyncGeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncGeneratorBody is true and + IsSimpleParameterList of FormalParameters is false. + + 14.7.1 Static Semantics: Early Errors + + AsyncMethod : async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncFunctionBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + AsyncFunctionDeclaration : async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody } + AsyncFunctionDeclaration : async function ( FormalParameters ) { AsyncFunctionBody } + AsyncFunctionExpression : async function ( FormalParameters ) { AsyncFunctionBody } + AsyncFunctionExpression : async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncFunctionBody is true and + IsSimpleParameterList of FormalParameters is false. + + 14.8.1 Static Semantics: Early Errors + + AsyncArrowFunction : CoverCallExpressionAndAsyncArrowHead => AsyncConciseBody + + - It is a Syntax Error if ContainsUseStrict of AsyncConciseBody is true and + IsSimpleParameterList of CoverCallExpressionAndAsyncArrowHead is false. + +---*/ +$DONOTEVALUATE(); + + +class C { + static async method({property}) { + "use strict"; + } +} diff --git a/js/src/tests/test262/language/statements/class/async-method-static/params-trailing-comma-multiple.js b/js/src/tests/test262/language/statements/class/async-method-static/params-trailing-comma-multiple.js new file mode 100644 index 0000000000..5893063cbf --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-method-static/params-trailing-comma-multiple.js @@ -0,0 +1,65 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/function-forms/params-trailing-comma-multiple.case +// - src/function-forms/default/cls-decl-async-meth-static.template +/*--- +description: A trailing comma should not increase the respective length, using multiple parameters (static class declaration async method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-functions] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncMethod : async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncMethod is strict mode code, let strict be true. Otherwise + let strict be false. + 4. Let scope be the LexicalEnvironment of the running execution context. + 5. Let closure be ! AsyncFunctionCreate(Method, UniqueFormalParameters, AsyncFunctionBody, + scope, strict). + [...] + + + Trailing comma in the parameters list + + 14.1 Function Definitions + + FormalParameters[Yield, Await] : FormalParameterList[?Yield, ?Await] , +---*/ + + +var callCount = 0; +class C { + static async method(a, b,) { + assert.sameValue(a, 42); + assert.sameValue(b, 39); + callCount = callCount + 1; + } +} + +// Stores a reference `ref` for case evaluation +var ref = C.method; + +ref(42, 39, 1).then(() => { + assert.sameValue(callCount, 1, 'method invoked exactly once'); +}).then($DONE, $DONE); + +assert.sameValue(ref.length, 2, 'length is properly set'); diff --git a/js/src/tests/test262/language/statements/class/async-method-static/params-trailing-comma-single.js b/js/src/tests/test262/language/statements/class/async-method-static/params-trailing-comma-single.js new file mode 100644 index 0000000000..ddc52c4af0 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-method-static/params-trailing-comma-single.js @@ -0,0 +1,64 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/function-forms/params-trailing-comma-single.case +// - src/function-forms/default/cls-decl-async-meth-static.template +/*--- +description: A trailing comma should not increase the respective length, using a single parameter (static class declaration async method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-functions] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncMethod : async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncMethod is strict mode code, let strict be true. Otherwise + let strict be false. + 4. Let scope be the LexicalEnvironment of the running execution context. + 5. Let closure be ! AsyncFunctionCreate(Method, UniqueFormalParameters, AsyncFunctionBody, + scope, strict). + [...] + + + Trailing comma in the parameters list + + 14.1 Function Definitions + + FormalParameters[Yield, Await] : FormalParameterList[?Yield, ?Await] , +---*/ + + +var callCount = 0; +class C { + static async method(a,) { + assert.sameValue(a, 42); + callCount = callCount + 1; + } +} + +// Stores a reference `ref` for case evaluation +var ref = C.method; + +ref(42, 39).then(() => { + assert.sameValue(callCount, 1, 'method invoked exactly once'); +}).then($DONE, $DONE); + +assert.sameValue(ref.length, 1, 'length is properly set'); diff --git a/js/src/tests/test262/language/statements/class/async-method-static/rest-param-strict-body.js b/js/src/tests/test262/language/statements/class/async-method-static/rest-param-strict-body.js new file mode 100644 index 0000000000..94e556e31a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-method-static/rest-param-strict-body.js @@ -0,0 +1,135 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/function-forms/rest-param-strict-body.case +// - src/function-forms/syntax/cls-decl-async-meth-static.template +/*--- +description: RestParameter and Use Strict Directive are not allowed to coexist for the same function. (static class declaration async method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [rest-parameters] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncMethod : async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncMethod is strict mode code, let strict be true. Otherwise + let strict be false. + 4. Let scope be the LexicalEnvironment of the running execution context. + 5. Let closure be ! AsyncFunctionCreate(Method, UniqueFormalParameters, AsyncFunctionBody, + scope, strict). + [...] + + 14.1.13 Static Semantics: IsSimpleParameterList + + FormalParameters : FormalParameterList , FunctionRestParameter + + 1. Return false. + + 14.1.2 Static Semantics: Early Errors + + FunctionDeclaration : function BindingIdentifier ( FormalParameters ) { FunctionBody } + FunctionDeclaration : function ( FormalParameters ) { FunctionBody } + FunctionExpression : function BindingIdentifier ( FormalParameters ) { FunctionBody } + + - It is a Syntax Error if ContainsUseStrict of FunctionBody is true and + IsSimpleParameterList of FormalParameters is false. + + 14.2.1 Static Semantics: Early Errors + + ArrowFunction : ArrowParameters => ConciseBody + + - It is a Syntax Error if ContainsUseStrict of ConciseBody is true and + IsSimpleParameterList of ArrowParameters is false. + + 14.3.1 Static Semantics: Early Errors + + MethodDefinition : PropertyName ( UniqueFormalParameters ) { FunctionBody } + + - It is a Syntax Error if ContainsUseStrict of FunctionBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + MethodDefinition : set PropertyName ( PropertySetParameterList ) { FunctionBody } + + - It is a Syntax Error if ContainsUseStrict of FunctionBody is true and + IsSimpleParameterList of PropertySetParameterList is false. + + 14.4.1 Static Semantics: Early Errors + + GeneratorMethod : * PropertyName ( UniqueFormalParameters ) { GeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of GeneratorBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + GeneratorDeclaration : function * BindingIdentifier ( FormalParameters ) { GeneratorBody } + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + GeneratorExpression : function * BindingIdentifier ( FormalParameters ) { GeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of GeneratorBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + 14.5.1 Static Semantics: Early Errors + + AsyncGeneratorMethod : async * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncGeneratorBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + AsyncGeneratorDeclaration : async function * BindingIdentifier ( FormalParameters ) { AsyncGeneratorBody } + AsyncGeneratorDeclaration : async function * ( FormalParameters ) { AsyncGeneratorBody } + AsyncGeneratorExpression : async function * BindingIdentifier ( FormalParameters ) { AsyncGeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncGeneratorBody is true and + IsSimpleParameterList of FormalParameters is false. + + 14.7.1 Static Semantics: Early Errors + + AsyncMethod : async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncFunctionBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + AsyncFunctionDeclaration : async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody } + AsyncFunctionDeclaration : async function ( FormalParameters ) { AsyncFunctionBody } + AsyncFunctionExpression : async function ( FormalParameters ) { AsyncFunctionBody } + AsyncFunctionExpression : async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncFunctionBody is true and + IsSimpleParameterList of FormalParameters is false. + + 14.8.1 Static Semantics: Early Errors + + AsyncArrowFunction : CoverCallExpressionAndAsyncArrowHead => AsyncConciseBody + + - It is a Syntax Error if ContainsUseStrict of AsyncConciseBody is true and + IsSimpleParameterList of CoverCallExpressionAndAsyncArrowHead is false. + +---*/ +$DONOTEVALUATE(); + + +class C { + static async method(a,...rest) { + "use strict"; + } +} diff --git a/js/src/tests/test262/language/statements/class/async-method-static/rest-params-trailing-comma-early-error.js b/js/src/tests/test262/language/statements/class/async-method-static/rest-params-trailing-comma-early-error.js new file mode 100644 index 0000000000..39b5166cf1 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-method-static/rest-params-trailing-comma-early-error.js @@ -0,0 +1,60 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/function-forms/rest-params-trailing-comma-early-error.case +// - src/function-forms/syntax/cls-decl-async-meth-static.template +/*--- +description: It's a syntax error if a FunctionRestParameter is followed by a trailing comma (static class declaration async method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncMethod : async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncMethod is strict mode code, let strict be true. Otherwise + let strict be false. + 4. Let scope be the LexicalEnvironment of the running execution context. + 5. Let closure be ! AsyncFunctionCreate(Method, UniqueFormalParameters, AsyncFunctionBody, + scope, strict). + [...] + + Trailing comma in the parameters list + + 14.1 Function Definitions + + FormalParameters[Yield, Await] : + [empty] + FunctionRestParameter[?Yield, ?Await] + FormalParameterList[?Yield, ?Await] + FormalParameterList[?Yield, ?Await] , + FormalParameterList[?Yield, ?Await] , FunctionRestParameter[?Yield, ?Await] +---*/ +$DONOTEVALUATE(); + + +class C { + static async method(...a,) { + + } +} diff --git a/js/src/tests/test262/language/statements/class/async-method-static/returns-async-arrow-returns-arguments-from-parent-function.js b/js/src/tests/test262/language/statements/class/async-method-static/returns-async-arrow-returns-arguments-from-parent-function.js new file mode 100644 index 0000000000..014ac6e200 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-method-static/returns-async-arrow-returns-arguments-from-parent-function.js @@ -0,0 +1,41 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-functions/returns-async-arrow-returns-arguments-from-parent-function.case +// - src/async-functions/evaluation/async-class-decl-static-method.template +/*--- +description: Async function returns an async function. (Static async method as a ClassDeclaration element) +esid: prod-AsyncMethod +features: [async-functions] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncMethod + + Async Function Definitions + + AsyncMethod : + async [no LineTerminator here] PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + +---*/ +let count = 0; + + +class C { + static async method(x) { + let a = arguments; + return async () => a === arguments; + } +} +// Stores a reference `asyncFn` for case evaluation +let asyncFn = C.method; + +asyncFn().then(retFn => { + count++; + return retFn(); +}).then(result => { + assert.sameValue(result, true); + assert.sameValue(count, 1); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/async-method-static/returns-async-arrow-returns-newtarget.js b/js/src/tests/test262/language/statements/class/async-method-static/returns-async-arrow-returns-newtarget.js new file mode 100644 index 0000000000..5f62fd347e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-method-static/returns-async-arrow-returns-newtarget.js @@ -0,0 +1,40 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-functions/returns-async-arrow-returns-newtarget.case +// - src/async-functions/evaluation/async-class-decl-static-method.template +/*--- +description: Async function returns an async function. (Static async method as a ClassDeclaration element) +esid: prod-AsyncMethod +features: [async-functions] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncMethod + + Async Function Definitions + + AsyncMethod : + async [no LineTerminator here] PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + +---*/ +let count = 0; + + +class C { + static async method(x) { + return async () => new.target; + } +} +// Stores a reference `asyncFn` for case evaluation +let asyncFn = C.method; + +asyncFn().then(retFn => { + count++; + return retFn(); +}).then(result => { + assert.sameValue(result, undefined); + assert.sameValue(count, 1); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/async-method-static/returns-async-arrow.js b/js/src/tests/test262/language/statements/class/async-method-static/returns-async-arrow.js new file mode 100644 index 0000000000..718b3a1780 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-method-static/returns-async-arrow.js @@ -0,0 +1,40 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-functions/returns-async-arrow.case +// - src/async-functions/evaluation/async-class-decl-static-method.template +/*--- +description: Async function returns an async function. (Static async method as a ClassDeclaration element) +esid: prod-AsyncMethod +features: [async-functions] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncMethod + + Async Function Definitions + + AsyncMethod : + async [no LineTerminator here] PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + +---*/ +let count = 0; + + +class C { + static async method(x) { + return async () => x; + } +} +// Stores a reference `asyncFn` for case evaluation +let asyncFn = C.method; + +asyncFn(1).then(retFn => { + count++; + return retFn(); +}).then(result => { + assert.sameValue(result, 1); + assert.sameValue(count, 1); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/async-method-static/returns-async-function-returns-arguments-from-own-function.js b/js/src/tests/test262/language/statements/class/async-method-static/returns-async-function-returns-arguments-from-own-function.js new file mode 100644 index 0000000000..30f95d44a4 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-method-static/returns-async-function-returns-arguments-from-own-function.js @@ -0,0 +1,41 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-functions/returns-async-function-returns-arguments-from-own-function.case +// - src/async-functions/evaluation/async-class-decl-static-method.template +/*--- +description: Async function returns an async function. (Static async method as a ClassDeclaration element) +esid: prod-AsyncMethod +features: [async-functions] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncMethod + + Async Function Definitions + + AsyncMethod : + async [no LineTerminator here] PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + +---*/ +let count = 0; + + +class C { + static async method(x) { + let a = arguments; + return async function() { return a === arguments; }; + } +} +// Stores a reference `asyncFn` for case evaluation +let asyncFn = C.method; + +asyncFn(1).then(retFn => { + count++; + return retFn(); +}).then(result => { + assert.sameValue(result, false); + assert.sameValue(count, 1); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/async-method-static/returns-async-function-returns-newtarget.js b/js/src/tests/test262/language/statements/class/async-method-static/returns-async-function-returns-newtarget.js new file mode 100644 index 0000000000..35d0fc10f6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-method-static/returns-async-function-returns-newtarget.js @@ -0,0 +1,40 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-functions/returns-async-function-returns-newtarget.case +// - src/async-functions/evaluation/async-class-decl-static-method.template +/*--- +description: Async function returns an async function. (Static async method as a ClassDeclaration element) +esid: prod-AsyncMethod +features: [async-functions] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncMethod + + Async Function Definitions + + AsyncMethod : + async [no LineTerminator here] PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + +---*/ +let count = 0; + + +class C { + static async method(x) { + return async function() { return new.target; }; + } +} +// Stores a reference `asyncFn` for case evaluation +let asyncFn = C.method; + +asyncFn(1).then(retFn => { + count++; + return retFn(); +}).then(result => { + assert.sameValue(result, undefined); + assert.sameValue(count, 1); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/async-method-static/returns-async-function.js b/js/src/tests/test262/language/statements/class/async-method-static/returns-async-function.js new file mode 100644 index 0000000000..f7f91ce8c4 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-method-static/returns-async-function.js @@ -0,0 +1,40 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-functions/returns-async-function.case +// - src/async-functions/evaluation/async-class-decl-static-method.template +/*--- +description: Async function returns an async function. (Static async method as a ClassDeclaration element) +esid: prod-AsyncMethod +features: [async-functions] +flags: [generated, async] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + AsyncMethod + + Async Function Definitions + + AsyncMethod : + async [no LineTerminator here] PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + +---*/ +let count = 0; + + +class C { + static async method(x) { + return async function() { return x; }; + } +} +// Stores a reference `asyncFn` for case evaluation +let asyncFn = C.method; + +asyncFn(1).then(retFn => { + count++; + return retFn(); +}).then(result => { + assert.sameValue(result, 1); + assert.sameValue(count, 1); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/async-method-static/shell.js b/js/src/tests/test262/language/statements/class/async-method-static/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/async-method/array-destructuring-param-strict-body.js b/js/src/tests/test262/language/statements/class/async-method/array-destructuring-param-strict-body.js new file mode 100644 index 0000000000..3beeff44be --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-method/array-destructuring-param-strict-body.js @@ -0,0 +1,136 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/function-forms/array-destructuring-param-strict-body.case +// - src/function-forms/syntax/cls-decl-async-meth.template +/*--- +description: ArrayBindingPattern and Use Strict Directive are not allowed to coexist for the same function. (class declaration async method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [rest-parameters] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncMethod : async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncMethod is strict mode code, let strict be true. Otherwise + let strict be false. + 4. Let scope be the LexicalEnvironment of the running execution context. + 5. Let closure be ! AsyncFunctionCreate(Method, UniqueFormalParameters, AsyncFunctionBody, + scope, strict). + [...] + + + 13.3.3.4 Static Semantics: IsSimpleParameterList + + BindingElement : BindingPattern + + 1. Return false. + + 14.1.2 Static Semantics: Early Errors + + FunctionDeclaration : function BindingIdentifier ( FormalParameters ) { FunctionBody } + FunctionDeclaration : function ( FormalParameters ) { FunctionBody } + FunctionExpression : function BindingIdentifier ( FormalParameters ) { FunctionBody } + + - It is a Syntax Error if ContainsUseStrict of FunctionBody is true and + IsSimpleParameterList of FormalParameters is false. + + 14.2.1 Static Semantics: Early Errors + + ArrowFunction : ArrowParameters => ConciseBody + + - It is a Syntax Error if ContainsUseStrict of ConciseBody is true and + IsSimpleParameterList of ArrowParameters is false. + + 14.3.1 Static Semantics: Early Errors + + MethodDefinition : PropertyName ( UniqueFormalParameters ) { FunctionBody } + + - It is a Syntax Error if ContainsUseStrict of FunctionBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + MethodDefinition : set PropertyName ( PropertySetParameterList ) { FunctionBody } + + - It is a Syntax Error if ContainsUseStrict of FunctionBody is true and + IsSimpleParameterList of PropertySetParameterList is false. + + 14.4.1 Static Semantics: Early Errors + + GeneratorMethod : * PropertyName ( UniqueFormalParameters ) { GeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of GeneratorBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + GeneratorDeclaration : function * BindingIdentifier ( FormalParameters ) { GeneratorBody } + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + GeneratorExpression : function * BindingIdentifier ( FormalParameters ) { GeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of GeneratorBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + 14.5.1 Static Semantics: Early Errors + + AsyncGeneratorMethod : async * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncGeneratorBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + AsyncGeneratorDeclaration : async function * BindingIdentifier ( FormalParameters ) { AsyncGeneratorBody } + AsyncGeneratorDeclaration : async function * ( FormalParameters ) { AsyncGeneratorBody } + AsyncGeneratorExpression : async function * BindingIdentifier ( FormalParameters ) { AsyncGeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncGeneratorBody is true and + IsSimpleParameterList of FormalParameters is false. + + 14.7.1 Static Semantics: Early Errors + + AsyncMethod : async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncFunctionBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + AsyncFunctionDeclaration : async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody } + AsyncFunctionDeclaration : async function ( FormalParameters ) { AsyncFunctionBody } + AsyncFunctionExpression : async function ( FormalParameters ) { AsyncFunctionBody } + AsyncFunctionExpression : async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncFunctionBody is true and + IsSimpleParameterList of FormalParameters is false. + + 14.8.1 Static Semantics: Early Errors + + AsyncArrowFunction : CoverCallExpressionAndAsyncArrowHead => AsyncConciseBody + + - It is a Syntax Error if ContainsUseStrict of AsyncConciseBody is true and + IsSimpleParameterList of CoverCallExpressionAndAsyncArrowHead is false. + +---*/ +$DONOTEVALUATE(); + + +class C { + async method([element]) { + "use strict"; + } +} diff --git a/js/src/tests/test262/language/statements/class/async-method/await-as-binding-identifier-escaped.js b/js/src/tests/test262/language/statements/class/async-method/await-as-binding-identifier-escaped.js new file mode 100644 index 0000000000..37f594452e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-method/await-as-binding-identifier-escaped.js @@ -0,0 +1,39 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/async-functions/await-as-binding-identifier-escaped.case +// - src/async-functions/syntax/async-class-decl-method.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as a binding identifier. (Async method as a ClassDeclaration element) +esid: prod-AsyncMethod +features: [async-functions] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncMethod + + Async Function Definitions + + AsyncMethod : + async [no LineTerminator here] PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + + BindingIdentifier : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +$DONOTEVALUATE(); + + +class C { + async method() { + var \u0061wait; + } +} diff --git a/js/src/tests/test262/language/statements/class/async-method/await-as-binding-identifier.js b/js/src/tests/test262/language/statements/class/async-method/await-as-binding-identifier.js new file mode 100644 index 0000000000..d5316d1f95 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-method/await-as-binding-identifier.js @@ -0,0 +1,39 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/async-functions/await-as-binding-identifier.case +// - src/async-functions/syntax/async-class-decl-method.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as a binding identifier. (Async method as a ClassDeclaration element) +esid: prod-AsyncMethod +features: [async-functions] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncMethod + + Async Function Definitions + + AsyncMethod : + async [no LineTerminator here] PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + + BindingIdentifier : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +$DONOTEVALUATE(); + + +class C { + async method() { + var await; + } +} diff --git a/js/src/tests/test262/language/statements/class/async-method/await-as-identifier-reference-escaped.js b/js/src/tests/test262/language/statements/class/async-method/await-as-identifier-reference-escaped.js new file mode 100644 index 0000000000..d50ac7bbf1 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-method/await-as-identifier-reference-escaped.js @@ -0,0 +1,39 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/async-functions/await-as-identifier-reference-escaped.case +// - src/async-functions/syntax/async-class-decl-method.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as an identifier reference. (Async method as a ClassDeclaration element) +esid: prod-AsyncMethod +features: [async-functions] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncMethod + + Async Function Definitions + + AsyncMethod : + async [no LineTerminator here] PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + + IdentifierReference : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +$DONOTEVALUATE(); + + +class C { + async method() { + void \u0061wait; + } +} diff --git a/js/src/tests/test262/language/statements/class/async-method/await-as-identifier-reference.js b/js/src/tests/test262/language/statements/class/async-method/await-as-identifier-reference.js new file mode 100644 index 0000000000..33d12e86cf --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-method/await-as-identifier-reference.js @@ -0,0 +1,39 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/async-functions/await-as-identifier-reference.case +// - src/async-functions/syntax/async-class-decl-method.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as an identifier reference. (Async method as a ClassDeclaration element) +esid: prod-AsyncMethod +features: [async-functions] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncMethod + + Async Function Definitions + + AsyncMethod : + async [no LineTerminator here] PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + + IdentifierReference : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +$DONOTEVALUATE(); + + +class C { + async method() { + void await; + } +} diff --git a/js/src/tests/test262/language/statements/class/async-method/await-as-label-identifier-escaped.js b/js/src/tests/test262/language/statements/class/async-method/await-as-label-identifier-escaped.js new file mode 100644 index 0000000000..cb57855059 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-method/await-as-label-identifier-escaped.js @@ -0,0 +1,39 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/async-functions/await-as-label-identifier-escaped.case +// - src/async-functions/syntax/async-class-decl-method.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as a label identifier. (Async method as a ClassDeclaration element) +esid: prod-AsyncMethod +features: [async-functions] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncMethod + + Async Function Definitions + + AsyncMethod : + async [no LineTerminator here] PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + + LabelIdentifier : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +$DONOTEVALUATE(); + + +class C { + async method() { + \u0061wait: ; + } +} diff --git a/js/src/tests/test262/language/statements/class/async-method/await-as-label-identifier.js b/js/src/tests/test262/language/statements/class/async-method/await-as-label-identifier.js new file mode 100644 index 0000000000..514d8fa7d1 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-method/await-as-label-identifier.js @@ -0,0 +1,39 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/async-functions/await-as-label-identifier.case +// - src/async-functions/syntax/async-class-decl-method.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as a label identifier. (Async method as a ClassDeclaration element) +esid: prod-AsyncMethod +features: [async-functions] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncMethod + + Async Function Definitions + + AsyncMethod : + async [no LineTerminator here] PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + + LabelIdentifier : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +$DONOTEVALUATE(); + + +class C { + async method() { + await: ; + } +} diff --git a/js/src/tests/test262/language/statements/class/async-method/browser.js b/js/src/tests/test262/language/statements/class/async-method/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/async-method/dflt-params-abrupt.js b/js/src/tests/test262/language/statements/class/async-method/dflt-params-abrupt.js new file mode 100644 index 0000000000..aaac592903 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-method/dflt-params-abrupt.js @@ -0,0 +1,69 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-abrupt.case +// - src/function-forms/error/cls-decl-async-meth.template +/*--- +description: Abrupt completion returned by evaluation of initializer (class declaration async method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [default-parameters, async-functions] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncMethod : async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncMethod is strict mode code, let strict be true. Otherwise + let strict be false. + 4. Let scope be the LexicalEnvironment of the running execution context. + 5. Let closure be ! AsyncFunctionCreate(Method, UniqueFormalParameters, AsyncFunctionBody, + scope, strict). + [...] + + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. + +---*/ + + +var callCount = 0; +class C { + async method(_ = (function() { throw new Test262Error(); }())) { + + callCount = callCount + 1; + } +} + +C.prototype.method() + .then(_ => { + throw new Test262Error('function should not be resolved'); + }, error => assert.sameValue(error.constructor, Test262Error)) + .then(() => { + assert.sameValue(callCount, 0, 'function body is not evaluated'); + }, $DONE) + .then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/async-method/dflt-params-arg-val-not-undefined.js b/js/src/tests/test262/language/statements/class/async-method/dflt-params-arg-val-not-undefined.js new file mode 100644 index 0000000000..bed4014129 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-method/dflt-params-arg-val-not-undefined.js @@ -0,0 +1,90 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-arg-val-not-undefined.case +// - src/function-forms/default/cls-decl-async-meth.template +/*--- +description: Use of initializer when argument value is not `undefined` (class declaration async method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [default-parameters, async-functions] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncMethod : async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncMethod is strict mode code, let strict be true. Otherwise + let strict be false. + 4. Let scope be the LexicalEnvironment of the running execution context. + 5. Let closure be ! AsyncFunctionCreate(Method, UniqueFormalParameters, AsyncFunctionBody, + scope, strict). + [...] + + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + [...] + 23. Let iteratorRecord be Record {[[Iterator]]: + CreateListIterator(argumentsList), [[Done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + a. Perform ? IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + +---*/ +var obj = {}; +var falseCount = 0; +var stringCount = 0; +var nanCount = 0; +var zeroCount = 0; +var nullCount = 0; +var objCount = 0; + + +var callCount = 0; +class C { + async method(aFalse = falseCount +=1, aString = stringCount += 1, aNaN = nanCount += 1, a0 = zeroCount += 1, aNull = nullCount += 1, aObj = objCount +=1) { + assert.sameValue(aFalse, false); + assert.sameValue(aString, ''); + assert.sameValue(aNaN, NaN); + assert.sameValue(a0, 0); + assert.sameValue(aNull, null); + assert.sameValue(aObj, obj); + callCount = callCount + 1; + } +} + +// Stores a reference `ref` for case evaluation +var ref = C.prototype.method; + +ref(false, '', NaN, 0, null, obj).then(() => { + assert.sameValue(callCount, 1, 'method invoked exactly once'); +}).then($DONE, $DONE); + +assert.sameValue(falseCount, 0, 'initializer not evaluated: false'); +assert.sameValue(stringCount, 0, 'initializer not evaluated: string'); +assert.sameValue(nanCount, 0, 'initializer not evaluated: NaN'); +assert.sameValue(zeroCount, 0, 'initializer not evaluated: 0'); +assert.sameValue(nullCount, 0, 'initializer not evaluated: null'); +assert.sameValue(objCount, 0, 'initializer not evaluated: object'); diff --git a/js/src/tests/test262/language/statements/class/async-method/dflt-params-arg-val-undefined.js b/js/src/tests/test262/language/statements/class/async-method/dflt-params-arg-val-undefined.js new file mode 100644 index 0000000000..1081d0286d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-method/dflt-params-arg-val-undefined.js @@ -0,0 +1,73 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-arg-val-undefined.case +// - src/function-forms/default/cls-decl-async-meth.template +/*--- +description: Use of initializer when argument value is `undefined` (class declaration async method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [default-parameters, async-functions] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncMethod : async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncMethod is strict mode code, let strict be true. Otherwise + let strict be false. + 4. Let scope be the LexicalEnvironment of the running execution context. + 5. Let closure be ! AsyncFunctionCreate(Method, UniqueFormalParameters, AsyncFunctionBody, + scope, strict). + [...] + + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + [...] + 23. Let iteratorRecord be Record {[[Iterator]]: + CreateListIterator(argumentsList), [[Done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + a. Perform ? IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + +---*/ + + +var callCount = 0; +class C { + async method(fromLiteral = 23, fromExpr = 45, fromHole = 99) { + assert.sameValue(fromLiteral, 23); + assert.sameValue(fromExpr, 45); + assert.sameValue(fromHole, 99); + callCount = callCount + 1; + } +} + +// Stores a reference `ref` for case evaluation +var ref = C.prototype.method; + +ref(undefined, void 0).then(() => { + assert.sameValue(callCount, 1, 'method invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/async-method/dflt-params-duplicates.js b/js/src/tests/test262/language/statements/class/async-method/dflt-params-duplicates.js new file mode 100644 index 0000000000..929fa6fe0c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-method/dflt-params-duplicates.js @@ -0,0 +1,65 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-duplicates.case +// - src/function-forms/syntax/cls-decl-async-meth.template +/*--- +description: It is a Syntax Error if BoundNames of FormalParameters contains any duplicate elements. (class declaration async method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [default-parameters] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncMethod : async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncMethod is strict mode code, let strict be true. Otherwise + let strict be false. + 4. Let scope be the LexicalEnvironment of the running execution context. + 5. Let closure be ! AsyncFunctionCreate(Method, UniqueFormalParameters, AsyncFunctionBody, + scope, strict). + [...] + + + 14.1.2 Static Semantics: Early Errors + + StrictFormalParameters : FormalParameters + + - It is a Syntax Error if BoundNames of FormalParameters contains any + duplicate elements. + + FormalParameters : FormalParameterList + + - It is a Syntax Error if IsSimpleParameterList of FormalParameterList is + false and BoundNames of FormalParameterList contains any duplicate + elements. + +---*/ +$DONOTEVALUATE(); + + +class C { + async method(x = 0, x) { + + } +} diff --git a/js/src/tests/test262/language/statements/class/async-method/dflt-params-ref-later.js b/js/src/tests/test262/language/statements/class/async-method/dflt-params-ref-later.js new file mode 100644 index 0000000000..6354543331 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-method/dflt-params-ref-later.js @@ -0,0 +1,70 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-ref-later.case +// - src/function-forms/error/cls-decl-async-meth.template +/*--- +description: Referencing a parameter that occurs later in the ParameterList (class declaration async method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [default-parameters, async-functions] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncMethod : async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncMethod is strict mode code, let strict be true. Otherwise + let strict be false. + 4. Let scope be the LexicalEnvironment of the running execution context. + 5. Let closure be ! AsyncFunctionCreate(Method, UniqueFormalParameters, AsyncFunctionBody, + scope, strict). + [...] + + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. + +---*/ +var x = 0; + + +var callCount = 0; +class C { + async method(x = y, y) { + + callCount = callCount + 1; + } +} + +C.prototype.method() + .then(_ => { + throw new Test262Error('function should not be resolved'); + }, error => assert.sameValue(error.constructor, ReferenceError)) + .then(() => { + assert.sameValue(callCount, 0, 'function body is not evaluated'); + }, $DONE) + .then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/async-method/dflt-params-ref-prior.js b/js/src/tests/test262/language/statements/class/async-method/dflt-params-ref-prior.js new file mode 100644 index 0000000000..4ccffdb34a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-method/dflt-params-ref-prior.js @@ -0,0 +1,70 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-ref-prior.case +// - src/function-forms/default/cls-decl-async-meth.template +/*--- +description: Referencing a parameter that occurs earlier in the ParameterList (class declaration async method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [default-parameters, async-functions] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncMethod : async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncMethod is strict mode code, let strict be true. Otherwise + let strict be false. + 4. Let scope be the LexicalEnvironment of the running execution context. + 5. Let closure be ! AsyncFunctionCreate(Method, UniqueFormalParameters, AsyncFunctionBody, + scope, strict). + [...] + + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. + +---*/ +var x = 0; + + +var callCount = 0; +class C { + async method(x, y = x, z = y) { + assert.sameValue(x, 3, 'first argument value'); + assert.sameValue(y, 3, 'second argument value'); + assert.sameValue(z, 3, 'third argument value'); + callCount = callCount + 1; + } +} + +// Stores a reference `ref` for case evaluation +var ref = C.prototype.method; + +ref(3).then(() => { + assert.sameValue(callCount, 1, 'method invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/async-method/dflt-params-ref-self.js b/js/src/tests/test262/language/statements/class/async-method/dflt-params-ref-self.js new file mode 100644 index 0000000000..60d0a36730 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-method/dflt-params-ref-self.js @@ -0,0 +1,70 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-ref-self.case +// - src/function-forms/error/cls-decl-async-meth.template +/*--- +description: Referencing a parameter from within its own initializer (class declaration async method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [default-parameters, async-functions] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncMethod : async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncMethod is strict mode code, let strict be true. Otherwise + let strict be false. + 4. Let scope be the LexicalEnvironment of the running execution context. + 5. Let closure be ! AsyncFunctionCreate(Method, UniqueFormalParameters, AsyncFunctionBody, + scope, strict). + [...] + + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. + +---*/ +var x = 0; + + +var callCount = 0; +class C { + async method(x = x) { + + callCount = callCount + 1; + } +} + +C.prototype.method() + .then(_ => { + throw new Test262Error('function should not be resolved'); + }, error => assert.sameValue(error.constructor, ReferenceError)) + .then(() => { + assert.sameValue(callCount, 0, 'function body is not evaluated'); + }, $DONE) + .then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/async-method/dflt-params-rest.js b/js/src/tests/test262/language/statements/class/async-method/dflt-params-rest.js new file mode 100644 index 0000000000..053a8ea6e3 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-method/dflt-params-rest.js @@ -0,0 +1,69 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-rest.case +// - src/function-forms/syntax/cls-decl-async-meth.template +/*--- +description: RestParameter does not support an initializer (class declaration async method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [default-parameters] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncMethod : async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncMethod is strict mode code, let strict be true. Otherwise + let strict be false. + 4. Let scope be the LexicalEnvironment of the running execution context. + 5. Let closure be ! AsyncFunctionCreate(Method, UniqueFormalParameters, AsyncFunctionBody, + scope, strict). + [...] + + + 14.1 Function Definitions + + Syntax + + FunctionRestParameter[Yield] : + + BindingRestElement[?Yield] + + 13.3.3 Destructuring Binding Patterns + + Syntax + + BindingRestElement[Yield] : + + ...BindingIdentifier[?Yield] + ...BindingPattern[?Yield] + +---*/ +$DONOTEVALUATE(); + + +class C { + async method(...x = []) { + + } +} diff --git a/js/src/tests/test262/language/statements/class/async-method/dflt-params-trailing-comma.js b/js/src/tests/test262/language/statements/class/async-method/dflt-params-trailing-comma.js new file mode 100644 index 0000000000..c37207785a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-method/dflt-params-trailing-comma.js @@ -0,0 +1,65 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-trailing-comma.case +// - src/function-forms/default/cls-decl-async-meth.template +/*--- +description: A trailing comma should not increase the respective length, using default parameters (class declaration async method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-functions] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncMethod : async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncMethod is strict mode code, let strict be true. Otherwise + let strict be false. + 4. Let scope be the LexicalEnvironment of the running execution context. + 5. Let closure be ! AsyncFunctionCreate(Method, UniqueFormalParameters, AsyncFunctionBody, + scope, strict). + [...] + + + Trailing comma in the parameters list + + 14.1 Function Definitions + + FormalParameters[Yield, Await] : FormalParameterList[?Yield, ?Await] , +---*/ + + +var callCount = 0; +class C { + async method(a, b = 39,) { + assert.sameValue(a, 42); + assert.sameValue(b, 39); + callCount = callCount + 1; + } +} + +// Stores a reference `ref` for case evaluation +var ref = C.prototype.method; + +ref(42, undefined, 1).then(() => { + assert.sameValue(callCount, 1, 'method invoked exactly once'); +}).then($DONE, $DONE); + +assert.sameValue(ref.length, 1, 'length is properly set'); diff --git a/js/src/tests/test262/language/statements/class/async-method/forbidden-ext/b1/browser.js b/js/src/tests/test262/language/statements/class/async-method/forbidden-ext/b1/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/async-method/forbidden-ext/b1/cls-decl-async-meth-forbidden-ext-direct-access-prop-arguments.js b/js/src/tests/test262/language/statements/class/async-method/forbidden-ext/b1/cls-decl-async-meth-forbidden-ext-direct-access-prop-arguments.js new file mode 100644 index 0000000000..741a765447 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-method/forbidden-ext/b1/cls-decl-async-meth-forbidden-ext-direct-access-prop-arguments.js @@ -0,0 +1,39 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/function-forms/forbidden-ext-direct-access-prop-arguments.case +// - src/function-forms/forbidden-extensions/bullet-one/cls-decl-async-meth.template +/*--- +description: Forbidden extension, f.arguments (class declaration async method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [arrow-function, async-functions, class] +flags: [generated, noStrict, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + + ECMAScript function objects defined using syntactic constructors in strict mode code must + not be created with own properties named "caller" or "arguments". Such own properties also + must not be created for function objects defined using an ArrowFunction, MethodDefinition, + GeneratorDeclaration, GeneratorExpression, AsyncGeneratorDeclaration, AsyncGeneratorExpression, + ClassDeclaration, ClassExpression, AsyncFunctionDeclaration, AsyncFunctionExpression, or + AsyncArrowFunction regardless of whether the definition is contained in strict mode code. + Built-in functions, strict functions created using the Function constructor, generator functions + created using the Generator constructor, async functions created using the AsyncFunction + constructor, and functions created using the bind method also must not be created with such own + properties. + +---*/ + + +var callCount = 0; +class C { + async method() { + assert.sameValue(this.method.hasOwnProperty("arguments"), false); + callCount++; + } +} + +C.prototype.method() + .then(() => { + assert.sameValue(callCount, 1, 'function body evaluated'); + }, $DONE).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/async-method/forbidden-ext/b1/cls-decl-async-meth-forbidden-ext-direct-access-prop-caller.js b/js/src/tests/test262/language/statements/class/async-method/forbidden-ext/b1/cls-decl-async-meth-forbidden-ext-direct-access-prop-caller.js new file mode 100644 index 0000000000..dd2def5668 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-method/forbidden-ext/b1/cls-decl-async-meth-forbidden-ext-direct-access-prop-caller.js @@ -0,0 +1,39 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/function-forms/forbidden-ext-direct-access-prop-caller.case +// - src/function-forms/forbidden-extensions/bullet-one/cls-decl-async-meth.template +/*--- +description: Forbidden extension, o.caller (class declaration async method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [arrow-function, async-functions, class] +flags: [generated, noStrict, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + + ECMAScript function objects defined using syntactic constructors in strict mode code must + not be created with own properties named "caller" or "arguments". Such own properties also + must not be created for function objects defined using an ArrowFunction, MethodDefinition, + GeneratorDeclaration, GeneratorExpression, AsyncGeneratorDeclaration, AsyncGeneratorExpression, + ClassDeclaration, ClassExpression, AsyncFunctionDeclaration, AsyncFunctionExpression, or + AsyncArrowFunction regardless of whether the definition is contained in strict mode code. + Built-in functions, strict functions created using the Function constructor, generator functions + created using the Generator constructor, async functions created using the AsyncFunction + constructor, and functions created using the bind method also must not be created with such own + properties. + +---*/ + + +var callCount = 0; +class C { + async method() { + assert.sameValue(this.method.hasOwnProperty("caller"), false); + callCount++; + } +} + +C.prototype.method() + .then(() => { + assert.sameValue(callCount, 1, 'function body evaluated'); + }, $DONE).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/async-method/forbidden-ext/b1/shell.js b/js/src/tests/test262/language/statements/class/async-method/forbidden-ext/b1/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/async-method/forbidden-ext/b2/browser.js b/js/src/tests/test262/language/statements/class/async-method/forbidden-ext/b2/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/async-method/forbidden-ext/b2/cls-decl-async-meth-forbidden-ext-indirect-access-own-prop-caller-get.js b/js/src/tests/test262/language/statements/class/async-method/forbidden-ext/b2/cls-decl-async-meth-forbidden-ext-indirect-access-own-prop-caller-get.js new file mode 100644 index 0000000000..affd996b64 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-method/forbidden-ext/b2/cls-decl-async-meth-forbidden-ext-indirect-access-own-prop-caller-get.js @@ -0,0 +1,65 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/function-forms/forbidden-ext-indirect-access-own-prop-caller-get.case +// - src/function-forms/forbidden-extensions/bullet-two/cls-decl-async-meth.template +/*--- +description: Forbidden extension, o.caller (class declaration async method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [arrow-function, async-functions, class] +flags: [generated, noStrict, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + + If an implementation extends any function object with an own property named "caller" the value of + that property, as observed using [[Get]] or [[GetOwnProperty]], must not be a strict function + object. If it is an accessor property, the function that is the value of the property's [[Get]] + attribute must never return a strict function when called. + +---*/ +var CALLER_OWN_PROPERTY_DOES_NOT_EXIST = Symbol(); +function inner() { + // This property may exist, but is forbidden from having a value that is a strict function object + return inner.hasOwnProperty("caller") + ? inner.caller + : CALLER_OWN_PROPERTY_DOES_NOT_EXIST; +} + + +var callCount = 0; +class C { + async method() { + /* implicit strict */ + // This and the following conditional value is set in the test's .case file. + // For every test that has a "true" value here, there is a + // corresponding test that has a "false" value here. + // They are generated from two different case files, which use + let descriptor = Object.getOwnPropertyDescriptor(inner, "caller"); + if (descriptor && descriptor.configurable && true) { + Object.defineProperty(inner, "caller", {get(){return 1}}); + } + var result = inner(); + if (descriptor && descriptor.configurable && true) { + assert.sameValue(result, 1, 'If this test defined an own "caller" property on the inner function, then it should be accessible and should return the value it was set to.'); + } + + // "CALLER_OWN_PROPERTY_DOES_NOT_EXIST" is from + // forbidden-ext-indirect-access-prop-caller.case + // + // If the function object "inner" has an own property + // named "caller", then its value will be returned. + // + // If the function object "inner" DOES NOT have an + // own property named "caller", then the symbol + // CALLER_OWN_PROPERTY_DOES_NOT_EXIST will be returned. + if (result !== CALLER_OWN_PROPERTY_DOES_NOT_EXIST) { + assert.notSameValue(result, this.method); + } + callCount++; + } +} + +C.prototype.method() + .then(() => { + assert.sameValue(callCount, 1, 'function body evaluated'); + }, $DONE).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/async-method/forbidden-ext/b2/cls-decl-async-meth-forbidden-ext-indirect-access-own-prop-caller-value.js b/js/src/tests/test262/language/statements/class/async-method/forbidden-ext/b2/cls-decl-async-meth-forbidden-ext-indirect-access-own-prop-caller-value.js new file mode 100644 index 0000000000..e144379c64 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-method/forbidden-ext/b2/cls-decl-async-meth-forbidden-ext-indirect-access-own-prop-caller-value.js @@ -0,0 +1,65 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/function-forms/forbidden-ext-indirect-access-own-prop-caller-value.case +// - src/function-forms/forbidden-extensions/bullet-two/cls-decl-async-meth.template +/*--- +description: Forbidden extension, o.caller (class declaration async method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [arrow-function, async-functions, class] +flags: [generated, noStrict, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + + If an implementation extends any function object with an own property named "caller" the value of + that property, as observed using [[Get]] or [[GetOwnProperty]], must not be a strict function + object. If it is an accessor property, the function that is the value of the property's [[Get]] + attribute must never return a strict function when called. + +---*/ +var CALLER_OWN_PROPERTY_DOES_NOT_EXIST = Symbol(); +function inner() { + // This property may exist, but is forbidden from having a value that is a strict function object + return inner.hasOwnProperty("caller") + ? inner.caller + : CALLER_OWN_PROPERTY_DOES_NOT_EXIST; +} + + +var callCount = 0; +class C { + async method() { + /* implicit strict */ + // This and the following conditional value is set in the test's .case file. + // For every test that has a "true" value here, there is a + // corresponding test that has a "false" value here. + // They are generated from two different case files, which use + let descriptor = Object.getOwnPropertyDescriptor(inner, "caller"); + if (descriptor && descriptor.configurable && true) { + Object.defineProperty(inner, "caller", {value: 1}); + } + var result = inner(); + if (descriptor && descriptor.configurable && true) { + assert.sameValue(result, 1, 'If this test defined an own "caller" property on the inner function, then it should be accessible and should return the value it was set to.'); + } + + // "CALLER_OWN_PROPERTY_DOES_NOT_EXIST" is from + // forbidden-ext-indirect-access-prop-caller.case + // + // If the function object "inner" has an own property + // named "caller", then its value will be returned. + // + // If the function object "inner" DOES NOT have an + // own property named "caller", then the symbol + // CALLER_OWN_PROPERTY_DOES_NOT_EXIST will be returned. + if (result !== CALLER_OWN_PROPERTY_DOES_NOT_EXIST) { + assert.notSameValue(result, this.method); + } + callCount++; + } +} + +C.prototype.method() + .then(() => { + assert.sameValue(callCount, 1, 'function body evaluated'); + }, $DONE).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/async-method/forbidden-ext/b2/cls-decl-async-meth-forbidden-ext-indirect-access-prop-caller.js b/js/src/tests/test262/language/statements/class/async-method/forbidden-ext/b2/cls-decl-async-meth-forbidden-ext-indirect-access-prop-caller.js new file mode 100644 index 0000000000..6691fb340c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-method/forbidden-ext/b2/cls-decl-async-meth-forbidden-ext-indirect-access-prop-caller.js @@ -0,0 +1,65 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/function-forms/forbidden-ext-indirect-access-prop-caller.case +// - src/function-forms/forbidden-extensions/bullet-two/cls-decl-async-meth.template +/*--- +description: Forbidden extension, o.caller (class declaration async method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [arrow-function, async-functions, class] +flags: [generated, noStrict, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + + If an implementation extends any function object with an own property named "caller" the value of + that property, as observed using [[Get]] or [[GetOwnProperty]], must not be a strict function + object. If it is an accessor property, the function that is the value of the property's [[Get]] + attribute must never return a strict function when called. + +---*/ +var CALLER_OWN_PROPERTY_DOES_NOT_EXIST = Symbol(); +function inner() { + // This property may exist, but is forbidden from having a value that is a strict function object + return inner.hasOwnProperty("caller") + ? inner.caller + : CALLER_OWN_PROPERTY_DOES_NOT_EXIST; +} + + +var callCount = 0; +class C { + async method() { + /* implicit strict */ + // This and the following conditional value is set in the test's .case file. + // For every test that has a "true" value here, there is a + // corresponding test that has a "false" value here. + // They are generated from two different case files, which use + let descriptor = Object.getOwnPropertyDescriptor(inner, "caller"); + if (descriptor && descriptor.configurable && false) { + Object.defineProperty(inner, "caller", {}); + } + var result = inner(); + if (descriptor && descriptor.configurable && false) { + assert.sameValue(result, 1, 'If this test defined an own "caller" property on the inner function, then it should be accessible and should return the value it was set to.'); + } + + // "CALLER_OWN_PROPERTY_DOES_NOT_EXIST" is from + // forbidden-ext-indirect-access-prop-caller.case + // + // If the function object "inner" has an own property + // named "caller", then its value will be returned. + // + // If the function object "inner" DOES NOT have an + // own property named "caller", then the symbol + // CALLER_OWN_PROPERTY_DOES_NOT_EXIST will be returned. + if (result !== CALLER_OWN_PROPERTY_DOES_NOT_EXIST) { + assert.notSameValue(result, this.method); + } + callCount++; + } +} + +C.prototype.method() + .then(() => { + assert.sameValue(callCount, 1, 'function body evaluated'); + }, $DONE).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/async-method/forbidden-ext/b2/shell.js b/js/src/tests/test262/language/statements/class/async-method/forbidden-ext/b2/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/async-method/forbidden-ext/browser.js b/js/src/tests/test262/language/statements/class/async-method/forbidden-ext/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/async-method/forbidden-ext/shell.js b/js/src/tests/test262/language/statements/class/async-method/forbidden-ext/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/async-method/object-destructuring-param-strict-body.js b/js/src/tests/test262/language/statements/class/async-method/object-destructuring-param-strict-body.js new file mode 100644 index 0000000000..cf462c5e84 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-method/object-destructuring-param-strict-body.js @@ -0,0 +1,136 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/function-forms/object-destructuring-param-strict-body.case +// - src/function-forms/syntax/cls-decl-async-meth.template +/*--- +description: ObjectBindingPattern and Use Strict Directive are not allowed to coexist for the same function. (class declaration async method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [rest-parameters] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncMethod : async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncMethod is strict mode code, let strict be true. Otherwise + let strict be false. + 4. Let scope be the LexicalEnvironment of the running execution context. + 5. Let closure be ! AsyncFunctionCreate(Method, UniqueFormalParameters, AsyncFunctionBody, + scope, strict). + [...] + + + 13.3.3.4 Static Semantics: IsSimpleParameterList + + BindingElement : BindingPattern + + 1. Return false. + + 14.1.2 Static Semantics: Early Errors + + FunctionDeclaration : function BindingIdentifier ( FormalParameters ) { FunctionBody } + FunctionDeclaration : function ( FormalParameters ) { FunctionBody } + FunctionExpression : function BindingIdentifier ( FormalParameters ) { FunctionBody } + + - It is a Syntax Error if ContainsUseStrict of FunctionBody is true and + IsSimpleParameterList of FormalParameters is false. + + 14.2.1 Static Semantics: Early Errors + + ArrowFunction : ArrowParameters => ConciseBody + + - It is a Syntax Error if ContainsUseStrict of ConciseBody is true and + IsSimpleParameterList of ArrowParameters is false. + + 14.3.1 Static Semantics: Early Errors + + MethodDefinition : PropertyName ( UniqueFormalParameters ) { FunctionBody } + + - It is a Syntax Error if ContainsUseStrict of FunctionBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + MethodDefinition : set PropertyName ( PropertySetParameterList ) { FunctionBody } + + - It is a Syntax Error if ContainsUseStrict of FunctionBody is true and + IsSimpleParameterList of PropertySetParameterList is false. + + 14.4.1 Static Semantics: Early Errors + + GeneratorMethod : * PropertyName ( UniqueFormalParameters ) { GeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of GeneratorBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + GeneratorDeclaration : function * BindingIdentifier ( FormalParameters ) { GeneratorBody } + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + GeneratorExpression : function * BindingIdentifier ( FormalParameters ) { GeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of GeneratorBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + 14.5.1 Static Semantics: Early Errors + + AsyncGeneratorMethod : async * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncGeneratorBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + AsyncGeneratorDeclaration : async function * BindingIdentifier ( FormalParameters ) { AsyncGeneratorBody } + AsyncGeneratorDeclaration : async function * ( FormalParameters ) { AsyncGeneratorBody } + AsyncGeneratorExpression : async function * BindingIdentifier ( FormalParameters ) { AsyncGeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncGeneratorBody is true and + IsSimpleParameterList of FormalParameters is false. + + 14.7.1 Static Semantics: Early Errors + + AsyncMethod : async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncFunctionBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + AsyncFunctionDeclaration : async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody } + AsyncFunctionDeclaration : async function ( FormalParameters ) { AsyncFunctionBody } + AsyncFunctionExpression : async function ( FormalParameters ) { AsyncFunctionBody } + AsyncFunctionExpression : async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncFunctionBody is true and + IsSimpleParameterList of FormalParameters is false. + + 14.8.1 Static Semantics: Early Errors + + AsyncArrowFunction : CoverCallExpressionAndAsyncArrowHead => AsyncConciseBody + + - It is a Syntax Error if ContainsUseStrict of AsyncConciseBody is true and + IsSimpleParameterList of CoverCallExpressionAndAsyncArrowHead is false. + +---*/ +$DONOTEVALUATE(); + + +class C { + async method({property}) { + "use strict"; + } +} diff --git a/js/src/tests/test262/language/statements/class/async-method/params-trailing-comma-multiple.js b/js/src/tests/test262/language/statements/class/async-method/params-trailing-comma-multiple.js new file mode 100644 index 0000000000..3ed41638d7 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-method/params-trailing-comma-multiple.js @@ -0,0 +1,65 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/function-forms/params-trailing-comma-multiple.case +// - src/function-forms/default/cls-decl-async-meth.template +/*--- +description: A trailing comma should not increase the respective length, using multiple parameters (class declaration async method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-functions] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncMethod : async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncMethod is strict mode code, let strict be true. Otherwise + let strict be false. + 4. Let scope be the LexicalEnvironment of the running execution context. + 5. Let closure be ! AsyncFunctionCreate(Method, UniqueFormalParameters, AsyncFunctionBody, + scope, strict). + [...] + + + Trailing comma in the parameters list + + 14.1 Function Definitions + + FormalParameters[Yield, Await] : FormalParameterList[?Yield, ?Await] , +---*/ + + +var callCount = 0; +class C { + async method(a, b,) { + assert.sameValue(a, 42); + assert.sameValue(b, 39); + callCount = callCount + 1; + } +} + +// Stores a reference `ref` for case evaluation +var ref = C.prototype.method; + +ref(42, 39, 1).then(() => { + assert.sameValue(callCount, 1, 'method invoked exactly once'); +}).then($DONE, $DONE); + +assert.sameValue(ref.length, 2, 'length is properly set'); diff --git a/js/src/tests/test262/language/statements/class/async-method/params-trailing-comma-single.js b/js/src/tests/test262/language/statements/class/async-method/params-trailing-comma-single.js new file mode 100644 index 0000000000..7f9df37483 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-method/params-trailing-comma-single.js @@ -0,0 +1,64 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/function-forms/params-trailing-comma-single.case +// - src/function-forms/default/cls-decl-async-meth.template +/*--- +description: A trailing comma should not increase the respective length, using a single parameter (class declaration async method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-functions] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncMethod : async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncMethod is strict mode code, let strict be true. Otherwise + let strict be false. + 4. Let scope be the LexicalEnvironment of the running execution context. + 5. Let closure be ! AsyncFunctionCreate(Method, UniqueFormalParameters, AsyncFunctionBody, + scope, strict). + [...] + + + Trailing comma in the parameters list + + 14.1 Function Definitions + + FormalParameters[Yield, Await] : FormalParameterList[?Yield, ?Await] , +---*/ + + +var callCount = 0; +class C { + async method(a,) { + assert.sameValue(a, 42); + callCount = callCount + 1; + } +} + +// Stores a reference `ref` for case evaluation +var ref = C.prototype.method; + +ref(42, 39).then(() => { + assert.sameValue(callCount, 1, 'method invoked exactly once'); +}).then($DONE, $DONE); + +assert.sameValue(ref.length, 1, 'length is properly set'); diff --git a/js/src/tests/test262/language/statements/class/async-method/rest-param-strict-body.js b/js/src/tests/test262/language/statements/class/async-method/rest-param-strict-body.js new file mode 100644 index 0000000000..0309fc746a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-method/rest-param-strict-body.js @@ -0,0 +1,136 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/function-forms/rest-param-strict-body.case +// - src/function-forms/syntax/cls-decl-async-meth.template +/*--- +description: RestParameter and Use Strict Directive are not allowed to coexist for the same function. (class declaration async method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [rest-parameters] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncMethod : async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncMethod is strict mode code, let strict be true. Otherwise + let strict be false. + 4. Let scope be the LexicalEnvironment of the running execution context. + 5. Let closure be ! AsyncFunctionCreate(Method, UniqueFormalParameters, AsyncFunctionBody, + scope, strict). + [...] + + + 14.1.13 Static Semantics: IsSimpleParameterList + + FormalParameters : FormalParameterList , FunctionRestParameter + + 1. Return false. + + 14.1.2 Static Semantics: Early Errors + + FunctionDeclaration : function BindingIdentifier ( FormalParameters ) { FunctionBody } + FunctionDeclaration : function ( FormalParameters ) { FunctionBody } + FunctionExpression : function BindingIdentifier ( FormalParameters ) { FunctionBody } + + - It is a Syntax Error if ContainsUseStrict of FunctionBody is true and + IsSimpleParameterList of FormalParameters is false. + + 14.2.1 Static Semantics: Early Errors + + ArrowFunction : ArrowParameters => ConciseBody + + - It is a Syntax Error if ContainsUseStrict of ConciseBody is true and + IsSimpleParameterList of ArrowParameters is false. + + 14.3.1 Static Semantics: Early Errors + + MethodDefinition : PropertyName ( UniqueFormalParameters ) { FunctionBody } + + - It is a Syntax Error if ContainsUseStrict of FunctionBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + MethodDefinition : set PropertyName ( PropertySetParameterList ) { FunctionBody } + + - It is a Syntax Error if ContainsUseStrict of FunctionBody is true and + IsSimpleParameterList of PropertySetParameterList is false. + + 14.4.1 Static Semantics: Early Errors + + GeneratorMethod : * PropertyName ( UniqueFormalParameters ) { GeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of GeneratorBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + GeneratorDeclaration : function * BindingIdentifier ( FormalParameters ) { GeneratorBody } + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + GeneratorExpression : function * BindingIdentifier ( FormalParameters ) { GeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of GeneratorBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + 14.5.1 Static Semantics: Early Errors + + AsyncGeneratorMethod : async * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncGeneratorBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + AsyncGeneratorDeclaration : async function * BindingIdentifier ( FormalParameters ) { AsyncGeneratorBody } + AsyncGeneratorDeclaration : async function * ( FormalParameters ) { AsyncGeneratorBody } + AsyncGeneratorExpression : async function * BindingIdentifier ( FormalParameters ) { AsyncGeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncGeneratorBody is true and + IsSimpleParameterList of FormalParameters is false. + + 14.7.1 Static Semantics: Early Errors + + AsyncMethod : async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncFunctionBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + AsyncFunctionDeclaration : async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody } + AsyncFunctionDeclaration : async function ( FormalParameters ) { AsyncFunctionBody } + AsyncFunctionExpression : async function ( FormalParameters ) { AsyncFunctionBody } + AsyncFunctionExpression : async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncFunctionBody is true and + IsSimpleParameterList of FormalParameters is false. + + 14.8.1 Static Semantics: Early Errors + + AsyncArrowFunction : CoverCallExpressionAndAsyncArrowHead => AsyncConciseBody + + - It is a Syntax Error if ContainsUseStrict of AsyncConciseBody is true and + IsSimpleParameterList of CoverCallExpressionAndAsyncArrowHead is false. + +---*/ +$DONOTEVALUATE(); + + +class C { + async method(a,...rest) { + "use strict"; + } +} diff --git a/js/src/tests/test262/language/statements/class/async-method/rest-params-trailing-comma-early-error.js b/js/src/tests/test262/language/statements/class/async-method/rest-params-trailing-comma-early-error.js new file mode 100644 index 0000000000..0599033ac7 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-method/rest-params-trailing-comma-early-error.js @@ -0,0 +1,61 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/function-forms/rest-params-trailing-comma-early-error.case +// - src/function-forms/syntax/cls-decl-async-meth.template +/*--- +description: It's a syntax error if a FunctionRestParameter is followed by a trailing comma (class declaration async method) +esid: sec-class-definitions-runtime-semantics-evaluation +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncMethod : async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncMethod is strict mode code, let strict be true. Otherwise + let strict be false. + 4. Let scope be the LexicalEnvironment of the running execution context. + 5. Let closure be ! AsyncFunctionCreate(Method, UniqueFormalParameters, AsyncFunctionBody, + scope, strict). + [...] + + + Trailing comma in the parameters list + + 14.1 Function Definitions + + FormalParameters[Yield, Await] : + [empty] + FunctionRestParameter[?Yield, ?Await] + FormalParameterList[?Yield, ?Await] + FormalParameterList[?Yield, ?Await] , + FormalParameterList[?Yield, ?Await] , FunctionRestParameter[?Yield, ?Await] +---*/ +$DONOTEVALUATE(); + + +class C { + async method(...a,) { + + } +} diff --git a/js/src/tests/test262/language/statements/class/async-method/returns-async-arrow-returns-arguments-from-parent-function.js b/js/src/tests/test262/language/statements/class/async-method/returns-async-arrow-returns-arguments-from-parent-function.js new file mode 100644 index 0000000000..0cdf4958cd --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-method/returns-async-arrow-returns-arguments-from-parent-function.js @@ -0,0 +1,42 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-functions/returns-async-arrow-returns-arguments-from-parent-function.case +// - src/async-functions/evaluation/async-class-decl-method.template +/*--- +description: Async function returns an async function. (Async method as a ClassDeclaration element) +esid: prod-AsyncMethod +features: [async-functions] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncMethod + + Async Function Definitions + + AsyncMethod : + async [no LineTerminator here] PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + +---*/ +let count = 0; + + +class C { + async method(x) { + let a = arguments; + return async () => a === arguments; + } +} +// Stores a reference `asyncFn` for case evaluation +let c = new C(); +let asyncFn = c.method.bind(c); + +asyncFn().then(retFn => { + count++; + return retFn(); +}).then(result => { + assert.sameValue(result, true); + assert.sameValue(count, 1); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/async-method/returns-async-arrow-returns-newtarget.js b/js/src/tests/test262/language/statements/class/async-method/returns-async-arrow-returns-newtarget.js new file mode 100644 index 0000000000..d61779e664 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-method/returns-async-arrow-returns-newtarget.js @@ -0,0 +1,41 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-functions/returns-async-arrow-returns-newtarget.case +// - src/async-functions/evaluation/async-class-decl-method.template +/*--- +description: Async function returns an async function. (Async method as a ClassDeclaration element) +esid: prod-AsyncMethod +features: [async-functions] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncMethod + + Async Function Definitions + + AsyncMethod : + async [no LineTerminator here] PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + +---*/ +let count = 0; + + +class C { + async method(x) { + return async () => new.target; + } +} +// Stores a reference `asyncFn` for case evaluation +let c = new C(); +let asyncFn = c.method.bind(c); + +asyncFn().then(retFn => { + count++; + return retFn(); +}).then(result => { + assert.sameValue(result, undefined); + assert.sameValue(count, 1); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/async-method/returns-async-arrow.js b/js/src/tests/test262/language/statements/class/async-method/returns-async-arrow.js new file mode 100644 index 0000000000..aacd815b31 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-method/returns-async-arrow.js @@ -0,0 +1,41 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-functions/returns-async-arrow.case +// - src/async-functions/evaluation/async-class-decl-method.template +/*--- +description: Async function returns an async function. (Async method as a ClassDeclaration element) +esid: prod-AsyncMethod +features: [async-functions] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncMethod + + Async Function Definitions + + AsyncMethod : + async [no LineTerminator here] PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + +---*/ +let count = 0; + + +class C { + async method(x) { + return async () => x; + } +} +// Stores a reference `asyncFn` for case evaluation +let c = new C(); +let asyncFn = c.method.bind(c); + +asyncFn(1).then(retFn => { + count++; + return retFn(); +}).then(result => { + assert.sameValue(result, 1); + assert.sameValue(count, 1); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/async-method/returns-async-function-returns-arguments-from-own-function.js b/js/src/tests/test262/language/statements/class/async-method/returns-async-function-returns-arguments-from-own-function.js new file mode 100644 index 0000000000..98a0426f37 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-method/returns-async-function-returns-arguments-from-own-function.js @@ -0,0 +1,42 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-functions/returns-async-function-returns-arguments-from-own-function.case +// - src/async-functions/evaluation/async-class-decl-method.template +/*--- +description: Async function returns an async function. (Async method as a ClassDeclaration element) +esid: prod-AsyncMethod +features: [async-functions] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncMethod + + Async Function Definitions + + AsyncMethod : + async [no LineTerminator here] PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + +---*/ +let count = 0; + + +class C { + async method(x) { + let a = arguments; + return async function() { return a === arguments; }; + } +} +// Stores a reference `asyncFn` for case evaluation +let c = new C(); +let asyncFn = c.method.bind(c); + +asyncFn(1).then(retFn => { + count++; + return retFn(); +}).then(result => { + assert.sameValue(result, false); + assert.sameValue(count, 1); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/async-method/returns-async-function-returns-newtarget.js b/js/src/tests/test262/language/statements/class/async-method/returns-async-function-returns-newtarget.js new file mode 100644 index 0000000000..cb0f41d3ae --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-method/returns-async-function-returns-newtarget.js @@ -0,0 +1,41 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-functions/returns-async-function-returns-newtarget.case +// - src/async-functions/evaluation/async-class-decl-method.template +/*--- +description: Async function returns an async function. (Async method as a ClassDeclaration element) +esid: prod-AsyncMethod +features: [async-functions] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncMethod + + Async Function Definitions + + AsyncMethod : + async [no LineTerminator here] PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + +---*/ +let count = 0; + + +class C { + async method(x) { + return async function() { return new.target; }; + } +} +// Stores a reference `asyncFn` for case evaluation +let c = new C(); +let asyncFn = c.method.bind(c); + +asyncFn(1).then(retFn => { + count++; + return retFn(); +}).then(result => { + assert.sameValue(result, undefined); + assert.sameValue(count, 1); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/async-method/returns-async-function.js b/js/src/tests/test262/language/statements/class/async-method/returns-async-function.js new file mode 100644 index 0000000000..6ad1e995de --- /dev/null +++ b/js/src/tests/test262/language/statements/class/async-method/returns-async-function.js @@ -0,0 +1,41 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-functions/returns-async-function.case +// - src/async-functions/evaluation/async-class-decl-method.template +/*--- +description: Async function returns an async function. (Async method as a ClassDeclaration element) +esid: prod-AsyncMethod +features: [async-functions] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + AsyncMethod + + Async Function Definitions + + AsyncMethod : + async [no LineTerminator here] PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + +---*/ +let count = 0; + + +class C { + async method(x) { + return async function() { return x; }; + } +} +// Stores a reference `asyncFn` for case evaluation +let c = new C(); +let asyncFn = c.method.bind(c); + +asyncFn(1).then(retFn => { + count++; + return retFn(); +}).then(result => { + assert.sameValue(result, 1); + assert.sameValue(count, 1); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/async-method/shell.js b/js/src/tests/test262/language/statements/class/async-method/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/browser.js b/js/src/tests/test262/language/statements/class/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/class-name-ident-await-escaped-module.js b/js/src/tests/test262/language/statements/class/class-name-ident-await-escaped-module.js new file mode 100644 index 0000000000..bded6b457b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/class-name-ident-await-escaped-module.js @@ -0,0 +1,24 @@ +// |reftest| error:SyntaxError module +// Copyright (C) 2018 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-class-definitions +description: > + `await` with escape sequence is a valid class-name identifier. +info: | + 12.1.1 Static Semantics: Early Errors + + Identifier : IdentifierName but not ReservedWord + + It is a Syntax Error if the goal symbol of the syntactic grammar is Module + and the StringValue of IdentifierName is "await". +negative: + phase: parse + type: SyntaxError +flags: [module] +---*/ + +$DONOTEVALUATE(); + +class aw\u0061it {} diff --git a/js/src/tests/test262/language/statements/class/class-name-ident-await-escaped.js b/js/src/tests/test262/language/statements/class/class-name-ident-await-escaped.js new file mode 100644 index 0000000000..6cf03b3ef0 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/class-name-ident-await-escaped.js @@ -0,0 +1,19 @@ +// Copyright (C) 2018 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-class-definitions +description: > + `await` with escape sequence is a valid class-name identifier. +info: | + 12.1.1 Static Semantics: Early Errors + + Identifier : IdentifierName but not ReservedWord + + It is a Syntax Error if the goal symbol of the syntactic grammar is Module + and the StringValue of IdentifierName is "await". +---*/ + +class aw\u0061it {} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/class-name-ident-await-module.js b/js/src/tests/test262/language/statements/class/class-name-ident-await-module.js new file mode 100644 index 0000000000..5b5b4d7424 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/class-name-ident-await-module.js @@ -0,0 +1,23 @@ +// |reftest| error:SyntaxError module +// Copyright (C) 2018 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-class-definitions +description: > + `await` is a valid class-name identifier. +info: | + 12.1.1 Static Semantics: Early Errors + + IdentifierReference : await + + It is a Syntax Error if the goal symbol of the syntactic grammar is Module. +negative: + phase: parse + type: SyntaxError +flags: [module] +---*/ + +$DONOTEVALUATE(); + +class await {} diff --git a/js/src/tests/test262/language/statements/class/class-name-ident-await.js b/js/src/tests/test262/language/statements/class/class-name-ident-await.js new file mode 100644 index 0000000000..aca98d4766 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/class-name-ident-await.js @@ -0,0 +1,18 @@ +// Copyright (C) 2018 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-class-definitions +description: > + `await` is a valid class-name identifier. +info: | + 12.1.1 Static Semantics: Early Errors + + IdentifierReference : await + + It is a Syntax Error if the goal symbol of the syntactic grammar is Module. +---*/ + +class await {} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/class-name-ident-let-escaped.js b/js/src/tests/test262/language/statements/class/class-name-ident-let-escaped.js new file mode 100644 index 0000000000..47dd2701a7 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/class-name-ident-let-escaped.js @@ -0,0 +1,28 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2018 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-class-definitions +description: > + `let` with escape sequence is not a valid class-name identifier. +info: | + 12.1.1 Static Semantics: Early Errors + + Identifier : IdentifierName but not ReservedWord + + It is a Syntax Error if this phrase is contained in strict mode code and the + StringValue of IdentifierName is: "implements", "interface", "let", "package", + "private", "protected", "public", "static", or "yield". + + 10.2.1 Strict Mode Code + + All parts of a ClassDeclaration or a ClassExpression are strict mode code. +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +class l\u0065t {} diff --git a/js/src/tests/test262/language/statements/class/class-name-ident-let.js b/js/src/tests/test262/language/statements/class/class-name-ident-let.js new file mode 100644 index 0000000000..16bb5d0190 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/class-name-ident-let.js @@ -0,0 +1,28 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2018 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-class-definitions +description: > + `let` is not a valid class-name identifier. +info: | + 12.1.1 Static Semantics: Early Errors + + Identifier : IdentifierName but not ReservedWord + + It is a Syntax Error if this phrase is contained in strict mode code and the + StringValue of IdentifierName is: "implements", "interface", "let", "package", + "private", "protected", "public", "static", or "yield". + + 10.2.1 Strict Mode Code + + All parts of a ClassDeclaration or a ClassExpression are strict mode code. +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +class let {} diff --git a/js/src/tests/test262/language/statements/class/class-name-ident-static-escaped.js b/js/src/tests/test262/language/statements/class/class-name-ident-static-escaped.js new file mode 100644 index 0000000000..5c41524021 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/class-name-ident-static-escaped.js @@ -0,0 +1,28 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2018 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-class-definitions +description: > + `static` with escape sequence is not a valid class-name identifier. +info: | + 12.1.1 Static Semantics: Early Errors + + Identifier : IdentifierName but not ReservedWord + + It is a Syntax Error if this phrase is contained in strict mode code and the + StringValue of IdentifierName is: "implements", "interface", "let", "package", + "private", "protected", "public", "static", or "yield". + + 10.2.1 Strict Mode Code + + All parts of a ClassDeclaration or a ClassExpression are strict mode code. +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +class st\u0061tic {} diff --git a/js/src/tests/test262/language/statements/class/class-name-ident-static.js b/js/src/tests/test262/language/statements/class/class-name-ident-static.js new file mode 100644 index 0000000000..3ad03ceb52 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/class-name-ident-static.js @@ -0,0 +1,28 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2018 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-class-definitions +description: > + `static` is not a valid class-name identifier. +info: | + 12.1.1 Static Semantics: Early Errors + + Identifier : IdentifierName but not ReservedWord + + It is a Syntax Error if this phrase is contained in strict mode code and the + StringValue of IdentifierName is: "implements", "interface", "let", "package", + "private", "protected", "public", "static", or "yield". + + 10.2.1 Strict Mode Code + + All parts of a ClassDeclaration or a ClassExpression are strict mode code. +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +class static {} diff --git a/js/src/tests/test262/language/statements/class/class-name-ident-yield-escaped.js b/js/src/tests/test262/language/statements/class/class-name-ident-yield-escaped.js new file mode 100644 index 0000000000..79d93b963c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/class-name-ident-yield-escaped.js @@ -0,0 +1,28 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2018 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-class-definitions +description: > + `yield` with escape sequence is not a valid class-name identifier. +info: | + 12.1.1 Static Semantics: Early Errors + + Identifier : IdentifierName but not ReservedWord + + It is a Syntax Error if this phrase is contained in strict mode code and the + StringValue of IdentifierName is: "implements", "interface", "let", "package", + "private", "protected", "public", "static", or "yield". + + 10.2.1 Strict Mode Code + + All parts of a ClassDeclaration or a ClassExpression are strict mode code. +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +class yi\u0065ld {} diff --git a/js/src/tests/test262/language/statements/class/class-name-ident-yield.js b/js/src/tests/test262/language/statements/class/class-name-ident-yield.js new file mode 100644 index 0000000000..ad79976e01 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/class-name-ident-yield.js @@ -0,0 +1,26 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2018 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-class-definitions +description: > + `yield` is not a valid class-name identifier. +info: | + 12.1.1 Static Semantics: Early Errors + + IdentifierReference : yield + + It is a Syntax Error if the code matched by this production is contained in strict mode code. + + 10.2.1 Strict Mode Code + + All parts of a ClassDeclaration or a ClassExpression are strict mode code. +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +class yield {} diff --git a/js/src/tests/test262/language/statements/class/classelementname-abrupt-completion.js b/js/src/tests/test262/language/statements/class/classelementname-abrupt-completion.js new file mode 100644 index 0000000000..365825d9f7 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/classelementname-abrupt-completion.js @@ -0,0 +1,44 @@ +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Class definition should error if evaluation of ClassElementName errors +esid: sec-runtime-semantics-classdefinitionevaluation +info: | + Runtime Semantics: ClassDefinitionEvaluation + ... + 27. For each ClassElement e in order from elements + a. If IsStatic of e is false, then + i. Let fields be the result of performing ClassElementEvaluation for e with arguments proto and false. + b. Else, + i. Let fields be the result of performing ClassElementEvaluation for e with arguments F and false. + c. If fields is an abrupt completion, then + i. Set the running execution context's LexicalEnvironment to lex. + ii. Set the running execution context's PrivateNameEnvironment to outerPrivateEnvironment. + iii. Return Completion(status). + + Runtime Semantics: ClassElementEvaluation + ... + ClassElement : FieldDefinition ; + 1. Return ClassFieldDefinitionEvaluation of FieldDefinition with parameter false and object. + + Runtime Semantics: ClassFieldDefinitionEvaluation + With parameters isStatic and homeObject. + FieldDefinition : ClassElementNameInitializer + 1. Let fieldName be the result of evaluating ClassElementName. + 2. ReturnIfAbrupt(fieldName). + +features: [class, class-fields-public] +---*/ + +function f() { + throw new Test262Error(); +} + +assert.throws(Test262Error, function() { + class C { + [f()] + } +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-additive-expression-add.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-additive-expression-add.js new file mode 100644 index 0000000000..0c03860f13 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-additive-expression-add.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-additive-expression-add.case +// - src/computed-property-names/evaluation/class-declaration-accessors.template +/*--- +description: Computed property name from additive expression "add" (ComputedPropertyName in ClassDeclaration) +esid: prod-ComputedPropertyName +features: [computed-property-names] +flags: [generated] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ + + +class C { + get [1 + 1]() { + return 2; + } + + set [1 + 1](v) { + return 2; + } + + static get [1 + 1]() { + return 2; + } + + static set [1 + 1](v) { + return 2; + } +}; + +let c = new C(); + +assert.sameValue( + c[1 + 1], + 2 +); +assert.sameValue( + c[1 + 1] = 2, + 2 +); + +assert.sameValue( + C[1 + 1], + 2 +); +assert.sameValue( + C[1 + 1] = 2, + 2 +); +assert.sameValue( + c[String(1 + 1)], + 2 +); +assert.sameValue( + c[String(1 + 1)] = 2, + 2 +); + +assert.sameValue( + C[String(1 + 1)], + 2 +); +assert.sameValue( + C[String(1 + 1)] = 2, + 2 +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-additive-expression-subtract.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-additive-expression-subtract.js new file mode 100644 index 0000000000..1687b05265 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-additive-expression-subtract.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-additive-expression-subtract.case +// - src/computed-property-names/evaluation/class-declaration-accessors.template +/*--- +description: Computed property name from additive expression "subtract" (ComputedPropertyName in ClassDeclaration) +esid: prod-ComputedPropertyName +features: [computed-property-names] +flags: [generated] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ + + +class C { + get [1 - 1]() { + return 0; + } + + set [1 - 1](v) { + return 0; + } + + static get [1 - 1]() { + return 0; + } + + static set [1 - 1](v) { + return 0; + } +}; + +let c = new C(); + +assert.sameValue( + c[1 - 1], + 0 +); +assert.sameValue( + c[1 - 1] = 0, + 0 +); + +assert.sameValue( + C[1 - 1], + 0 +); +assert.sameValue( + C[1 - 1] = 0, + 0 +); +assert.sameValue( + c[String(1 - 1)], + 0 +); +assert.sameValue( + c[String(1 - 1)] = 0, + 0 +); + +assert.sameValue( + C[String(1 - 1)], + 0 +); +assert.sameValue( + C[String(1 - 1)] = 0, + 0 +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-arrow-function-expression.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-arrow-function-expression.js new file mode 100644 index 0000000000..35c62752f0 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-arrow-function-expression.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-arrow-function-expression.case +// - src/computed-property-names/evaluation/class-declaration-accessors.template +/*--- +description: Computed property name from arrow function (ComputedPropertyName in ClassDeclaration) +esid: prod-ComputedPropertyName +features: [computed-property-names] +flags: [generated] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ + + +class C { + get [() => { }]() { + return 1; + } + + set [() => { }](v) { + return 1; + } + + static get [() => { }]() { + return 1; + } + + static set [() => { }](v) { + return 1; + } +}; + +let c = new C(); + +assert.sameValue( + c[() => { }], + 1 +); +assert.sameValue( + c[() => { }] = 1, + 1 +); + +assert.sameValue( + C[() => { }], + 1 +); +assert.sameValue( + C[() => { }] = 1, + 1 +); +assert.sameValue( + c[String(() => { })], + 1 +); +assert.sameValue( + c[String(() => { })] = 1, + 1 +); + +assert.sameValue( + C[String(() => { })], + 1 +); +assert.sameValue( + C[String(() => { })] = 1, + 1 +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-assignment-expression-assignment.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-assignment-expression-assignment.js new file mode 100644 index 0000000000..03e77aa351 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-assignment-expression-assignment.js @@ -0,0 +1,96 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-assignment-expression-assignment.case +// - src/computed-property-names/evaluation/class-declaration-accessors.template +/*--- +description: Computed property name from assignment expression (ComputedPropertyName in ClassDeclaration) +esid: prod-ComputedPropertyName +features: [computed-property-names] +flags: [generated] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ +let x = 0; + + +class C { + get [x = 1]() { + return 2; + } + + set [x = 1](v) { + return 2; + } + + static get [x = 1]() { + return 2; + } + + static set [x = 1](v) { + return 2; + } +}; + +let c = new C(); + +assert.sameValue( + c[x = 1], + 2 +); +assert.sameValue( + c[x = 1] = 2, + 2 +); + +assert.sameValue( + C[x = 1], + 2 +); +assert.sameValue( + C[x = 1] = 2, + 2 +); +assert.sameValue( + c[String(x = 1)], + 2 +); +assert.sameValue( + c[String(x = 1)] = 2, + 2 +); + +assert.sameValue( + C[String(x = 1)], + 2 +); +assert.sameValue( + C[String(x = 1)] = 2, + 2 +); + +assert.sameValue(x, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-assignment-expression-bitwise-or.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-assignment-expression-bitwise-or.js new file mode 100644 index 0000000000..b4596691f3 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-assignment-expression-bitwise-or.js @@ -0,0 +1,96 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-assignment-expression-bitwise-or.case +// - src/computed-property-names/evaluation/class-declaration-accessors.template +/*--- +description: Computed property name from assignment expression bitwise or (ComputedPropertyName in ClassDeclaration) +esid: prod-ComputedPropertyName +features: [computed-property-names] +flags: [generated] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ +let x = 0; + + +class C { + get [x |= 1]() { + return 2; + } + + set [x |= 1](v) { + return 2; + } + + static get [x |= 1]() { + return 2; + } + + static set [x |= 1](v) { + return 2; + } +}; + +let c = new C(); + +assert.sameValue( + c[x |= 1], + 2 +); +assert.sameValue( + c[x |= 1] = 2, + 2 +); + +assert.sameValue( + C[x |= 1], + 2 +); +assert.sameValue( + C[x |= 1] = 2, + 2 +); +assert.sameValue( + c[String(x |= 1)], + 2 +); +assert.sameValue( + c[String(x |= 1)] = 2, + 2 +); + +assert.sameValue( + C[String(x |= 1)], + 2 +); +assert.sameValue( + C[String(x |= 1)] = 2, + 2 +); + +assert.sameValue(x, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-assignment-expression-coalesce.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-assignment-expression-coalesce.js new file mode 100644 index 0000000000..4cebeb89d5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-assignment-expression-coalesce.js @@ -0,0 +1,96 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-assignment-expression-coalesce.case +// - src/computed-property-names/evaluation/class-declaration-accessors.template +/*--- +description: Computed property name from assignment expression coalesce (ComputedPropertyName in ClassDeclaration) +esid: prod-ComputedPropertyName +features: [computed-property-names, logical-assignment-operators] +flags: [generated] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ +let x = null; + + +class C { + get [x ??= 1]() { + return 2; + } + + set [x ??= 1](v) { + return 2; + } + + static get [x ??= 1]() { + return 2; + } + + static set [x ??= 1](v) { + return 2; + } +}; + +let c = new C(); + +assert.sameValue( + c[x ??= 1], + 2 +); +assert.sameValue( + c[x ??= 1] = 2, + 2 +); + +assert.sameValue( + C[x ??= 1], + 2 +); +assert.sameValue( + C[x ??= 1] = 2, + 2 +); +assert.sameValue( + c[String(x ??= 1)], + 2 +); +assert.sameValue( + c[String(x ??= 1)] = 2, + 2 +); + +assert.sameValue( + C[String(x ??= 1)], + 2 +); +assert.sameValue( + C[String(x ??= 1)] = 2, + 2 +); + +assert.sameValue(x, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-assignment-expression-logical-and.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-assignment-expression-logical-and.js new file mode 100644 index 0000000000..4ed3d8ada7 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-assignment-expression-logical-and.js @@ -0,0 +1,96 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-assignment-expression-logical-and.case +// - src/computed-property-names/evaluation/class-declaration-accessors.template +/*--- +description: Computed property name from assignment expression logical and (ComputedPropertyName in ClassDeclaration) +esid: prod-ComputedPropertyName +features: [computed-property-names, logical-assignment-operators] +flags: [generated] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ +let x = 0; + + +class C { + get [x &&= 1]() { + return 2; + } + + set [x &&= 1](v) { + return 2; + } + + static get [x &&= 1]() { + return 2; + } + + static set [x &&= 1](v) { + return 2; + } +}; + +let c = new C(); + +assert.sameValue( + c[x &&= 1], + 2 +); +assert.sameValue( + c[x &&= 1] = 2, + 2 +); + +assert.sameValue( + C[x &&= 1], + 2 +); +assert.sameValue( + C[x &&= 1] = 2, + 2 +); +assert.sameValue( + c[String(x &&= 1)], + 2 +); +assert.sameValue( + c[String(x &&= 1)] = 2, + 2 +); + +assert.sameValue( + C[String(x &&= 1)], + 2 +); +assert.sameValue( + C[String(x &&= 1)] = 2, + 2 +); + +assert.sameValue(x, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-assignment-expression-logical-or.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-assignment-expression-logical-or.js new file mode 100644 index 0000000000..f6735ff285 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-assignment-expression-logical-or.js @@ -0,0 +1,96 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-assignment-expression-logical-or.case +// - src/computed-property-names/evaluation/class-declaration-accessors.template +/*--- +description: Computed property name from assignment expression logical or (ComputedPropertyName in ClassDeclaration) +esid: prod-ComputedPropertyName +features: [computed-property-names, logical-assignment-operators] +flags: [generated] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ +let x = 0; + + +class C { + get [x ||= 1]() { + return 2; + } + + set [x ||= 1](v) { + return 2; + } + + static get [x ||= 1]() { + return 2; + } + + static set [x ||= 1](v) { + return 2; + } +}; + +let c = new C(); + +assert.sameValue( + c[x ||= 1], + 2 +); +assert.sameValue( + c[x ||= 1] = 2, + 2 +); + +assert.sameValue( + C[x ||= 1], + 2 +); +assert.sameValue( + C[x ||= 1] = 2, + 2 +); +assert.sameValue( + c[String(x ||= 1)], + 2 +); +assert.sameValue( + c[String(x ||= 1)] = 2, + 2 +); + +assert.sameValue( + C[String(x ||= 1)], + 2 +); +assert.sameValue( + C[String(x ||= 1)] = 2, + 2 +); + +assert.sameValue(x, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-async-arrow-function-expression.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-async-arrow-function-expression.js new file mode 100644 index 0000000000..188e1bad9a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-async-arrow-function-expression.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-async-arrow-function-expression.case +// - src/computed-property-names/evaluation/class-declaration-accessors.template +/*--- +description: Computed property name from function expression (ComputedPropertyName in ClassDeclaration) +esid: prod-ComputedPropertyName +features: [computed-property-names] +flags: [generated] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ + + +class C { + get [async () => {}]() { + return 1; + } + + set [async () => {}](v) { + return 1; + } + + static get [async () => {}]() { + return 1; + } + + static set [async () => {}](v) { + return 1; + } +}; + +let c = new C(); + +assert.sameValue( + c[async () => {}], + 1 +); +assert.sameValue( + c[async () => {}] = 1, + 1 +); + +assert.sameValue( + C[async () => {}], + 1 +); +assert.sameValue( + C[async () => {}] = 1, + 1 +); +assert.sameValue( + c[String(async () => {})], + 1 +); +assert.sameValue( + c[String(async () => {})] = 1, + 1 +); + +assert.sameValue( + C[String(async () => {})], + 1 +); +assert.sameValue( + C[String(async () => {})] = 1, + 1 +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-await-expression.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-await-expression.js new file mode 100644 index 0000000000..f6ae5c0905 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-await-expression.js @@ -0,0 +1,98 @@ +// |reftest| module async +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-await-expression.case +// - src/computed-property-names/evaluation/class-declaration-accessors.template +/*--- +description: Computed property name from condition expression (ComputedPropertyName in ClassDeclaration) +esid: prod-ComputedPropertyName +features: [computed-property-names, top-level-await] +flags: [generated, async, module] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ +try { + + +class C { + get [await 9]() { + return 9; + } + + set [await 9](v) { + return 9; + } + + static get [await 9]() { + return 9; + } + + static set [await 9](v) { + return 9; + } +}; + +let c = new C(); + +assert.sameValue( + c[await 9], + 9 +); +assert.sameValue( + c[await 9] = 9, + 9 +); + +assert.sameValue( + C[await 9], + 9 +); +assert.sameValue( + C[await 9] = 9, + 9 +); +assert.sameValue( + c[String(await 9)], + 9 +); +assert.sameValue( + c[String(await 9)] = 9, + 9 +); + +assert.sameValue( + C[String(await 9)], + 9 +); +assert.sameValue( + C[String(await 9)] = 9, + 9 +); + +} catch (e) { + $DONE(e); +} +$DONE(); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-condition-expression-false.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-condition-expression-false.js new file mode 100644 index 0000000000..0e4a243c48 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-condition-expression-false.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-condition-expression-false.case +// - src/computed-property-names/evaluation/class-declaration-accessors.template +/*--- +description: Computed property name from condition expression (ComputedPropertyName in ClassDeclaration) +esid: prod-ComputedPropertyName +features: [computed-property-names] +flags: [generated] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ + + +class C { + get [false ? 1 : 2]() { + return 1; + } + + set [false ? 1 : 2](v) { + return 1; + } + + static get [false ? 1 : 2]() { + return 1; + } + + static set [false ? 1 : 2](v) { + return 1; + } +}; + +let c = new C(); + +assert.sameValue( + c[false ? 1 : 2], + 1 +); +assert.sameValue( + c[false ? 1 : 2] = 1, + 1 +); + +assert.sameValue( + C[false ? 1 : 2], + 1 +); +assert.sameValue( + C[false ? 1 : 2] = 1, + 1 +); +assert.sameValue( + c[String(false ? 1 : 2)], + 1 +); +assert.sameValue( + c[String(false ? 1 : 2)] = 1, + 1 +); + +assert.sameValue( + C[String(false ? 1 : 2)], + 1 +); +assert.sameValue( + C[String(false ? 1 : 2)] = 1, + 1 +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-condition-expression-true.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-condition-expression-true.js new file mode 100644 index 0000000000..95837e2f4e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-condition-expression-true.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-condition-expression-true.case +// - src/computed-property-names/evaluation/class-declaration-accessors.template +/*--- +description: Computed property name from condition expression (ComputedPropertyName in ClassDeclaration) +esid: prod-ComputedPropertyName +features: [computed-property-names] +flags: [generated] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ + + +class C { + get [true ? 1 : 2]() { + return 2; + } + + set [true ? 1 : 2](v) { + return 2; + } + + static get [true ? 1 : 2]() { + return 2; + } + + static set [true ? 1 : 2](v) { + return 2; + } +}; + +let c = new C(); + +assert.sameValue( + c[true ? 1 : 2], + 2 +); +assert.sameValue( + c[true ? 1 : 2] = 2, + 2 +); + +assert.sameValue( + C[true ? 1 : 2], + 2 +); +assert.sameValue( + C[true ? 1 : 2] = 2, + 2 +); +assert.sameValue( + c[String(true ? 1 : 2)], + 2 +); +assert.sameValue( + c[String(true ? 1 : 2)] = 2, + 2 +); + +assert.sameValue( + C[String(true ? 1 : 2)], + 2 +); +assert.sameValue( + C[String(true ? 1 : 2)] = 2, + 2 +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-decimal-e-notational-literal.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-decimal-e-notational-literal.js new file mode 100644 index 0000000000..775ad6ec7f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-decimal-e-notational-literal.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-decimal-e-notational-literal.case +// - src/computed-property-names/evaluation/class-declaration-accessors.template +/*--- +description: Computed property name from decimal e notational literal (ComputedPropertyName in ClassDeclaration) +esid: prod-ComputedPropertyName +features: [computed-property-names] +flags: [generated] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ + + +class C { + get [1.e1]() { + return 2; + } + + set [1.e1](v) { + return 2; + } + + static get [1.e1]() { + return 2; + } + + static set [1.e1](v) { + return 2; + } +}; + +let c = new C(); + +assert.sameValue( + c[1.e1], + 2 +); +assert.sameValue( + c[1.e1] = 2, + 2 +); + +assert.sameValue( + C[1.e1], + 2 +); +assert.sameValue( + C[1.e1] = 2, + 2 +); +assert.sameValue( + c[String(1.e1)], + 2 +); +assert.sameValue( + c[String(1.e1)] = 2, + 2 +); + +assert.sameValue( + C[String(1.e1)], + 2 +); +assert.sameValue( + C[String(1.e1)] = 2, + 2 +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-decimal-literal.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-decimal-literal.js new file mode 100644 index 0000000000..94171ec027 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-decimal-literal.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-decimal-literal.case +// - src/computed-property-names/evaluation/class-declaration-accessors.template +/*--- +description: Computed property name from decimal literal (ComputedPropertyName in ClassDeclaration) +esid: prod-ComputedPropertyName +features: [computed-property-names] +flags: [generated] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ + + +class C { + get [1.1]() { + return 2; + } + + set [1.1](v) { + return 2; + } + + static get [1.1]() { + return 2; + } + + static set [1.1](v) { + return 2; + } +}; + +let c = new C(); + +assert.sameValue( + c[1.1], + 2 +); +assert.sameValue( + c[1.1] = 2, + 2 +); + +assert.sameValue( + C[1.1], + 2 +); +assert.sameValue( + C[1.1] = 2, + 2 +); +assert.sameValue( + c[String(1.1)], + 2 +); +assert.sameValue( + c[String(1.1)] = 2, + 2 +); + +assert.sameValue( + C[String(1.1)], + 2 +); +assert.sameValue( + C[String(1.1)] = 2, + 2 +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-exponetiation-expression.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-exponetiation-expression.js new file mode 100644 index 0000000000..a90ad74977 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-exponetiation-expression.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-exponetiation-expression.case +// - src/computed-property-names/evaluation/class-declaration-accessors.template +/*--- +description: Computed property name from exponentiation expression (ComputedPropertyName in ClassDeclaration) +esid: prod-ComputedPropertyName +features: [computed-property-names, exponentiation] +flags: [generated] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ + + +class C { + get [2 ** 2]() { + return 4; + } + + set [2 ** 2](v) { + return 4; + } + + static get [2 ** 2]() { + return 4; + } + + static set [2 ** 2](v) { + return 4; + } +}; + +let c = new C(); + +assert.sameValue( + c[2 ** 2], + 4 +); +assert.sameValue( + c[2 ** 2] = 4, + 4 +); + +assert.sameValue( + C[2 ** 2], + 4 +); +assert.sameValue( + C[2 ** 2] = 4, + 4 +); +assert.sameValue( + c[String(2 ** 2)], + 4 +); +assert.sameValue( + c[String(2 ** 2)] = 4, + 4 +); + +assert.sameValue( + C[String(2 ** 2)], + 4 +); +assert.sameValue( + C[String(2 ** 2)] = 4, + 4 +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-expression-coalesce.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-expression-coalesce.js new file mode 100644 index 0000000000..3df04c728b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-expression-coalesce.js @@ -0,0 +1,96 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-expression-coalesce.case +// - src/computed-property-names/evaluation/class-declaration-accessors.template +/*--- +description: Computed property name from coalesce (ComputedPropertyName in ClassDeclaration) +esid: prod-ComputedPropertyName +features: [computed-property-names] +flags: [generated] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ +let x; + + +class C { + get [x ?? 1]() { + return 2; + } + + set [x ?? 1](v) { + return 2; + } + + static get [x ?? 1]() { + return 2; + } + + static set [x ?? 1](v) { + return 2; + } +}; + +let c = new C(); + +assert.sameValue( + c[x ?? 1], + 2 +); +assert.sameValue( + c[x ?? 1] = 2, + 2 +); + +assert.sameValue( + C[x ?? 1], + 2 +); +assert.sameValue( + C[x ?? 1] = 2, + 2 +); +assert.sameValue( + c[String(x ?? 1)], + 2 +); +assert.sameValue( + c[String(x ?? 1)] = 2, + 2 +); + +assert.sameValue( + C[String(x ?? 1)], + 2 +); +assert.sameValue( + C[String(x ?? 1)] = 2, + 2 +); + +assert.sameValue(x, undefined); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-expression-logical-and.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-expression-logical-and.js new file mode 100644 index 0000000000..24a267a167 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-expression-logical-and.js @@ -0,0 +1,96 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-expression-logical-and.case +// - src/computed-property-names/evaluation/class-declaration-accessors.template +/*--- +description: Computed property name from logical and (ComputedPropertyName in ClassDeclaration) +esid: prod-ComputedPropertyName +features: [computed-property-names] +flags: [generated] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ +let x = 0; + + +class C { + get [x && 1]() { + return 2; + } + + set [x && 1](v) { + return 2; + } + + static get [x && 1]() { + return 2; + } + + static set [x && 1](v) { + return 2; + } +}; + +let c = new C(); + +assert.sameValue( + c[x && 1], + 2 +); +assert.sameValue( + c[x && 1] = 2, + 2 +); + +assert.sameValue( + C[x && 1], + 2 +); +assert.sameValue( + C[x && 1] = 2, + 2 +); +assert.sameValue( + c[String(x && 1)], + 2 +); +assert.sameValue( + c[String(x && 1)] = 2, + 2 +); + +assert.sameValue( + C[String(x && 1)], + 2 +); +assert.sameValue( + C[String(x && 1)] = 2, + 2 +); + +assert.sameValue(x, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-expression-logical-or.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-expression-logical-or.js new file mode 100644 index 0000000000..98866bc591 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-expression-logical-or.js @@ -0,0 +1,96 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-expression-logical-or.case +// - src/computed-property-names/evaluation/class-declaration-accessors.template +/*--- +description: Computed property name from logical or (ComputedPropertyName in ClassDeclaration) +esid: prod-ComputedPropertyName +features: [computed-property-names] +flags: [generated] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ +let x = 0; + + +class C { + get [x || 1]() { + return 2; + } + + set [x || 1](v) { + return 2; + } + + static get [x || 1]() { + return 2; + } + + static set [x || 1](v) { + return 2; + } +}; + +let c = new C(); + +assert.sameValue( + c[x || 1], + 2 +); +assert.sameValue( + c[x || 1] = 2, + 2 +); + +assert.sameValue( + C[x || 1], + 2 +); +assert.sameValue( + C[x || 1] = 2, + 2 +); +assert.sameValue( + c[String(x || 1)], + 2 +); +assert.sameValue( + c[String(x || 1)] = 2, + 2 +); + +assert.sameValue( + C[String(x || 1)], + 2 +); +assert.sameValue( + C[String(x || 1)] = 2, + 2 +); + +assert.sameValue(x, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-function-declaration.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-function-declaration.js new file mode 100644 index 0000000000..e97802248c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-function-declaration.js @@ -0,0 +1,94 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-function-declaration.case +// - src/computed-property-names/evaluation/class-declaration-accessors.template +/*--- +description: Computed property name from function (ComputedPropertyName in ClassDeclaration) +esid: prod-ComputedPropertyName +features: [computed-property-names] +flags: [generated] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ +function f() {} + + +class C { + get [f()]() { + return 1; + } + + set [f()](v) { + return 1; + } + + static get [f()]() { + return 1; + } + + static set [f()](v) { + return 1; + } +}; + +let c = new C(); + +assert.sameValue( + c[f()], + 1 +); +assert.sameValue( + c[f()] = 1, + 1 +); + +assert.sameValue( + C[f()], + 1 +); +assert.sameValue( + C[f()] = 1, + 1 +); +assert.sameValue( + c[String(f())], + 1 +); +assert.sameValue( + c[String(f())] = 1, + 1 +); + +assert.sameValue( + C[String(f())], + 1 +); +assert.sameValue( + C[String(f())] = 1, + 1 +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-function-expression.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-function-expression.js new file mode 100644 index 0000000000..0d63210a14 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-function-expression.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-function-expression.case +// - src/computed-property-names/evaluation/class-declaration-accessors.template +/*--- +description: Computed property name from function expression (ComputedPropertyName in ClassDeclaration) +esid: prod-ComputedPropertyName +features: [computed-property-names] +flags: [generated] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ + + +class C { + get [function () {}]() { + return 1; + } + + set [function () {}](v) { + return 1; + } + + static get [function () {}]() { + return 1; + } + + static set [function () {}](v) { + return 1; + } +}; + +let c = new C(); + +assert.sameValue( + c[function () {}], + 1 +); +assert.sameValue( + c[function () {}] = 1, + 1 +); + +assert.sameValue( + C[function () {}], + 1 +); +assert.sameValue( + C[function () {}] = 1, + 1 +); +assert.sameValue( + c[String(function () {})], + 1 +); +assert.sameValue( + c[String(function () {})] = 1, + 1 +); + +assert.sameValue( + C[String(function () {})], + 1 +); +assert.sameValue( + C[String(function () {})] = 1, + 1 +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-generator-function-declaration.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-generator-function-declaration.js new file mode 100644 index 0000000000..4cbe0999b4 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-generator-function-declaration.js @@ -0,0 +1,94 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-generator-function-declaration.case +// - src/computed-property-names/evaluation/class-declaration-accessors.template +/*--- +description: Computed property name from generator function (ComputedPropertyName in ClassDeclaration) +esid: prod-ComputedPropertyName +features: [computed-property-names] +flags: [generated] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ +function * g() { return 1; } + + +class C { + get [g()]() { + return 1; + } + + set [g()](v) { + return 1; + } + + static get [g()]() { + return 1; + } + + static set [g()](v) { + return 1; + } +}; + +let c = new C(); + +assert.sameValue( + c[g()], + 1 +); +assert.sameValue( + c[g()] = 1, + 1 +); + +assert.sameValue( + C[g()], + 1 +); +assert.sameValue( + C[g()] = 1, + 1 +); +assert.sameValue( + c[String(g())], + 1 +); +assert.sameValue( + c[String(g())] = 1, + 1 +); + +assert.sameValue( + C[String(g())], + 1 +); +assert.sameValue( + C[String(g())] = 1, + 1 +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-identifier.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-identifier.js new file mode 100644 index 0000000000..147cb9176f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-identifier.js @@ -0,0 +1,95 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-identifier.case +// - src/computed-property-names/evaluation/class-declaration-accessors.template +/*--- +description: Computed property name from string literal (ComputedPropertyName in ClassDeclaration) +esid: prod-ComputedPropertyName +features: [computed-property-names] +flags: [generated] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ +let x = 1; + + + +class C { + get [x]() { + return '2'; + } + + set [x](v) { + return '2'; + } + + static get [x]() { + return '2'; + } + + static set [x](v) { + return '2'; + } +}; + +let c = new C(); + +assert.sameValue( + c[x], + '2' +); +assert.sameValue( + c[x] = '2', + '2' +); + +assert.sameValue( + C[x], + '2' +); +assert.sameValue( + C[x] = '2', + '2' +); +assert.sameValue( + c[String(x)], + '2' +); +assert.sameValue( + c[String(x)] = '2', + '2' +); + +assert.sameValue( + C[String(x)], + '2' +); +assert.sameValue( + C[String(x)] = '2', + '2' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-integer-e-notational-literal.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-integer-e-notational-literal.js new file mode 100644 index 0000000000..bedc60dc61 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-integer-e-notational-literal.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-integer-e-notational-literal.case +// - src/computed-property-names/evaluation/class-declaration-accessors.template +/*--- +description: Computed property name from numeric literal (ComputedPropertyName in ClassDeclaration) +esid: prod-ComputedPropertyName +features: [computed-property-names] +flags: [generated] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ + + +class C { + get [1]() { + return 2; + } + + set [1](v) { + return 2; + } + + static get [1]() { + return 2; + } + + static set [1](v) { + return 2; + } +}; + +let c = new C(); + +assert.sameValue( + c[1], + 2 +); +assert.sameValue( + c[1] = 2, + 2 +); + +assert.sameValue( + C[1], + 2 +); +assert.sameValue( + C[1] = 2, + 2 +); +assert.sameValue( + c[String(1)], + 2 +); +assert.sameValue( + c[String(1)] = 2, + 2 +); + +assert.sameValue( + C[String(1)], + 2 +); +assert.sameValue( + C[String(1)] = 2, + 2 +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-integer-separators.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-integer-separators.js new file mode 100644 index 0000000000..22d12be97c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-integer-separators.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-integer-separators.case +// - src/computed-property-names/evaluation/class-declaration-accessors.template +/*--- +description: Computed property name from integer with separators (ComputedPropertyName in ClassDeclaration) +esid: prod-ComputedPropertyName +features: [computed-property-names] +flags: [generated] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ + + +class C { + get [1_2_3_4_5_6_7_8]() { + return 1_2_3_4_5_6_7_8; + } + + set [1_2_3_4_5_6_7_8](v) { + return 1_2_3_4_5_6_7_8; + } + + static get [1_2_3_4_5_6_7_8]() { + return 1_2_3_4_5_6_7_8; + } + + static set [1_2_3_4_5_6_7_8](v) { + return 1_2_3_4_5_6_7_8; + } +}; + +let c = new C(); + +assert.sameValue( + c[1_2_3_4_5_6_7_8], + 1_2_3_4_5_6_7_8 +); +assert.sameValue( + c[1_2_3_4_5_6_7_8] = 1_2_3_4_5_6_7_8, + 1_2_3_4_5_6_7_8 +); + +assert.sameValue( + C[1_2_3_4_5_6_7_8], + 1_2_3_4_5_6_7_8 +); +assert.sameValue( + C[1_2_3_4_5_6_7_8] = 1_2_3_4_5_6_7_8, + 1_2_3_4_5_6_7_8 +); +assert.sameValue( + c[String(1_2_3_4_5_6_7_8)], + 1_2_3_4_5_6_7_8 +); +assert.sameValue( + c[String(1_2_3_4_5_6_7_8)] = 1_2_3_4_5_6_7_8, + 1_2_3_4_5_6_7_8 +); + +assert.sameValue( + C[String(1_2_3_4_5_6_7_8)], + 1_2_3_4_5_6_7_8 +); +assert.sameValue( + C[String(1_2_3_4_5_6_7_8)] = 1_2_3_4_5_6_7_8, + 1_2_3_4_5_6_7_8 +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-math.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-math.js new file mode 100644 index 0000000000..aae0475f47 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-math.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-math.case +// - src/computed-property-names/evaluation/class-declaration-accessors.template +/*--- +description: Computed property name from math (ComputedPropertyName in ClassDeclaration) +esid: prod-ComputedPropertyName +features: [computed-property-names, exponentiation] +flags: [generated] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ + + +class C { + get [1 + 2 - 3 * 4 / 5 ** 6]() { + return 2.999232; + } + + set [1 + 2 - 3 * 4 / 5 ** 6](v) { + return 2.999232; + } + + static get [1 + 2 - 3 * 4 / 5 ** 6]() { + return 2.999232; + } + + static set [1 + 2 - 3 * 4 / 5 ** 6](v) { + return 2.999232; + } +}; + +let c = new C(); + +assert.sameValue( + c[1 + 2 - 3 * 4 / 5 ** 6], + 2.999232 +); +assert.sameValue( + c[1 + 2 - 3 * 4 / 5 ** 6] = 2.999232, + 2.999232 +); + +assert.sameValue( + C[1 + 2 - 3 * 4 / 5 ** 6], + 2.999232 +); +assert.sameValue( + C[1 + 2 - 3 * 4 / 5 ** 6] = 2.999232, + 2.999232 +); +assert.sameValue( + c[String(1 + 2 - 3 * 4 / 5 ** 6)], + 2.999232 +); +assert.sameValue( + c[String(1 + 2 - 3 * 4 / 5 ** 6)] = 2.999232, + 2.999232 +); + +assert.sameValue( + C[String(1 + 2 - 3 * 4 / 5 ** 6)], + 2.999232 +); +assert.sameValue( + C[String(1 + 2 - 3 * 4 / 5 ** 6)] = 2.999232, + 2.999232 +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-multiplicative-expression-div.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-multiplicative-expression-div.js new file mode 100644 index 0000000000..9d5acec131 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-multiplicative-expression-div.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-multiplicative-expression-div.case +// - src/computed-property-names/evaluation/class-declaration-accessors.template +/*--- +description: Computed property name from multiplicative expression "divide" (ComputedPropertyName in ClassDeclaration) +esid: prod-ComputedPropertyName +features: [computed-property-names] +flags: [generated] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ + + +class C { + get [1 / 1]() { + return 1; + } + + set [1 / 1](v) { + return 1; + } + + static get [1 / 1]() { + return 1; + } + + static set [1 / 1](v) { + return 1; + } +}; + +let c = new C(); + +assert.sameValue( + c[1 / 1], + 1 +); +assert.sameValue( + c[1 / 1] = 1, + 1 +); + +assert.sameValue( + C[1 / 1], + 1 +); +assert.sameValue( + C[1 / 1] = 1, + 1 +); +assert.sameValue( + c[String(1 / 1)], + 1 +); +assert.sameValue( + c[String(1 / 1)] = 1, + 1 +); + +assert.sameValue( + C[String(1 / 1)], + 1 +); +assert.sameValue( + C[String(1 / 1)] = 1, + 1 +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-multiplicative-expression-mult.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-multiplicative-expression-mult.js new file mode 100644 index 0000000000..174dd1cd91 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-multiplicative-expression-mult.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-multiplicative-expression-mult.case +// - src/computed-property-names/evaluation/class-declaration-accessors.template +/*--- +description: Computed property name from multiplicative expression "multiply" (ComputedPropertyName in ClassDeclaration) +esid: prod-ComputedPropertyName +features: [computed-property-names] +flags: [generated] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ + + +class C { + get [1 * 1]() { + return 1; + } + + set [1 * 1](v) { + return 1; + } + + static get [1 * 1]() { + return 1; + } + + static set [1 * 1](v) { + return 1; + } +}; + +let c = new C(); + +assert.sameValue( + c[1 * 1], + 1 +); +assert.sameValue( + c[1 * 1] = 1, + 1 +); + +assert.sameValue( + C[1 * 1], + 1 +); +assert.sameValue( + C[1 * 1] = 1, + 1 +); +assert.sameValue( + c[String(1 * 1)], + 1 +); +assert.sameValue( + c[String(1 * 1)] = 1, + 1 +); + +assert.sameValue( + C[String(1 * 1)], + 1 +); +assert.sameValue( + C[String(1 * 1)] = 1, + 1 +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-null.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-null.js new file mode 100644 index 0000000000..9c2ff4f83e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-null.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-null.case +// - src/computed-property-names/evaluation/class-declaration-accessors.template +/*--- +description: Computed property name from condition expression (ComputedPropertyName in ClassDeclaration) +esid: prod-ComputedPropertyName +features: [computed-property-names] +flags: [generated] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ + + +class C { + get [null]() { + return null; + } + + set [null](v) { + return null; + } + + static get [null]() { + return null; + } + + static set [null](v) { + return null; + } +}; + +let c = new C(); + +assert.sameValue( + c[null], + null +); +assert.sameValue( + c[null] = null, + null +); + +assert.sameValue( + C[null], + null +); +assert.sameValue( + C[null] = null, + null +); +assert.sameValue( + c[String(null)], + null +); +assert.sameValue( + c[String(null)] = null, + null +); + +assert.sameValue( + C[String(null)], + null +); +assert.sameValue( + C[String(null)] = null, + null +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-numeric-literal.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-numeric-literal.js new file mode 100644 index 0000000000..60255b701f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-numeric-literal.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-numeric-literal.case +// - src/computed-property-names/evaluation/class-declaration-accessors.template +/*--- +description: Computed property name from numeric literal (ComputedPropertyName in ClassDeclaration) +esid: prod-ComputedPropertyName +features: [computed-property-names] +flags: [generated] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ + + +class C { + get [1]() { + return 2; + } + + set [1](v) { + return 2; + } + + static get [1]() { + return 2; + } + + static set [1](v) { + return 2; + } +}; + +let c = new C(); + +assert.sameValue( + c[1], + 2 +); +assert.sameValue( + c[1] = 2, + 2 +); + +assert.sameValue( + C[1], + 2 +); +assert.sameValue( + C[1] = 2, + 2 +); +assert.sameValue( + c[String(1)], + 2 +); +assert.sameValue( + c[String(1)] = 2, + 2 +); + +assert.sameValue( + C[String(1)], + 2 +); +assert.sameValue( + C[String(1)] = 2, + 2 +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-string-literal.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-string-literal.js new file mode 100644 index 0000000000..f12c05f7dc --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-string-literal.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-string-literal.case +// - src/computed-property-names/evaluation/class-declaration-accessors.template +/*--- +description: Computed property name from string literal (ComputedPropertyName in ClassDeclaration) +esid: prod-ComputedPropertyName +features: [computed-property-names] +flags: [generated] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ + + +class C { + get ['1']() { + return '2'; + } + + set ['1'](v) { + return '2'; + } + + static get ['1']() { + return '2'; + } + + static set ['1'](v) { + return '2'; + } +}; + +let c = new C(); + +assert.sameValue( + c['1'], + '2' +); +assert.sameValue( + c['1'] = '2', + '2' +); + +assert.sameValue( + C['1'], + '2' +); +assert.sameValue( + C['1'] = '2', + '2' +); +assert.sameValue( + c[String('1')], + '2' +); +assert.sameValue( + c[String('1')] = '2', + '2' +); + +assert.sameValue( + C[String('1')], + '2' +); +assert.sameValue( + C[String('1')] = '2', + '2' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-yield-expression.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-yield-expression.js new file mode 100644 index 0000000000..c3b76eb7c0 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-yield-expression.js @@ -0,0 +1,98 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-yield-expression.case +// - src/computed-property-names/evaluation/class-declaration-accessors.template +/*--- +description: Computed property name from yield expression (ComputedPropertyName in ClassDeclaration) +esid: prod-ComputedPropertyName +features: [computed-property-names] +flags: [generated] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ +function * g() { + + +class C { + get [yield 9]() { + return 9; + } + + set [yield 9](v) { + return 9; + } + + static get [yield 9]() { + return 9; + } + + static set [yield 9](v) { + return 9; + } +}; + +let c = new C(); + +assert.sameValue( + c[yield 9], + 9 +); +assert.sameValue( + c[yield 9] = 9, + 9 +); + +assert.sameValue( + C[yield 9], + 9 +); +assert.sameValue( + C[yield 9] = 9, + 9 +); +assert.sameValue( + c[String(yield 9)], + 9 +); +assert.sameValue( + c[String(yield 9)] = 9, + 9 +); + +assert.sameValue( + C[String(yield 9)], + 9 +); +assert.sameValue( + C[String(yield 9)] = 9, + 9 +); + +} +var iter = g(); +while (iter.next().done === false) ; + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-additive-expression-add.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-additive-expression-add.js new file mode 100644 index 0000000000..57a374324e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-additive-expression-add.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-additive-expression-add.case +// - src/computed-property-names/evaluation/class-declaration.template +/*--- +description: Computed property name from additive expression "add" (ComputedPropertyName in ClassDeclaration) +esid: prod-ComputedPropertyName +features: [computed-property-names] +flags: [generated] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ + + +class C { + [1 + 1]() { + return 2; + } + static [1 + 1]() { + return 2; + } +}; + +let c = new C(); + +assert.sameValue( + c[1 + 1](), + 2 +); +assert.sameValue( + C[1 + 1](), + 2 +); +assert.sameValue( + c[String(1 + 1)](), + 2 +); +assert.sameValue( + C[String(1 + 1)](), + 2 +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-additive-expression-subtract.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-additive-expression-subtract.js new file mode 100644 index 0000000000..ec491a4fd8 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-additive-expression-subtract.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-additive-expression-subtract.case +// - src/computed-property-names/evaluation/class-declaration.template +/*--- +description: Computed property name from additive expression "subtract" (ComputedPropertyName in ClassDeclaration) +esid: prod-ComputedPropertyName +features: [computed-property-names] +flags: [generated] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ + + +class C { + [1 - 1]() { + return 0; + } + static [1 - 1]() { + return 0; + } +}; + +let c = new C(); + +assert.sameValue( + c[1 - 1](), + 0 +); +assert.sameValue( + C[1 - 1](), + 0 +); +assert.sameValue( + c[String(1 - 1)](), + 0 +); +assert.sameValue( + C[String(1 - 1)](), + 0 +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-arrow-function-expression.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-arrow-function-expression.js new file mode 100644 index 0000000000..e583c3d74b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-arrow-function-expression.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-arrow-function-expression.case +// - src/computed-property-names/evaluation/class-declaration.template +/*--- +description: Computed property name from arrow function (ComputedPropertyName in ClassDeclaration) +esid: prod-ComputedPropertyName +features: [computed-property-names] +flags: [generated] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ + + +class C { + [() => { }]() { + return 1; + } + static [() => { }]() { + return 1; + } +}; + +let c = new C(); + +assert.sameValue( + c[() => { }](), + 1 +); +assert.sameValue( + C[() => { }](), + 1 +); +assert.sameValue( + c[String(() => { })](), + 1 +); +assert.sameValue( + C[String(() => { })](), + 1 +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-assignment-expression-assignment.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-assignment-expression-assignment.js new file mode 100644 index 0000000000..85bc1dfd24 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-assignment-expression-assignment.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-assignment-expression-assignment.case +// - src/computed-property-names/evaluation/class-declaration.template +/*--- +description: Computed property name from assignment expression (ComputedPropertyName in ClassDeclaration) +esid: prod-ComputedPropertyName +features: [computed-property-names] +flags: [generated] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ +let x = 0; + + +class C { + [x = 1]() { + return 2; + } + static [x = 1]() { + return 2; + } +}; + +let c = new C(); + +assert.sameValue( + c[x = 1](), + 2 +); +assert.sameValue( + C[x = 1](), + 2 +); +assert.sameValue( + c[String(x = 1)](), + 2 +); +assert.sameValue( + C[String(x = 1)](), + 2 +); + +assert.sameValue(x, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-assignment-expression-bitwise-or.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-assignment-expression-bitwise-or.js new file mode 100644 index 0000000000..b5f4a9aeca --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-assignment-expression-bitwise-or.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-assignment-expression-bitwise-or.case +// - src/computed-property-names/evaluation/class-declaration.template +/*--- +description: Computed property name from assignment expression bitwise or (ComputedPropertyName in ClassDeclaration) +esid: prod-ComputedPropertyName +features: [computed-property-names] +flags: [generated] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ +let x = 0; + + +class C { + [x |= 1]() { + return 2; + } + static [x |= 1]() { + return 2; + } +}; + +let c = new C(); + +assert.sameValue( + c[x |= 1](), + 2 +); +assert.sameValue( + C[x |= 1](), + 2 +); +assert.sameValue( + c[String(x |= 1)](), + 2 +); +assert.sameValue( + C[String(x |= 1)](), + 2 +); + +assert.sameValue(x, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-assignment-expression-coalesce.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-assignment-expression-coalesce.js new file mode 100644 index 0000000000..07ef956289 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-assignment-expression-coalesce.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-assignment-expression-coalesce.case +// - src/computed-property-names/evaluation/class-declaration.template +/*--- +description: Computed property name from assignment expression coalesce (ComputedPropertyName in ClassDeclaration) +esid: prod-ComputedPropertyName +features: [computed-property-names, logical-assignment-operators] +flags: [generated] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ +let x = null; + + +class C { + [x ??= 1]() { + return 2; + } + static [x ??= 1]() { + return 2; + } +}; + +let c = new C(); + +assert.sameValue( + c[x ??= 1](), + 2 +); +assert.sameValue( + C[x ??= 1](), + 2 +); +assert.sameValue( + c[String(x ??= 1)](), + 2 +); +assert.sameValue( + C[String(x ??= 1)](), + 2 +); + +assert.sameValue(x, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-assignment-expression-logical-and.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-assignment-expression-logical-and.js new file mode 100644 index 0000000000..a3e1d17fb0 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-assignment-expression-logical-and.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-assignment-expression-logical-and.case +// - src/computed-property-names/evaluation/class-declaration.template +/*--- +description: Computed property name from assignment expression logical and (ComputedPropertyName in ClassDeclaration) +esid: prod-ComputedPropertyName +features: [computed-property-names, logical-assignment-operators] +flags: [generated] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ +let x = 0; + + +class C { + [x &&= 1]() { + return 2; + } + static [x &&= 1]() { + return 2; + } +}; + +let c = new C(); + +assert.sameValue( + c[x &&= 1](), + 2 +); +assert.sameValue( + C[x &&= 1](), + 2 +); +assert.sameValue( + c[String(x &&= 1)](), + 2 +); +assert.sameValue( + C[String(x &&= 1)](), + 2 +); + +assert.sameValue(x, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-assignment-expression-logical-or.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-assignment-expression-logical-or.js new file mode 100644 index 0000000000..86ad101180 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-assignment-expression-logical-or.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-assignment-expression-logical-or.case +// - src/computed-property-names/evaluation/class-declaration.template +/*--- +description: Computed property name from assignment expression logical or (ComputedPropertyName in ClassDeclaration) +esid: prod-ComputedPropertyName +features: [computed-property-names, logical-assignment-operators] +flags: [generated] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ +let x = 0; + + +class C { + [x ||= 1]() { + return 2; + } + static [x ||= 1]() { + return 2; + } +}; + +let c = new C(); + +assert.sameValue( + c[x ||= 1](), + 2 +); +assert.sameValue( + C[x ||= 1](), + 2 +); +assert.sameValue( + c[String(x ||= 1)](), + 2 +); +assert.sameValue( + C[String(x ||= 1)](), + 2 +); + +assert.sameValue(x, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-async-arrow-function-expression.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-async-arrow-function-expression.js new file mode 100644 index 0000000000..0579c324dc --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-async-arrow-function-expression.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-async-arrow-function-expression.case +// - src/computed-property-names/evaluation/class-declaration.template +/*--- +description: Computed property name from function expression (ComputedPropertyName in ClassDeclaration) +esid: prod-ComputedPropertyName +features: [computed-property-names] +flags: [generated] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ + + +class C { + [async () => {}]() { + return 1; + } + static [async () => {}]() { + return 1; + } +}; + +let c = new C(); + +assert.sameValue( + c[async () => {}](), + 1 +); +assert.sameValue( + C[async () => {}](), + 1 +); +assert.sameValue( + c[String(async () => {})](), + 1 +); +assert.sameValue( + C[String(async () => {})](), + 1 +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-await-expression.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-await-expression.js new file mode 100644 index 0000000000..a38011aa2e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-await-expression.js @@ -0,0 +1,71 @@ +// |reftest| module async +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-await-expression.case +// - src/computed-property-names/evaluation/class-declaration.template +/*--- +description: Computed property name from condition expression (ComputedPropertyName in ClassDeclaration) +esid: prod-ComputedPropertyName +features: [computed-property-names, top-level-await] +flags: [generated, async, module] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ +try { + + +class C { + [await 9]() { + return 9; + } + static [await 9]() { + return 9; + } +}; + +let c = new C(); + +assert.sameValue( + c[await 9](), + 9 +); +assert.sameValue( + C[await 9](), + 9 +); +assert.sameValue( + c[String(await 9)](), + 9 +); +assert.sameValue( + C[String(await 9)](), + 9 +); + +} catch (e) { + $DONE(e); +} +$DONE(); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-condition-expression-false.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-condition-expression-false.js new file mode 100644 index 0000000000..f4715db2c3 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-condition-expression-false.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-condition-expression-false.case +// - src/computed-property-names/evaluation/class-declaration.template +/*--- +description: Computed property name from condition expression (ComputedPropertyName in ClassDeclaration) +esid: prod-ComputedPropertyName +features: [computed-property-names] +flags: [generated] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ + + +class C { + [false ? 1 : 2]() { + return 1; + } + static [false ? 1 : 2]() { + return 1; + } +}; + +let c = new C(); + +assert.sameValue( + c[false ? 1 : 2](), + 1 +); +assert.sameValue( + C[false ? 1 : 2](), + 1 +); +assert.sameValue( + c[String(false ? 1 : 2)](), + 1 +); +assert.sameValue( + C[String(false ? 1 : 2)](), + 1 +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-condition-expression-true.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-condition-expression-true.js new file mode 100644 index 0000000000..889e80a7a0 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-condition-expression-true.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-condition-expression-true.case +// - src/computed-property-names/evaluation/class-declaration.template +/*--- +description: Computed property name from condition expression (ComputedPropertyName in ClassDeclaration) +esid: prod-ComputedPropertyName +features: [computed-property-names] +flags: [generated] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ + + +class C { + [true ? 1 : 2]() { + return 2; + } + static [true ? 1 : 2]() { + return 2; + } +}; + +let c = new C(); + +assert.sameValue( + c[true ? 1 : 2](), + 2 +); +assert.sameValue( + C[true ? 1 : 2](), + 2 +); +assert.sameValue( + c[String(true ? 1 : 2)](), + 2 +); +assert.sameValue( + C[String(true ? 1 : 2)](), + 2 +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-decimal-e-notational-literal.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-decimal-e-notational-literal.js new file mode 100644 index 0000000000..fcfcad1e75 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-decimal-e-notational-literal.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-decimal-e-notational-literal.case +// - src/computed-property-names/evaluation/class-declaration.template +/*--- +description: Computed property name from decimal e notational literal (ComputedPropertyName in ClassDeclaration) +esid: prod-ComputedPropertyName +features: [computed-property-names] +flags: [generated] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ + + +class C { + [1.e1]() { + return 2; + } + static [1.e1]() { + return 2; + } +}; + +let c = new C(); + +assert.sameValue( + c[1.e1](), + 2 +); +assert.sameValue( + C[1.e1](), + 2 +); +assert.sameValue( + c[String(1.e1)](), + 2 +); +assert.sameValue( + C[String(1.e1)](), + 2 +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-decimal-literal.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-decimal-literal.js new file mode 100644 index 0000000000..554345d4f3 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-decimal-literal.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-decimal-literal.case +// - src/computed-property-names/evaluation/class-declaration.template +/*--- +description: Computed property name from decimal literal (ComputedPropertyName in ClassDeclaration) +esid: prod-ComputedPropertyName +features: [computed-property-names] +flags: [generated] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ + + +class C { + [1.1]() { + return 2; + } + static [1.1]() { + return 2; + } +}; + +let c = new C(); + +assert.sameValue( + c[1.1](), + 2 +); +assert.sameValue( + C[1.1](), + 2 +); +assert.sameValue( + c[String(1.1)](), + 2 +); +assert.sameValue( + C[String(1.1)](), + 2 +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-exponetiation-expression.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-exponetiation-expression.js new file mode 100644 index 0000000000..ac090d918c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-exponetiation-expression.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-exponetiation-expression.case +// - src/computed-property-names/evaluation/class-declaration.template +/*--- +description: Computed property name from exponentiation expression (ComputedPropertyName in ClassDeclaration) +esid: prod-ComputedPropertyName +features: [computed-property-names, exponentiation] +flags: [generated] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ + + +class C { + [2 ** 2]() { + return 4; + } + static [2 ** 2]() { + return 4; + } +}; + +let c = new C(); + +assert.sameValue( + c[2 ** 2](), + 4 +); +assert.sameValue( + C[2 ** 2](), + 4 +); +assert.sameValue( + c[String(2 ** 2)](), + 4 +); +assert.sameValue( + C[String(2 ** 2)](), + 4 +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-expression-coalesce.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-expression-coalesce.js new file mode 100644 index 0000000000..ac6cafbecb --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-expression-coalesce.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-expression-coalesce.case +// - src/computed-property-names/evaluation/class-declaration.template +/*--- +description: Computed property name from coalesce (ComputedPropertyName in ClassDeclaration) +esid: prod-ComputedPropertyName +features: [computed-property-names] +flags: [generated] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ +let x; + + +class C { + [x ?? 1]() { + return 2; + } + static [x ?? 1]() { + return 2; + } +}; + +let c = new C(); + +assert.sameValue( + c[x ?? 1](), + 2 +); +assert.sameValue( + C[x ?? 1](), + 2 +); +assert.sameValue( + c[String(x ?? 1)](), + 2 +); +assert.sameValue( + C[String(x ?? 1)](), + 2 +); + +assert.sameValue(x, undefined); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-expression-logical-and.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-expression-logical-and.js new file mode 100644 index 0000000000..f66cf31eef --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-expression-logical-and.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-expression-logical-and.case +// - src/computed-property-names/evaluation/class-declaration.template +/*--- +description: Computed property name from logical and (ComputedPropertyName in ClassDeclaration) +esid: prod-ComputedPropertyName +features: [computed-property-names] +flags: [generated] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ +let x = 0; + + +class C { + [x && 1]() { + return 2; + } + static [x && 1]() { + return 2; + } +}; + +let c = new C(); + +assert.sameValue( + c[x && 1](), + 2 +); +assert.sameValue( + C[x && 1](), + 2 +); +assert.sameValue( + c[String(x && 1)](), + 2 +); +assert.sameValue( + C[String(x && 1)](), + 2 +); + +assert.sameValue(x, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-expression-logical-or.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-expression-logical-or.js new file mode 100644 index 0000000000..a25598f806 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-expression-logical-or.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-expression-logical-or.case +// - src/computed-property-names/evaluation/class-declaration.template +/*--- +description: Computed property name from logical or (ComputedPropertyName in ClassDeclaration) +esid: prod-ComputedPropertyName +features: [computed-property-names] +flags: [generated] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ +let x = 0; + + +class C { + [x || 1]() { + return 2; + } + static [x || 1]() { + return 2; + } +}; + +let c = new C(); + +assert.sameValue( + c[x || 1](), + 2 +); +assert.sameValue( + C[x || 1](), + 2 +); +assert.sameValue( + c[String(x || 1)](), + 2 +); +assert.sameValue( + C[String(x || 1)](), + 2 +); + +assert.sameValue(x, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-function-declaration.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-function-declaration.js new file mode 100644 index 0000000000..fb7d91ad3c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-function-declaration.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-function-declaration.case +// - src/computed-property-names/evaluation/class-declaration.template +/*--- +description: Computed property name from function (ComputedPropertyName in ClassDeclaration) +esid: prod-ComputedPropertyName +features: [computed-property-names] +flags: [generated] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ +function f() {} + + +class C { + [f()]() { + return 1; + } + static [f()]() { + return 1; + } +}; + +let c = new C(); + +assert.sameValue( + c[f()](), + 1 +); +assert.sameValue( + C[f()](), + 1 +); +assert.sameValue( + c[String(f())](), + 1 +); +assert.sameValue( + C[String(f())](), + 1 +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-function-expression.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-function-expression.js new file mode 100644 index 0000000000..96da957346 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-function-expression.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-function-expression.case +// - src/computed-property-names/evaluation/class-declaration.template +/*--- +description: Computed property name from function expression (ComputedPropertyName in ClassDeclaration) +esid: prod-ComputedPropertyName +features: [computed-property-names] +flags: [generated] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ + + +class C { + [function () {}]() { + return 1; + } + static [function () {}]() { + return 1; + } +}; + +let c = new C(); + +assert.sameValue( + c[function () {}](), + 1 +); +assert.sameValue( + C[function () {}](), + 1 +); +assert.sameValue( + c[String(function () {})](), + 1 +); +assert.sameValue( + C[String(function () {})](), + 1 +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-generator-function-declaration.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-generator-function-declaration.js new file mode 100644 index 0000000000..977e2b510e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-generator-function-declaration.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-generator-function-declaration.case +// - src/computed-property-names/evaluation/class-declaration.template +/*--- +description: Computed property name from generator function (ComputedPropertyName in ClassDeclaration) +esid: prod-ComputedPropertyName +features: [computed-property-names] +flags: [generated] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ +function * g() { return 1; } + + +class C { + [g()]() { + return 1; + } + static [g()]() { + return 1; + } +}; + +let c = new C(); + +assert.sameValue( + c[g()](), + 1 +); +assert.sameValue( + C[g()](), + 1 +); +assert.sameValue( + c[String(g())](), + 1 +); +assert.sameValue( + C[String(g())](), + 1 +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-identifier.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-identifier.js new file mode 100644 index 0000000000..a10cb61e94 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-identifier.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-identifier.case +// - src/computed-property-names/evaluation/class-declaration.template +/*--- +description: Computed property name from string literal (ComputedPropertyName in ClassDeclaration) +esid: prod-ComputedPropertyName +features: [computed-property-names] +flags: [generated] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ +let x = 1; + + + +class C { + [x]() { + return '2'; + } + static [x]() { + return '2'; + } +}; + +let c = new C(); + +assert.sameValue( + c[x](), + '2' +); +assert.sameValue( + C[x](), + '2' +); +assert.sameValue( + c[String(x)](), + '2' +); +assert.sameValue( + C[String(x)](), + '2' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-integer-e-notational-literal.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-integer-e-notational-literal.js new file mode 100644 index 0000000000..452d9c3a11 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-integer-e-notational-literal.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-integer-e-notational-literal.case +// - src/computed-property-names/evaluation/class-declaration.template +/*--- +description: Computed property name from numeric literal (ComputedPropertyName in ClassDeclaration) +esid: prod-ComputedPropertyName +features: [computed-property-names] +flags: [generated] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ + + +class C { + [1]() { + return 2; + } + static [1]() { + return 2; + } +}; + +let c = new C(); + +assert.sameValue( + c[1](), + 2 +); +assert.sameValue( + C[1](), + 2 +); +assert.sameValue( + c[String(1)](), + 2 +); +assert.sameValue( + C[String(1)](), + 2 +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-integer-separators.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-integer-separators.js new file mode 100644 index 0000000000..44aa87db00 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-integer-separators.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-integer-separators.case +// - src/computed-property-names/evaluation/class-declaration.template +/*--- +description: Computed property name from integer with separators (ComputedPropertyName in ClassDeclaration) +esid: prod-ComputedPropertyName +features: [computed-property-names] +flags: [generated] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ + + +class C { + [1_2_3_4_5_6_7_8]() { + return 1_2_3_4_5_6_7_8; + } + static [1_2_3_4_5_6_7_8]() { + return 1_2_3_4_5_6_7_8; + } +}; + +let c = new C(); + +assert.sameValue( + c[1_2_3_4_5_6_7_8](), + 1_2_3_4_5_6_7_8 +); +assert.sameValue( + C[1_2_3_4_5_6_7_8](), + 1_2_3_4_5_6_7_8 +); +assert.sameValue( + c[String(1_2_3_4_5_6_7_8)](), + 1_2_3_4_5_6_7_8 +); +assert.sameValue( + C[String(1_2_3_4_5_6_7_8)](), + 1_2_3_4_5_6_7_8 +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-math.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-math.js new file mode 100644 index 0000000000..e146251c4e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-math.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-math.case +// - src/computed-property-names/evaluation/class-declaration.template +/*--- +description: Computed property name from math (ComputedPropertyName in ClassDeclaration) +esid: prod-ComputedPropertyName +features: [computed-property-names, exponentiation] +flags: [generated] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ + + +class C { + [1 + 2 - 3 * 4 / 5 ** 6]() { + return 2.999232; + } + static [1 + 2 - 3 * 4 / 5 ** 6]() { + return 2.999232; + } +}; + +let c = new C(); + +assert.sameValue( + c[1 + 2 - 3 * 4 / 5 ** 6](), + 2.999232 +); +assert.sameValue( + C[1 + 2 - 3 * 4 / 5 ** 6](), + 2.999232 +); +assert.sameValue( + c[String(1 + 2 - 3 * 4 / 5 ** 6)](), + 2.999232 +); +assert.sameValue( + C[String(1 + 2 - 3 * 4 / 5 ** 6)](), + 2.999232 +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-multiplicative-expression-div.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-multiplicative-expression-div.js new file mode 100644 index 0000000000..0d26171ee7 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-multiplicative-expression-div.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-multiplicative-expression-div.case +// - src/computed-property-names/evaluation/class-declaration.template +/*--- +description: Computed property name from multiplicative expression "divide" (ComputedPropertyName in ClassDeclaration) +esid: prod-ComputedPropertyName +features: [computed-property-names] +flags: [generated] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ + + +class C { + [1 / 1]() { + return 1; + } + static [1 / 1]() { + return 1; + } +}; + +let c = new C(); + +assert.sameValue( + c[1 / 1](), + 1 +); +assert.sameValue( + C[1 / 1](), + 1 +); +assert.sameValue( + c[String(1 / 1)](), + 1 +); +assert.sameValue( + C[String(1 / 1)](), + 1 +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-multiplicative-expression-mult.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-multiplicative-expression-mult.js new file mode 100644 index 0000000000..f95ec64b93 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-multiplicative-expression-mult.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-multiplicative-expression-mult.case +// - src/computed-property-names/evaluation/class-declaration.template +/*--- +description: Computed property name from multiplicative expression "multiply" (ComputedPropertyName in ClassDeclaration) +esid: prod-ComputedPropertyName +features: [computed-property-names] +flags: [generated] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ + + +class C { + [1 * 1]() { + return 1; + } + static [1 * 1]() { + return 1; + } +}; + +let c = new C(); + +assert.sameValue( + c[1 * 1](), + 1 +); +assert.sameValue( + C[1 * 1](), + 1 +); +assert.sameValue( + c[String(1 * 1)](), + 1 +); +assert.sameValue( + C[String(1 * 1)](), + 1 +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-null.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-null.js new file mode 100644 index 0000000000..ea49134f50 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-null.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-null.case +// - src/computed-property-names/evaluation/class-declaration.template +/*--- +description: Computed property name from condition expression (ComputedPropertyName in ClassDeclaration) +esid: prod-ComputedPropertyName +features: [computed-property-names] +flags: [generated] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ + + +class C { + [null]() { + return null; + } + static [null]() { + return null; + } +}; + +let c = new C(); + +assert.sameValue( + c[null](), + null +); +assert.sameValue( + C[null](), + null +); +assert.sameValue( + c[String(null)](), + null +); +assert.sameValue( + C[String(null)](), + null +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-numeric-literal.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-numeric-literal.js new file mode 100644 index 0000000000..cda6602bc7 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-numeric-literal.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-numeric-literal.case +// - src/computed-property-names/evaluation/class-declaration.template +/*--- +description: Computed property name from numeric literal (ComputedPropertyName in ClassDeclaration) +esid: prod-ComputedPropertyName +features: [computed-property-names] +flags: [generated] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ + + +class C { + [1]() { + return 2; + } + static [1]() { + return 2; + } +}; + +let c = new C(); + +assert.sameValue( + c[1](), + 2 +); +assert.sameValue( + C[1](), + 2 +); +assert.sameValue( + c[String(1)](), + 2 +); +assert.sameValue( + C[String(1)](), + 2 +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-string-literal.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-string-literal.js new file mode 100644 index 0000000000..09c7f5ce57 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-string-literal.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-string-literal.case +// - src/computed-property-names/evaluation/class-declaration.template +/*--- +description: Computed property name from string literal (ComputedPropertyName in ClassDeclaration) +esid: prod-ComputedPropertyName +features: [computed-property-names] +flags: [generated] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ + + +class C { + ['1']() { + return '2'; + } + static ['1']() { + return '2'; + } +}; + +let c = new C(); + +assert.sameValue( + c['1'](), + '2' +); +assert.sameValue( + C['1'](), + '2' +); +assert.sameValue( + c[String('1')](), + '2' +); +assert.sameValue( + C[String('1')](), + '2' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-yield-expression.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-yield-expression.js new file mode 100644 index 0000000000..3ad6aa530a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-computed-property-name-from-yield-expression.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-yield-expression.case +// - src/computed-property-names/evaluation/class-declaration.template +/*--- +description: Computed property name from yield expression (ComputedPropertyName in ClassDeclaration) +esid: prod-ComputedPropertyName +features: [computed-property-names] +flags: [generated] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ +function * g() { + + +class C { + [yield 9]() { + return 9; + } + static [yield 9]() { + return 9; + } +}; + +let c = new C(); + +assert.sameValue( + c[yield 9](), + 9 +); +assert.sameValue( + C[yield 9](), + 9 +); +assert.sameValue( + c[String(yield 9)](), + 9 +); +assert.sameValue( + C[String(yield 9)](), + 9 +); + +} +var iter = g(); +while (iter.next().done === false) ; + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-additive-expression-add.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-additive-expression-add.js new file mode 100644 index 0000000000..ea6ffb3850 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-additive-expression-add.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-additive-expression-add.case +// - src/computed-property-names/evaluation/class-declaration-fields.template +/*--- +description: Computed property name from additive expression "add" (ComputedPropertyName in ClassExpression) +esid: prod-ComputedPropertyName +features: [computed-property-names, class-fields-public, class-static-fields-public] +flags: [generated] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ + + +let C = class { + [1 + 1] = 2; + + static [1 + 1] = 2; +}; + +let c = new C(); + +assert.sameValue( + c[1 + 1], + 2 +); +assert.sameValue( + C[1 + 1], + 2 +); +assert.sameValue( + c[String(1 + 1)], + 2 +); +assert.sameValue( + C[String(1 + 1)], + 2 +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-additive-expression-subtract.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-additive-expression-subtract.js new file mode 100644 index 0000000000..98eef5ec8b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-additive-expression-subtract.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-additive-expression-subtract.case +// - src/computed-property-names/evaluation/class-declaration-fields.template +/*--- +description: Computed property name from additive expression "subtract" (ComputedPropertyName in ClassExpression) +esid: prod-ComputedPropertyName +features: [computed-property-names, class-fields-public, class-static-fields-public] +flags: [generated] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ + + +let C = class { + [1 - 1] = 0; + + static [1 - 1] = 0; +}; + +let c = new C(); + +assert.sameValue( + c[1 - 1], + 0 +); +assert.sameValue( + C[1 - 1], + 0 +); +assert.sameValue( + c[String(1 - 1)], + 0 +); +assert.sameValue( + C[String(1 - 1)], + 0 +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-arrow-function-expression.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-arrow-function-expression.js new file mode 100644 index 0000000000..7a295dd4eb --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-arrow-function-expression.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-arrow-function-expression.case +// - src/computed-property-names/evaluation/class-declaration-fields.template +/*--- +description: Computed property name from arrow function (ComputedPropertyName in ClassExpression) +esid: prod-ComputedPropertyName +features: [computed-property-names, class-fields-public, class-static-fields-public] +flags: [generated] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ + + +let C = class { + [() => { }] = 1; + + static [() => { }] = 1; +}; + +let c = new C(); + +assert.sameValue( + c[() => { }], + 1 +); +assert.sameValue( + C[() => { }], + 1 +); +assert.sameValue( + c[String(() => { })], + 1 +); +assert.sameValue( + C[String(() => { })], + 1 +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-assignment-expression-assignment.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-assignment-expression-assignment.js new file mode 100644 index 0000000000..bb04fb5d34 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-assignment-expression-assignment.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-assignment-expression-assignment.case +// - src/computed-property-names/evaluation/class-declaration-fields.template +/*--- +description: Computed property name from assignment expression (ComputedPropertyName in ClassExpression) +esid: prod-ComputedPropertyName +features: [computed-property-names, class-fields-public, class-static-fields-public] +flags: [generated] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ +let x = 0; + + +let C = class { + [x = 1] = 2; + + static [x = 1] = 2; +}; + +let c = new C(); + +assert.sameValue( + c[x = 1], + 2 +); +assert.sameValue( + C[x = 1], + 2 +); +assert.sameValue( + c[String(x = 1)], + 2 +); +assert.sameValue( + C[String(x = 1)], + 2 +); + +assert.sameValue(x, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-assignment-expression-bitwise-or.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-assignment-expression-bitwise-or.js new file mode 100644 index 0000000000..736ca0d344 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-assignment-expression-bitwise-or.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-assignment-expression-bitwise-or.case +// - src/computed-property-names/evaluation/class-declaration-fields.template +/*--- +description: Computed property name from assignment expression bitwise or (ComputedPropertyName in ClassExpression) +esid: prod-ComputedPropertyName +features: [computed-property-names, class-fields-public, class-static-fields-public] +flags: [generated] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ +let x = 0; + + +let C = class { + [x |= 1] = 2; + + static [x |= 1] = 2; +}; + +let c = new C(); + +assert.sameValue( + c[x |= 1], + 2 +); +assert.sameValue( + C[x |= 1], + 2 +); +assert.sameValue( + c[String(x |= 1)], + 2 +); +assert.sameValue( + C[String(x |= 1)], + 2 +); + +assert.sameValue(x, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-assignment-expression-coalesce.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-assignment-expression-coalesce.js new file mode 100644 index 0000000000..1c726926e3 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-assignment-expression-coalesce.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-assignment-expression-coalesce.case +// - src/computed-property-names/evaluation/class-declaration-fields.template +/*--- +description: Computed property name from assignment expression coalesce (ComputedPropertyName in ClassExpression) +esid: prod-ComputedPropertyName +features: [computed-property-names, logical-assignment-operators, class-fields-public, class-static-fields-public] +flags: [generated] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ +let x = null; + + +let C = class { + [x ??= 1] = 2; + + static [x ??= 1] = 2; +}; + +let c = new C(); + +assert.sameValue( + c[x ??= 1], + 2 +); +assert.sameValue( + C[x ??= 1], + 2 +); +assert.sameValue( + c[String(x ??= 1)], + 2 +); +assert.sameValue( + C[String(x ??= 1)], + 2 +); + +assert.sameValue(x, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-assignment-expression-logical-and.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-assignment-expression-logical-and.js new file mode 100644 index 0000000000..692d88d7b5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-assignment-expression-logical-and.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-assignment-expression-logical-and.case +// - src/computed-property-names/evaluation/class-declaration-fields.template +/*--- +description: Computed property name from assignment expression logical and (ComputedPropertyName in ClassExpression) +esid: prod-ComputedPropertyName +features: [computed-property-names, logical-assignment-operators, class-fields-public, class-static-fields-public] +flags: [generated] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ +let x = 0; + + +let C = class { + [x &&= 1] = 2; + + static [x &&= 1] = 2; +}; + +let c = new C(); + +assert.sameValue( + c[x &&= 1], + 2 +); +assert.sameValue( + C[x &&= 1], + 2 +); +assert.sameValue( + c[String(x &&= 1)], + 2 +); +assert.sameValue( + C[String(x &&= 1)], + 2 +); + +assert.sameValue(x, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-assignment-expression-logical-or.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-assignment-expression-logical-or.js new file mode 100644 index 0000000000..a92aa655b7 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-assignment-expression-logical-or.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-assignment-expression-logical-or.case +// - src/computed-property-names/evaluation/class-declaration-fields.template +/*--- +description: Computed property name from assignment expression logical or (ComputedPropertyName in ClassExpression) +esid: prod-ComputedPropertyName +features: [computed-property-names, logical-assignment-operators, class-fields-public, class-static-fields-public] +flags: [generated] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ +let x = 0; + + +let C = class { + [x ||= 1] = 2; + + static [x ||= 1] = 2; +}; + +let c = new C(); + +assert.sameValue( + c[x ||= 1], + 2 +); +assert.sameValue( + C[x ||= 1], + 2 +); +assert.sameValue( + c[String(x ||= 1)], + 2 +); +assert.sameValue( + C[String(x ||= 1)], + 2 +); + +assert.sameValue(x, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-async-arrow-function-expression.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-async-arrow-function-expression.js new file mode 100644 index 0000000000..2b28a7eddd --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-async-arrow-function-expression.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-async-arrow-function-expression.case +// - src/computed-property-names/evaluation/class-declaration-fields.template +/*--- +description: Computed property name from function expression (ComputedPropertyName in ClassExpression) +esid: prod-ComputedPropertyName +features: [computed-property-names, class-fields-public, class-static-fields-public] +flags: [generated] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ + + +let C = class { + [async () => {}] = 1; + + static [async () => {}] = 1; +}; + +let c = new C(); + +assert.sameValue( + c[async () => {}], + 1 +); +assert.sameValue( + C[async () => {}], + 1 +); +assert.sameValue( + c[String(async () => {})], + 1 +); +assert.sameValue( + C[String(async () => {})], + 1 +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-await-expression.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-await-expression.js new file mode 100644 index 0000000000..25ef78cae5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-await-expression.js @@ -0,0 +1,68 @@ +// |reftest| module async +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-await-expression.case +// - src/computed-property-names/evaluation/class-declaration-fields.template +/*--- +description: Computed property name from condition expression (ComputedPropertyName in ClassExpression) +esid: prod-ComputedPropertyName +features: [computed-property-names, top-level-await, class-fields-public, class-static-fields-public] +flags: [generated, async, module] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ +try { + + +let C = class { + [await 9] = 9; + + static [await 9] = 9; +}; + +let c = new C(); + +assert.sameValue( + c[await 9], + 9 +); +assert.sameValue( + C[await 9], + 9 +); +assert.sameValue( + c[String(await 9)], + 9 +); +assert.sameValue( + C[String(await 9)], + 9 +); + +} catch (e) { + $DONE(e); +} +$DONE(); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-condition-expression-false.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-condition-expression-false.js new file mode 100644 index 0000000000..e03c8b7f89 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-condition-expression-false.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-condition-expression-false.case +// - src/computed-property-names/evaluation/class-declaration-fields.template +/*--- +description: Computed property name from condition expression (ComputedPropertyName in ClassExpression) +esid: prod-ComputedPropertyName +features: [computed-property-names, class-fields-public, class-static-fields-public] +flags: [generated] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ + + +let C = class { + [false ? 1 : 2] = 1; + + static [false ? 1 : 2] = 1; +}; + +let c = new C(); + +assert.sameValue( + c[false ? 1 : 2], + 1 +); +assert.sameValue( + C[false ? 1 : 2], + 1 +); +assert.sameValue( + c[String(false ? 1 : 2)], + 1 +); +assert.sameValue( + C[String(false ? 1 : 2)], + 1 +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-condition-expression-true.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-condition-expression-true.js new file mode 100644 index 0000000000..ad0ab90036 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-condition-expression-true.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-condition-expression-true.case +// - src/computed-property-names/evaluation/class-declaration-fields.template +/*--- +description: Computed property name from condition expression (ComputedPropertyName in ClassExpression) +esid: prod-ComputedPropertyName +features: [computed-property-names, class-fields-public, class-static-fields-public] +flags: [generated] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ + + +let C = class { + [true ? 1 : 2] = 2; + + static [true ? 1 : 2] = 2; +}; + +let c = new C(); + +assert.sameValue( + c[true ? 1 : 2], + 2 +); +assert.sameValue( + C[true ? 1 : 2], + 2 +); +assert.sameValue( + c[String(true ? 1 : 2)], + 2 +); +assert.sameValue( + C[String(true ? 1 : 2)], + 2 +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-decimal-e-notational-literal.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-decimal-e-notational-literal.js new file mode 100644 index 0000000000..8c2c102ea3 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-decimal-e-notational-literal.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-decimal-e-notational-literal.case +// - src/computed-property-names/evaluation/class-declaration-fields.template +/*--- +description: Computed property name from decimal e notational literal (ComputedPropertyName in ClassExpression) +esid: prod-ComputedPropertyName +features: [computed-property-names, class-fields-public, class-static-fields-public] +flags: [generated] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ + + +let C = class { + [1.e1] = 2; + + static [1.e1] = 2; +}; + +let c = new C(); + +assert.sameValue( + c[1.e1], + 2 +); +assert.sameValue( + C[1.e1], + 2 +); +assert.sameValue( + c[String(1.e1)], + 2 +); +assert.sameValue( + C[String(1.e1)], + 2 +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-decimal-literal.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-decimal-literal.js new file mode 100644 index 0000000000..661b7f5fd4 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-decimal-literal.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-decimal-literal.case +// - src/computed-property-names/evaluation/class-declaration-fields.template +/*--- +description: Computed property name from decimal literal (ComputedPropertyName in ClassExpression) +esid: prod-ComputedPropertyName +features: [computed-property-names, class-fields-public, class-static-fields-public] +flags: [generated] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ + + +let C = class { + [1.1] = 2; + + static [1.1] = 2; +}; + +let c = new C(); + +assert.sameValue( + c[1.1], + 2 +); +assert.sameValue( + C[1.1], + 2 +); +assert.sameValue( + c[String(1.1)], + 2 +); +assert.sameValue( + C[String(1.1)], + 2 +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-exponetiation-expression.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-exponetiation-expression.js new file mode 100644 index 0000000000..3e8f3e6018 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-exponetiation-expression.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-exponetiation-expression.case +// - src/computed-property-names/evaluation/class-declaration-fields.template +/*--- +description: Computed property name from exponentiation expression (ComputedPropertyName in ClassExpression) +esid: prod-ComputedPropertyName +features: [computed-property-names, exponentiation, class-fields-public, class-static-fields-public] +flags: [generated] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ + + +let C = class { + [2 ** 2] = 4; + + static [2 ** 2] = 4; +}; + +let c = new C(); + +assert.sameValue( + c[2 ** 2], + 4 +); +assert.sameValue( + C[2 ** 2], + 4 +); +assert.sameValue( + c[String(2 ** 2)], + 4 +); +assert.sameValue( + C[String(2 ** 2)], + 4 +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-expression-coalesce.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-expression-coalesce.js new file mode 100644 index 0000000000..e8fd6d9cac --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-expression-coalesce.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-expression-coalesce.case +// - src/computed-property-names/evaluation/class-declaration-fields.template +/*--- +description: Computed property name from coalesce (ComputedPropertyName in ClassExpression) +esid: prod-ComputedPropertyName +features: [computed-property-names, class-fields-public, class-static-fields-public] +flags: [generated] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ +let x; + + +let C = class { + [x ?? 1] = 2; + + static [x ?? 1] = 2; +}; + +let c = new C(); + +assert.sameValue( + c[x ?? 1], + 2 +); +assert.sameValue( + C[x ?? 1], + 2 +); +assert.sameValue( + c[String(x ?? 1)], + 2 +); +assert.sameValue( + C[String(x ?? 1)], + 2 +); + +assert.sameValue(x, undefined); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-expression-logical-and.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-expression-logical-and.js new file mode 100644 index 0000000000..12d8b5a909 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-expression-logical-and.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-expression-logical-and.case +// - src/computed-property-names/evaluation/class-declaration-fields.template +/*--- +description: Computed property name from logical and (ComputedPropertyName in ClassExpression) +esid: prod-ComputedPropertyName +features: [computed-property-names, class-fields-public, class-static-fields-public] +flags: [generated] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ +let x = 0; + + +let C = class { + [x && 1] = 2; + + static [x && 1] = 2; +}; + +let c = new C(); + +assert.sameValue( + c[x && 1], + 2 +); +assert.sameValue( + C[x && 1], + 2 +); +assert.sameValue( + c[String(x && 1)], + 2 +); +assert.sameValue( + C[String(x && 1)], + 2 +); + +assert.sameValue(x, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-expression-logical-or.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-expression-logical-or.js new file mode 100644 index 0000000000..8e8bfc82aa --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-expression-logical-or.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-expression-logical-or.case +// - src/computed-property-names/evaluation/class-declaration-fields.template +/*--- +description: Computed property name from logical or (ComputedPropertyName in ClassExpression) +esid: prod-ComputedPropertyName +features: [computed-property-names, class-fields-public, class-static-fields-public] +flags: [generated] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ +let x = 0; + + +let C = class { + [x || 1] = 2; + + static [x || 1] = 2; +}; + +let c = new C(); + +assert.sameValue( + c[x || 1], + 2 +); +assert.sameValue( + C[x || 1], + 2 +); +assert.sameValue( + c[String(x || 1)], + 2 +); +assert.sameValue( + C[String(x || 1)], + 2 +); + +assert.sameValue(x, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-function-declaration.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-function-declaration.js new file mode 100644 index 0000000000..aeeb9adbc8 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-function-declaration.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-function-declaration.case +// - src/computed-property-names/evaluation/class-declaration-fields.template +/*--- +description: Computed property name from function (ComputedPropertyName in ClassExpression) +esid: prod-ComputedPropertyName +features: [computed-property-names, class-fields-public, class-static-fields-public] +flags: [generated] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ +function f() {} + + +let C = class { + [f()] = 1; + + static [f()] = 1; +}; + +let c = new C(); + +assert.sameValue( + c[f()], + 1 +); +assert.sameValue( + C[f()], + 1 +); +assert.sameValue( + c[String(f())], + 1 +); +assert.sameValue( + C[String(f())], + 1 +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-function-expression.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-function-expression.js new file mode 100644 index 0000000000..9eaea1afdb --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-function-expression.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-function-expression.case +// - src/computed-property-names/evaluation/class-declaration-fields.template +/*--- +description: Computed property name from function expression (ComputedPropertyName in ClassExpression) +esid: prod-ComputedPropertyName +features: [computed-property-names, class-fields-public, class-static-fields-public] +flags: [generated] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ + + +let C = class { + [function () {}] = 1; + + static [function () {}] = 1; +}; + +let c = new C(); + +assert.sameValue( + c[function () {}], + 1 +); +assert.sameValue( + C[function () {}], + 1 +); +assert.sameValue( + c[String(function () {})], + 1 +); +assert.sameValue( + C[String(function () {})], + 1 +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-generator-function-declaration.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-generator-function-declaration.js new file mode 100644 index 0000000000..35ff6866b2 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-generator-function-declaration.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-generator-function-declaration.case +// - src/computed-property-names/evaluation/class-declaration-fields.template +/*--- +description: Computed property name from generator function (ComputedPropertyName in ClassExpression) +esid: prod-ComputedPropertyName +features: [computed-property-names, class-fields-public, class-static-fields-public] +flags: [generated] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ +function * g() { return 1; } + + +let C = class { + [g()] = 1; + + static [g()] = 1; +}; + +let c = new C(); + +assert.sameValue( + c[g()], + 1 +); +assert.sameValue( + C[g()], + 1 +); +assert.sameValue( + c[String(g())], + 1 +); +assert.sameValue( + C[String(g())], + 1 +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-identifier.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-identifier.js new file mode 100644 index 0000000000..2d39292d1b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-identifier.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-identifier.case +// - src/computed-property-names/evaluation/class-declaration-fields.template +/*--- +description: Computed property name from string literal (ComputedPropertyName in ClassExpression) +esid: prod-ComputedPropertyName +features: [computed-property-names, class-fields-public, class-static-fields-public] +flags: [generated] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ +let x = 1; + + + +let C = class { + [x] = '2'; + + static [x] = '2'; +}; + +let c = new C(); + +assert.sameValue( + c[x], + '2' +); +assert.sameValue( + C[x], + '2' +); +assert.sameValue( + c[String(x)], + '2' +); +assert.sameValue( + C[String(x)], + '2' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-integer-e-notational-literal.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-integer-e-notational-literal.js new file mode 100644 index 0000000000..a8696e07cf --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-integer-e-notational-literal.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-integer-e-notational-literal.case +// - src/computed-property-names/evaluation/class-declaration-fields.template +/*--- +description: Computed property name from numeric literal (ComputedPropertyName in ClassExpression) +esid: prod-ComputedPropertyName +features: [computed-property-names, class-fields-public, class-static-fields-public] +flags: [generated] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ + + +let C = class { + [1] = 2; + + static [1] = 2; +}; + +let c = new C(); + +assert.sameValue( + c[1], + 2 +); +assert.sameValue( + C[1], + 2 +); +assert.sameValue( + c[String(1)], + 2 +); +assert.sameValue( + C[String(1)], + 2 +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-integer-separators.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-integer-separators.js new file mode 100644 index 0000000000..012230a62e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-integer-separators.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-integer-separators.case +// - src/computed-property-names/evaluation/class-declaration-fields.template +/*--- +description: Computed property name from integer with separators (ComputedPropertyName in ClassExpression) +esid: prod-ComputedPropertyName +features: [computed-property-names, class-fields-public, class-static-fields-public] +flags: [generated] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ + + +let C = class { + [1_2_3_4_5_6_7_8] = 1_2_3_4_5_6_7_8; + + static [1_2_3_4_5_6_7_8] = 1_2_3_4_5_6_7_8; +}; + +let c = new C(); + +assert.sameValue( + c[1_2_3_4_5_6_7_8], + 1_2_3_4_5_6_7_8 +); +assert.sameValue( + C[1_2_3_4_5_6_7_8], + 1_2_3_4_5_6_7_8 +); +assert.sameValue( + c[String(1_2_3_4_5_6_7_8)], + 1_2_3_4_5_6_7_8 +); +assert.sameValue( + C[String(1_2_3_4_5_6_7_8)], + 1_2_3_4_5_6_7_8 +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-math.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-math.js new file mode 100644 index 0000000000..b506f576fe --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-math.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-math.case +// - src/computed-property-names/evaluation/class-declaration-fields.template +/*--- +description: Computed property name from math (ComputedPropertyName in ClassExpression) +esid: prod-ComputedPropertyName +features: [computed-property-names, exponentiation, class-fields-public, class-static-fields-public] +flags: [generated] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ + + +let C = class { + [1 + 2 - 3 * 4 / 5 ** 6] = 2.999232; + + static [1 + 2 - 3 * 4 / 5 ** 6] = 2.999232; +}; + +let c = new C(); + +assert.sameValue( + c[1 + 2 - 3 * 4 / 5 ** 6], + 2.999232 +); +assert.sameValue( + C[1 + 2 - 3 * 4 / 5 ** 6], + 2.999232 +); +assert.sameValue( + c[String(1 + 2 - 3 * 4 / 5 ** 6)], + 2.999232 +); +assert.sameValue( + C[String(1 + 2 - 3 * 4 / 5 ** 6)], + 2.999232 +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-multiplicative-expression-div.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-multiplicative-expression-div.js new file mode 100644 index 0000000000..7a779fca7d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-multiplicative-expression-div.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-multiplicative-expression-div.case +// - src/computed-property-names/evaluation/class-declaration-fields.template +/*--- +description: Computed property name from multiplicative expression "divide" (ComputedPropertyName in ClassExpression) +esid: prod-ComputedPropertyName +features: [computed-property-names, class-fields-public, class-static-fields-public] +flags: [generated] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ + + +let C = class { + [1 / 1] = 1; + + static [1 / 1] = 1; +}; + +let c = new C(); + +assert.sameValue( + c[1 / 1], + 1 +); +assert.sameValue( + C[1 / 1], + 1 +); +assert.sameValue( + c[String(1 / 1)], + 1 +); +assert.sameValue( + C[String(1 / 1)], + 1 +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-multiplicative-expression-mult.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-multiplicative-expression-mult.js new file mode 100644 index 0000000000..25ee51bee9 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-multiplicative-expression-mult.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-multiplicative-expression-mult.case +// - src/computed-property-names/evaluation/class-declaration-fields.template +/*--- +description: Computed property name from multiplicative expression "multiply" (ComputedPropertyName in ClassExpression) +esid: prod-ComputedPropertyName +features: [computed-property-names, class-fields-public, class-static-fields-public] +flags: [generated] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ + + +let C = class { + [1 * 1] = 1; + + static [1 * 1] = 1; +}; + +let c = new C(); + +assert.sameValue( + c[1 * 1], + 1 +); +assert.sameValue( + C[1 * 1], + 1 +); +assert.sameValue( + c[String(1 * 1)], + 1 +); +assert.sameValue( + C[String(1 * 1)], + 1 +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-null.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-null.js new file mode 100644 index 0000000000..50b533c9d3 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-null.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-null.case +// - src/computed-property-names/evaluation/class-declaration-fields.template +/*--- +description: Computed property name from condition expression (ComputedPropertyName in ClassExpression) +esid: prod-ComputedPropertyName +features: [computed-property-names, class-fields-public, class-static-fields-public] +flags: [generated] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ + + +let C = class { + [null] = null; + + static [null] = null; +}; + +let c = new C(); + +assert.sameValue( + c[null], + null +); +assert.sameValue( + C[null], + null +); +assert.sameValue( + c[String(null)], + null +); +assert.sameValue( + C[String(null)], + null +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-numeric-literal.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-numeric-literal.js new file mode 100644 index 0000000000..2f66cd4384 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-numeric-literal.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-numeric-literal.case +// - src/computed-property-names/evaluation/class-declaration-fields.template +/*--- +description: Computed property name from numeric literal (ComputedPropertyName in ClassExpression) +esid: prod-ComputedPropertyName +features: [computed-property-names, class-fields-public, class-static-fields-public] +flags: [generated] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ + + +let C = class { + [1] = 2; + + static [1] = 2; +}; + +let c = new C(); + +assert.sameValue( + c[1], + 2 +); +assert.sameValue( + C[1], + 2 +); +assert.sameValue( + c[String(1)], + 2 +); +assert.sameValue( + C[String(1)], + 2 +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-string-literal.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-string-literal.js new file mode 100644 index 0000000000..d3e613bed3 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-string-literal.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-string-literal.case +// - src/computed-property-names/evaluation/class-declaration-fields.template +/*--- +description: Computed property name from string literal (ComputedPropertyName in ClassExpression) +esid: prod-ComputedPropertyName +features: [computed-property-names, class-fields-public, class-static-fields-public] +flags: [generated] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ + + +let C = class { + ['1'] = '2'; + + static ['1'] = '2'; +}; + +let c = new C(); + +assert.sameValue( + c['1'], + '2' +); +assert.sameValue( + C['1'], + '2' +); +assert.sameValue( + c[String('1')], + '2' +); +assert.sameValue( + C[String('1')], + '2' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-yield-expression.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-yield-expression.js new file mode 100644 index 0000000000..b48c6f884c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-computed-property-name-from-yield-expression.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-yield-expression.case +// - src/computed-property-names/evaluation/class-declaration-fields.template +/*--- +description: Computed property name from yield expression (ComputedPropertyName in ClassExpression) +esid: prod-ComputedPropertyName +features: [computed-property-names, class-fields-public, class-static-fields-public] +flags: [generated] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ +function * g() { + + +let C = class { + [yield 9] = 9; + + static [yield 9] = 9; +}; + +let c = new C(); + +assert.sameValue( + c[yield 9], + 9 +); +assert.sameValue( + C[yield 9], + 9 +); +assert.sameValue( + c[String(yield 9)], + 9 +); +assert.sameValue( + C[String(yield 9)], + 9 +); + +} +var iter = g(); +while (iter.next().done === false) ; + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-additive-expression-add.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-additive-expression-add.js new file mode 100644 index 0000000000..71eec0118a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-additive-expression-add.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-additive-expression-add.case +// - src/computed-property-names/evaluation/class-declaration-fields-methods.template +/*--- +description: Computed property name from additive expression "add" (ComputedPropertyName in ClassExpression) +esid: prod-ComputedPropertyName +features: [computed-property-names, class-fields-public, class-static-fields-public] +flags: [generated] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ + + +let C = class { + [1 + 1] = () => { + return 2; + }; + + static [1 + 1] = () => { + return 2; + }; +}; + +let c = new C(); + +assert.sameValue( + c[1 + 1](), + 2 +); +assert.sameValue( + C[1 + 1](), + 2 +); +assert.sameValue( + c[String(1 + 1)](), + 2 +); +assert.sameValue( + C[String(1 + 1)](), + 2 +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-additive-expression-subtract.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-additive-expression-subtract.js new file mode 100644 index 0000000000..97dbdbf6e2 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-additive-expression-subtract.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-additive-expression-subtract.case +// - src/computed-property-names/evaluation/class-declaration-fields-methods.template +/*--- +description: Computed property name from additive expression "subtract" (ComputedPropertyName in ClassExpression) +esid: prod-ComputedPropertyName +features: [computed-property-names, class-fields-public, class-static-fields-public] +flags: [generated] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ + + +let C = class { + [1 - 1] = () => { + return 0; + }; + + static [1 - 1] = () => { + return 0; + }; +}; + +let c = new C(); + +assert.sameValue( + c[1 - 1](), + 0 +); +assert.sameValue( + C[1 - 1](), + 0 +); +assert.sameValue( + c[String(1 - 1)](), + 0 +); +assert.sameValue( + C[String(1 - 1)](), + 0 +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-arrow-function-expression.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-arrow-function-expression.js new file mode 100644 index 0000000000..c0c57223a8 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-arrow-function-expression.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-arrow-function-expression.case +// - src/computed-property-names/evaluation/class-declaration-fields-methods.template +/*--- +description: Computed property name from arrow function (ComputedPropertyName in ClassExpression) +esid: prod-ComputedPropertyName +features: [computed-property-names, class-fields-public, class-static-fields-public] +flags: [generated] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ + + +let C = class { + [() => { }] = () => { + return 1; + }; + + static [() => { }] = () => { + return 1; + }; +}; + +let c = new C(); + +assert.sameValue( + c[() => { }](), + 1 +); +assert.sameValue( + C[() => { }](), + 1 +); +assert.sameValue( + c[String(() => { })](), + 1 +); +assert.sameValue( + C[String(() => { })](), + 1 +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-assignment-expression-assignment.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-assignment-expression-assignment.js new file mode 100644 index 0000000000..d5724dedda --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-assignment-expression-assignment.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-assignment-expression-assignment.case +// - src/computed-property-names/evaluation/class-declaration-fields-methods.template +/*--- +description: Computed property name from assignment expression (ComputedPropertyName in ClassExpression) +esid: prod-ComputedPropertyName +features: [computed-property-names, class-fields-public, class-static-fields-public] +flags: [generated] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ +let x = 0; + + +let C = class { + [x = 1] = () => { + return 2; + }; + + static [x = 1] = () => { + return 2; + }; +}; + +let c = new C(); + +assert.sameValue( + c[x = 1](), + 2 +); +assert.sameValue( + C[x = 1](), + 2 +); +assert.sameValue( + c[String(x = 1)](), + 2 +); +assert.sameValue( + C[String(x = 1)](), + 2 +); + +assert.sameValue(x, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-assignment-expression-bitwise-or.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-assignment-expression-bitwise-or.js new file mode 100644 index 0000000000..0363c3513d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-assignment-expression-bitwise-or.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-assignment-expression-bitwise-or.case +// - src/computed-property-names/evaluation/class-declaration-fields-methods.template +/*--- +description: Computed property name from assignment expression bitwise or (ComputedPropertyName in ClassExpression) +esid: prod-ComputedPropertyName +features: [computed-property-names, class-fields-public, class-static-fields-public] +flags: [generated] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ +let x = 0; + + +let C = class { + [x |= 1] = () => { + return 2; + }; + + static [x |= 1] = () => { + return 2; + }; +}; + +let c = new C(); + +assert.sameValue( + c[x |= 1](), + 2 +); +assert.sameValue( + C[x |= 1](), + 2 +); +assert.sameValue( + c[String(x |= 1)](), + 2 +); +assert.sameValue( + C[String(x |= 1)](), + 2 +); + +assert.sameValue(x, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-assignment-expression-coalesce.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-assignment-expression-coalesce.js new file mode 100644 index 0000000000..3dee6a5629 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-assignment-expression-coalesce.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-assignment-expression-coalesce.case +// - src/computed-property-names/evaluation/class-declaration-fields-methods.template +/*--- +description: Computed property name from assignment expression coalesce (ComputedPropertyName in ClassExpression) +esid: prod-ComputedPropertyName +features: [computed-property-names, logical-assignment-operators, class-fields-public, class-static-fields-public] +flags: [generated] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ +let x = null; + + +let C = class { + [x ??= 1] = () => { + return 2; + }; + + static [x ??= 1] = () => { + return 2; + }; +}; + +let c = new C(); + +assert.sameValue( + c[x ??= 1](), + 2 +); +assert.sameValue( + C[x ??= 1](), + 2 +); +assert.sameValue( + c[String(x ??= 1)](), + 2 +); +assert.sameValue( + C[String(x ??= 1)](), + 2 +); + +assert.sameValue(x, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-assignment-expression-logical-and.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-assignment-expression-logical-and.js new file mode 100644 index 0000000000..f2299078af --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-assignment-expression-logical-and.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-assignment-expression-logical-and.case +// - src/computed-property-names/evaluation/class-declaration-fields-methods.template +/*--- +description: Computed property name from assignment expression logical and (ComputedPropertyName in ClassExpression) +esid: prod-ComputedPropertyName +features: [computed-property-names, logical-assignment-operators, class-fields-public, class-static-fields-public] +flags: [generated] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ +let x = 0; + + +let C = class { + [x &&= 1] = () => { + return 2; + }; + + static [x &&= 1] = () => { + return 2; + }; +}; + +let c = new C(); + +assert.sameValue( + c[x &&= 1](), + 2 +); +assert.sameValue( + C[x &&= 1](), + 2 +); +assert.sameValue( + c[String(x &&= 1)](), + 2 +); +assert.sameValue( + C[String(x &&= 1)](), + 2 +); + +assert.sameValue(x, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-assignment-expression-logical-or.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-assignment-expression-logical-or.js new file mode 100644 index 0000000000..bad6dbd0aa --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-assignment-expression-logical-or.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-assignment-expression-logical-or.case +// - src/computed-property-names/evaluation/class-declaration-fields-methods.template +/*--- +description: Computed property name from assignment expression logical or (ComputedPropertyName in ClassExpression) +esid: prod-ComputedPropertyName +features: [computed-property-names, logical-assignment-operators, class-fields-public, class-static-fields-public] +flags: [generated] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ +let x = 0; + + +let C = class { + [x ||= 1] = () => { + return 2; + }; + + static [x ||= 1] = () => { + return 2; + }; +}; + +let c = new C(); + +assert.sameValue( + c[x ||= 1](), + 2 +); +assert.sameValue( + C[x ||= 1](), + 2 +); +assert.sameValue( + c[String(x ||= 1)](), + 2 +); +assert.sameValue( + C[String(x ||= 1)](), + 2 +); + +assert.sameValue(x, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-async-arrow-function-expression.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-async-arrow-function-expression.js new file mode 100644 index 0000000000..1205a426ba --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-async-arrow-function-expression.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-async-arrow-function-expression.case +// - src/computed-property-names/evaluation/class-declaration-fields-methods.template +/*--- +description: Computed property name from function expression (ComputedPropertyName in ClassExpression) +esid: prod-ComputedPropertyName +features: [computed-property-names, class-fields-public, class-static-fields-public] +flags: [generated] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ + + +let C = class { + [async () => {}] = () => { + return 1; + }; + + static [async () => {}] = () => { + return 1; + }; +}; + +let c = new C(); + +assert.sameValue( + c[async () => {}](), + 1 +); +assert.sameValue( + C[async () => {}](), + 1 +); +assert.sameValue( + c[String(async () => {})](), + 1 +); +assert.sameValue( + C[String(async () => {})](), + 1 +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-await-expression.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-await-expression.js new file mode 100644 index 0000000000..195a54bafc --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-await-expression.js @@ -0,0 +1,72 @@ +// |reftest| module async +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-await-expression.case +// - src/computed-property-names/evaluation/class-declaration-fields-methods.template +/*--- +description: Computed property name from condition expression (ComputedPropertyName in ClassExpression) +esid: prod-ComputedPropertyName +features: [computed-property-names, top-level-await, class-fields-public, class-static-fields-public] +flags: [generated, async, module] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ +try { + + +let C = class { + [await 9] = () => { + return 9; + }; + + static [await 9] = () => { + return 9; + }; +}; + +let c = new C(); + +assert.sameValue( + c[await 9](), + 9 +); +assert.sameValue( + C[await 9](), + 9 +); +assert.sameValue( + c[String(await 9)](), + 9 +); +assert.sameValue( + C[String(await 9)](), + 9 +); + +} catch (e) { + $DONE(e); +} +$DONE(); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-condition-expression-false.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-condition-expression-false.js new file mode 100644 index 0000000000..bd79d94e1a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-condition-expression-false.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-condition-expression-false.case +// - src/computed-property-names/evaluation/class-declaration-fields-methods.template +/*--- +description: Computed property name from condition expression (ComputedPropertyName in ClassExpression) +esid: prod-ComputedPropertyName +features: [computed-property-names, class-fields-public, class-static-fields-public] +flags: [generated] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ + + +let C = class { + [false ? 1 : 2] = () => { + return 1; + }; + + static [false ? 1 : 2] = () => { + return 1; + }; +}; + +let c = new C(); + +assert.sameValue( + c[false ? 1 : 2](), + 1 +); +assert.sameValue( + C[false ? 1 : 2](), + 1 +); +assert.sameValue( + c[String(false ? 1 : 2)](), + 1 +); +assert.sameValue( + C[String(false ? 1 : 2)](), + 1 +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-condition-expression-true.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-condition-expression-true.js new file mode 100644 index 0000000000..ebab97ae18 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-condition-expression-true.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-condition-expression-true.case +// - src/computed-property-names/evaluation/class-declaration-fields-methods.template +/*--- +description: Computed property name from condition expression (ComputedPropertyName in ClassExpression) +esid: prod-ComputedPropertyName +features: [computed-property-names, class-fields-public, class-static-fields-public] +flags: [generated] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ + + +let C = class { + [true ? 1 : 2] = () => { + return 2; + }; + + static [true ? 1 : 2] = () => { + return 2; + }; +}; + +let c = new C(); + +assert.sameValue( + c[true ? 1 : 2](), + 2 +); +assert.sameValue( + C[true ? 1 : 2](), + 2 +); +assert.sameValue( + c[String(true ? 1 : 2)](), + 2 +); +assert.sameValue( + C[String(true ? 1 : 2)](), + 2 +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-decimal-e-notational-literal.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-decimal-e-notational-literal.js new file mode 100644 index 0000000000..3f58d25b79 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-decimal-e-notational-literal.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-decimal-e-notational-literal.case +// - src/computed-property-names/evaluation/class-declaration-fields-methods.template +/*--- +description: Computed property name from decimal e notational literal (ComputedPropertyName in ClassExpression) +esid: prod-ComputedPropertyName +features: [computed-property-names, class-fields-public, class-static-fields-public] +flags: [generated] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ + + +let C = class { + [1.e1] = () => { + return 2; + }; + + static [1.e1] = () => { + return 2; + }; +}; + +let c = new C(); + +assert.sameValue( + c[1.e1](), + 2 +); +assert.sameValue( + C[1.e1](), + 2 +); +assert.sameValue( + c[String(1.e1)](), + 2 +); +assert.sameValue( + C[String(1.e1)](), + 2 +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-decimal-literal.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-decimal-literal.js new file mode 100644 index 0000000000..3d97072386 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-decimal-literal.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-decimal-literal.case +// - src/computed-property-names/evaluation/class-declaration-fields-methods.template +/*--- +description: Computed property name from decimal literal (ComputedPropertyName in ClassExpression) +esid: prod-ComputedPropertyName +features: [computed-property-names, class-fields-public, class-static-fields-public] +flags: [generated] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ + + +let C = class { + [1.1] = () => { + return 2; + }; + + static [1.1] = () => { + return 2; + }; +}; + +let c = new C(); + +assert.sameValue( + c[1.1](), + 2 +); +assert.sameValue( + C[1.1](), + 2 +); +assert.sameValue( + c[String(1.1)](), + 2 +); +assert.sameValue( + C[String(1.1)](), + 2 +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-exponetiation-expression.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-exponetiation-expression.js new file mode 100644 index 0000000000..524720575e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-exponetiation-expression.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-exponetiation-expression.case +// - src/computed-property-names/evaluation/class-declaration-fields-methods.template +/*--- +description: Computed property name from exponentiation expression (ComputedPropertyName in ClassExpression) +esid: prod-ComputedPropertyName +features: [computed-property-names, exponentiation, class-fields-public, class-static-fields-public] +flags: [generated] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ + + +let C = class { + [2 ** 2] = () => { + return 4; + }; + + static [2 ** 2] = () => { + return 4; + }; +}; + +let c = new C(); + +assert.sameValue( + c[2 ** 2](), + 4 +); +assert.sameValue( + C[2 ** 2](), + 4 +); +assert.sameValue( + c[String(2 ** 2)](), + 4 +); +assert.sameValue( + C[String(2 ** 2)](), + 4 +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-expression-coalesce.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-expression-coalesce.js new file mode 100644 index 0000000000..a7cf9a1929 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-expression-coalesce.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-expression-coalesce.case +// - src/computed-property-names/evaluation/class-declaration-fields-methods.template +/*--- +description: Computed property name from coalesce (ComputedPropertyName in ClassExpression) +esid: prod-ComputedPropertyName +features: [computed-property-names, class-fields-public, class-static-fields-public] +flags: [generated] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ +let x; + + +let C = class { + [x ?? 1] = () => { + return 2; + }; + + static [x ?? 1] = () => { + return 2; + }; +}; + +let c = new C(); + +assert.sameValue( + c[x ?? 1](), + 2 +); +assert.sameValue( + C[x ?? 1](), + 2 +); +assert.sameValue( + c[String(x ?? 1)](), + 2 +); +assert.sameValue( + C[String(x ?? 1)](), + 2 +); + +assert.sameValue(x, undefined); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-expression-logical-and.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-expression-logical-and.js new file mode 100644 index 0000000000..5c4ba7c819 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-expression-logical-and.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-expression-logical-and.case +// - src/computed-property-names/evaluation/class-declaration-fields-methods.template +/*--- +description: Computed property name from logical and (ComputedPropertyName in ClassExpression) +esid: prod-ComputedPropertyName +features: [computed-property-names, class-fields-public, class-static-fields-public] +flags: [generated] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ +let x = 0; + + +let C = class { + [x && 1] = () => { + return 2; + }; + + static [x && 1] = () => { + return 2; + }; +}; + +let c = new C(); + +assert.sameValue( + c[x && 1](), + 2 +); +assert.sameValue( + C[x && 1](), + 2 +); +assert.sameValue( + c[String(x && 1)](), + 2 +); +assert.sameValue( + C[String(x && 1)](), + 2 +); + +assert.sameValue(x, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-expression-logical-or.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-expression-logical-or.js new file mode 100644 index 0000000000..0f960760fa --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-expression-logical-or.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-expression-logical-or.case +// - src/computed-property-names/evaluation/class-declaration-fields-methods.template +/*--- +description: Computed property name from logical or (ComputedPropertyName in ClassExpression) +esid: prod-ComputedPropertyName +features: [computed-property-names, class-fields-public, class-static-fields-public] +flags: [generated] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ +let x = 0; + + +let C = class { + [x || 1] = () => { + return 2; + }; + + static [x || 1] = () => { + return 2; + }; +}; + +let c = new C(); + +assert.sameValue( + c[x || 1](), + 2 +); +assert.sameValue( + C[x || 1](), + 2 +); +assert.sameValue( + c[String(x || 1)](), + 2 +); +assert.sameValue( + C[String(x || 1)](), + 2 +); + +assert.sameValue(x, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-function-declaration.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-function-declaration.js new file mode 100644 index 0000000000..27d7dcd92d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-function-declaration.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-function-declaration.case +// - src/computed-property-names/evaluation/class-declaration-fields-methods.template +/*--- +description: Computed property name from function (ComputedPropertyName in ClassExpression) +esid: prod-ComputedPropertyName +features: [computed-property-names, class-fields-public, class-static-fields-public] +flags: [generated] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ +function f() {} + + +let C = class { + [f()] = () => { + return 1; + }; + + static [f()] = () => { + return 1; + }; +}; + +let c = new C(); + +assert.sameValue( + c[f()](), + 1 +); +assert.sameValue( + C[f()](), + 1 +); +assert.sameValue( + c[String(f())](), + 1 +); +assert.sameValue( + C[String(f())](), + 1 +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-function-expression.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-function-expression.js new file mode 100644 index 0000000000..087ffd71fa --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-function-expression.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-function-expression.case +// - src/computed-property-names/evaluation/class-declaration-fields-methods.template +/*--- +description: Computed property name from function expression (ComputedPropertyName in ClassExpression) +esid: prod-ComputedPropertyName +features: [computed-property-names, class-fields-public, class-static-fields-public] +flags: [generated] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ + + +let C = class { + [function () {}] = () => { + return 1; + }; + + static [function () {}] = () => { + return 1; + }; +}; + +let c = new C(); + +assert.sameValue( + c[function () {}](), + 1 +); +assert.sameValue( + C[function () {}](), + 1 +); +assert.sameValue( + c[String(function () {})](), + 1 +); +assert.sameValue( + C[String(function () {})](), + 1 +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-generator-function-declaration.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-generator-function-declaration.js new file mode 100644 index 0000000000..cee833fe26 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-generator-function-declaration.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-generator-function-declaration.case +// - src/computed-property-names/evaluation/class-declaration-fields-methods.template +/*--- +description: Computed property name from generator function (ComputedPropertyName in ClassExpression) +esid: prod-ComputedPropertyName +features: [computed-property-names, class-fields-public, class-static-fields-public] +flags: [generated] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ +function * g() { return 1; } + + +let C = class { + [g()] = () => { + return 1; + }; + + static [g()] = () => { + return 1; + }; +}; + +let c = new C(); + +assert.sameValue( + c[g()](), + 1 +); +assert.sameValue( + C[g()](), + 1 +); +assert.sameValue( + c[String(g())](), + 1 +); +assert.sameValue( + C[String(g())](), + 1 +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-identifier.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-identifier.js new file mode 100644 index 0000000000..5fed37d68f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-identifier.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-identifier.case +// - src/computed-property-names/evaluation/class-declaration-fields-methods.template +/*--- +description: Computed property name from string literal (ComputedPropertyName in ClassExpression) +esid: prod-ComputedPropertyName +features: [computed-property-names, class-fields-public, class-static-fields-public] +flags: [generated] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ +let x = 1; + + + +let C = class { + [x] = () => { + return '2'; + }; + + static [x] = () => { + return '2'; + }; +}; + +let c = new C(); + +assert.sameValue( + c[x](), + '2' +); +assert.sameValue( + C[x](), + '2' +); +assert.sameValue( + c[String(x)](), + '2' +); +assert.sameValue( + C[String(x)](), + '2' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-integer-e-notational-literal.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-integer-e-notational-literal.js new file mode 100644 index 0000000000..40eb283d21 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-integer-e-notational-literal.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-integer-e-notational-literal.case +// - src/computed-property-names/evaluation/class-declaration-fields-methods.template +/*--- +description: Computed property name from numeric literal (ComputedPropertyName in ClassExpression) +esid: prod-ComputedPropertyName +features: [computed-property-names, class-fields-public, class-static-fields-public] +flags: [generated] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ + + +let C = class { + [1] = () => { + return 2; + }; + + static [1] = () => { + return 2; + }; +}; + +let c = new C(); + +assert.sameValue( + c[1](), + 2 +); +assert.sameValue( + C[1](), + 2 +); +assert.sameValue( + c[String(1)](), + 2 +); +assert.sameValue( + C[String(1)](), + 2 +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-integer-separators.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-integer-separators.js new file mode 100644 index 0000000000..1683c8839f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-integer-separators.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-integer-separators.case +// - src/computed-property-names/evaluation/class-declaration-fields-methods.template +/*--- +description: Computed property name from integer with separators (ComputedPropertyName in ClassExpression) +esid: prod-ComputedPropertyName +features: [computed-property-names, class-fields-public, class-static-fields-public] +flags: [generated] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ + + +let C = class { + [1_2_3_4_5_6_7_8] = () => { + return 1_2_3_4_5_6_7_8; + }; + + static [1_2_3_4_5_6_7_8] = () => { + return 1_2_3_4_5_6_7_8; + }; +}; + +let c = new C(); + +assert.sameValue( + c[1_2_3_4_5_6_7_8](), + 1_2_3_4_5_6_7_8 +); +assert.sameValue( + C[1_2_3_4_5_6_7_8](), + 1_2_3_4_5_6_7_8 +); +assert.sameValue( + c[String(1_2_3_4_5_6_7_8)](), + 1_2_3_4_5_6_7_8 +); +assert.sameValue( + C[String(1_2_3_4_5_6_7_8)](), + 1_2_3_4_5_6_7_8 +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-math.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-math.js new file mode 100644 index 0000000000..a2c3cd15f2 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-math.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-math.case +// - src/computed-property-names/evaluation/class-declaration-fields-methods.template +/*--- +description: Computed property name from math (ComputedPropertyName in ClassExpression) +esid: prod-ComputedPropertyName +features: [computed-property-names, exponentiation, class-fields-public, class-static-fields-public] +flags: [generated] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ + + +let C = class { + [1 + 2 - 3 * 4 / 5 ** 6] = () => { + return 2.999232; + }; + + static [1 + 2 - 3 * 4 / 5 ** 6] = () => { + return 2.999232; + }; +}; + +let c = new C(); + +assert.sameValue( + c[1 + 2 - 3 * 4 / 5 ** 6](), + 2.999232 +); +assert.sameValue( + C[1 + 2 - 3 * 4 / 5 ** 6](), + 2.999232 +); +assert.sameValue( + c[String(1 + 2 - 3 * 4 / 5 ** 6)](), + 2.999232 +); +assert.sameValue( + C[String(1 + 2 - 3 * 4 / 5 ** 6)](), + 2.999232 +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-multiplicative-expression-div.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-multiplicative-expression-div.js new file mode 100644 index 0000000000..60660f747c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-multiplicative-expression-div.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-multiplicative-expression-div.case +// - src/computed-property-names/evaluation/class-declaration-fields-methods.template +/*--- +description: Computed property name from multiplicative expression "divide" (ComputedPropertyName in ClassExpression) +esid: prod-ComputedPropertyName +features: [computed-property-names, class-fields-public, class-static-fields-public] +flags: [generated] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ + + +let C = class { + [1 / 1] = () => { + return 1; + }; + + static [1 / 1] = () => { + return 1; + }; +}; + +let c = new C(); + +assert.sameValue( + c[1 / 1](), + 1 +); +assert.sameValue( + C[1 / 1](), + 1 +); +assert.sameValue( + c[String(1 / 1)](), + 1 +); +assert.sameValue( + C[String(1 / 1)](), + 1 +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-multiplicative-expression-mult.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-multiplicative-expression-mult.js new file mode 100644 index 0000000000..40a2ae3d4e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-multiplicative-expression-mult.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-multiplicative-expression-mult.case +// - src/computed-property-names/evaluation/class-declaration-fields-methods.template +/*--- +description: Computed property name from multiplicative expression "multiply" (ComputedPropertyName in ClassExpression) +esid: prod-ComputedPropertyName +features: [computed-property-names, class-fields-public, class-static-fields-public] +flags: [generated] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ + + +let C = class { + [1 * 1] = () => { + return 1; + }; + + static [1 * 1] = () => { + return 1; + }; +}; + +let c = new C(); + +assert.sameValue( + c[1 * 1](), + 1 +); +assert.sameValue( + C[1 * 1](), + 1 +); +assert.sameValue( + c[String(1 * 1)](), + 1 +); +assert.sameValue( + C[String(1 * 1)](), + 1 +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-null.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-null.js new file mode 100644 index 0000000000..10fd20ff21 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-null.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-null.case +// - src/computed-property-names/evaluation/class-declaration-fields-methods.template +/*--- +description: Computed property name from condition expression (ComputedPropertyName in ClassExpression) +esid: prod-ComputedPropertyName +features: [computed-property-names, class-fields-public, class-static-fields-public] +flags: [generated] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ + + +let C = class { + [null] = () => { + return null; + }; + + static [null] = () => { + return null; + }; +}; + +let c = new C(); + +assert.sameValue( + c[null](), + null +); +assert.sameValue( + C[null](), + null +); +assert.sameValue( + c[String(null)](), + null +); +assert.sameValue( + C[String(null)](), + null +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-numeric-literal.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-numeric-literal.js new file mode 100644 index 0000000000..64cb221ce7 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-numeric-literal.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-numeric-literal.case +// - src/computed-property-names/evaluation/class-declaration-fields-methods.template +/*--- +description: Computed property name from numeric literal (ComputedPropertyName in ClassExpression) +esid: prod-ComputedPropertyName +features: [computed-property-names, class-fields-public, class-static-fields-public] +flags: [generated] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ + + +let C = class { + [1] = () => { + return 2; + }; + + static [1] = () => { + return 2; + }; +}; + +let c = new C(); + +assert.sameValue( + c[1](), + 2 +); +assert.sameValue( + C[1](), + 2 +); +assert.sameValue( + c[String(1)](), + 2 +); +assert.sameValue( + C[String(1)](), + 2 +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-string-literal.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-string-literal.js new file mode 100644 index 0000000000..a12c751807 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-string-literal.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-string-literal.case +// - src/computed-property-names/evaluation/class-declaration-fields-methods.template +/*--- +description: Computed property name from string literal (ComputedPropertyName in ClassExpression) +esid: prod-ComputedPropertyName +features: [computed-property-names, class-fields-public, class-static-fields-public] +flags: [generated] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ + + +let C = class { + ['1'] = () => { + return '2'; + }; + + static ['1'] = () => { + return '2'; + }; +}; + +let c = new C(); + +assert.sameValue( + c['1'](), + '2' +); +assert.sameValue( + C['1'](), + '2' +); +assert.sameValue( + c[String('1')](), + '2' +); +assert.sameValue( + C[String('1')](), + '2' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-yield-expression.js b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-yield-expression.js new file mode 100644 index 0000000000..24ab16a2c6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-yield-expression.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/computed-property-names/computed-property-name-from-yield-expression.case +// - src/computed-property-names/evaluation/class-declaration-fields-methods.template +/*--- +description: Computed property name from yield expression (ComputedPropertyName in ClassExpression) +esid: prod-ComputedPropertyName +features: [computed-property-names, class-fields-public, class-static-fields-public] +flags: [generated] +info: | + ClassExpression: + classBindingIdentifier opt ClassTail + + ClassTail: + ClassHeritage opt { ClassBody opt } + + ClassBody: + ClassElementList + + ClassElementList: + ClassElement + + ClassElement: + MethodDefinition + + MethodDefinition: + PropertyName ... + get PropertyName ... + set PropertyName ... + + PropertyName: + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] +---*/ +function * g() { + + +let C = class { + [yield 9] = () => { + return 9; + }; + + static [yield 9] = () => { + return 9; + }; +}; + +let c = new C(); + +assert.sameValue( + c[yield 9](), + 9 +); +assert.sameValue( + C[yield 9](), + 9 +); +assert.sameValue( + c[String(yield 9)](), + 9 +); +assert.sameValue( + C[String(yield 9)](), + 9 +); + +} +var iter = g(); +while (iter.next().done === false) ; + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/cptn-decl.js b/js/src/tests/test262/language/statements/class/cptn-decl.js new file mode 100644 index 0000000000..f3beb693c1 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/cptn-decl.js @@ -0,0 +1,16 @@ +// Copyright (C) 2017 Apple Inc. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-class-definitions-runtime-semantics-evaluation +description: Class declaration completion value is empty. +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Perform ? BindingClassDeclarationEvaluation of this ClassDeclaration. + 2. Return NormalCompletion(empty). +---*/ + +assert.sameValue(eval('class C {}'), undefined); +assert.sameValue(eval('1; class C {}'), 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/decorator/browser.js b/js/src/tests/test262/language/statements/class/decorator/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/decorator/shell.js b/js/src/tests/test262/language/statements/class/decorator/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/decorator/syntax/browser.js b/js/src/tests/test262/language/statements/class/decorator/syntax/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/decorator/syntax/class-valid/browser.js b/js/src/tests/test262/language/statements/class/decorator/syntax/class-valid/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/decorator/syntax/class-valid/decorator-member-expr-private-identifier.js b/js/src/tests/test262/language/statements/class/decorator/syntax/class-valid/decorator-member-expr-private-identifier.js new file mode 100644 index 0000000000..11587354a2 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/decorator/syntax/class-valid/decorator-member-expr-private-identifier.js @@ -0,0 +1,57 @@ +// |reftest| skip -- decorators is not supported +// This file was procedurally generated from the following sources: +// - src/decorator/decorator-member-expr-private-identifier.case +// - src/decorator/syntax/class-valid/cls-decl-decorators-valid-syntax.template +/*--- +description: Decorator @ DecoratorMemberExpression (Valid syntax for decorator on class declaration in class body.) +esid: prod-ClassDeclaration +features: [class, decorators] +flags: [generated] +info: | + ClassDeclaration[Yield, Await, Default] : + DecoratorList[?Yield, ?Await]opt class BindingIdentifier[?Yield, ?Await] ClassTail[?Yield, ?Await] + [+Default] DecoratorList[?Yield, ?Await]opt class ClassTail[?Yield, ?Await] + + DecoratorList[Yield, Await] : + DecoratorList[?Yield, ?Await]opt Decorator[?Yield, ?Await] + + Decorator[Yield, Await] : + @ DecoratorMemberExpression[?Yield, ?Await] + @ DecoratorParenthesizedExpression[?Yield, ?Await] + @ DecoratorCallExpression[?Yield, ?Await] + + ... + + + DecoratorMemberExpression[Yield, Await] : + PrivateIdentifier + + PrivateIdentifier :: + # IdentifierName + +---*/ + + +class C { + static #$() {} + static #_() {} + static #\u{6F}() {} + static #\u2118() {} + static #ZW_\u200C_NJ() {} + static #ZW_\u200D_J() {} + static #yield() {} + static #await() {} + + static { + @#$ + @#_ + @#\u{6F} + @#\u2118 + @#ZW_\u200C_NJ + @#ZW_\u200D_J + @#yield + @#await class C {} + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/decorator/syntax/class-valid/shell.js b/js/src/tests/test262/language/statements/class/decorator/syntax/class-valid/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/decorator/syntax/shell.js b/js/src/tests/test262/language/statements/class/decorator/syntax/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/decorator/syntax/valid/browser.js b/js/src/tests/test262/language/statements/class/decorator/syntax/valid/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/decorator/syntax/valid/class-element-decorator-call-expr-identifier-reference.js b/js/src/tests/test262/language/statements/class/decorator/syntax/valid/class-element-decorator-call-expr-identifier-reference.js new file mode 100644 index 0000000000..b50802ba42 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/decorator/syntax/valid/class-element-decorator-call-expr-identifier-reference.js @@ -0,0 +1,88 @@ +// |reftest| skip -- decorators is not supported +// This file was procedurally generated from the following sources: +// - src/decorator/decorator-call-expr-identifier-reference.case +// - src/decorator/syntax/valid/cls-element-decorators-valid-syntax.template +/*--- +description: Decorator @ DecoratorCallExpression (Valid syntax for decorator on class.) +esid: prod-ClassDeclaration +features: [class, decorators] +flags: [generated] +info: | + ClassElement[Yield, Await] : + DecoratorList[?Yield, ?Await]opt MethodDefinition[?Yield, ?Await] + DecoratorList[?Yield, ?Await]opt static MethodDefinition[?Yield, ?Await] + DecoratorList[?Yield, ?Await]opt FieldDefinition[?Yield, ?Await] ; + DecoratorList[?Yield, ?Await]opt static FieldDefinition[?Yield, ?Await] ; + ClassStaticBlock + ; + + DecoratorList[Yield, Await] : + DecoratorList[?Yield, ?Await]opt Decorator[?Yield, ?Await] + + Decorator[Yield, Await] : + @ DecoratorMemberExpression[?Yield, ?Await] + @ DecoratorParenthesizedExpression[?Yield, ?Await] + @ DecoratorCallExpression[?Yield, ?Await] + + ... + + + DecoratorCallExpression[Yield, Await] : + DecoratorMemberExpression[?Yield, ?Await] Arguments[?Yield, ?Await] + + DecoratorMemberExpression[Yield, Await] : + IdentifierReference[?Yield, ?Await] + PrivateIdentifier + DecoratorMemberExpression[?Yield, ?Await] . IdentifierName + + IdentifierReference[Yield, Await] : + Identifier + [~Yield] yield + [~Await] await + +---*/ +function decorator() { + return () => {}; +} +var $ = decorator; +var _ = decorator; +var \u{6F} = decorator; +var \u2118 = decorator; +var ZW_\u200C_NJ = decorator; +var ZW_\u200D_J = decorator; +var await = decorator; + + + +class C { + @$() + @_() + @\u{6F}() + @\u2118() + @ZW_\u200C_NJ() + @ZW_\u200D_J() + @await() method() {} + @$() + @_() + @\u{6F}() + @\u2118() + @ZW_\u200C_NJ() + @ZW_\u200D_J() + @await() static method() {} + @$() + @_() + @\u{6F}() + @\u2118() + @ZW_\u200C_NJ() + @ZW_\u200D_J() + @await() field; + @$() + @_() + @\u{6F}() + @\u2118() + @ZW_\u200C_NJ() + @ZW_\u200D_J() + @await() static field; +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/decorator/syntax/valid/class-element-decorator-member-expr-decorator-member-expr.js b/js/src/tests/test262/language/statements/class/decorator/syntax/valid/class-element-decorator-member-expr-decorator-member-expr.js new file mode 100644 index 0000000000..38db55bc84 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/decorator/syntax/valid/class-element-decorator-member-expr-decorator-member-expr.js @@ -0,0 +1,84 @@ +// |reftest| skip -- decorators is not supported +// This file was procedurally generated from the following sources: +// - src/decorator/decorator-member-expr-decorator-member-expr.case +// - src/decorator/syntax/valid/cls-element-decorators-valid-syntax.template +/*--- +description: Decorator @ DecoratorMemberExpression (Valid syntax for decorator on class.) +esid: prod-ClassDeclaration +features: [class, decorators] +flags: [generated] +info: | + ClassElement[Yield, Await] : + DecoratorList[?Yield, ?Await]opt MethodDefinition[?Yield, ?Await] + DecoratorList[?Yield, ?Await]opt static MethodDefinition[?Yield, ?Await] + DecoratorList[?Yield, ?Await]opt FieldDefinition[?Yield, ?Await] ; + DecoratorList[?Yield, ?Await]opt static FieldDefinition[?Yield, ?Await] ; + ClassStaticBlock + ; + + DecoratorList[Yield, Await] : + DecoratorList[?Yield, ?Await]opt Decorator[?Yield, ?Await] + + Decorator[Yield, Await] : + @ DecoratorMemberExpression[?Yield, ?Await] + @ DecoratorParenthesizedExpression[?Yield, ?Await] + @ DecoratorCallExpression[?Yield, ?Await] + + ... + + + DecoratorMemberExpression[Yield, Await] : + IdentifierReference[?Yield, ?Await] + PrivateIdentifier + DecoratorMemberExpression[?Yield, ?Await] . IdentifierName + +---*/ +let ns = { + $() {}, + _() {}, + \u{6F}() {}, + \u2118() {}, + ZW_\u200C_NJ() {}, + ZW_\u200D_J() {}, + yield() {}, + await() {}, +} + + + +class C { + @ns.$ + @ns._ + @ns.\u{6F} + @ns.\u2118 + @ns.ZW_\u200C_NJ + @ns.ZW_\u200D_J + @ns.yield + @ns.await method() {} + @ns.$ + @ns._ + @ns.\u{6F} + @ns.\u2118 + @ns.ZW_\u200C_NJ + @ns.ZW_\u200D_J + @ns.yield + @ns.await static method() {} + @ns.$ + @ns._ + @ns.\u{6F} + @ns.\u2118 + @ns.ZW_\u200C_NJ + @ns.ZW_\u200D_J + @ns.yield + @ns.await field; + @ns.$ + @ns._ + @ns.\u{6F} + @ns.\u2118 + @ns.ZW_\u200C_NJ + @ns.ZW_\u200D_J + @ns.yield + @ns.await static field; +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/decorator/syntax/valid/class-element-decorator-member-expr-identifier-reference.js b/js/src/tests/test262/language/statements/class/decorator/syntax/valid/class-element-decorator-member-expr-identifier-reference.js new file mode 100644 index 0000000000..468d3e2b2c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/decorator/syntax/valid/class-element-decorator-member-expr-identifier-reference.js @@ -0,0 +1,77 @@ +// |reftest| skip -- decorators is not supported +// This file was procedurally generated from the following sources: +// - src/decorator/decorator-member-expr-identifier-reference.case +// - src/decorator/syntax/valid/cls-element-decorators-valid-syntax.template +/*--- +description: Decorator @ DecoratorMemberExpression (Valid syntax for decorator on class.) +esid: prod-ClassDeclaration +features: [class, decorators] +flags: [generated] +info: | + ClassElement[Yield, Await] : + DecoratorList[?Yield, ?Await]opt MethodDefinition[?Yield, ?Await] + DecoratorList[?Yield, ?Await]opt static MethodDefinition[?Yield, ?Await] + DecoratorList[?Yield, ?Await]opt FieldDefinition[?Yield, ?Await] ; + DecoratorList[?Yield, ?Await]opt static FieldDefinition[?Yield, ?Await] ; + ClassStaticBlock + ; + + DecoratorList[Yield, Await] : + DecoratorList[?Yield, ?Await]opt Decorator[?Yield, ?Await] + + Decorator[Yield, Await] : + @ DecoratorMemberExpression[?Yield, ?Await] + @ DecoratorParenthesizedExpression[?Yield, ?Await] + @ DecoratorCallExpression[?Yield, ?Await] + + ... + + + IdentifierReference[Yield, Await] : + Identifier + [~Yield] yield + [~Await] await + +---*/ +function $() {} +function _() {} +function \u{6F}() {} +function \u2118() {} +function ZW_\u200C_NJ() {} +function ZW_\u200D_J() {} +function await() {} + + + +class C { + @$ + @_ + @\u{6F} + @\u2118 + @ZW_\u200C_NJ + @ZW_\u200D_J + @await method() {} + @$ + @_ + @\u{6F} + @\u2118 + @ZW_\u200C_NJ + @ZW_\u200D_J + @await static method() {} + @$ + @_ + @\u{6F} + @\u2118 + @ZW_\u200C_NJ + @ZW_\u200D_J + @await field; + @$ + @_ + @\u{6F} + @\u2118 + @ZW_\u200C_NJ + @ZW_\u200D_J + @await static field; +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/decorator/syntax/valid/class-element-decorator-parenthesized-expr-identifier-reference.js b/js/src/tests/test262/language/statements/class/decorator/syntax/valid/class-element-decorator-parenthesized-expr-identifier-reference.js new file mode 100644 index 0000000000..8acb98f1c4 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/decorator/syntax/valid/class-element-decorator-parenthesized-expr-identifier-reference.js @@ -0,0 +1,90 @@ +// |reftest| skip -- decorators is not supported +// This file was procedurally generated from the following sources: +// - src/decorator/decorator-parenthesized-expr-identifier-reference.case +// - src/decorator/syntax/valid/cls-element-decorators-valid-syntax.template +/*--- +description: Decorator @ DecoratorParenthesizedExpression (Valid syntax for decorator on class.) +esid: prod-ClassDeclaration +features: [class, decorators] +flags: [generated] +info: | + ClassElement[Yield, Await] : + DecoratorList[?Yield, ?Await]opt MethodDefinition[?Yield, ?Await] + DecoratorList[?Yield, ?Await]opt static MethodDefinition[?Yield, ?Await] + DecoratorList[?Yield, ?Await]opt FieldDefinition[?Yield, ?Await] ; + DecoratorList[?Yield, ?Await]opt static FieldDefinition[?Yield, ?Await] ; + ClassStaticBlock + ; + + DecoratorList[Yield, Await] : + DecoratorList[?Yield, ?Await]opt Decorator[?Yield, ?Await] + + Decorator[Yield, Await] : + @ DecoratorMemberExpression[?Yield, ?Await] + @ DecoratorParenthesizedExpression[?Yield, ?Await] + @ DecoratorCallExpression[?Yield, ?Await] + + ... + + + DecoratorParenthesizedExpression[Yield, Await] : + ( Expression[+In, ?Yield, ?Await] ) + + PrimaryExpression[Yield, Await] : + this + IdentifierReference[?Yield, ?Await] + Literal + ArrayLiteral[?Yield, ?Await] + ObjectLiteral[?Yield, ?Await] + FunctionExpression + ClassExpression[?Yield, ?Await] + GeneratorExpression + AsyncFunctionExpression + AsyncGeneratorExpression + RegularExpressionLiteral + TemplateLiteral[?Yield, ?Await, ~Tagged] + CoverParenthesizedExpressionAndArrowParameterList[?Yield, ?Await] + +---*/ +function $() {} +function _() {} +function \u{6F}() {} +function \u2118() {} +function ZW_\u200C_NJ() {} +function ZW_\u200D_J() {} +function await() {} + + + +class C { + @($) + @(_) + @(\u{6F}) + @(\u2118) + @(ZW_\u200C_NJ) + @(ZW_\u200D_J) + @(await) method() {} + @($) + @(_) + @(\u{6F}) + @(\u2118) + @(ZW_\u200C_NJ) + @(ZW_\u200D_J) + @(await) static method() {} + @($) + @(_) + @(\u{6F}) + @(\u2118) + @(ZW_\u200C_NJ) + @(ZW_\u200D_J) + @(await) field; + @($) + @(_) + @(\u{6F}) + @(\u2118) + @(ZW_\u200C_NJ) + @(ZW_\u200D_J) + @(await) static field; +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/decorator/syntax/valid/decorator-call-expr-identifier-reference-yield.js b/js/src/tests/test262/language/statements/class/decorator/syntax/valid/decorator-call-expr-identifier-reference-yield.js new file mode 100644 index 0000000000..f86f894f1d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/decorator/syntax/valid/decorator-call-expr-identifier-reference-yield.js @@ -0,0 +1,48 @@ +// |reftest| skip -- decorators is not supported +// This file was procedurally generated from the following sources: +// - src/decorator/decorator-call-expr-identifier-reference-yield.case +// - src/decorator/syntax/valid/cls-decl-decorators-valid-syntax.template +/*--- +description: Decorator @ DecoratorCallExpression (Valid syntax for decorator on class.) +esid: prod-ClassDeclaration +features: [class, decorators] +flags: [generated, noStrict] +info: | + ClassDeclaration[Yield, Await, Default] : + DecoratorList[?Yield, ?Await]opt class BindingIdentifier[?Yield, ?Await] ClassTail[?Yield, ?Await] + [+Default] DecoratorList[?Yield, ?Await]opt class ClassTail[?Yield, ?Await] + + DecoratorList[Yield, Await] : + DecoratorList[?Yield, ?Await]opt Decorator[?Yield, ?Await] + + Decorator[Yield, Await] : + @ DecoratorMemberExpression[?Yield, ?Await] + @ DecoratorParenthesizedExpression[?Yield, ?Await] + @ DecoratorCallExpression[?Yield, ?Await] + + ... + + + DecoratorCallExpression[Yield, Await] : + DecoratorMemberExpression[?Yield, ?Await] Arguments[?Yield, ?Await] + + DecoratorMemberExpression[Yield, Await] : + IdentifierReference[?Yield, ?Await] + PrivateIdentifier + DecoratorMemberExpression[?Yield, ?Await] . IdentifierName + + IdentifierReference[Yield, Await] : + [~Yield] yield + ... + +---*/ +function decorator() { + return () => {}; +} +var yield = decorator; + + + +@yield() class C {} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/decorator/syntax/valid/decorator-call-expr-identifier-reference.js b/js/src/tests/test262/language/statements/class/decorator/syntax/valid/decorator-call-expr-identifier-reference.js new file mode 100644 index 0000000000..217747833b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/decorator/syntax/valid/decorator-call-expr-identifier-reference.js @@ -0,0 +1,61 @@ +// |reftest| skip -- decorators is not supported +// This file was procedurally generated from the following sources: +// - src/decorator/decorator-call-expr-identifier-reference.case +// - src/decorator/syntax/valid/cls-decl-decorators-valid-syntax.template +/*--- +description: Decorator @ DecoratorCallExpression (Valid syntax for decorator on class.) +esid: prod-ClassDeclaration +features: [class, decorators] +flags: [generated] +info: | + ClassDeclaration[Yield, Await, Default] : + DecoratorList[?Yield, ?Await]opt class BindingIdentifier[?Yield, ?Await] ClassTail[?Yield, ?Await] + [+Default] DecoratorList[?Yield, ?Await]opt class ClassTail[?Yield, ?Await] + + DecoratorList[Yield, Await] : + DecoratorList[?Yield, ?Await]opt Decorator[?Yield, ?Await] + + Decorator[Yield, Await] : + @ DecoratorMemberExpression[?Yield, ?Await] + @ DecoratorParenthesizedExpression[?Yield, ?Await] + @ DecoratorCallExpression[?Yield, ?Await] + + ... + + + DecoratorCallExpression[Yield, Await] : + DecoratorMemberExpression[?Yield, ?Await] Arguments[?Yield, ?Await] + + DecoratorMemberExpression[Yield, Await] : + IdentifierReference[?Yield, ?Await] + PrivateIdentifier + DecoratorMemberExpression[?Yield, ?Await] . IdentifierName + + IdentifierReference[Yield, Await] : + Identifier + [~Yield] yield + [~Await] await + +---*/ +function decorator() { + return () => {}; +} +var $ = decorator; +var _ = decorator; +var \u{6F} = decorator; +var \u2118 = decorator; +var ZW_\u200C_NJ = decorator; +var ZW_\u200D_J = decorator; +var await = decorator; + + + +@$() +@_() +@\u{6F}() +@\u2118() +@ZW_\u200C_NJ() +@ZW_\u200D_J() +@await() class C {} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/decorator/syntax/valid/decorator-member-expr-decorator-member-expr.js b/js/src/tests/test262/language/statements/class/decorator/syntax/valid/decorator-member-expr-decorator-member-expr.js new file mode 100644 index 0000000000..ce38509819 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/decorator/syntax/valid/decorator-member-expr-decorator-member-expr.js @@ -0,0 +1,54 @@ +// |reftest| skip -- decorators is not supported +// This file was procedurally generated from the following sources: +// - src/decorator/decorator-member-expr-decorator-member-expr.case +// - src/decorator/syntax/valid/cls-decl-decorators-valid-syntax.template +/*--- +description: Decorator @ DecoratorMemberExpression (Valid syntax for decorator on class.) +esid: prod-ClassDeclaration +features: [class, decorators] +flags: [generated] +info: | + ClassDeclaration[Yield, Await, Default] : + DecoratorList[?Yield, ?Await]opt class BindingIdentifier[?Yield, ?Await] ClassTail[?Yield, ?Await] + [+Default] DecoratorList[?Yield, ?Await]opt class ClassTail[?Yield, ?Await] + + DecoratorList[Yield, Await] : + DecoratorList[?Yield, ?Await]opt Decorator[?Yield, ?Await] + + Decorator[Yield, Await] : + @ DecoratorMemberExpression[?Yield, ?Await] + @ DecoratorParenthesizedExpression[?Yield, ?Await] + @ DecoratorCallExpression[?Yield, ?Await] + + ... + + + DecoratorMemberExpression[Yield, Await] : + IdentifierReference[?Yield, ?Await] + PrivateIdentifier + DecoratorMemberExpression[?Yield, ?Await] . IdentifierName + +---*/ +let ns = { + $() {}, + _() {}, + \u{6F}() {}, + \u2118() {}, + ZW_\u200C_NJ() {}, + ZW_\u200D_J() {}, + yield() {}, + await() {}, +} + + + +@ns.$ +@ns._ +@ns.\u{6F} +@ns.\u2118 +@ns.ZW_\u200C_NJ +@ns.ZW_\u200D_J +@ns.yield +@ns.await class C {} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/decorator/syntax/valid/decorator-member-expr-identifier-reference-yield.js b/js/src/tests/test262/language/statements/class/decorator/syntax/valid/decorator-member-expr-identifier-reference-yield.js new file mode 100644 index 0000000000..216d97d4ab --- /dev/null +++ b/js/src/tests/test262/language/statements/class/decorator/syntax/valid/decorator-member-expr-identifier-reference-yield.js @@ -0,0 +1,37 @@ +// |reftest| skip -- decorators is not supported +// This file was procedurally generated from the following sources: +// - src/decorator/decorator-member-expr-identifier-reference-yield.case +// - src/decorator/syntax/valid/cls-decl-decorators-valid-syntax.template +/*--- +description: Decorator @ DecoratorMemberExpression (Valid syntax for decorator on class.) +esid: prod-ClassDeclaration +features: [class, decorators] +flags: [generated, noStrict] +info: | + ClassDeclaration[Yield, Await, Default] : + DecoratorList[?Yield, ?Await]opt class BindingIdentifier[?Yield, ?Await] ClassTail[?Yield, ?Await] + [+Default] DecoratorList[?Yield, ?Await]opt class ClassTail[?Yield, ?Await] + + DecoratorList[Yield, Await] : + DecoratorList[?Yield, ?Await]opt Decorator[?Yield, ?Await] + + Decorator[Yield, Await] : + @ DecoratorMemberExpression[?Yield, ?Await] + @ DecoratorParenthesizedExpression[?Yield, ?Await] + @ DecoratorCallExpression[?Yield, ?Await] + + ... + + + IdentifierReference[Yield, Await] : + [~Yield] yield + ... + +---*/ +function yield() {} + + + +@yield class C {} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/decorator/syntax/valid/decorator-member-expr-identifier-reference.js b/js/src/tests/test262/language/statements/class/decorator/syntax/valid/decorator-member-expr-identifier-reference.js new file mode 100644 index 0000000000..e77cec62dc --- /dev/null +++ b/js/src/tests/test262/language/statements/class/decorator/syntax/valid/decorator-member-expr-identifier-reference.js @@ -0,0 +1,50 @@ +// |reftest| skip -- decorators is not supported +// This file was procedurally generated from the following sources: +// - src/decorator/decorator-member-expr-identifier-reference.case +// - src/decorator/syntax/valid/cls-decl-decorators-valid-syntax.template +/*--- +description: Decorator @ DecoratorMemberExpression (Valid syntax for decorator on class.) +esid: prod-ClassDeclaration +features: [class, decorators] +flags: [generated] +info: | + ClassDeclaration[Yield, Await, Default] : + DecoratorList[?Yield, ?Await]opt class BindingIdentifier[?Yield, ?Await] ClassTail[?Yield, ?Await] + [+Default] DecoratorList[?Yield, ?Await]opt class ClassTail[?Yield, ?Await] + + DecoratorList[Yield, Await] : + DecoratorList[?Yield, ?Await]opt Decorator[?Yield, ?Await] + + Decorator[Yield, Await] : + @ DecoratorMemberExpression[?Yield, ?Await] + @ DecoratorParenthesizedExpression[?Yield, ?Await] + @ DecoratorCallExpression[?Yield, ?Await] + + ... + + + IdentifierReference[Yield, Await] : + Identifier + [~Yield] yield + [~Await] await + +---*/ +function $() {} +function _() {} +function \u{6F}() {} +function \u2118() {} +function ZW_\u200C_NJ() {} +function ZW_\u200D_J() {} +function await() {} + + + +@$ +@_ +@\u{6F} +@\u2118 +@ZW_\u200C_NJ +@ZW_\u200D_J +@await class C {} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/decorator/syntax/valid/decorator-parenthesized-expr-identifier-reference-yield.js b/js/src/tests/test262/language/statements/class/decorator/syntax/valid/decorator-parenthesized-expr-identifier-reference-yield.js new file mode 100644 index 0000000000..a8bdc2488a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/decorator/syntax/valid/decorator-parenthesized-expr-identifier-reference-yield.js @@ -0,0 +1,55 @@ +// |reftest| skip -- decorators is not supported +// This file was procedurally generated from the following sources: +// - src/decorator/decorator-parenthesized-expr-identifier-reference-yield.case +// - src/decorator/syntax/valid/cls-decl-decorators-valid-syntax.template +/*--- +description: Decorator @ DecoratorParenthesizedExpression (Valid syntax for decorator on class.) +esid: prod-ClassDeclaration +features: [class, decorators] +flags: [generated, noStrict] +info: | + ClassDeclaration[Yield, Await, Default] : + DecoratorList[?Yield, ?Await]opt class BindingIdentifier[?Yield, ?Await] ClassTail[?Yield, ?Await] + [+Default] DecoratorList[?Yield, ?Await]opt class ClassTail[?Yield, ?Await] + + DecoratorList[Yield, Await] : + DecoratorList[?Yield, ?Await]opt Decorator[?Yield, ?Await] + + Decorator[Yield, Await] : + @ DecoratorMemberExpression[?Yield, ?Await] + @ DecoratorParenthesizedExpression[?Yield, ?Await] + @ DecoratorCallExpression[?Yield, ?Await] + + ... + + + DecoratorParenthesizedExpression[Yield, Await] : + ( Expression[+In, ?Yield, ?Await] ) + + PrimaryExpression[Yield, Await] : + this + IdentifierReference[?Yield, ?Await] + Literal + ArrayLiteral[?Yield, ?Await] + ObjectLiteral[?Yield, ?Await] + FunctionExpression + ClassExpression[?Yield, ?Await] + GeneratorExpression + AsyncFunctionExpression + AsyncGeneratorExpression + RegularExpressionLiteral + TemplateLiteral[?Yield, ?Await, ~Tagged] + CoverParenthesizedExpressionAndArrowParameterList[?Yield, ?Await] + + IdentifierReference[Yield, Await] : + [~Yield] yield + ... + +---*/ +function yield() {} + + + +@(yield) class C {} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/decorator/syntax/valid/decorator-parenthesized-expr-identifier-reference.js b/js/src/tests/test262/language/statements/class/decorator/syntax/valid/decorator-parenthesized-expr-identifier-reference.js new file mode 100644 index 0000000000..709f352eea --- /dev/null +++ b/js/src/tests/test262/language/statements/class/decorator/syntax/valid/decorator-parenthesized-expr-identifier-reference.js @@ -0,0 +1,63 @@ +// |reftest| skip -- decorators is not supported +// This file was procedurally generated from the following sources: +// - src/decorator/decorator-parenthesized-expr-identifier-reference.case +// - src/decorator/syntax/valid/cls-decl-decorators-valid-syntax.template +/*--- +description: Decorator @ DecoratorParenthesizedExpression (Valid syntax for decorator on class.) +esid: prod-ClassDeclaration +features: [class, decorators] +flags: [generated] +info: | + ClassDeclaration[Yield, Await, Default] : + DecoratorList[?Yield, ?Await]opt class BindingIdentifier[?Yield, ?Await] ClassTail[?Yield, ?Await] + [+Default] DecoratorList[?Yield, ?Await]opt class ClassTail[?Yield, ?Await] + + DecoratorList[Yield, Await] : + DecoratorList[?Yield, ?Await]opt Decorator[?Yield, ?Await] + + Decorator[Yield, Await] : + @ DecoratorMemberExpression[?Yield, ?Await] + @ DecoratorParenthesizedExpression[?Yield, ?Await] + @ DecoratorCallExpression[?Yield, ?Await] + + ... + + + DecoratorParenthesizedExpression[Yield, Await] : + ( Expression[+In, ?Yield, ?Await] ) + + PrimaryExpression[Yield, Await] : + this + IdentifierReference[?Yield, ?Await] + Literal + ArrayLiteral[?Yield, ?Await] + ObjectLiteral[?Yield, ?Await] + FunctionExpression + ClassExpression[?Yield, ?Await] + GeneratorExpression + AsyncFunctionExpression + AsyncGeneratorExpression + RegularExpressionLiteral + TemplateLiteral[?Yield, ?Await, ~Tagged] + CoverParenthesizedExpressionAndArrowParameterList[?Yield, ?Await] + +---*/ +function $() {} +function _() {} +function \u{6F}() {} +function \u2118() {} +function ZW_\u200C_NJ() {} +function ZW_\u200D_J() {} +function await() {} + + + +@($) +@(_) +@(\u{6F}) +@(\u2118) +@(ZW_\u200C_NJ) +@(ZW_\u200D_J) +@(await) class C {} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/decorator/syntax/valid/shell.js b/js/src/tests/test262/language/statements/class/decorator/syntax/valid/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/definition/accessors.js b/js/src/tests/test262/language/statements/class/definition/accessors.js new file mode 100644 index 0000000000..aea9a74946 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/definition/accessors.js @@ -0,0 +1,54 @@ +// Copyright (C) 2014 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.5 +description: > + class accessors +---*/ + +function assertAccessorDescriptor(object, name) { + var desc = Object.getOwnPropertyDescriptor(object, name); + assert.sameValue(desc.configurable, true, "The value of `desc.configurable` is `true`"); + assert.sameValue(desc.enumerable, false, "The value of `desc.enumerable` is `false`"); + assert.sameValue(typeof desc.get, 'function', "`typeof desc.get` is `'function'`"); + assert.sameValue(typeof desc.set, 'function', "`typeof desc.set` is `'function'`"); + assert.sameValue( + 'prototype' in desc.get, + false, + "The result of `'prototype' in desc.get` is `false`" + ); + assert.sameValue( + 'prototype' in desc.set, + false, + "The result of `'prototype' in desc.set` is `false`" + ); +} + + +class C { + constructor(x) { + this._x = x; + } + + get x() { return this._x; } + set x(v) { this._x = v; } + + static get staticX() { return this._x; } + static set staticX(v) { this._x = v; } +} + +assertAccessorDescriptor(C.prototype, 'x'); +assertAccessorDescriptor(C, 'staticX'); + +var c = new C(1); +c._x = 1; +assert.sameValue(c.x, 1, "The value of `c.x` is `1`, after executing `c._x = 1;`"); +c.x = 2; +assert.sameValue(c._x, 2, "The value of `c._x` is `2`, after executing `c.x = 2;`"); + +C._x = 3; +assert.sameValue(C.staticX, 3, "The value of `C.staticX` is `3`, after executing `C._x = 3;`"); +C._x = 4; +assert.sameValue(C.staticX, 4, "The value of `C.staticX` is `4`, after executing `C._x = 4;`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/definition/basics.js b/js/src/tests/test262/language/statements/class/definition/basics.js new file mode 100644 index 0000000000..bead8794e5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/definition/basics.js @@ -0,0 +1,45 @@ +// Copyright (C) 2014 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.5 +description: > + class basics +---*/ +var C = class C {} +assert.sameValue(typeof C, 'function', "`typeof C` is `'function'`"); +assert.sameValue( + Object.getPrototypeOf(C.prototype), + Object.prototype, + "`Object.getPrototypeOf(C.prototype)` returns `Object.prototype`" +); +assert.sameValue( + Object.getPrototypeOf(C), + Function.prototype, + "`Object.getPrototypeOf(C)` returns `Function.prototype`" +); +assert.sameValue(C.name, 'C', "The value of `C.name` is `'C'`"); + +class D {} +assert.sameValue(typeof D, 'function', "`typeof D` is `'function'`"); +assert.sameValue( + Object.getPrototypeOf(D.prototype), + Object.prototype, + "`Object.getPrototypeOf(D.prototype)` returns `Object.prototype`" +); +assert.sameValue( + Object.getPrototypeOf(D), + Function.prototype, + "`Object.getPrototypeOf(D)` returns `Function.prototype`" +); +assert.sameValue(D.name, 'D', "The value of `D.name` is `'D'`"); + +class D2 { constructor() {} } +assert.sameValue(D2.name, 'D2', "The value of `D2.name` is `'D2'`"); + +var E = class {} +assert.sameValue(E.name, 'E', "The value of `E.name` is `'E'`"); + +var F = class { constructor() {} }; +assert.sameValue(F.name, 'F', "The value of `F.name` is `'F'`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/definition/browser.js b/js/src/tests/test262/language/statements/class/definition/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/definition/class-method-returns-promise.js b/js/src/tests/test262/language/statements/class/definition/class-method-returns-promise.js new file mode 100644 index 0000000000..faa55ae7a0 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/definition/class-method-returns-promise.js @@ -0,0 +1,17 @@ +// Copyright 2016 Microsoft, Inc. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Brian Terlson +esid: pending +features: [async-functions] +description: > + Async function expressions return promises +---*/ +class Foo { + async method() {}; +} +var p = new Foo().method(); +assert(p instanceof Promise, "async functions return promise instances"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/definition/constructable-but-no-prototype.js b/js/src/tests/test262/language/statements/class/definition/constructable-but-no-prototype.js new file mode 100644 index 0000000000..f765200b24 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/definition/constructable-but-no-prototype.js @@ -0,0 +1,13 @@ +// Copyright (C) 2014 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.5 +description: > + class constructable but no prototype +---*/ +var Base = function() {}.bind(); +assert.throws(TypeError, function() { + class C extends Base {} +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/definition/constructor-property.js b/js/src/tests/test262/language/statements/class/definition/constructor-property.js new file mode 100644 index 0000000000..d19269c38e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/definition/constructor-property.js @@ -0,0 +1,19 @@ +// Copyright (C) 2014 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.5 +description: > + class constructor property +---*/ +class C {} +assert.sameValue( + C, + C.prototype.constructor, + "The value of `C` is `C.prototype.constructor`" +); +var desc = Object.getOwnPropertyDescriptor(C.prototype, 'constructor'); +assert.sameValue(desc.configurable, true, "The value of `desc.configurable` is `true`, after executing `var desc = Object.getOwnPropertyDescriptor(C.prototype, 'constructor');`"); +assert.sameValue(desc.enumerable, false, "The value of `desc.enumerable` is `false`, after executing `var desc = Object.getOwnPropertyDescriptor(C.prototype, 'constructor');`"); +assert.sameValue(desc.writable, true, "The value of `desc.writable` is `true`, after executing `var desc = Object.getOwnPropertyDescriptor(C.prototype, 'constructor');`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/definition/constructor-strict-by-default.js b/js/src/tests/test262/language/statements/class/definition/constructor-strict-by-default.js new file mode 100644 index 0000000000..5680bfcc05 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/definition/constructor-strict-by-default.js @@ -0,0 +1,17 @@ +// Copyright (C) 2014 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.5 +description: > + class constructor strict +---*/ +class C { + constructor() { + assert.throws(ReferenceError, function() { + nonExistingBinding = 42; + }); + } +} +new C(); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/definition/constructor.js b/js/src/tests/test262/language/statements/class/definition/constructor.js new file mode 100644 index 0000000000..c084dbdb29 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/definition/constructor.js @@ -0,0 +1,37 @@ +// Copyright (C) 2014 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.5 +description: > + class constructor +---*/ +var count = 0; +class C { + constructor() { + assert.sameValue( + Object.getPrototypeOf(this), + C.prototype, + "`Object.getPrototypeOf(this)` returns `C.prototype`" + ); + count++; + } +} +assert.sameValue( + C, + C.prototype.constructor, + "The value of `C` is `C.prototype.constructor`" +); +var desc = Object.getOwnPropertyDescriptor(C.prototype, 'constructor'); +assert.sameValue(desc.configurable, true, "The value of `desc.configurable` is `true`, after executing `var desc = Object.getOwnPropertyDescriptor(C.prototype, 'constructor');`"); +assert.sameValue(desc.enumerable, false, "The value of `desc.enumerable` is `false`, after executing `var desc = Object.getOwnPropertyDescriptor(C.prototype, 'constructor');`"); +assert.sameValue(desc.writable, true, "The value of `descr.writable` is `true`, after executing `var desc = Object.getOwnPropertyDescriptor(C.prototype, 'constructor');`"); + +var c = new C(); +assert.sameValue(count, 1, "The value of `count` is `1`"); +assert.sameValue( + Object.getPrototypeOf(c), + C.prototype, + "`Object.getPrototypeOf(c)` returns `C.prototype`" +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/definition/early-errors-class-async-method-duplicate-parameters.js b/js/src/tests/test262/language/statements/class/definition/early-errors-class-async-method-duplicate-parameters.js new file mode 100644 index 0000000000..58ec8e3d98 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/definition/early-errors-class-async-method-duplicate-parameters.js @@ -0,0 +1,30 @@ +// |reftest| error:SyntaxError +// Copyright 2016 Microsoft, Inc. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Brian Terlson +esid: sec-async-function-definitions +description: Formal parameters may not contain duplicates +info: | + # 14.7 Arrow Function Definitions + + AsyncMethod[Yield, Await]: + async[no LineTerminator here]PropertyName[?Yield, ?Await](UniqueFormalParameters[~Yield, +Await]){AsyncFunctionBody} + + # 14.1.2 Static Semantics: Early Errors + + UniqueFormalParameters:FormalParameters + + - It is a Syntax Error if BoundNames of FormalParameters contains any + duplicate elements. +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +class Foo { + async foo(a, a) { } +} diff --git a/js/src/tests/test262/language/statements/class/definition/early-errors-class-method-NSPL-with-USD.js b/js/src/tests/test262/language/statements/class/definition/early-errors-class-method-NSPL-with-USD.js new file mode 100644 index 0000000000..49482b14a3 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/definition/early-errors-class-method-NSPL-with-USD.js @@ -0,0 +1,18 @@ +// |reftest| error:SyntaxError +// Copyright 2016 Microsoft, Inc. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Brian Terlson +esid: pending +description: > + It is a Syntax Error if ContainsUseStrict of AsyncConciseBody is *true* and IsSimpleParameterList of ArrowParameters is *false*. +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); +class Foo { + async bar(x = 1) {"use strict"} +} diff --git a/js/src/tests/test262/language/statements/class/definition/early-errors-class-method-arguments-in-formal-parameters.js b/js/src/tests/test262/language/statements/class/definition/early-errors-class-method-arguments-in-formal-parameters.js new file mode 100644 index 0000000000..08efd9e9b6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/definition/early-errors-class-method-arguments-in-formal-parameters.js @@ -0,0 +1,17 @@ +// |reftest| error:SyntaxError +// Copyright 2016 Microsoft, Inc. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Brian Terlson +esid: pending +description: It is a SyntaxError if FormalParameters contains arguments +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); +class Foo { + async foo (arguments) { } +} diff --git a/js/src/tests/test262/language/statements/class/definition/early-errors-class-method-await-in-formals-default.js b/js/src/tests/test262/language/statements/class/definition/early-errors-class-method-await-in-formals-default.js new file mode 100644 index 0000000000..c4a99c4b58 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/definition/early-errors-class-method-await-in-formals-default.js @@ -0,0 +1,18 @@ +// |reftest| error:SyntaxError +// Copyright 2016 Microsoft, Inc. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Brian Terlson +esid: pending +description: It is a SyntaxError if FormalParameters' default expressions contains await +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); +class Foo { + async foo (x = await) { } +} + diff --git a/js/src/tests/test262/language/statements/class/definition/early-errors-class-method-await-in-formals.js b/js/src/tests/test262/language/statements/class/definition/early-errors-class-method-await-in-formals.js new file mode 100644 index 0000000000..67641cd169 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/definition/early-errors-class-method-await-in-formals.js @@ -0,0 +1,17 @@ +// |reftest| error:SyntaxError +// Copyright 2016 Microsoft, Inc. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Brian Terlson +esid: pending +description: It is a SyntaxError if FormalParameters contains await +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); +class Foo { + async foo (await) { } +} diff --git a/js/src/tests/test262/language/statements/class/definition/early-errors-class-method-body-contains-super-call.js b/js/src/tests/test262/language/statements/class/definition/early-errors-class-method-body-contains-super-call.js new file mode 100644 index 0000000000..61fc064ca4 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/definition/early-errors-class-method-body-contains-super-call.js @@ -0,0 +1,17 @@ +// |reftest| error:SyntaxError +// Copyright 2016 Microsoft, Inc. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Brian Terlson +esid: pending +description: It is a SyntaxError if AsyncFunctionBody contains SuperCall is true +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); +class Foo { + async foo () { super() } +} diff --git a/js/src/tests/test262/language/statements/class/definition/early-errors-class-method-duplicate-parameters.js b/js/src/tests/test262/language/statements/class/definition/early-errors-class-method-duplicate-parameters.js new file mode 100644 index 0000000000..b92ae46a08 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/definition/early-errors-class-method-duplicate-parameters.js @@ -0,0 +1,29 @@ +// |reftest| error:SyntaxError +// Copyright 2019 Mike Pennisi. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-method-definitions +description: Formal parameters may not contain duplicates +info: | + # 14.3 Method Definitions + + MethodDefinition[Yield, Await]: + PropertyName[?Yield, ?Await](UniqueFormalParameters[~Yield, ~Await]){FunctionBody[~Yield, ~Await]} + + # 14.1.2 Static Semantics: Early Errors + + UniqueFormalParameters:FormalParameters + + - It is a Syntax Error if BoundNames of FormalParameters contains any + duplicate elements. +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +class Foo { + foo(a, a) { } +} diff --git a/js/src/tests/test262/language/statements/class/definition/early-errors-class-method-eval-in-formal-parameters.js b/js/src/tests/test262/language/statements/class/definition/early-errors-class-method-eval-in-formal-parameters.js new file mode 100644 index 0000000000..16f456926e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/definition/early-errors-class-method-eval-in-formal-parameters.js @@ -0,0 +1,17 @@ +// |reftest| error:SyntaxError +// Copyright 2016 Microsoft, Inc. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Brian Terlson +esid: pending +description: It is a SyntaxError if FormalParameters contains eval in strict mode +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); +class Foo { + async foo(eval) { } +} diff --git a/js/src/tests/test262/language/statements/class/definition/early-errors-class-method-formals-body-duplicate.js b/js/src/tests/test262/language/statements/class/definition/early-errors-class-method-formals-body-duplicate.js new file mode 100644 index 0000000000..e1986d88ac --- /dev/null +++ b/js/src/tests/test262/language/statements/class/definition/early-errors-class-method-formals-body-duplicate.js @@ -0,0 +1,19 @@ +// |reftest| error:SyntaxError +// Copyright 2016 Microsoft, Inc. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Brian Terlson +esid: pending +description: > + It is a SyntaxError if BoundNames of FormalParameters also occurs in the LexicallyDeclaredNames of AsyncFunctionBody +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +class Foo { + async function foo(bar) { let bar; } +} diff --git a/js/src/tests/test262/language/statements/class/definition/early-errors-class-method-formals-contains-super-call.js b/js/src/tests/test262/language/statements/class/definition/early-errors-class-method-formals-contains-super-call.js new file mode 100644 index 0000000000..ebcc041b35 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/definition/early-errors-class-method-formals-contains-super-call.js @@ -0,0 +1,17 @@ +// |reftest| error:SyntaxError +// Copyright 2016 Microsoft, Inc. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Brian Terlson +esid: pending +description: It is a syntax error if FormalParameters contains SuperCall is true +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); +class Foo { + async foo(foo = super()) { } +} diff --git a/js/src/tests/test262/language/statements/class/definition/fn-length-static-precedence-order.js b/js/src/tests/test262/language/statements/class/definition/fn-length-static-precedence-order.js new file mode 100644 index 0000000000..ec6501c61f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/definition/fn-length-static-precedence-order.js @@ -0,0 +1,74 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-runtime-semantics-classdefinitionevaluation +description: > + Function `length` attribute not inferred in presence of static `length` method +info: | + ClassTail : ClassHeritage_opt { ClassBody_opt } + + 14. If constructor is empty, then [...] + b. Let F be ! CreateBuiltinFunction(steps, 0, className, « [[ConstructorKind]], [[SourceText]] », empty, constructorParent). + 15. Else, + a. Let constructorInfo be ! DefineMethod of constructor with arguments proto and constructorParent. + [ This sets the length property on constructorInfo.[[Closure]]. ] + b. Let F be constructorInfo.[[Closure]]. + [...] + 25. For each ClassElement e of elements, do + a. If IsStatic of e is false, then [...] + b. Else, + i. Let field be ClassElementEvaluation of e with arguments F and false. + [ This overwrites the length property on F. ] +includes: [compareArray.js] +features: [generators] +---*/ + +class A { + static method() { + throw new Test262Error('Static method should not be executed during definition'); + } + static length() { + throw new Test262Error('Static method should not be executed during definition'); + } +} + +assert.compareArray(Object.getOwnPropertyNames(A), ['length', 'name', 'prototype', 'method']) + +var attr = 'length'; +class B { + static [attr]() { + throw new Test262Error( + 'Static method defined via computed property should not be executed ' + + 'during definition' + ); + } +} + +assert.compareArray(Object.getOwnPropertyNames(B), ['length', 'name', 'prototype']) + +class C { + static get length() { + throw new Test262Error('Static `get` accessor should not be executed during definition'); + } +} + +assert.compareArray(Object.getOwnPropertyNames(C), ['length', 'name', 'prototype']) + +class D { + static set length(_) { + throw new Test262Error('Static `set` accessor should not be executed during definition'); + } +} + +assert.compareArray(Object.getOwnPropertyNames(D), ['length', 'name', 'prototype']) + +class E { + static *length() { + throw new Test262Error('Static GeneratorMethod should not be executed during definition'); + } +} + +assert.compareArray(Object.getOwnPropertyNames(E), ['length', 'name', 'prototype']) + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/definition/fn-length-static-precedence.js b/js/src/tests/test262/language/statements/class/definition/fn-length-static-precedence.js new file mode 100644 index 0000000000..51ac1bf7aa --- /dev/null +++ b/js/src/tests/test262/language/statements/class/definition/fn-length-static-precedence.js @@ -0,0 +1,78 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-runtime-semantics-classdefinitionevaluation +description: > + Function `length` attribute not inferred in presence of static `length` method +info: | + ClassTail : ClassHeritage_opt { ClassBody_opt } + + 14. If constructor is empty, then [...] + b. Let F be ! CreateBuiltinFunction(steps, 0, className, « [[ConstructorKind]], [[SourceText]] », empty, constructorParent). + 15. Else, + a. Let constructorInfo be ! DefineMethod of constructor with arguments proto and constructorParent. + [ This sets the length property on constructorInfo.[[Closure]]. ] + b. Let F be constructorInfo.[[Closure]]. + [...] + 25. For each ClassElement e of elements, do + a. If IsStatic of e is false, then [...] + b. Else, + i. Let field be ClassElementEvaluation of e with arguments F and false. + [ This overwrites the length property on F. ] +features: [generators] +---*/ + +class A { + static method() { + throw new Test262Error('Static method should not be executed during definition'); + } + static length() { + throw new Test262Error('Static method should not be executed during definition'); + } +} + +assert.sameValue(typeof A.length, 'function'); + +var attr = 'length'; +class B { + static [attr]() { + throw new Test262Error( + 'Static method defined via computed property should not be executed ' + + 'during definition' + ); + } +} + +assert.sameValue(typeof B.length, 'function'); + +var isDefined = false; +class C { + static get length() { + if (isDefined) { + return 'pass'; + } + throw new Test262Error('Static `get` accessor should not be executed during definition'); + } +} + +isDefined = true; +assert.sameValue(C.length, 'pass'); + +class D { + static set length(_) { + throw new Test262Error('Static `set` accessor should not be executed during definition'); + } +} + +assert.sameValue(D.length, undefined); + +class E { + static *length() { + throw new Test262Error('Static GeneratorMethod should not be executed during definition'); + } +} + +assert.sameValue(typeof E.length, 'function'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/definition/fn-name-accessor-get.js b/js/src/tests/test262/language/statements/class/definition/fn-name-accessor-get.js new file mode 100644 index 0000000000..8d329f0de5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/definition/fn-name-accessor-get.js @@ -0,0 +1,65 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 14.3.9 +description: Assignment of function `name` attribute ("get" accessor) +info: | + MethodDefinition : get PropertyName ( ) { FunctionBody } + + [...] + 8. Perform SetFunctionName(closure, propKey, "get"). +includes: [propertyHelper.js] +features: [Symbol] +---*/ + +var namedSym = Symbol('test262'); +var anonSym = Symbol(); +var getter; + +class A { + get id() {} + get [anonSym]() {} + get [namedSym]() {} + static get id() {} + static get [anonSym]() {} + static get [namedSym]() {} +} + +getter = Object.getOwnPropertyDescriptor(A.prototype, 'id').get; +assert.sameValue(getter.name, 'get id'); +verifyNotEnumerable(getter, 'name'); +verifyNotWritable(getter, 'name'); +verifyConfigurable(getter, 'name'); + +getter = Object.getOwnPropertyDescriptor(A.prototype, anonSym).get; +assert.sameValue(getter.name, 'get '); +verifyNotEnumerable(getter, 'name'); +verifyNotWritable(getter, 'name'); +verifyConfigurable(getter, 'name'); + +getter = Object.getOwnPropertyDescriptor(A.prototype, namedSym).get; +assert.sameValue(getter.name, 'get [test262]'); +verifyNotEnumerable(getter, 'name'); +verifyNotWritable(getter, 'name'); +verifyConfigurable(getter, 'name'); + +getter = Object.getOwnPropertyDescriptor(A, 'id').get; +assert.sameValue(getter.name, 'get id'); +verifyNotEnumerable(getter, 'name'); +verifyNotWritable(getter, 'name'); +verifyConfigurable(getter, 'name'); + +getter = Object.getOwnPropertyDescriptor(A, anonSym).get; +assert.sameValue(getter.name, 'get '); +verifyNotEnumerable(getter, 'name'); +verifyNotWritable(getter, 'name'); +verifyConfigurable(getter, 'name'); + +getter = Object.getOwnPropertyDescriptor(A, namedSym).get; +assert.sameValue(getter.name, 'get [test262]'); +verifyNotEnumerable(getter, 'name'); +verifyNotWritable(getter, 'name'); +verifyConfigurable(getter, 'name'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/definition/fn-name-accessor-set.js b/js/src/tests/test262/language/statements/class/definition/fn-name-accessor-set.js new file mode 100644 index 0000000000..22d97ca844 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/definition/fn-name-accessor-set.js @@ -0,0 +1,66 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 14.3.9 +description: Assignment of function `name` attribute ("set" accessor) +info: | + MethodDefinition : + set PropertyName ( PropertySetParameterList ) { FunctionBody } + + [...] + 7. Perform SetFunctionName(closure, propKey, "set"). +includes: [propertyHelper.js] +features: [Symbol] +---*/ + +var namedSym = Symbol('test262'); +var anonSym = Symbol(); +var setter; + +class A { + set id(_) {} + set [anonSym](_) {} + set [namedSym](_) {} + static set id(_) {} + static set [anonSym](_) {} + static set [namedSym](_) {} +} + +setter = Object.getOwnPropertyDescriptor(A.prototype, 'id').set; +assert.sameValue(setter.name, 'set id'); +verifyNotEnumerable(setter, 'name'); +verifyNotWritable(setter, 'name'); +verifyConfigurable(setter, 'name'); + +setter = Object.getOwnPropertyDescriptor(A.prototype, anonSym).set; +assert.sameValue(setter.name, 'set '); +verifyNotEnumerable(setter, 'name'); +verifyNotWritable(setter, 'name'); +verifyConfigurable(setter, 'name'); + +setter = Object.getOwnPropertyDescriptor(A.prototype, namedSym).set; +assert.sameValue(setter.name, 'set [test262]'); +verifyNotEnumerable(setter, 'name'); +verifyNotWritable(setter, 'name'); +verifyConfigurable(setter, 'name'); + +setter = Object.getOwnPropertyDescriptor(A, 'id').set; +assert.sameValue(setter.name, 'set id'); +verifyNotEnumerable(setter, 'name'); +verifyNotWritable(setter, 'name'); +verifyConfigurable(setter, 'name'); + +setter = Object.getOwnPropertyDescriptor(A, anonSym).set; +assert.sameValue(setter.name, 'set '); +verifyNotEnumerable(setter, 'name'); +verifyNotWritable(setter, 'name'); +verifyConfigurable(setter, 'name'); + +setter = Object.getOwnPropertyDescriptor(A, namedSym).set; +assert.sameValue(setter.name, 'set [test262]'); +verifyNotEnumerable(setter, 'name'); +verifyNotWritable(setter, 'name'); +verifyConfigurable(setter, 'name'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/definition/fn-name-gen-method.js b/js/src/tests/test262/language/statements/class/definition/fn-name-gen-method.js new file mode 100644 index 0000000000..f6bb4781af --- /dev/null +++ b/js/src/tests/test262/language/statements/class/definition/fn-name-gen-method.js @@ -0,0 +1,60 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 14.4.13 +description: > + Assignment of function `name` attribute (GeneratorMethod) +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + [...] + 9. Perform SetFunctionName(closure, propKey). +includes: [propertyHelper.js] +features: [generators, Symbol] +---*/ + +var namedSym = Symbol('test262'); +var anonSym = Symbol(); + +class A { + *id() {} + *[anonSym]() {} + *[namedSym]() {} + static *id() {} + static *[anonSym]() {} + static *[namedSym]() {} +} + +assert.sameValue(A.prototype.id.name, 'id', 'via IdentifierName'); +verifyNotEnumerable(A.prototype.id, 'name'); +verifyNotWritable(A.prototype.id, 'name'); +verifyConfigurable(A.prototype.id, 'name'); + +assert.sameValue(A.prototype[anonSym].name, '', 'via anonymous Symbol'); +verifyNotEnumerable(A.prototype[anonSym], 'name'); +verifyNotWritable(A.prototype[anonSym], 'name'); +verifyConfigurable(A.prototype[anonSym], 'name'); + +assert.sameValue(A.prototype[namedSym].name, '[test262]', 'via Symbol'); +verifyNotEnumerable(A.prototype[namedSym], 'name'); +verifyNotWritable(A.prototype[namedSym], 'name'); +verifyConfigurable(A.prototype[namedSym], 'name'); + +assert.sameValue(A.id.name, 'id', 'static via IdentifierName'); +verifyNotEnumerable(A.id, 'name'); +verifyNotWritable(A.id, 'name'); +verifyConfigurable(A.id, 'name'); + +assert.sameValue(A[anonSym].name, '', 'static via anonymous Symbol'); +verifyNotEnumerable(A[anonSym], 'name'); +verifyNotWritable(A[anonSym], 'name'); +verifyConfigurable(A[anonSym], 'name'); + +assert.sameValue(A[namedSym].name, '[test262]', 'static via Symbol'); +verifyNotEnumerable(A[namedSym], 'name'); +verifyNotWritable(A[namedSym], 'name'); +verifyConfigurable(A[namedSym], 'name'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/definition/fn-name-method.js b/js/src/tests/test262/language/statements/class/definition/fn-name-method.js new file mode 100644 index 0000000000..f01641f5c0 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/definition/fn-name-method.js @@ -0,0 +1,59 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 12.2.6.9 +description: Assignment of function `name` attribute (MethodDefinition) +info: | + 6. If IsAnonymousFunctionDefinition(AssignmentExpression) is true, then + a. Let hasNameProperty be HasOwnProperty(propValue, "name"). + b. ReturnIfAbrupt(hasNameProperty). + c. If hasNameProperty is false, perform SetFunctionName(propValue, + propKey). +includes: [propertyHelper.js] +features: [Symbol] +---*/ + +var namedSym = Symbol('test262'); +var anonSym = Symbol(); + +class A { + id() {} + [anonSym]() {} + [namedSym]() {} + static id() {} + static [anonSym]() {} + static [namedSym]() {} +} + +assert.sameValue(A.prototype.id.name, 'id', 'via IdentifierName'); +verifyNotEnumerable(A.prototype.id, 'name'); +verifyNotWritable(A.prototype.id, 'name'); +verifyConfigurable(A.prototype.id, 'name'); + +assert.sameValue(A.prototype[anonSym].name, '', 'via anonymous Symbol'); +verifyNotEnumerable(A.prototype[anonSym], 'name'); +verifyNotWritable(A.prototype[anonSym], 'name'); +verifyConfigurable(A.prototype[anonSym], 'name'); + +assert.sameValue(A.prototype[namedSym].name, '[test262]', 'via Symbol'); +verifyNotEnumerable(A.prototype[namedSym], 'name'); +verifyNotWritable(A.prototype[namedSym], 'name'); +verifyConfigurable(A.prototype[namedSym], 'name'); + +assert.sameValue(A.id.name, 'id', 'static via IdentifierName'); +verifyNotEnumerable(A.id, 'name'); +verifyNotWritable(A.id, 'name'); +verifyConfigurable(A.id, 'name'); + +assert.sameValue(A[anonSym].name, '', 'static via anonymous Symbol'); +verifyNotEnumerable(A[anonSym], 'name'); +verifyNotWritable(A[anonSym], 'name'); +verifyConfigurable(A[anonSym], 'name'); + +assert.sameValue(A[namedSym].name, '[test262]', 'static via Symbol'); +verifyNotEnumerable(A[namedSym], 'name'); +verifyNotWritable(A[namedSym], 'name'); +verifyConfigurable(A[namedSym], 'name'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/definition/fn-name-static-precedence-order.js b/js/src/tests/test262/language/statements/class/definition/fn-name-static-precedence-order.js new file mode 100644 index 0000000000..b9e64a64b6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/definition/fn-name-static-precedence-order.js @@ -0,0 +1,71 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-runtime-semantics-classdefinitionevaluation +description: > + Function `name` attribute not inferred in presence of static `name` method +info: | + ClassTail : ClassHeritage_opt { ClassBody_opt } + + 14. If constructor is empty, then [...] + b. Let F be ! CreateBuiltinFunction(steps, 0, className, « [[ConstructorKind]], [[SourceText]] », empty, constructorParent). + 15. Else, [...] + d. Perform ! SetFunctionName(F, className). + 25. For each ClassElement e of elements, do + a. If IsStatic of e is false, then [...] + b. Else, + i. Let field be ClassElementEvaluation of e with arguments F and false. + [ This overwrites the name property on F. ] +includes: [compareArray.js] +features: [generators] +---*/ + +class A { + static method() { + throw new Test262Error('Static method should not be executed during definition'); + } + static name() { + throw new Test262Error('Static method should not be executed during definition'); + } +} + +assert.compareArray(Object.getOwnPropertyNames(A), ['length', 'name', 'prototype', 'method']) + +var attr = 'name'; +class B { + static [attr]() { + throw new Test262Error( + 'Static method defined via computed property should not be executed ' + + 'during definition' + ); + } +} + +assert.compareArray(Object.getOwnPropertyNames(B), ['length', 'name', 'prototype']) + +class C { + static get name() { + throw new Test262Error('Static `get` accessor should not be executed during definition'); + } +} + +assert.compareArray(Object.getOwnPropertyNames(C), ['length', 'name', 'prototype']) + +class D { + static set name(_) { + throw new Test262Error('Static `set` accessor should not be executed during definition'); + } +} + +assert.compareArray(Object.getOwnPropertyNames(D), ['length', 'name', 'prototype']) + +class E { + static *name() { + throw new Test262Error('Static GeneratorMethod should not be executed during definition'); + } +} + +assert.compareArray(Object.getOwnPropertyNames(E), ['length', 'name', 'prototype']) + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/definition/fn-name-static-precedence.js b/js/src/tests/test262/language/statements/class/definition/fn-name-static-precedence.js new file mode 100644 index 0000000000..0521ae7681 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/definition/fn-name-static-precedence.js @@ -0,0 +1,75 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-runtime-semantics-classdefinitionevaluation +description: > + Function `name` attribute not inferred in presence of static `name` method +info: | + ClassTail : ClassHeritage_opt { ClassBody_opt } + + 14. If constructor is empty, then [...] + b. Let F be ! CreateBuiltinFunction(steps, 0, className, « [[ConstructorKind]], [[SourceText]] », empty, constructorParent). + 15. Else, [...] + d. Perform ! SetFunctionName(F, className). + 25. For each ClassElement e of elements, do + a. If IsStatic of e is false, then [...] + b. Else, + i. Let field be ClassElementEvaluation of e with arguments F and false. + [ This overwrites the name property on F. ] +features: [generators] +---*/ + +class A { + static method() { + throw new Test262Error('Static method should not be executed during definition'); + } + static name() { + throw new Test262Error('Static method should not be executed during definition'); + } +} + +assert.sameValue(typeof A.name, 'function'); + +var attr = 'name'; +class B { + static [attr]() { + throw new Test262Error( + 'Static method defined via computed property should not be executed ' + + 'during definition' + ); + } +} + +assert.sameValue(typeof B.name, 'function'); + +var isDefined = false; +class C { + static get name() { + if (isDefined) { + return 'pass'; + } + throw new Test262Error('Static `get` accessor should not be executed during definition'); + } +} + +isDefined = true; +assert.sameValue(C.name, 'pass'); + +class D { + static set name(_) { + throw new Test262Error('Static `set` accessor should not be executed during definition'); + } +} + +assert.sameValue(D.name, undefined); + +class E { + static *name() { + throw new Test262Error('Static GeneratorMethod should not be executed during definition'); + } +} + +assert.sameValue(typeof E.name, 'function'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/definition/getters-non-configurable-err.js b/js/src/tests/test262/language/statements/class/definition/getters-non-configurable-err.js new file mode 100644 index 0000000000..90745ff901 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/definition/getters-non-configurable-err.js @@ -0,0 +1,19 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-method-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.3.9 +description: Failure to define property for static method +info: | + [...] + 9. Let desc be the PropertyDescriptor{[[Get]]: closure, [[Enumerable]]: + enumerable, [[Configurable]]: true}. + 10. Return ? DefinePropertyOrThrow(object, propKey, desc). +features: [generators] +---*/ + +assert.throws(TypeError, function() { + class C { static get ['prototype']() {} } +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/definition/getters-prop-desc.js b/js/src/tests/test262/language/statements/class/definition/getters-prop-desc.js new file mode 100644 index 0000000000..f541118067 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/definition/getters-prop-desc.js @@ -0,0 +1,36 @@ +// Copyright (C) 2014 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-class-definitions +es6id: 14.5 +description: Class methods - "get" accessors +includes: [propertyHelper.js] +---*/ + +function assertGetterDescriptor(object, name) { + var desc = Object.getOwnPropertyDescriptor(object, name); + verifyNotEnumerable(object, name); + verifyConfigurable(object, name); + assert.sameValue(typeof desc.get, 'function', "`typeof desc.get` is `'function'`"); + assert.sameValue('prototype' in desc.get, false, "The result of `'prototype' in desc.get` is `false`"); + assert.sameValue(desc.set, undefined, "The value of `desc.set` is `undefined`"); +} + +class C { + get x() { return 1; } + static get staticX() { return 2; } + get y() { return 3; } + static get staticY() { return 4; } +} + +assert.sameValue(new C().x, 1, "The value of `new C().x` is `1`. Defined as `get x() { return 1; }`"); +assert.sameValue(C.staticX, 2, "The value of `C.staticX` is `2`. Defined as `static get staticX() { return 2; }`"); +assert.sameValue(new C().y, 3, "The value of `new C().y` is `3`. Defined as `get y() { return 3; }`"); +assert.sameValue(C.staticY, 4, "The value of `C.staticY` is `4`. Defined as `static get staticY() { return 4; }`"); + +assertGetterDescriptor(C.prototype, 'x'); +assertGetterDescriptor(C.prototype, 'y'); +assertGetterDescriptor(C, 'staticX'); +assertGetterDescriptor(C, 'staticY'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/definition/getters-restricted-ids.js b/js/src/tests/test262/language/statements/class/definition/getters-restricted-ids.js new file mode 100644 index 0000000000..ab41252801 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/definition/getters-restricted-ids.js @@ -0,0 +1,28 @@ +// Copyright (C) 2014 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.5 +description: > + class getters 2 +---*/ +class C { + get eval() { + return 1; + } + get arguments() { + return 2; + } + static get eval() { + return 3; + } + static get arguments() { + return 4; + } +}; + +assert.sameValue(new C().eval, 1, "The value of `new C().eval` is `1`"); +assert.sameValue(new C().arguments, 2, "The value of `new C().arguments` is `2`"); +assert.sameValue(C.eval, 3, "The value of `C.eval` is `3`"); +assert.sameValue(C.arguments, 4, "The value of `C.arguments` is `4`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/definition/implicit-constructor.js b/js/src/tests/test262/language/statements/class/definition/implicit-constructor.js new file mode 100644 index 0000000000..1d9d689c48 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/definition/implicit-constructor.js @@ -0,0 +1,16 @@ +// Copyright (C) 2014 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.5 +description: > + class implicit constructor +---*/ +class C {} +var c = new C(); +assert.sameValue( + Object.getPrototypeOf(c), + C.prototype, + "`Object.getPrototypeOf(c)` returns `C.prototype`" +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/definition/invalid-extends.js b/js/src/tests/test262/language/statements/class/definition/invalid-extends.js new file mode 100644 index 0000000000..3bd1f15781 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/definition/invalid-extends.js @@ -0,0 +1,23 @@ +// Copyright (C) 2014 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.5 +description: > + class invalid extends +---*/ +assert.throws(TypeError, function() { + class C extends 42 {} +}); + +assert.throws(TypeError, function() { + // Function but its .prototype is not null or a function. + class C extends Math.abs {} +}); + +assert.throws(TypeError, function() { + Math.abs.prototype = 42; + class C extends Math.abs {} +}); +delete Math.abs.prototype; + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/definition/methods-async-super-call-body.js b/js/src/tests/test262/language/statements/class/definition/methods-async-super-call-body.js new file mode 100644 index 0000000000..36930de14e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/definition/methods-async-super-call-body.js @@ -0,0 +1,27 @@ +// |reftest| async +// Copyright 2016 Microsoft, Inc. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Brian Terlson +esid: pending +description: > + Super calls work in body of async methods +flags: [async] +features: [async-functions] +---*/ +class A { + async method() { + return 'sup'; + } +} + +class B extends A { + async method() { + var x = await super.method(); + assert.sameValue(x, 'sup'); + } +} +var child = new B(); +child.method().then($DONE, $DONE); + diff --git a/js/src/tests/test262/language/statements/class/definition/methods-async-super-call-param.js b/js/src/tests/test262/language/statements/class/definition/methods-async-super-call-param.js new file mode 100644 index 0000000000..a2ca86be8d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/definition/methods-async-super-call-param.js @@ -0,0 +1,26 @@ +// |reftest| async +// Copyright 2016 Microsoft, Inc. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Brian Terlson +esid: pending +description: > + Super calls work in the parameter list of async methods +flags: [async] +features: [async-functions] +---*/ + +class A { + async method() { + return 'sup'; + } +} + +class B extends A { + async method(x = super.method()) { + assert.sameValue(await x, 'sup'); + } +} +var child = new B(); +child.method().then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/definition/methods-gen-no-yield.js b/js/src/tests/test262/language/statements/class/definition/methods-gen-no-yield.js new file mode 100644 index 0000000000..8979af1c48 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/definition/methods-gen-no-yield.js @@ -0,0 +1,22 @@ +// Copyright (C) 2013 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- + description: > + Generators declared with GeneratorMethod syntax do not require a + `yield` expression. + features: [generators] + es6id: 14.4 +---*/ + +var result; +class A { + *foo(a) {} +} + +result = A.prototype.foo(3).next(); + +assert.sameValue(result.value, undefined); +assert.sameValue(result.done, true); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/definition/methods-gen-return.js b/js/src/tests/test262/language/statements/class/definition/methods-gen-return.js new file mode 100644 index 0000000000..06d4d4cddb --- /dev/null +++ b/js/src/tests/test262/language/statements/class/definition/methods-gen-return.js @@ -0,0 +1,25 @@ +// Copyright (C) 2013 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- + description: > + `return` is a valid statement within generator function bodies. + features: [generators] + es6id: 14.4 +---*/ + +var result; +class A { + *g1() { return; } + *g2() { return 1; } +} + +result = A.prototype.g1().next(); +assert.sameValue(result.value, undefined); +assert.sameValue(result.done, true); + +result = A.prototype.g2().next(); +assert.sameValue(result.value, 1); +assert.sameValue(result.done, true); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/definition/methods-gen-yield-as-expression-with-rhs.js b/js/src/tests/test262/language/statements/class/definition/methods-gen-yield-as-expression-with-rhs.js new file mode 100644 index 0000000000..953152207c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/definition/methods-gen-yield-as-expression-with-rhs.js @@ -0,0 +1,120 @@ +// Copyright (C) 2013 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- + description: > + `yield` is a valid expression within generator function bodies. + features: [generators] + es6id: 14.4 +---*/ + +var iter, result; +class A { + *g1() { (yield 1) } + *g2() { [yield 1] } + *g3() { {yield 1} } + *g4() { yield 1, yield 2; } + *g5() { (yield 1) ? yield 2 : yield 3; } +} + +iter = A.prototype.g1(); +result = iter.next(); +assert.sameValue(result.value, 1, 'Within grouping operator: result `value`'); +assert.sameValue( + result.done, false, 'Within grouping operator: result `done` flag' +); +result = iter.next(); +assert.sameValue( + result.value, undefined, 'Following grouping operator: result `value`' +); +assert.sameValue( + result.done, true, 'Following grouping operator: result `done` flag' +); + +iter = A.prototype.g2(); +result = iter.next(); +assert.sameValue(result.value, 1, 'Within array literal: result `value`'); +assert.sameValue( + result.done, false, 'Within array literal: result `done` flag' +); +result = iter.next(); +assert.sameValue( + result.value, undefined, 'Following array literal: result `value`' +); +assert.sameValue( + result.done, true, 'Following array literal: result `done` flag' +); + +iter = A.prototype.g3(); +result = iter.next(); +assert.sameValue(result.value, 1, 'Within object literal: result `value`'); +assert.sameValue( + result.done, false, 'Within object literal: result `done` flag' +); +result = iter.next(); +assert.sameValue( + result.value, undefined, 'Following object literal: result `value`' +); +assert.sameValue( + result.done, true, 'Following object literal: result `done` flag' +); + +iter = A.prototype.g4(); +result = iter.next(); +assert.sameValue( + result.value, 1, 'First expression in comma expression: result `value`' +); +assert.sameValue( + result.done, + false, + 'First expression in comma expression: result `done` flag' +); +result = iter.next(); +assert.sameValue( + result.value, 2, 'Second expression in comma expression: result `value`' +); +assert.sameValue( + result.done, + false, + 'Second expression in comma expression: result `done` flag' +); +result = iter.next(); +assert.sameValue( + result.value, undefined, 'Following comma expression: result `value`' +); +assert.sameValue( + result.done, true, 'Following comma expression: result `done` flag' +); + +iter = A.prototype.g5(); +result = iter.next(); +assert.sameValue( + result.value, + 1, + 'Conditional expression in conditional operator: result `value`' +); +assert.sameValue( + result.done, + false, + 'Conditional expression in conditional operator: result `done` flag' +); +result = iter.next(); +assert.sameValue( + result.value, + 3, + 'Branch in conditional operator: result `value`' +); +assert.sameValue( + result.done, + false, + 'Branch in conditional operator: result `done` flag' +); +result = iter.next(); +assert.sameValue( + result.value, undefined, 'Following conditional operator: result `value`' +); +assert.sameValue( + result.done, true, 'Following conditional operator: result `done` flag' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/definition/methods-gen-yield-as-expression-without-rhs.js b/js/src/tests/test262/language/statements/class/definition/methods-gen-yield-as-expression-without-rhs.js new file mode 100644 index 0000000000..b42c406358 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/definition/methods-gen-yield-as-expression-without-rhs.js @@ -0,0 +1,130 @@ +// Copyright (C) 2013 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- + description: > + `yield` is a valid expression within generator function bodies. + features: [generators] + es6id: 14.4 +---*/ + +var iter, result; +class A { + *g1() { (yield) } + *g2() { [yield] } + *g3() { {yield} } + *g4() { yield, yield; } + *g5() { (yield) ? yield : yield; } +} + +iter = A.prototype.g1(); +result = iter.next(); +assert.sameValue( + result.value, undefined, 'Within grouping operator: result `value`' +); +assert.sameValue( + result.done, false, 'Within grouping operator: result `done` flag' +); +result = iter.next(); +assert.sameValue( + result.value, undefined, 'Following grouping operator: result `value`' +); +assert.sameValue( + result.done, true, 'Following grouping operator: result `done` flag' +); + +iter = A.prototype.g2(); +result = iter.next(); +assert.sameValue( + result.value, undefined, 'Within array literal: result `value`' +); +assert.sameValue( + result.done, false, 'Within array literal: result `done` flag' +); +result = iter.next(); +assert.sameValue( + result.value, undefined, 'Following array literal: result `value`' +); +assert.sameValue( + result.done, true, 'Following array literal: result `done` flag' +); + +iter = A.prototype.g3(); +result = iter.next(); +assert.sameValue( + result.value, undefined, 'Within object literal: result `value`' +); +assert.sameValue( + result.done, false, 'Within object literal: result `done` flag' +); +result = iter.next(); +assert.sameValue( + result.value, undefined, 'Following object literal: result `value`' +); +assert.sameValue( + result.done, true, 'Following object literal: result `done` flag' +); + +iter = A.prototype.g4(); +result = iter.next(); +assert.sameValue( + result.value, + undefined, + 'First expression in comma expression: result `value`' +); +assert.sameValue( + result.done, + false, + 'First expression in comma expression: result `done` flag' +); +result = iter.next(); +assert.sameValue( + result.value, + undefined, + 'Second expression in comma expression: result `value`' +); +assert.sameValue( + result.done, + false, + 'Second expression in comma expression: result `done` flag' +); +result = iter.next(); +assert.sameValue( + result.value, undefined, 'Following comma expression: result `value`' +); +assert.sameValue( + result.done, true, 'Following comma expression: result `done` flag' +); + +iter = A.prototype.g5(); +result = iter.next(); +assert.sameValue( + result.value, + undefined, + 'Conditional expression in conditional operator: result `value`' +); +assert.sameValue( + result.done, + false, + 'Conditional expression in conditional operator: result `done` flag' +); +result = iter.next(); +assert.sameValue( + result.value, + undefined, + 'Branch in conditional operator: result `value`' +); +assert.sameValue( + result.done, + false, + 'Branch in conditional operator: result `done` flag' +); +result = iter.next(); +assert.sameValue( + result.value, undefined, 'Following conditional operator: result `value`' +); +assert.sameValue( + result.done, true, 'Following conditional operator: result `done` flag' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/definition/methods-gen-yield-as-function-expression-binding-identifier.js b/js/src/tests/test262/language/statements/class/definition/methods-gen-yield-as-function-expression-binding-identifier.js new file mode 100644 index 0000000000..40ef23222f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/definition/methods-gen-yield-as-function-expression-binding-identifier.js @@ -0,0 +1,22 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2013 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- + description: > + `yield` may not be used as the binding identifier of a function + expression within classes. + features: [generators] + es6id: 14.1 + negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +class A { + *g() { + (function yield() {}); + } +} diff --git a/js/src/tests/test262/language/statements/class/definition/methods-gen-yield-as-generator-method-binding-identifier.js b/js/src/tests/test262/language/statements/class/definition/methods-gen-yield-as-generator-method-binding-identifier.js new file mode 100644 index 0000000000..6f0dfff5a1 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/definition/methods-gen-yield-as-generator-method-binding-identifier.js @@ -0,0 +1,31 @@ +// Copyright (C) 2013 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- + description: > + `yield` is a valid BindingIdentifier for GeneratorMethods outside of + strict mode. + features: [generators] + es6id: 12.1.1 +---*/ + +var iter, result; +class A { + *yield() { (yield 3) + (yield 4); } +} + +iter = A.prototype.yield(); + +result = iter.next(); +assert.sameValue(result.value, 3, 'First result `value`'); +assert.sameValue(result.done, false, 'First result `done` flag'); + +result = iter.next(); +assert.sameValue(result.value, 4, 'Second result `value`'); +assert.sameValue(result.done, false, 'Second result `done` flag'); + +result = iter.next(); +assert.sameValue(result.value, undefined, 'Third result `value`'); +assert.sameValue(result.done, true, 'Third result `done` flag'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/definition/methods-gen-yield-as-identifier-in-nested-function.js b/js/src/tests/test262/language/statements/class/definition/methods-gen-yield-as-identifier-in-nested-function.js new file mode 100644 index 0000000000..eb35c7cb3a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/definition/methods-gen-yield-as-identifier-in-nested-function.js @@ -0,0 +1,24 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2013 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- + description: > + `yield` is a reserved keyword within normal function bodies declared + within classes. + features: [generators] + es6id: 12.1.1 + negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +class A { + *g() { + function h() { + yield = 1; + } + } +} diff --git a/js/src/tests/test262/language/statements/class/definition/methods-gen-yield-as-literal-property-name.js b/js/src/tests/test262/language/statements/class/definition/methods-gen-yield-as-literal-property-name.js new file mode 100644 index 0000000000..ce60db6fb7 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/definition/methods-gen-yield-as-literal-property-name.js @@ -0,0 +1,23 @@ +// Copyright (C) 2013 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- + description: > + `yield` may be used as a literal property name in an object literal + within generator function bodies. + features: [generators] + es6id: 12.1.1 +---*/ + +var result; +class A { + *g() { + ({ get yield() { return 1 } }); + } +} + +result = A.prototype.g().next(); +assert.sameValue(result.value, undefined); +assert.sameValue(result.done, true); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/definition/methods-gen-yield-as-logical-or-expression.js b/js/src/tests/test262/language/statements/class/definition/methods-gen-yield-as-logical-or-expression.js new file mode 100644 index 0000000000..5edac93178 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/definition/methods-gen-yield-as-logical-or-expression.js @@ -0,0 +1,21 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2013 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- + description: > + `yield` expressions are not LogicalOrExpressions. + features: [generators] + es6id: 12.1.1 + negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +class A { + *g() { + yield ? yield : yield; + } +} diff --git a/js/src/tests/test262/language/statements/class/definition/methods-gen-yield-as-parameter.js b/js/src/tests/test262/language/statements/class/definition/methods-gen-yield-as-parameter.js new file mode 100644 index 0000000000..f4cf062cf4 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/definition/methods-gen-yield-as-parameter.js @@ -0,0 +1,20 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2013 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- + description: > + `yield` is a reserved keyword within generator function bodies and may + not be used as the binding identifier of a parameter. + features: [generators] + es6id: 12.1.1 + negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +class A { + *g(yield) {} +} diff --git a/js/src/tests/test262/language/statements/class/definition/methods-gen-yield-as-property-name.js b/js/src/tests/test262/language/statements/class/definition/methods-gen-yield-as-property-name.js new file mode 100644 index 0000000000..60f99d9b29 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/definition/methods-gen-yield-as-property-name.js @@ -0,0 +1,23 @@ +// Copyright (C) 2013 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- + description: > + `yield` may be used as a literal property name in an object literal + within generator function bodies. + features: [generators] + es6id: 12.1.1 +---*/ + +var result; +class A { + *g() { + ({ yield: 1 }); + } +} + +result = A.prototype.g().next(); +assert.sameValue(result.value, undefined); +assert.sameValue(result.done, true); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/definition/methods-gen-yield-as-statement.js b/js/src/tests/test262/language/statements/class/definition/methods-gen-yield-as-statement.js new file mode 100644 index 0000000000..605fc0f6fb --- /dev/null +++ b/js/src/tests/test262/language/statements/class/definition/methods-gen-yield-as-statement.js @@ -0,0 +1,49 @@ +// Copyright (C) 2013 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- + description: > + `yield` is a valid statement within generator function bodies. + features: [generators] + es6id: 14.4 +---*/ + +var iter, result; +class A { + *g1() { yield; } + *g2() { yield 1; } +} + +iter = A.prototype.g1(); +result = iter.next(); +assert.sameValue( + result.value, undefined, 'Without right-hand-side: first result `value`' +); +assert.sameValue( + result.done, false, 'Without right-hand-side: first result `done` flag' +); +result = iter.next(); +assert.sameValue( + result.value, undefined, 'Without right-hand-side: second result `value`' +); +assert.sameValue( + result.done, true, 'Without right-hand-eside: second result `done` flag' +); + +iter = A.prototype.g2(); +result = iter.next(); +assert.sameValue( + result.value, 1, 'With right-hand-side: first result `value`' +); +assert.sameValue( + result.done, false, 'With right-hand-side: first result `done` flag' +); +result = iter.next(); +assert.sameValue( + result.value, undefined, 'With right-hand-side: second result `value`' +); +assert.sameValue( + result.done, true, 'With right-hand-eside: second result `done` flag' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/definition/methods-gen-yield-as-yield-operand.js b/js/src/tests/test262/language/statements/class/definition/methods-gen-yield-as-yield-operand.js new file mode 100644 index 0000000000..a440f04d0a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/definition/methods-gen-yield-as-yield-operand.js @@ -0,0 +1,33 @@ +// Copyright (C) 2013 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- + description: > + `yield` expressions may be used as the right-hand-side of other `yield` + expressions. + features: [generators] + es6id: 14.4 +---*/ + +var iter, result; +class A { + *g() { + yield yield 1; + } +} + +iter = A.prototype.g(); + +result = iter.next(); +assert.sameValue(result.value, 1, 'First result `value`'); +assert.sameValue(result.done, false, 'First result `done` flag'); + +result = iter.next(); +assert.sameValue(result.value, undefined, 'Second result `value`'); +assert.sameValue(result.done, false, 'Second result `done` flag'); + +result = iter.next(); +assert.sameValue(result.value, undefined, 'Third result `value`'); +assert.sameValue(result.done, true, 'Thid result `done` flag'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/definition/methods-gen-yield-newline.js b/js/src/tests/test262/language/statements/class/definition/methods-gen-yield-newline.js new file mode 100644 index 0000000000..b2f23da27d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/definition/methods-gen-yield-newline.js @@ -0,0 +1,29 @@ +// Copyright (C) 2013 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- + description: > + Newlines terminate `yield` expressions. + features: [generators] + es6id: 14.4 +---*/ + +var iter, result; +class A { + *g() { + yield + 1 + } +} + +iter = A.prototype.g(); + +result = iter.next(); +assert.sameValue(result.value, undefined, 'First result `value`'); +assert.sameValue(result.done, false, 'First result `done` flag'); + +result = iter.next(); +assert.sameValue(result.value, undefined, 'Second result `value`'); +assert.sameValue(result.done, true, 'Second result `done` flag'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/definition/methods-gen-yield-star-after-newline.js b/js/src/tests/test262/language/statements/class/definition/methods-gen-yield-star-after-newline.js new file mode 100644 index 0000000000..ca1913c00a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/definition/methods-gen-yield-star-after-newline.js @@ -0,0 +1,22 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2013 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- + description: > + A newline may not precede the `*` token in a `yield` expression. + features: [generators] + es6id: 14.4 + negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +class A { + *g() { + yield + * 1 + } +} diff --git a/js/src/tests/test262/language/statements/class/definition/methods-gen-yield-star-before-newline.js b/js/src/tests/test262/language/statements/class/definition/methods-gen-yield-star-before-newline.js new file mode 100644 index 0000000000..bc68cbbdb2 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/definition/methods-gen-yield-star-before-newline.js @@ -0,0 +1,24 @@ +// Copyright (C) 2013 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- + description: > + The right-hand side of a `yield *` expression may appear on a new line. + features: [generators] + es6id: 14.4 +---*/ + +var result; +class A { + *g() { + yield * + g2() + } +} +var g2 = function*() {}; + +result = A.prototype.g().next(); +assert.sameValue(result.value, undefined); +assert.sameValue(result.done, true); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/definition/methods-gen-yield-weak-binding.js b/js/src/tests/test262/language/statements/class/definition/methods-gen-yield-weak-binding.js new file mode 100644 index 0000000000..0c2f54376a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/definition/methods-gen-yield-weak-binding.js @@ -0,0 +1,19 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2013 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- + description: > + `yield` expressions bind weakly + features: [generators] + es6id: 14.4 + negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +class A { + *g() { yield 3 + yield 4; } +} diff --git a/js/src/tests/test262/language/statements/class/definition/methods-named-eval-arguments.js b/js/src/tests/test262/language/statements/class/definition/methods-named-eval-arguments.js new file mode 100644 index 0000000000..bb99527117 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/definition/methods-named-eval-arguments.js @@ -0,0 +1,28 @@ +// Copyright (C) 2014 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.5 +description: > + class methods 2 +---*/ +class C { + eval() { + return 1; + } + arguments() { + return 2; + } + static eval() { + return 3; + } + static arguments() { + return 4; + } +}; + +assert.sameValue(new C().eval(), 1, "`new C().eval()` returns `1`"); +assert.sameValue(new C().arguments(), 2, "`new C().arguments()` returns `2`"); +assert.sameValue(C.eval(), 3, "`C.eval()` returns `3`"); +assert.sameValue(C.arguments(), 4, "`C.arguments()` returns `4`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/definition/methods-restricted-properties.js b/js/src/tests/test262/language/statements/class/definition/methods-restricted-properties.js new file mode 100644 index 0000000000..f01bb2a643 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/definition/methods-restricted-properties.js @@ -0,0 +1,106 @@ +// Copyright (C) 2015 Caitlin Potter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + Functions created using MethodDefinition syntactic form do not have own + properties "caller" or "arguments", but inherit them from + %FunctionPrototype%. +es6id: 16.1 +---*/ + +class Class { + method() {} + get accessor() {} + set accessor(x) {} +}; + +var instance = new Class; +var accessor = Object.getOwnPropertyDescriptor(Class.prototype, "accessor"); + +assert.sameValue( + instance.method.hasOwnProperty('caller'), + false, + 'No "caller" own property (method)' +); +assert.sameValue( + instance.method.hasOwnProperty('arguments'), + false, + 'No "arguments" own property (method)' +); +assert.sameValue( + accessor.get.hasOwnProperty('caller'), + false, + 'No "caller" own property ("get" accessor)' +); +assert.sameValue( + accessor.get.hasOwnProperty('arguments'), + false, + 'No "arguments" own property ("get" accessor)' +); +assert.sameValue( + accessor.set.hasOwnProperty('caller'), + false, + 'No "caller" own property ("set" accessor)' +); +assert.sameValue( + accessor.set.hasOwnProperty('arguments'), + false, + 'No "arguments" own property ("set" accessor)' +); + +// --- Test method restricted properties throw + +assert.throws(TypeError, function() { + return instance.method.caller; +}); + +assert.throws(TypeError, function() { + instance.method.caller = {}; +}); + +assert.throws(TypeError, function() { + return instance.method.arguments; +}); + +assert.throws(TypeError, function() { + instance.method.arguments = {}; +}); + +// --- Test getter restricted properties throw + +assert.throws(TypeError, function() { + return accessor.get.caller; +}); + +assert.throws(TypeError, function() { + accessor.get.caller = {}; +}); + +assert.throws(TypeError, function() { + return accessor.get.arguments; +}); + +assert.throws(TypeError, function() { + accessor.get.arguments = {}; +}); + +// --- Test setter restricted properties throw + +assert.throws(TypeError, function() { + return accessor.set.caller; +}); + +assert.throws(TypeError, function() { + accessor.set.caller = {}; +}); + +assert.throws(TypeError, function() { + return accessor.set.arguments; +}); + +assert.throws(TypeError, function() { + accessor.set.arguments = {}; +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/definition/methods.js b/js/src/tests/test262/language/statements/class/definition/methods.js new file mode 100644 index 0000000000..66ad98189a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/definition/methods.js @@ -0,0 +1,34 @@ +// Copyright (C) 2014 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.5 +description: > + class methods +---*/ +function assertMethodDescriptor(object, name) { + var desc = Object.getOwnPropertyDescriptor(object, name); + assert.sameValue(desc.configurable, true, "The value of `desc.configurable` is `true`"); + assert.sameValue(desc.enumerable, false, "The value of `desc.enumerable` is `false`"); + assert.sameValue(desc.writable, true, "The value of `desc.writable` is `true`"); + assert.sameValue(typeof desc.value, 'function', "`typeof desc.value` is `'function'`"); + assert.sameValue('prototype' in desc.value, false, "The result of `'prototype' in desc.value` is `false`"); +} + +class C { + method() { return 1; } + static staticMethod() { return 2; } + method2() { return 3; } + static staticMethod2() { return 4; } +} + +assertMethodDescriptor(C.prototype, 'method'); +assertMethodDescriptor(C.prototype, 'method2'); +assertMethodDescriptor(C, 'staticMethod'); +assertMethodDescriptor(C, 'staticMethod2'); + +assert.sameValue(new C().method(), 1, "`new C().method()` returns `1`. Defined as `method() { return 1; }`"); +assert.sameValue(C.staticMethod(), 2, "`C.staticMethod()` returns `2`. Defined as `static staticMethod() { return 2; }`"); +assert.sameValue(new C().method2(), 3, "`new C().method2()` returns `3`. Defined as `method2() { return 3; }`"); +assert.sameValue(C.staticMethod2(), 4, "`C.staticMethod2()` returns `4`. Defined as `static staticMethod2() { return 4; }`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/definition/numeric-property-names.js b/js/src/tests/test262/language/statements/class/definition/numeric-property-names.js new file mode 100644 index 0000000000..f974c11a88 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/definition/numeric-property-names.js @@ -0,0 +1,65 @@ +// Copyright (C) 2014 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.5 +description: > + class numeric property names +---*/ +function assertMethodDescriptor(object, name) { + var desc = Object.getOwnPropertyDescriptor(object, name); + assert.sameValue(desc.configurable, true, "The value of `desc.configurable` is `true`"); + assert.sameValue(desc.enumerable, false, "The value of `desc.enumerable` is `false`"); + assert.sameValue(desc.writable, true, "The value of `desc.writable` is `true`"); + assert.sameValue(typeof desc.value, 'function', "`typeof desc.value` is `'function'`"); + assert.sameValue('prototype' in desc.value, false, "The result of `'prototype' in desc.value` is `false`"); +} + +function assertGetterDescriptor(object, name) { + var desc = Object.getOwnPropertyDescriptor(object, name); + assert.sameValue(desc.configurable, true, "The value of `desc.configurable` is `true`"); + assert.sameValue(desc.enumerable, false, "The value of `desc.enumerable` is `false`"); + assert.sameValue(typeof desc.get, 'function', "`typeof desc.get` is `'function'`"); + assert.sameValue('prototype' in desc.get, false, "The result of `'prototype' in desc.get` is `false`"); + assert.sameValue(desc.set, undefined, "The value of `desc.set` is `undefined`"); +} + +function assertSetterDescriptor(object, name) { + var desc = Object.getOwnPropertyDescriptor(object, name); + assert.sameValue(desc.configurable, true, "The value of `desc.configurable` is `true`"); + assert.sameValue(desc.enumerable, false, "The value of `desc.enumerable` is `false`"); + assert.sameValue(typeof desc.set, 'function', "`typeof desc.set` is `'function'`"); + assert.sameValue('prototype' in desc.set, false, "The result of `'prototype' in desc.set` is `false`"); + assert.sameValue(desc.get, undefined, "The value of `desc.get` is `undefined`"); +} + +class B { + 1() { return 1; } + get 2() { return 2; } + set 3(_) {} + + static 4() { return 4; } + static get 5() { return 5; } + static set 6(_) {} +} + +assertMethodDescriptor(B.prototype, '1'); +assertGetterDescriptor(B.prototype, '2'); +assertSetterDescriptor(B.prototype, '3'); + +assertMethodDescriptor(B, '4'); +assertGetterDescriptor(B, '5'); +assertSetterDescriptor(B, '6'); + +class C extends B { + 1() { return super[1](); } + get 2() { return super[2]; } + static 4() { return super[4](); } + static get 5() { return super[5]; } +} + +assert.sameValue(new C()[1](), 1, "`new C()[1]()` returns `1`. Defined as `1() { return super[1](); }`"); +assert.sameValue(new C()[2], 2, "The value of `new C()[2]` is `2`. Defined as `get 2() { return super[2]; }`"); +assert.sameValue(C[4](), 4, "`C[4]()` returns `4`. Defined as `static 4() { return super[4](); }`"); +assert.sameValue(C[5], 5, "The value of `C[5]` is `5`. Defined as `static get 5() { return super[5]; }`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/definition/prototype-getter.js b/js/src/tests/test262/language/statements/class/definition/prototype-getter.js new file mode 100644 index 0000000000..cbfe6ac1b7 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/definition/prototype-getter.js @@ -0,0 +1,33 @@ +// Copyright (C) 2014 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.5 +description: > + class prototype getter +---*/ +var calls = 0; +var Base = function() {}.bind(); +Object.defineProperty(Base, 'prototype', { + get: function() { + calls++; + return null; + }, + configurable: true +}); +class C extends Base {} +assert.sameValue(calls, 1, "The value of `calls` is `1`"); + +calls = 0; +Object.defineProperty(Base, 'prototype', { + get: function() { + calls++; + return 42; + }, + configurable: true +}); +assert.throws(TypeError, function() { + class C extends Base {} +}); +assert.sameValue(calls, 1, "The value of `calls` is `1`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/definition/prototype-property.js b/js/src/tests/test262/language/statements/class/definition/prototype-property.js new file mode 100644 index 0000000000..1c9110ca04 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/definition/prototype-property.js @@ -0,0 +1,14 @@ +// Copyright (C) 2014 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.5 +description: > + class prototype property +---*/ +class C {} +var descr = Object.getOwnPropertyDescriptor(C, 'prototype'); +assert.sameValue(descr.configurable, false, "The value of `descr.configurable` is `false`"); +assert.sameValue(descr.enumerable, false, "The value of `descr.enumerable` is `false`"); +assert.sameValue(descr.writable, false, "The value of `descr.writable` is `false`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/definition/prototype-setter.js b/js/src/tests/test262/language/statements/class/definition/prototype-setter.js new file mode 100644 index 0000000000..f6618c5a9c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/definition/prototype-setter.js @@ -0,0 +1,18 @@ +// Copyright (C) 2014 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.5 +description: > + class prototype setter +---*/ +var Base = function() {}.bind(); +Object.defineProperty(Base, 'prototype', { + set: function() { + throw new Test262Error("Cannot create a setter property named `prototype`"); + } +}); +assert.throws(TypeError, function() { + class C extends Base {} +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/definition/prototype-wiring.js b/js/src/tests/test262/language/statements/class/definition/prototype-wiring.js new file mode 100644 index 0000000000..608bde0586 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/definition/prototype-wiring.js @@ -0,0 +1,75 @@ +// Copyright (C) 2014 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.5 +description: > + class prototype wiring +---*/ + +class Base { + constructor(x) { + this.foobar = x; + } +} + +class Subclass extends Base { + constructor(x) { + super(x); + } +} + +var s = new Subclass(1); +assert.sameValue(s.foobar, 1, "The value of `s.foobar` is `1`"); +assert.sameValue( + Object.getPrototypeOf(s), + Subclass.prototype, + "`Object.getPrototypeOf(s)` returns `Subclass.prototype`" +); + +var s1 = new Subclass(1, 2); +assert.sameValue(s1.foobar, 1, "The value of `s1.foobar` is `1`"); +assert.sameValue( + Object.getPrototypeOf(s1) === Subclass.prototype, + true, + "The result of `Object.getPrototypeOf(s1) === Subclass.prototype` is `true`" +); + +var s2 = new Subclass(); +assert.sameValue(s2.foobar, undefined, "The value of `s2.foobar` is `undefined`"); +assert.sameValue( + Object.getPrototypeOf(s2), + Subclass.prototype, + "`Object.getPrototypeOf(s2)` returns `Subclass.prototype`" +); +assert.throws(TypeError, function() { Subclass(1); }); +assert.throws(TypeError, function() { Subclass(1,2,3,4); }); + +class Subclass2 extends Subclass { + constructor() { + super(5, 6, 7); + } +} + +var ss2 = new Subclass2(); +assert.sameValue(ss2.foobar, 5, "The value of `ss2.foobar` is `5`"); +assert.sameValue( + Object.getPrototypeOf(ss2), + Subclass2.prototype, + "`Object.getPrototypeOf(ss2)` returns `Subclass2.prototype`" +); + +class Subclass3 extends Base { + constructor(x, y) { + super(x + y); + } +} + +var ss3 = new Subclass3(27,42-27); +assert.sameValue(ss3.foobar, 42, "The value of `ss3.foobar` is `42`"); +assert.sameValue( + Object.getPrototypeOf(ss3), + Subclass3.prototype, + "`Object.getPrototypeOf(ss3)` returns `Subclass3.prototype`" +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/definition/setters-non-configurable-err.js b/js/src/tests/test262/language/statements/class/definition/setters-non-configurable-err.js new file mode 100644 index 0000000000..69e2dac8e6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/definition/setters-non-configurable-err.js @@ -0,0 +1,19 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-method-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.3.9 +description: Failure to define property for static method +info: | + [...] + 8. Let desc be the PropertyDescriptor{[[Set]]: closure, [[Enumerable]]: + enumerable, [[Configurable]]: true}. + 9. Return ? DefinePropertyOrThrow(object, propKey, desc). +features: [generators] +---*/ + +assert.throws(TypeError, function() { + class C { static set ['prototype'](_) {} } +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/definition/setters-prop-desc.js b/js/src/tests/test262/language/statements/class/definition/setters-prop-desc.js new file mode 100644 index 0000000000..46b2e0a3c7 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/definition/setters-prop-desc.js @@ -0,0 +1,41 @@ +// Copyright (C) 2014 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-class-definitions +es6id: 14.5 +description: Class methods - "set" accessors +includes: [propertyHelper.js] +---*/ + +function assertSetterDescriptor(object, name) { + var descr = Object.getOwnPropertyDescriptor(object, name); + verifyNotEnumerable(object, name); + verifyConfigurable(object, name); + assert.sameValue(typeof descr.set, 'function', "`typeof descr.set` is `'function'`"); + assert.sameValue('prototype' in descr.set, false, "The result of `'prototype' in descr.set` is `false`"); + assert.sameValue(descr.get, undefined, "The value of `descr.get` is `undefined`"); +} + +var x, staticX, y, staticY; +class C { + set x(v) { x = v; } + static set staticX(v) { staticX = v; } + set y(v) { y = v; } + static set staticY(v) { staticY = v; } +} + +assert.sameValue(new C().x = 1, 1, "`new C().x = 1` is `1`"); +assert.sameValue(x, 1, "The value of `x` is `1`"); +assert.sameValue(C.staticX = 2, 2, "`C.staticX = 2` is `2`"); +assert.sameValue(staticX, 2, "The value of `staticX` is `2`"); +assert.sameValue(new C().y = 3, 3, "`new C().y = 3` is `3`"); +assert.sameValue(y, 3, "The value of `y` is `3`"); +assert.sameValue(C.staticY = 4, 4, "`C.staticY = 4` is `4`"); +assert.sameValue(staticY, 4, "The value of `staticY` is `4`"); + +assertSetterDescriptor(C.prototype, 'x'); +assertSetterDescriptor(C.prototype, 'y'); +assertSetterDescriptor(C, 'staticX'); +assertSetterDescriptor(C, 'staticY'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/definition/setters-restricted-ids.js b/js/src/tests/test262/language/statements/class/definition/setters-restricted-ids.js new file mode 100644 index 0000000000..9e2e3c69b9 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/definition/setters-restricted-ids.js @@ -0,0 +1,33 @@ +// Copyright (C) 2014 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.5 +description: > + class setters 2 +---*/ +var x = 0; +class C { + set eval(v) { + x = v; + } + set arguments(v) { + x = v; + } + static set eval(v) { + x = v; + } + static set arguments(v) { + x = v; + } +}; + +new C().eval = 1; +assert.sameValue(x, 1, "The value of `x` is `1`"); +new C().arguments = 2; +assert.sameValue(x, 2, "The value of `x` is `2`"); +C.eval = 3; +assert.sameValue(x, 3, "The value of `x` is `3`"); +C.arguments = 4; +assert.sameValue(x, 4, "The value of `x` is `4`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/definition/shell.js b/js/src/tests/test262/language/statements/class/definition/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/definition/side-effects-in-extends.js b/js/src/tests/test262/language/statements/class/definition/side-effects-in-extends.js new file mode 100644 index 0000000000..bdbd255ef9 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/definition/side-effects-in-extends.js @@ -0,0 +1,20 @@ +// Copyright (C) 2014 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.5 +description: > + class side effect in extends +---*/ +var calls = 0; +class C {} +class D extends (calls++, C) {} +assert.sameValue(calls, 1, "The value of `calls` is `1`"); +assert.sameValue(typeof D, 'function', "`typeof D` is `'function'`"); +assert.sameValue(Object.getPrototypeOf(D), C, "`Object.getPrototypeOf(D)` returns `C`"); +assert.sameValue( + C.prototype, + Object.getPrototypeOf(D.prototype), + "The value of `C.prototype` is `Object.getPrototypeOf(D.prototype)`" +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/definition/side-effects-in-property-define.js b/js/src/tests/test262/language/statements/class/definition/side-effects-in-property-define.js new file mode 100644 index 0000000000..616797b19b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/definition/side-effects-in-property-define.js @@ -0,0 +1,22 @@ +// Copyright (C) 2014 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.5 +description: > + class side effects in property define +---*/ +function B() {} +B.prototype = { + constructor: B, + set m(v) { + throw Error(); + } +}; + +class C extends B { + m() { return 1; } +} + +assert.sameValue(new C().m(), 1, "`new C().m()` returns `1`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/definition/this-access-restriction-2.js b/js/src/tests/test262/language/statements/class/definition/this-access-restriction-2.js new file mode 100644 index 0000000000..e1f855aa1c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/definition/this-access-restriction-2.js @@ -0,0 +1,90 @@ +// Copyright (C) 2014 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.5 +description: > + class this access restriction 2 +---*/ +class Base { + constructor(a, b) { + var o = new Object(); + o.prp = a + b; + return o; + } +} + +class Subclass extends Base { + constructor(a, b) { + var exn; + try { + this.prp1 = 3; + } catch (e) { + exn = e; + } + assert.sameValue( + exn instanceof ReferenceError, + true, + "The result of `exn instanceof ReferenceError` is `true`" + ); + super(a, b); + assert.sameValue(this.prp, a + b, "The value of `this.prp` is `a + b`"); + assert.sameValue(this.prp1, undefined, "The value of `this.prp1` is `undefined`"); + assert.sameValue( + this.hasOwnProperty("prp1"), + false, + "`this.hasOwnProperty(\"prp1\")` returns `false`" + ); + return this; + } +} + +var b = new Base(1, 2); +assert.sameValue(b.prp, 3, "The value of `b.prp` is `3`"); + + +var s = new Subclass(2, -1); +assert.sameValue(s.prp, 1, "The value of `s.prp` is `1`"); +assert.sameValue(s.prp1, undefined, "The value of `s.prp1` is `undefined`"); +assert.sameValue( + s.hasOwnProperty("prp1"), + false, + "`s.hasOwnProperty(\"prp1\")` returns `false`" +); + +class Subclass2 extends Base { + constructor(x) { + super(1,2); + + if (x < 0) return; + + var called = false; + function tmp() { called = true; return 3; } + var exn = null; + try { + super(tmp(),4); + } catch (e) { exn = e; } + assert.sameValue( + exn instanceof ReferenceError, + true, + "The result of `exn instanceof ReferenceError` is `true`" + ); + assert.sameValue(called, true, "The value of `called` is `true`"); + } +} + +var s2 = new Subclass2(1); +assert.sameValue(s2.prp, 3, "The value of `s2.prp` is `3`"); + +var s3 = new Subclass2(-1); +assert.sameValue(s3.prp, 3, "The value of `s3.prp` is `3`"); + +assert.throws(TypeError, function() { Subclass.call(new Object(), 1, 2); }); +assert.throws(TypeError, function() { Base.call(new Object(), 1, 2); }); + +class BadSubclass extends Base { + constructor() {} +} + +assert.throws(ReferenceError, function() { new BadSubclass(); }); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/definition/this-access-restriction.js b/js/src/tests/test262/language/statements/class/definition/this-access-restriction.js new file mode 100644 index 0000000000..ce13e6a343 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/definition/this-access-restriction.js @@ -0,0 +1,100 @@ +// Copyright (C) 2014 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.5 +description: > + class this access restriction +---*/ +class Base {} +(function() { + class C extends Base { + constructor() { + var y; + super(); + } + }; new C(); +}()); +assert.throws(ReferenceError, function() { + class C extends Base { + constructor() { + super(this.x); + } + }; new C(); +}); +assert.throws(ReferenceError, function() { + class C extends Base { + constructor() { + super(this); + } + }; new C(); +}); +assert.throws(ReferenceError, function() { + class C extends Base { + constructor() { + super.method(); + super(this); + } + }; new C(); +}); +assert.throws(ReferenceError, function() { + class C extends Base { + constructor() { + super(super.method()); + } + }; new C(); +}); +assert.throws(ReferenceError, function() { + class C extends Base { + constructor() { + super(super()); + } + }; new C(); +}); +assert.throws(ReferenceError, function() { + class C extends Base { + constructor() { + super(1, 2, Object.getPrototypeOf(this)); + } + }; new C(); +}); +(function() { + class C extends Base { + constructor() { + { super(1, 2); } + } + }; new C(); +}()); +(function() { + class C extends Base { + constructor() { + if (1) super(); + } + }; new C(); +}()); + +class C1 extends Object { + constructor() { + 'use strict'; + super(); + } +}; +new C1(); + +class C2 extends Object { + constructor() { + ; 'use strict';;;;; + super(); + } +}; +new C2(); + +class C3 extends Object { + constructor() { + ; 'use strict';;;;; + // This is a comment. + super(); + } +}; +new C3(); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/definition/this-check-ordering.js b/js/src/tests/test262/language/statements/class/definition/this-check-ordering.js new file mode 100644 index 0000000000..c7f867db9b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/definition/this-check-ordering.js @@ -0,0 +1,72 @@ +// Copyright (C) 2014 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.5 +description: > + class this check ordering +---*/ +var baseCalled = 0; +class Base { + constructor() { baseCalled++ } +} + +var fCalled = 0; +function f() { fCalled++; return 3; } + +class Subclass1 extends Base { + constructor() { + baseCalled = 0; + super(); + assert.sameValue(baseCalled, 1, "The value of `baseCalled` is `1`"); + var obj = this; + + var exn = null; + baseCalled = 0; + fCalled = 0; + try { + super(f()); + } catch (e) { exn = e; } + assert.sameValue( + exn instanceof ReferenceError, + true, + "The result of `exn instanceof ReferenceError` is `true`" + ); + assert.sameValue(fCalled, 1, "The value of `fCalled` is `1`"); + assert.sameValue(baseCalled, 1, "The value of `baseCalled` is `1`"); + assert.sameValue(this, obj, "`this` is `obj`"); + + exn = null; + baseCalled = 0; + fCalled = 0; + try { + super(super(), f()); + } catch (e) { exn = e; } + assert.sameValue( + exn instanceof ReferenceError, + true, + "The result of `exn instanceof ReferenceError` is `true`" + ); + assert.sameValue(fCalled, 0, "The value of `fCalled` is `0`"); + assert.sameValue(baseCalled, 1, "The value of `baseCalled` is `1`"); + assert.sameValue(this, obj, "`this` is `obj`"); + + exn = null; + baseCalled = 0; + fCalled = 0; + try { + super(f(), super()); + } catch (e) { exn = e; } + assert.sameValue( + exn instanceof ReferenceError, + true, + "The result of `exn instanceof ReferenceError` is `true`" + ); + assert.sameValue(fCalled, 1, "The value of `fCalled` is `1`"); + assert.sameValue(baseCalled, 1, "The value of `baseCalled` is `1`"); + assert.sameValue(this, obj, "`this` is `obj`"); + } +} + +new Subclass1(); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-init-iter-close.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-init-iter-close.js new file mode 100644 index 0000000000..e52d69ed69 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-init-iter-close.js @@ -0,0 +1,78 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-close.case +// - src/dstr-binding/default/cls-decl-async-gen-meth.template +/*--- +description: Iterator is closed when not exhausted by pattern evaluation (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [Symbol.iterator, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: false }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + + +var callCount = 0; +class C { + async *method([x]) { + assert.sameValue(doneCallCount, 1); + callCount = callCount + 1; + } +}; + +new C().method(iter).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-init-iter-get-err-array-prototype.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-init-iter-get-err-array-prototype.js new file mode 100644 index 0000000000..ce97457026 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-init-iter-get-err-array-prototype.js @@ -0,0 +1,73 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-get-err-array-prototype.case +// - src/dstr-binding/error/cls-decl-async-gen-meth.template +/*--- +description: Abrupt completion returned by GetIterator (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [Symbol.iterator, async-iteration] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iteratorRecord be ? GetIterator(value). + + GetIterator ( obj [ , hint [ , method ] ] ) + + [...] + 4. Let iterator be ? Call(method, obj). + + Call ( F, V [ , argumentsList ] ) + + [...] + 2. If IsCallable(F) is false, throw a TypeError exception. + +---*/ +delete Array.prototype[Symbol.iterator]; + + +class C { + async *method([x, y, z]) { + + } +}; + +var method = C.prototype.method; + +assert.throws(TypeError, function() { + method([1, 2, 3]); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-init-iter-get-err.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-init-iter-get-err.js new file mode 100644 index 0000000000..8c57224e66 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-init-iter-get-err.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-get-err.case +// - src/dstr-binding/error/cls-decl-async-gen-meth.template +/*--- +description: Abrupt completion returned by GetIterator (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [Symbol.iterator, async-iteration] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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(); +}; + + +class C { + async *method([x]) { + + } +}; + +var method = C.prototype.method; + +assert.throws(Test262Error, function() { + method(iter); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-init-iter-no-close.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-init-iter-no-close.js new file mode 100644 index 0000000000..171bf0f296 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-init-iter-no-close.js @@ -0,0 +1,78 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-no-close.case +// - src/dstr-binding/default/cls-decl-async-gen-meth.template +/*--- +description: Iterator is not closed when exhausted by pattern evaluation (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [Symbol.iterator, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: true }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + + +var callCount = 0; +class C { + async *method([x]) { + assert.sameValue(doneCallCount, 0); + callCount = callCount + 1; + } +}; + +new C().method(iter).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-name-iter-val.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-name-iter-val.js new file mode 100644 index 0000000000..60999d9c15 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-name-iter-val.js @@ -0,0 +1,77 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-name-iter-val.case +// - src/dstr-binding/default/cls-decl-async-gen-meth.template +/*--- +description: SingleNameBinding with normal value iteration (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +class C { + async *method([x, y, z]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; + } +}; + +new C().method([1, 2, 3]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-ary-elem-init.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-ary-elem-init.js new file mode 100644 index 0000000000..5b9c858723 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-ary-elem-init.js @@ -0,0 +1,69 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-init.case +// - src/dstr-binding/default/cls-decl-async-gen-meth.template +/*--- +description: BindingElement with array binding pattern and initializer is used (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + + +var callCount = 0; +class C { + async *method([[x, y, z] = [4, 5, 6]]) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + callCount = callCount + 1; + } +}; + +new C().method([]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-ary-elem-iter.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-ary-elem-iter.js new file mode 100644 index 0000000000..e05a3010b1 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-ary-elem-iter.js @@ -0,0 +1,70 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-iter.case +// - src/dstr-binding/default/cls-decl-async-gen-meth.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + + +var callCount = 0; +class C { + async *method([[x, y, z] = [4, 5, 6]]) { + assert.sameValue(x, 7); + assert.sameValue(y, 8); + assert.sameValue(z, 9); + callCount = callCount + 1; + } +}; + +new C().method([[7, 8, 9]]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-ary-elision-init.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-ary-elision-init.js new file mode 100644 index 0000000000..d428628e0d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-ary-elision-init.js @@ -0,0 +1,76 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-init.case +// - src/dstr-binding/default/cls-decl-async-gen-meth.template +/*--- +description: BindingElement with array binding pattern and initializer is used (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + + +var callCount = 0; +class C { + async *method([[,] = g()]) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; + } +}; + +new C().method([]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-ary-elision-iter.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-ary-elision-iter.js new file mode 100644 index 0000000000..58ea24c4a0 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-ary-elision-iter.js @@ -0,0 +1,73 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-iter.case +// - src/dstr-binding/default/cls-decl-async-gen-meth.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var callCount = 0; +function* g() { + callCount += 1; +}; + + +var callCount = 0; +class C { + async *method([[,] = g()]) { + assert.sameValue(callCount, 0); + callCount = callCount + 1; + } +}; + +new C().method([[]]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-ary-empty-init.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-ary-empty-init.js new file mode 100644 index 0000000000..4a26167874 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-ary-empty-init.js @@ -0,0 +1,72 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-init.case +// - src/dstr-binding/default/cls-decl-async-gen-meth.template +/*--- +description: BindingElement with array binding pattern and initializer is used (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var initCount = 0; +var iterCount = 0; +var iter = function*() { iterCount += 1; }(); + + +var callCount = 0; +class C { + async *method([[] = function() { initCount += 1; return iter; }()]) { + assert.sameValue(initCount, 1); + assert.sameValue(iterCount, 0); + callCount = callCount + 1; + } +}; + +new C().method([]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-ary-empty-iter.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-ary-empty-iter.js new file mode 100644 index 0000000000..d64ac8883f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-ary-empty-iter.js @@ -0,0 +1,69 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-iter.case +// - src/dstr-binding/default/cls-decl-async-gen-meth.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var initCount = 0; + + +var callCount = 0; +class C { + async *method([[] = function() { initCount += 1; }()]) { + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +new C().method([[23]]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-ary-rest-init.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-ary-rest-init.js new file mode 100644 index 0000000000..9bb20c8f84 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-ary-rest-init.js @@ -0,0 +1,73 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-init.case +// - src/dstr-binding/default/cls-decl-async-gen-meth.template +/*--- +description: BindingElement with array binding pattern and initializer is used (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; + + +var callCount = 0; +class C { + async *method([[...x] = values]) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + callCount = callCount + 1; + } +}; + +new C().method([]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-ary-rest-iter.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-ary-rest-iter.js new file mode 100644 index 0000000000..41e2ce249d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-ary-rest-iter.js @@ -0,0 +1,76 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-iter.case +// - src/dstr-binding/default/cls-decl-async-gen-meth.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; +var initCount = 0; + + +var callCount = 0; +class C { + async *method([[...x] = function() { initCount += 1; }()]) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +new C().method([values]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-ary-val-null.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-ary-val-null.js new file mode 100644 index 0000000000..29f41a0e69 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-ary-val-null.js @@ -0,0 +1,74 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-val-null.case +// - src/dstr-binding/error/cls-decl-async-gen-meth.template +/*--- +description: Nested array destructuring with a null value (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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). +---*/ + + +class C { + async *method([[x]]) { + + } +}; + +var method = C.prototype.method; + +assert.throws(TypeError, function() { + method([null]); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-id-init-exhausted.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-id-init-exhausted.js new file mode 100644 index 0000000000..0540907fe6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-id-init-exhausted.js @@ -0,0 +1,68 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-exhausted.case +// - src/dstr-binding/default/cls-decl-async-gen-meth.template +/*--- +description: Destructuring initializer with an exhausted iterator (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +class C { + async *method([x = 23]) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } +}; + +new C().method([]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-id-init-fn-name-arrow.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..04ec410fa8 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-id-init-fn-name-arrow.js @@ -0,0 +1,69 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-arrow.case +// - src/dstr-binding/default/cls-decl-async-gen-meth.template +/*--- +description: SingleNameBinding does assign name to arrow functions (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +class C { + async *method([arrow = () => {}]) { + assert.sameValue(arrow.name, 'arrow'); + callCount = callCount + 1; + } +}; + +new C().method([]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-id-init-fn-name-class.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-id-init-fn-name-class.js new file mode 100644 index 0000000000..a29b23a43c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-id-init-fn-name-class.js @@ -0,0 +1,71 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-class.case +// - src/dstr-binding/default/cls-decl-async-gen-meth.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +class C { + async *method([cls = class {}, xCls = class X {}, xCls2 = class { static name() {} }]) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + assert.notSameValue(xCls2.name, 'xCls2'); + callCount = callCount + 1; + } +}; + +new C().method([]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-id-init-fn-name-cover.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-id-init-fn-name-cover.js new file mode 100644 index 0000000000..63a66a6cb7 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-id-init-fn-name-cover.js @@ -0,0 +1,70 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-cover.case +// - src/dstr-binding/default/cls-decl-async-gen-meth.template +/*--- +description: SingleNameBinding does assign name to "anonymous" functions "through" cover grammar (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +class C { + async *method([cover = (function () {}), xCover = (0, function() {})]) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + callCount = callCount + 1; + } +}; + +new C().method([]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-id-init-fn-name-fn.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-id-init-fn-name-fn.js new file mode 100644 index 0000000000..67cb08e087 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-id-init-fn-name-fn.js @@ -0,0 +1,70 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-fn.case +// - src/dstr-binding/default/cls-decl-async-gen-meth.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +class C { + async *method([fn = function () {}, xFn = function x() {}]) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + callCount = callCount + 1; + } +}; + +new C().method([]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-id-init-fn-name-gen.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-id-init-fn-name-gen.js new file mode 100644 index 0000000000..901fc42146 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-id-init-fn-name-gen.js @@ -0,0 +1,71 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-gen.case +// - src/dstr-binding/default/cls-decl-async-gen-meth.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). + +---*/ + + +var callCount = 0; +class C { + async *method([gen = function* () {}, xGen = function* x() {}]) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + callCount = callCount + 1; + } +}; + +new C().method([]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-id-init-hole.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-id-init-hole.js new file mode 100644 index 0000000000..601e2a9aab --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-id-init-hole.js @@ -0,0 +1,64 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-hole.case +// - src/dstr-binding/default/cls-decl-async-gen-meth.template +/*--- +description: Destructuring initializer with a "hole" (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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). + [...] + 7. If environment is undefined, return PutValue(lhs, v). 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +class C { + async *method([x = 23]) { + assert.sameValue(x, 23); + // another statement + callCount = callCount + 1; + } +}; + +new C().method([,]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-id-init-skipped.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-id-init-skipped.js new file mode 100644 index 0000000000..42ee26b072 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-id-init-skipped.js @@ -0,0 +1,73 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-skipped.case +// - src/dstr-binding/default/cls-decl-async-gen-meth.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + + +var callCount = 0; +class C { + async *method([w = counter(), x = counter(), y = counter(), z = counter()]) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +new C().method([null, 0, false, '']).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-id-init-throws.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-id-init-throws.js new file mode 100644 index 0000000000..4c3b3bd5d8 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-id-init-throws.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-throws.case +// - src/dstr-binding/error/cls-decl-async-gen-meth.template +/*--- +description: Destructuring initializer returns an abrupt completion (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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). +---*/ + + +class C { + async *method([x = (function() { throw new Test262Error(); })()]) { + + } +}; + +var method = C.prototype.method; + +assert.throws(Test262Error, function() { + method([undefined]); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-id-init-undef.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-id-init-undef.js new file mode 100644 index 0000000000..113dd7e7f4 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-id-init-undef.js @@ -0,0 +1,67 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-undef.case +// - src/dstr-binding/default/cls-decl-async-gen-meth.template +/*--- +description: Destructuring initializer with an undefined value (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +class C { + async *method([x = 23]) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } +}; + +new C().method([undefined]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-id-init-unresolvable.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-id-init-unresolvable.js new file mode 100644 index 0000000000..516c834aaa --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-id-init-unresolvable.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-unresolvable.case +// - src/dstr-binding/error/cls-decl-async-gen-meth.template +/*--- +description: Destructuring initializer is an unresolvable reference (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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. +---*/ + + +class C { + async *method([ x = unresolvableReference ]) { + + } +}; + +var method = C.prototype.method; + +assert.throws(ReferenceError, function() { + method([]); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-id-iter-complete.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-id-iter-complete.js new file mode 100644 index 0000000000..bb03bdbfb6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-id-iter-complete.js @@ -0,0 +1,71 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-complete.case +// - src/dstr-binding/default/cls-decl-async-gen-meth.template +/*--- +description: SingleNameBinding when value iteration completes (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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, + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +class C { + async *method([x]) { + assert.sameValue(x, undefined); + callCount = callCount + 1; + } +}; + +new C().method([]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-id-iter-done.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-id-iter-done.js new file mode 100644 index 0000000000..1d2e7bbc2f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-id-iter-done.js @@ -0,0 +1,66 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-done.case +// - src/dstr-binding/default/cls-decl-async-gen-meth.template +/*--- +description: SingleNameBinding when value iteration was completed previously (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +class C { + async *method([_, x]) { + assert.sameValue(x, undefined); + callCount = callCount + 1; + } +}; + +new C().method([]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-id-iter-step-err.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-id-iter-step-err.js new file mode 100644 index 0000000000..c8c823b57d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-id-iter-step-err.js @@ -0,0 +1,74 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-step-err.case +// - src/dstr-binding/error/cls-decl-async-gen-meth.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [Symbol.iterator, async-iteration] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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(); + } + }; +}; + + +class C { + async *method([x]) { + + } +}; + +var method = C.prototype.method; + +assert.throws(Test262Error, function() { + method(g); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-id-iter-val-array-prototype.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-id-iter-val-array-prototype.js new file mode 100644 index 0000000000..ea17e8512f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-id-iter-val-array-prototype.js @@ -0,0 +1,87 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val-array-prototype.case +// - src/dstr-binding/default/cls-decl-async-gen-meth.template +/*--- +description: Array destructuring uses overriden Array.prototype[Symbol.iterator] (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [Symbol.iterator, generators, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializer_opt + + 1. Let bindingId be StringValue of BindingIdentifier. + 2. Let lhs be ? ResolveBinding(bindingId, environment). + 3. If iteratorRecord.[[Done]] is false, then + a. Let next be IteratorStep(iteratorRecord). + 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). + [...] + 7. Return InitializeReferencedBinding(lhs, v). + +---*/ +Array.prototype[Symbol.iterator] = function* () { + if (this.length > 0) { + yield this[0]; + } + if (this.length > 1) { + yield this[1]; + } + if (this.length > 2) { + yield 42; + } +}; + + +var callCount = 0; +class C { + async *method([x, y, z]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 42); + callCount = callCount + 1; + } +}; + +new C().method([1, 2, 3]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-id-iter-val-err.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-id-iter-val-err.js new file mode 100644 index 0000000000..402298502a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-id-iter-val-err.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val-err.case +// - src/dstr-binding/error/cls-decl-async-gen-meth.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [Symbol.iterator, async-iteration] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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; + } + }; +}; + + +class C { + async *method([x]) { + + } +}; + +var method = C.prototype.method; + +assert.throws(Test262Error, function() { + method(g); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-id-iter-val.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-id-iter-val.js new file mode 100644 index 0000000000..c2f1cfafea --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-id-iter-val.js @@ -0,0 +1,77 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val.case +// - src/dstr-binding/default/cls-decl-async-gen-meth.template +/*--- +description: SingleNameBinding when value iteration was completed previously (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +class C { + async *method([x, y, z]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; + } +}; + +new C().method([1, 2, 3]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-obj-id-init.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-obj-id-init.js new file mode 100644 index 0000000000..553277bde1 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-obj-id-init.js @@ -0,0 +1,69 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id-init.case +// - src/dstr-binding/default/cls-decl-async-gen-meth.template +/*--- +description: BindingElement with object binding pattern and initializer is used (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + + +var callCount = 0; +class C { + async *method([{ x, y, z } = { x: 44, y: 55, z: 66 }]) { + assert.sameValue(x, 44); + assert.sameValue(y, 55); + assert.sameValue(z, 66); + callCount = callCount + 1; + } +}; + +new C().method([]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-obj-id.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-obj-id.js new file mode 100644 index 0000000000..5f738e9357 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-obj-id.js @@ -0,0 +1,69 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id.case +// - src/dstr-binding/default/cls-decl-async-gen-meth.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + + +var callCount = 0; +class C { + async *method([{ x, y, z } = { x: 44, y: 55, z: 66 }]) { + assert.sameValue(x, 11); + assert.sameValue(y, 22); + assert.sameValue(z, 33); + callCount = callCount + 1; + } +}; + +new C().method([{ x: 11, y: 22, z: 33 }]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-obj-prop-id-init.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-obj-prop-id-init.js new file mode 100644 index 0000000000..6a1328ba7e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-obj-prop-id-init.js @@ -0,0 +1,79 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id-init.case +// - src/dstr-binding/default/cls-decl-async-gen-meth.template +/*--- +description: BindingElement with object binding pattern and initializer is used (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + + +var callCount = 0; +class C { + async *method([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }]) { + assert.sameValue(v, 444); + assert.sameValue(x, 555); + assert.sameValue(z, 666); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } +}; + +new C().method([]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-obj-prop-id.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-obj-prop-id.js new file mode 100644 index 0000000000..61f05a2259 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-obj-prop-id.js @@ -0,0 +1,79 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id.case +// - src/dstr-binding/default/cls-decl-async-gen-meth.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + + +var callCount = 0; +class C { + async *method([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }]) { + assert.sameValue(v, 777); + assert.sameValue(x, 888); + assert.sameValue(z, 999); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } +}; + +new C().method([{ u: 777, w: 888, y: 999 }]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-obj-val-null.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-obj-val-null.js new file mode 100644 index 0000000000..9ab8b92d34 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-obj-val-null.js @@ -0,0 +1,74 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-null.case +// - src/dstr-binding/error/cls-decl-async-gen-meth.template +/*--- +description: Nested object destructuring with a null value (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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). +---*/ + + +class C { + async *method([{ x }]) { + + } +}; + +var method = C.prototype.method; + +assert.throws(TypeError, function() { + method([null]); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-obj-val-undef.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-obj-val-undef.js new file mode 100644 index 0000000000..2b20e89eac --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elem-obj-val-undef.js @@ -0,0 +1,74 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-undef.case +// - src/dstr-binding/error/cls-decl-async-gen-meth.template +/*--- +description: Nested object destructuring with a value of `undefined` (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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). +---*/ + + +class C { + async *method([{ x }]) { + + } +}; + +var method = C.prototype.method; + +assert.throws(TypeError, function() { + method([]); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elision-exhausted.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elision-exhausted.js new file mode 100644 index 0000000000..a1bdac3020 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elision-exhausted.js @@ -0,0 +1,74 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-exhausted.case +// - src/dstr-binding/default/cls-decl-async-gen-meth.template +/*--- +description: Elision accepts exhausted iterator (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 + [...] + 2. Return NormalCompletion(empty). + +---*/ +var iter = function*() {}(); +iter.next(); + + +var callCount = 0; +class C { + async *method([,]) { + + callCount = callCount + 1; + } +}; + +new C().method(iter).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elision-step-err.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elision-step-err.js new file mode 100644 index 0000000000..457de21945 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elision-step-err.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-step-err.case +// - src/dstr-binding/error/cls-decl-async-gen-meth.template +/*--- +description: Elision advances iterator and forwards abrupt completions (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, async-iteration] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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; +}(); + + +class C { + async *method([,]) { + + } +}; + +var method = C.prototype.method; + +assert.throws(Test262Error, function() { + method(iter); +}); + +iter.next(); +assert.sameValue(following, 0, 'Iterator was properly closed.'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elision.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elision.js new file mode 100644 index 0000000000..1a0920e99f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-elision.js @@ -0,0 +1,83 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision.case +// - src/dstr-binding/default/cls-decl-async-gen-meth.template +/*--- +description: Elision advances iterator (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + + +var callCount = 0; +class C { + async *method([,]) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; + } +}; + +new C().method(g()).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-empty.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-empty.js new file mode 100644 index 0000000000..b6566e2cc3 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-empty.js @@ -0,0 +1,66 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-empty.case +// - src/dstr-binding/default/cls-decl-async-gen-meth.template +/*--- +description: No iteration occurs for an "empty" array binding pattern (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + + +var callCount = 0; +class C { + async *method([]) { + assert.sameValue(iterations, 0); + callCount = callCount + 1; + } +}; + +new C().method(iter).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-rest-ary-elem.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-rest-ary-elem.js new file mode 100644 index 0000000000..e81767de0a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-rest-ary-elem.js @@ -0,0 +1,90 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elem.case +// - src/dstr-binding/default/cls-decl-async-gen-meth.template +/*--- +description: Rest element containing an array BindingElementList pattern (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the 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). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +class C { + async *method([...[x, y, z]]) { + assert.sameValue(x, 3); + assert.sameValue(y, 4); + assert.sameValue(z, 5); + callCount = callCount + 1; + } +}; + +new C().method([3, 4, 5]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-rest-ary-elision.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-rest-ary-elision.js new file mode 100644 index 0000000000..36d6da2178 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-rest-ary-elision.js @@ -0,0 +1,96 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elision.case +// - src/dstr-binding/default/cls-decl-async-gen-meth.template +/*--- +description: Rest element containing an elision (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the 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). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + + +var callCount = 0; +class C { + async *method([...[,]]) { + assert.sameValue(first, 1); + assert.sameValue(second, 1); + callCount = callCount + 1; + } +}; + +new C().method(g()).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-rest-ary-empty.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-rest-ary-empty.js new file mode 100644 index 0000000000..8b2e2fa166 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-rest-ary-empty.js @@ -0,0 +1,79 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-empty.case +// - src/dstr-binding/default/cls-decl-async-gen-meth.template +/*--- +description: Rest element containing an "empty" array pattern (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + + +var callCount = 0; +class C { + async *method([...[]]) { + assert.sameValue(iterations, 1); + callCount = callCount + 1; + } +}; + +new C().method(iter).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-rest-ary-rest.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-rest-ary-rest.js new file mode 100644 index 0000000000..9b47ffc1c3 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-rest-ary-rest.js @@ -0,0 +1,75 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-rest.case +// - src/dstr-binding/default/cls-decl-async-gen-meth.template +/*--- +description: Rest element containing a rest element (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ +var values = [1, 2, 3]; + + +var callCount = 0; +class C { + async *method([...[...x]]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + + callCount = callCount + 1; + } +}; + +new C().method(values).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-rest-id-direct.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-rest-id-direct.js new file mode 100644 index 0000000000..7e6b33b674 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-rest-id-direct.js @@ -0,0 +1,70 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-direct.case +// - src/dstr-binding/default/cls-decl-async-gen-meth.template +/*--- +description: Lone rest element (direct binding) (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated, async] +includes: [compareArray.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingIdentifier + + [...] + 2. Let A be ! ArrayCreate(0). + 3. Let n be 0. + 4. Repeat, + [...] + f. Perform ! CreateDataPropertyOrThrow(A, ! ToString(n), nextValue). + g. Set n to n + 1. + +---*/ + + +var callCount = 0; +class C { + async *method([...x]) { + assert(Array.isArray(x)); + assert.compareArray(x, [1]); + callCount = callCount + 1; + } +}; + +new C().method([1]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-rest-id-elision-next-err.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-rest-id-elision-next-err.js new file mode 100644 index 0000000000..34e0f7161c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-rest-id-elision-next-err.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision-next-err.case +// - src/dstr-binding/error/cls-decl-async-gen-meth.template +/*--- +description: Rest element following elision elements (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, async-iteration] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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(); })(); + + +class C { + async *method([, ...x]) { + + } +}; + +var method = C.prototype.method; + +assert.throws(Test262Error, function() { + method(iter); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-rest-id-elision.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-rest-id-elision.js new file mode 100644 index 0000000000..0478749315 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-rest-id-elision.js @@ -0,0 +1,71 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision.case +// - src/dstr-binding/default/cls-decl-async-gen-meth.template +/*--- +description: Rest element following elision elements (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 values = [1, 2, 3, 4, 5]; + + +var callCount = 0; +class C { + async *method([ , , ...x]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 3); + assert.sameValue(x[1], 4); + assert.sameValue(x[2], 5); + assert.notSameValue(x, values); + callCount = callCount + 1; + } +}; + +new C().method(values).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-rest-id-exhausted.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-rest-id-exhausted.js new file mode 100644 index 0000000000..9eb02b9a14 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-rest-id-exhausted.js @@ -0,0 +1,67 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-exhausted.case +// - src/dstr-binding/default/cls-decl-async-gen-meth.template +/*--- +description: RestElement applied to an exhausted iterator (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [Symbol.iterator, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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, + [...] + b. If iteratorRecord.[[done]] is true, then + i. If environment is undefined, return PutValue(lhs, A). + ii. Return InitializeReferencedBinding(lhs, A). + +---*/ + + +var callCount = 0; +class C { + async *method([, , ...x]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 0); + callCount = callCount + 1; + } +}; + +new C().method([1, 2]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-rest-id-iter-step-err.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-rest-id-iter-step-err.js new file mode 100644 index 0000000000..da9cbda40a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-rest-id-iter-step-err.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-step-err.case +// - src/dstr-binding/error/cls-decl-async-gen-meth.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, async-iteration] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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; +}(); + + +class C { + async *method([...x]) { + + } +}; + +var method = C.prototype.method; + +assert.throws(Test262Error, function() { + method(iter); +}); + +iter.next(); +assert.sameValue(first, 1); +assert.sameValue(second, 0, 'Iterator is closed following abrupt completion.'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-rest-id-iter-val-err.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-rest-id-iter-val-err.js new file mode 100644 index 0000000000..0f712cf9a5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-rest-id-iter-val-err.js @@ -0,0 +1,80 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-val-err.case +// - src/dstr-binding/error/cls-decl-async-gen-meth.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [Symbol.iterator, async-iteration] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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; + } + }; +}; + + +class C { + async *method([...x]) { + + } +}; + +var method = C.prototype.method; + +assert.throws(Test262Error, function() { + method(iter); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-rest-id.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-rest-id.js new file mode 100644 index 0000000000..de0c817075 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-rest-id.js @@ -0,0 +1,68 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id.case +// - src/dstr-binding/default/cls-decl-async-gen-meth.template +/*--- +description: Lone rest element (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + [...] 3. Let A be ArrayCreate(0). [...] 5. Repeat + [...] + f. Let status be CreateDataProperty(A, ToString (n), nextValue). + [...] +---*/ +var values = [1, 2, 3]; + + +var callCount = 0; +class C { + async *method([...x]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + callCount = callCount + 1; + } +}; + +new C().method(values).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-rest-init-ary.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-rest-init-ary.js new file mode 100644 index 0000000000..ae4025e39e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-rest-init-ary.js @@ -0,0 +1,65 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-ary.case +// - src/dstr-binding/default/cls-decl-async-gen-meth.template +/*--- +description: Rest element (nested array pattern) does not support initializer (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + + +var callCount = 0; +class C { + async *method([...[ x ] = []]) { + + callCount = callCount + 1; + } +}; + +new C().method([]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-rest-init-id.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-rest-init-id.js new file mode 100644 index 0000000000..1580c8310f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-rest-init-id.js @@ -0,0 +1,65 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-id.case +// - src/dstr-binding/default/cls-decl-async-gen-meth.template +/*--- +description: Rest element (identifier) does not support initializer (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + + +var callCount = 0; +class C { + async *method([...x = []]) { + + callCount = callCount + 1; + } +}; + +new C().method([]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-rest-init-obj.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-rest-init-obj.js new file mode 100644 index 0000000000..fe3880a2ca --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-rest-init-obj.js @@ -0,0 +1,65 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-obj.case +// - src/dstr-binding/default/cls-decl-async-gen-meth.template +/*--- +description: Rest element (nested object pattern) does not support initializer (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + + +var callCount = 0; +class C { + async *method([...{ x } = []]) { + + callCount = callCount + 1; + } +}; + +new C().method([]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-rest-not-final-ary.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-rest-not-final-ary.js new file mode 100644 index 0000000000..2c40934196 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-rest-not-final-ary.js @@ -0,0 +1,65 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-ary.case +// - src/dstr-binding/default/cls-decl-async-gen-meth.template +/*--- +description: Rest element (array binding pattern) may not be followed by any element (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + + +var callCount = 0; +class C { + async *method([...[x], y]) { + + callCount = callCount + 1; + } +}; + +new C().method([1, 2, 3]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-rest-not-final-id.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-rest-not-final-id.js new file mode 100644 index 0000000000..f395919c5d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-rest-not-final-id.js @@ -0,0 +1,65 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-id.case +// - src/dstr-binding/default/cls-decl-async-gen-meth.template +/*--- +description: Rest element (identifier) may not be followed by any element (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + + +var callCount = 0; +class C { + async *method([...x, y]) { + + callCount = callCount + 1; + } +}; + +new C().method([1, 2, 3]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-rest-not-final-obj.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-rest-not-final-obj.js new file mode 100644 index 0000000000..b219be6368 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-rest-not-final-obj.js @@ -0,0 +1,65 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-obj.case +// - src/dstr-binding/default/cls-decl-async-gen-meth.template +/*--- +description: Rest element (object binding pattern) may not be followed by any element (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + + +var callCount = 0; +class C { + async *method([...{ x }, y]) { + + callCount = callCount + 1; + } +}; + +new C().method([1, 2, 3]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-rest-obj-id.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-rest-obj-id.js new file mode 100644 index 0000000000..cebed99c3c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-rest-obj-id.js @@ -0,0 +1,68 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-id.case +// - src/dstr-binding/default/cls-decl-async-gen-meth.template +/*--- +description: Rest element containing an object binding pattern (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ + + +var callCount = 0; +class C { + async *method([...{ length }]) { + assert.sameValue(length, 3); + callCount = callCount + 1; + } +}; + +new C().method([1, 2, 3]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-rest-obj-prop-id.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-rest-obj-prop-id.js new file mode 100644 index 0000000000..f7f49a5be4 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-ary-ptrn-rest-obj-prop-id.js @@ -0,0 +1,75 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-prop-id.case +// - src/dstr-binding/default/cls-decl-async-gen-meth.template +/*--- +description: Rest element containing an object binding pattern (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ +let length = "outer"; + + +var callCount = 0; +class C { + async *method([...{ 0: v, 1: w, 2: x, 3: y, length: z }]) { + assert.sameValue(v, 7); + assert.sameValue(w, 8); + assert.sameValue(x, 9); + assert.sameValue(y, undefined); + assert.sameValue(z, 3); + + assert.sameValue(length, "outer", "the length prop is not set as a binding name"); + callCount = callCount + 1; + } +}; + +new C().method([7, 8, 9]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-init-iter-close.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-init-iter-close.js new file mode 100644 index 0000000000..162eed1127 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-init-iter-close.js @@ -0,0 +1,78 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-close.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-dflt.template +/*--- +description: Iterator is closed when not exhausted by pattern evaluation (class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [Symbol.iterator, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: false }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + + +var callCount = 0; +class C { + async *method([x] = iter) { + assert.sameValue(doneCallCount, 1); + callCount = callCount + 1; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-init-iter-get-err-array-prototype.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-init-iter-get-err-array-prototype.js new file mode 100644 index 0000000000..d41a8fb1cc --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-init-iter-get-err-array-prototype.js @@ -0,0 +1,73 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-get-err-array-prototype.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-dflt.template +/*--- +description: Abrupt completion returned by GetIterator (class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [Symbol.iterator, async-iteration] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iteratorRecord be ? GetIterator(value). + + GetIterator ( obj [ , hint [ , method ] ] ) + + [...] + 4. Let iterator be ? Call(method, obj). + + Call ( F, V [ , argumentsList ] ) + + [...] + 2. If IsCallable(F) is false, throw a TypeError exception. + +---*/ +delete Array.prototype[Symbol.iterator]; + + +class C { + async *method([x, y, z] = [1, 2, 3]) { + + } +}; + +var method = C.prototype.method; + +assert.throws(TypeError, function() { + method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-init-iter-get-err.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-init-iter-get-err.js new file mode 100644 index 0000000000..ee58f513d6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-init-iter-get-err.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-get-err.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-dflt.template +/*--- +description: Abrupt completion returned by GetIterator (class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [Symbol.iterator, async-iteration] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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(); +}; + + +class C { + async *method([x] = iter) { + + } +}; + +var method = C.prototype.method; + +assert.throws(Test262Error, function() { + method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-init-iter-no-close.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-init-iter-no-close.js new file mode 100644 index 0000000000..11213ed108 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-init-iter-no-close.js @@ -0,0 +1,78 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-no-close.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-dflt.template +/*--- +description: Iterator is not closed when exhausted by pattern evaluation (class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [Symbol.iterator, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: true }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + + +var callCount = 0; +class C { + async *method([x] = iter) { + assert.sameValue(doneCallCount, 0); + callCount = callCount + 1; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-name-iter-val.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-name-iter-val.js new file mode 100644 index 0000000000..e8da6e9f22 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-name-iter-val.js @@ -0,0 +1,77 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-name-iter-val.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-dflt.template +/*--- +description: SingleNameBinding with normal value iteration (class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +class C { + async *method([x, y, z] = [1, 2, 3]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-ary-elem-init.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-ary-elem-init.js new file mode 100644 index 0000000000..0602357580 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-ary-elem-init.js @@ -0,0 +1,69 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-init.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + + +var callCount = 0; +class C { + async *method([[x, y, z] = [4, 5, 6]] = []) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + callCount = callCount + 1; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-ary-elem-iter.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-ary-elem-iter.js new file mode 100644 index 0000000000..f7493c1180 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-ary-elem-iter.js @@ -0,0 +1,70 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-iter.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + + +var callCount = 0; +class C { + async *method([[x, y, z] = [4, 5, 6]] = [[7, 8, 9]]) { + assert.sameValue(x, 7); + assert.sameValue(y, 8); + assert.sameValue(z, 9); + callCount = callCount + 1; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-ary-elision-init.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-ary-elision-init.js new file mode 100644 index 0000000000..75dd18901f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-ary-elision-init.js @@ -0,0 +1,76 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-init.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + + +var callCount = 0; +class C { + async *method([[,] = g()] = []) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-ary-elision-iter.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-ary-elision-iter.js new file mode 100644 index 0000000000..14942f4890 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-ary-elision-iter.js @@ -0,0 +1,73 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-iter.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var callCount = 0; +function* g() { + callCount += 1; +}; + + +var callCount = 0; +class C { + async *method([[,] = g()] = [[]]) { + assert.sameValue(callCount, 0); + callCount = callCount + 1; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-ary-empty-init.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-ary-empty-init.js new file mode 100644 index 0000000000..6c43533ffd --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-ary-empty-init.js @@ -0,0 +1,72 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-init.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var initCount = 0; +var iterCount = 0; +var iter = function*() { iterCount += 1; }(); + + +var callCount = 0; +class C { + async *method([[] = function() { initCount += 1; return iter; }()] = []) { + assert.sameValue(initCount, 1); + assert.sameValue(iterCount, 0); + callCount = callCount + 1; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-ary-empty-iter.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-ary-empty-iter.js new file mode 100644 index 0000000000..352754eab3 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-ary-empty-iter.js @@ -0,0 +1,69 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-iter.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var initCount = 0; + + +var callCount = 0; +class C { + async *method([[] = function() { initCount += 1; }()] = [[23]]) { + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-ary-rest-init.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-ary-rest-init.js new file mode 100644 index 0000000000..e73fcb966e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-ary-rest-init.js @@ -0,0 +1,73 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-init.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; + + +var callCount = 0; +class C { + async *method([[...x] = values] = []) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + callCount = callCount + 1; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-ary-rest-iter.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-ary-rest-iter.js new file mode 100644 index 0000000000..d58b98598d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-ary-rest-iter.js @@ -0,0 +1,76 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-iter.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; +var initCount = 0; + + +var callCount = 0; +class C { + async *method([[...x] = function() { initCount += 1; }()] = [values]) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-ary-val-null.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-ary-val-null.js new file mode 100644 index 0000000000..03d238b882 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-ary-val-null.js @@ -0,0 +1,74 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-val-null.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-dflt.template +/*--- +description: Nested array destructuring with a null value (class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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). +---*/ + + +class C { + async *method([[x]] = [null]) { + + } +}; + +var method = C.prototype.method; + +assert.throws(TypeError, function() { + method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-init-exhausted.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-init-exhausted.js new file mode 100644 index 0000000000..cd8c161d4b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-init-exhausted.js @@ -0,0 +1,68 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-exhausted.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-dflt.template +/*--- +description: Destructuring initializer with an exhausted iterator (class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +class C { + async *method([x = 23] = []) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..f248fca743 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js @@ -0,0 +1,69 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-arrow.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-dflt.template +/*--- +description: SingleNameBinding does assign name to arrow functions (class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +class C { + async *method([arrow = () => {}] = []) { + assert.sameValue(arrow.name, 'arrow'); + callCount = callCount + 1; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-class.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-class.js new file mode 100644 index 0000000000..66e035212e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-class.js @@ -0,0 +1,71 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-class.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-dflt.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +class C { + async *method([cls = class {}, xCls = class X {}, xCls2 = class { static name() {} }] = []) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + assert.notSameValue(xCls2.name, 'xCls2'); + callCount = callCount + 1; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-cover.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-cover.js new file mode 100644 index 0000000000..991e23bbe3 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-cover.js @@ -0,0 +1,70 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-cover.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-dflt.template +/*--- +description: SingleNameBinding does assign name to "anonymous" functions "through" cover grammar (class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +class C { + async *method([cover = (function () {}), xCover = (0, function() {})] = []) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + callCount = callCount + 1; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-fn.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-fn.js new file mode 100644 index 0000000000..0dafa09666 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-fn.js @@ -0,0 +1,70 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-fn.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +class C { + async *method([fn = function () {}, xFn = function x() {}] = []) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + callCount = callCount + 1; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-gen.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-gen.js new file mode 100644 index 0000000000..48511b4b87 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-gen.js @@ -0,0 +1,71 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-gen.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). + +---*/ + + +var callCount = 0; +class C { + async *method([gen = function* () {}, xGen = function* x() {}] = []) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + callCount = callCount + 1; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-init-hole.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-init-hole.js new file mode 100644 index 0000000000..2c51f84ac0 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-init-hole.js @@ -0,0 +1,64 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-hole.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-dflt.template +/*--- +description: Destructuring initializer with a "hole" (class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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). + [...] + 7. If environment is undefined, return PutValue(lhs, v). 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +class C { + async *method([x = 23] = [,]) { + assert.sameValue(x, 23); + // another statement + callCount = callCount + 1; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-init-skipped.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-init-skipped.js new file mode 100644 index 0000000000..45821f3294 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-init-skipped.js @@ -0,0 +1,73 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-skipped.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-dflt.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + + +var callCount = 0; +class C { + async *method([w = counter(), x = counter(), y = counter(), z = counter()] = [null, 0, false, '']) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-init-throws.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-init-throws.js new file mode 100644 index 0000000000..03f6cdc031 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-init-throws.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-throws.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-dflt.template +/*--- +description: Destructuring initializer returns an abrupt completion (class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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). +---*/ + + +class C { + async *method([x = (function() { throw new Test262Error(); })()] = [undefined]) { + + } +}; + +var method = C.prototype.method; + +assert.throws(Test262Error, function() { + method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-init-undef.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-init-undef.js new file mode 100644 index 0000000000..9b5f181940 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-init-undef.js @@ -0,0 +1,67 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-undef.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-dflt.template +/*--- +description: Destructuring initializer with an undefined value (class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +class C { + async *method([x = 23] = [undefined]) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-init-unresolvable.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-init-unresolvable.js new file mode 100644 index 0000000000..e8c67667bb --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-init-unresolvable.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-unresolvable.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-dflt.template +/*--- +description: Destructuring initializer is an unresolvable reference (class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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. +---*/ + + +class C { + async *method([ x = unresolvableReference ] = []) { + + } +}; + +var method = C.prototype.method; + +assert.throws(ReferenceError, function() { + method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-iter-complete.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-iter-complete.js new file mode 100644 index 0000000000..3e98ff9928 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-iter-complete.js @@ -0,0 +1,71 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-complete.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-dflt.template +/*--- +description: SingleNameBinding when value iteration completes (class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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, + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +class C { + async *method([x] = []) { + assert.sameValue(x, undefined); + callCount = callCount + 1; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-iter-done.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-iter-done.js new file mode 100644 index 0000000000..98a2baabf6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-iter-done.js @@ -0,0 +1,66 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-done.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-dflt.template +/*--- +description: SingleNameBinding when value iteration was completed previously (class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +class C { + async *method([_, x] = []) { + assert.sameValue(x, undefined); + callCount = callCount + 1; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-iter-step-err.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-iter-step-err.js new file mode 100644 index 0000000000..1e7f455700 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-iter-step-err.js @@ -0,0 +1,74 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-step-err.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-dflt.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [Symbol.iterator, async-iteration] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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(); + } + }; +}; + + +class C { + async *method([x] = g) { + + } +}; + +var method = C.prototype.method; + +assert.throws(Test262Error, function() { + method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-iter-val-array-prototype.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-iter-val-array-prototype.js new file mode 100644 index 0000000000..16b17212d4 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-iter-val-array-prototype.js @@ -0,0 +1,87 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val-array-prototype.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-dflt.template +/*--- +description: Array destructuring uses overriden Array.prototype[Symbol.iterator] (class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [Symbol.iterator, generators, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializer_opt + + 1. Let bindingId be StringValue of BindingIdentifier. + 2. Let lhs be ? ResolveBinding(bindingId, environment). + 3. If iteratorRecord.[[Done]] is false, then + a. Let next be IteratorStep(iteratorRecord). + 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). + [...] + 7. Return InitializeReferencedBinding(lhs, v). + +---*/ +Array.prototype[Symbol.iterator] = function* () { + if (this.length > 0) { + yield this[0]; + } + if (this.length > 1) { + yield this[1]; + } + if (this.length > 2) { + yield 42; + } +}; + + +var callCount = 0; +class C { + async *method([x, y, z] = [1, 2, 3]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 42); + callCount = callCount + 1; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-iter-val-err.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-iter-val-err.js new file mode 100644 index 0000000000..a987cf315e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-iter-val-err.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val-err.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-dflt.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [Symbol.iterator, async-iteration] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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; + } + }; +}; + + +class C { + async *method([x] = g) { + + } +}; + +var method = C.prototype.method; + +assert.throws(Test262Error, function() { + method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-iter-val.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-iter-val.js new file mode 100644 index 0000000000..78272a3339 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-id-iter-val.js @@ -0,0 +1,77 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-dflt.template +/*--- +description: SingleNameBinding when value iteration was completed previously (class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +class C { + async *method([x, y, z] = [1, 2, 3]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-obj-id-init.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-obj-id-init.js new file mode 100644 index 0000000000..c58596ee46 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-obj-id-init.js @@ -0,0 +1,69 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id-init.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is used (class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + + +var callCount = 0; +class C { + async *method([{ x, y, z } = { x: 44, y: 55, z: 66 }] = []) { + assert.sameValue(x, 44); + assert.sameValue(y, 55); + assert.sameValue(z, 66); + callCount = callCount + 1; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-obj-id.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-obj-id.js new file mode 100644 index 0000000000..b8c9f3d8cd --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-obj-id.js @@ -0,0 +1,69 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + + +var callCount = 0; +class C { + async *method([{ x, y, z } = { x: 44, y: 55, z: 66 }] = [{ x: 11, y: 22, z: 33 }]) { + assert.sameValue(x, 11); + assert.sameValue(y, 22); + assert.sameValue(z, 33); + callCount = callCount + 1; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-obj-prop-id-init.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-obj-prop-id-init.js new file mode 100644 index 0000000000..1e5abee4af --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-obj-prop-id-init.js @@ -0,0 +1,79 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id-init.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is used (class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + + +var callCount = 0; +class C { + async *method([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] = []) { + assert.sameValue(v, 444); + assert.sameValue(x, 555); + assert.sameValue(z, 666); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-obj-prop-id.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-obj-prop-id.js new file mode 100644 index 0000000000..f038e24eab --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-obj-prop-id.js @@ -0,0 +1,79 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + + +var callCount = 0; +class C { + async *method([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] = [{ u: 777, w: 888, y: 999 }]) { + assert.sameValue(v, 777); + assert.sameValue(x, 888); + assert.sameValue(z, 999); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-obj-val-null.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-obj-val-null.js new file mode 100644 index 0000000000..772a6879cd --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-obj-val-null.js @@ -0,0 +1,74 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-null.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-dflt.template +/*--- +description: Nested object destructuring with a null value (class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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). +---*/ + + +class C { + async *method([{ x }] = [null]) { + + } +}; + +var method = C.prototype.method; + +assert.throws(TypeError, function() { + method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-obj-val-undef.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-obj-val-undef.js new file mode 100644 index 0000000000..daa4ea3751 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elem-obj-val-undef.js @@ -0,0 +1,74 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-undef.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-dflt.template +/*--- +description: Nested object destructuring with a value of `undefined` (class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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). +---*/ + + +class C { + async *method([{ x }] = []) { + + } +}; + +var method = C.prototype.method; + +assert.throws(TypeError, function() { + method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elision-exhausted.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elision-exhausted.js new file mode 100644 index 0000000000..7c1991dfef --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elision-exhausted.js @@ -0,0 +1,74 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-exhausted.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-dflt.template +/*--- +description: Elision accepts exhausted iterator (class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 + [...] + 2. Return NormalCompletion(empty). + +---*/ +var iter = function*() {}(); +iter.next(); + + +var callCount = 0; +class C { + async *method([,] = iter) { + + callCount = callCount + 1; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elision-step-err.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elision-step-err.js new file mode 100644 index 0000000000..ea6fa2a080 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elision-step-err.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-step-err.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-dflt.template +/*--- +description: Elision advances iterator and forwards abrupt completions (class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, async-iteration] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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; +}(); + + +class C { + async *method([,] = iter) { + + } +}; + +var method = C.prototype.method; + +assert.throws(Test262Error, function() { + method(); +}); + +iter.next(); +assert.sameValue(following, 0, 'Iterator was properly closed.'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elision.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elision.js new file mode 100644 index 0000000000..ec98123e8a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-elision.js @@ -0,0 +1,83 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-dflt.template +/*--- +description: Elision advances iterator (class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + + +var callCount = 0; +class C { + async *method([,] = g()) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-empty.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-empty.js new file mode 100644 index 0000000000..e2c7870d7f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-empty.js @@ -0,0 +1,66 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-empty.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-dflt.template +/*--- +description: No iteration occurs for an "empty" array binding pattern (class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + + +var callCount = 0; +class C { + async *method([] = iter) { + assert.sameValue(iterations, 0); + callCount = callCount + 1; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-rest-ary-elem.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-rest-ary-elem.js new file mode 100644 index 0000000000..939ac76037 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-rest-ary-elem.js @@ -0,0 +1,90 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elem.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-dflt.template +/*--- +description: Rest element containing an array BindingElementList pattern (class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the 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). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +class C { + async *method([...[x, y, z]] = [3, 4, 5]) { + assert.sameValue(x, 3); + assert.sameValue(y, 4); + assert.sameValue(z, 5); + callCount = callCount + 1; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-rest-ary-elision.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-rest-ary-elision.js new file mode 100644 index 0000000000..2e91589278 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-rest-ary-elision.js @@ -0,0 +1,96 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elision.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-dflt.template +/*--- +description: Rest element containing an elision (class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the 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). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + + +var callCount = 0; +class C { + async *method([...[,]] = g()) { + assert.sameValue(first, 1); + assert.sameValue(second, 1); + callCount = callCount + 1; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-rest-ary-empty.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-rest-ary-empty.js new file mode 100644 index 0000000000..0e1604370d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-rest-ary-empty.js @@ -0,0 +1,79 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-empty.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-dflt.template +/*--- +description: Rest element containing an "empty" array pattern (class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + + +var callCount = 0; +class C { + async *method([...[]] = iter) { + assert.sameValue(iterations, 1); + callCount = callCount + 1; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-rest-ary-rest.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-rest-ary-rest.js new file mode 100644 index 0000000000..699583754c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-rest-ary-rest.js @@ -0,0 +1,75 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-rest.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-dflt.template +/*--- +description: Rest element containing a rest element (class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ +var values = [1, 2, 3]; + + +var callCount = 0; +class C { + async *method([...[...x]] = values) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + + callCount = callCount + 1; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-rest-id-direct.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-rest-id-direct.js new file mode 100644 index 0000000000..96b68d3ba9 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-rest-id-direct.js @@ -0,0 +1,70 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-direct.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-dflt.template +/*--- +description: Lone rest element (direct binding) (class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated, async] +includes: [compareArray.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingIdentifier + + [...] + 2. Let A be ! ArrayCreate(0). + 3. Let n be 0. + 4. Repeat, + [...] + f. Perform ! CreateDataPropertyOrThrow(A, ! ToString(n), nextValue). + g. Set n to n + 1. + +---*/ + + +var callCount = 0; +class C { + async *method([...x] = [1]) { + assert(Array.isArray(x)); + assert.compareArray(x, [1]); + callCount = callCount + 1; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-rest-id-elision-next-err.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-rest-id-elision-next-err.js new file mode 100644 index 0000000000..58f7007841 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-rest-id-elision-next-err.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision-next-err.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-dflt.template +/*--- +description: Rest element following elision elements (class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, async-iteration] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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(); })(); + + +class C { + async *method([, ...x] = iter) { + + } +}; + +var method = C.prototype.method; + +assert.throws(Test262Error, function() { + method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-rest-id-elision.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-rest-id-elision.js new file mode 100644 index 0000000000..edeca7938f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-rest-id-elision.js @@ -0,0 +1,71 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-dflt.template +/*--- +description: Rest element following elision elements (class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 values = [1, 2, 3, 4, 5]; + + +var callCount = 0; +class C { + async *method([ , , ...x] = values) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 3); + assert.sameValue(x[1], 4); + assert.sameValue(x[2], 5); + assert.notSameValue(x, values); + callCount = callCount + 1; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-rest-id-exhausted.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-rest-id-exhausted.js new file mode 100644 index 0000000000..1e6aa07f19 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-rest-id-exhausted.js @@ -0,0 +1,67 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-exhausted.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-dflt.template +/*--- +description: RestElement applied to an exhausted iterator (class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [Symbol.iterator, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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, + [...] + b. If iteratorRecord.[[done]] is true, then + i. If environment is undefined, return PutValue(lhs, A). + ii. Return InitializeReferencedBinding(lhs, A). + +---*/ + + +var callCount = 0; +class C { + async *method([, , ...x] = [1, 2]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 0); + callCount = callCount + 1; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-rest-id-iter-step-err.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-rest-id-iter-step-err.js new file mode 100644 index 0000000000..3a06c3ab1d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-rest-id-iter-step-err.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-step-err.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-dflt.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, async-iteration] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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; +}(); + + +class C { + async *method([...x] = iter) { + + } +}; + +var method = C.prototype.method; + +assert.throws(Test262Error, function() { + method(); +}); + +iter.next(); +assert.sameValue(first, 1); +assert.sameValue(second, 0, 'Iterator is closed following abrupt completion.'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-rest-id-iter-val-err.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-rest-id-iter-val-err.js new file mode 100644 index 0000000000..0e17ed2e5a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-rest-id-iter-val-err.js @@ -0,0 +1,80 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-val-err.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-dflt.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [Symbol.iterator, async-iteration] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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; + } + }; +}; + + +class C { + async *method([...x] = iter) { + + } +}; + +var method = C.prototype.method; + +assert.throws(Test262Error, function() { + method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-rest-id.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-rest-id.js new file mode 100644 index 0000000000..cb89a4f210 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-rest-id.js @@ -0,0 +1,68 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-dflt.template +/*--- +description: Lone rest element (class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + [...] 3. Let A be ArrayCreate(0). [...] 5. Repeat + [...] + f. Let status be CreateDataProperty(A, ToString (n), nextValue). + [...] +---*/ +var values = [1, 2, 3]; + + +var callCount = 0; +class C { + async *method([...x] = values) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + callCount = callCount + 1; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-rest-init-ary.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-rest-init-ary.js new file mode 100644 index 0000000000..c4c17626e1 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-rest-init-ary.js @@ -0,0 +1,65 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-ary.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-dflt.template +/*--- +description: Rest element (nested array pattern) does not support initializer (class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + + +var callCount = 0; +class C { + async *method([...[ x ] = []] = []) { + + callCount = callCount + 1; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-rest-init-id.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-rest-init-id.js new file mode 100644 index 0000000000..7da673cbb2 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-rest-init-id.js @@ -0,0 +1,65 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-id.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-dflt.template +/*--- +description: Rest element (identifier) does not support initializer (class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + + +var callCount = 0; +class C { + async *method([...x = []] = []) { + + callCount = callCount + 1; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-rest-init-obj.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-rest-init-obj.js new file mode 100644 index 0000000000..87425aff6a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-rest-init-obj.js @@ -0,0 +1,65 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-obj.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-dflt.template +/*--- +description: Rest element (nested object pattern) does not support initializer (class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + + +var callCount = 0; +class C { + async *method([...{ x } = []] = []) { + + callCount = callCount + 1; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-rest-not-final-ary.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-rest-not-final-ary.js new file mode 100644 index 0000000000..dd2194eac3 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-rest-not-final-ary.js @@ -0,0 +1,65 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-ary.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-dflt.template +/*--- +description: Rest element (array binding pattern) may not be followed by any element (class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + + +var callCount = 0; +class C { + async *method([...[x], y] = [1, 2, 3]) { + + callCount = callCount + 1; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-rest-not-final-id.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-rest-not-final-id.js new file mode 100644 index 0000000000..40f347b7b9 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-rest-not-final-id.js @@ -0,0 +1,65 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-id.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-dflt.template +/*--- +description: Rest element (identifier) may not be followed by any element (class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + + +var callCount = 0; +class C { + async *method([...x, y] = [1, 2, 3]) { + + callCount = callCount + 1; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-rest-not-final-obj.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-rest-not-final-obj.js new file mode 100644 index 0000000000..cd23b30fc7 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-rest-not-final-obj.js @@ -0,0 +1,65 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-obj.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-dflt.template +/*--- +description: Rest element (object binding pattern) may not be followed by any element (class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + + +var callCount = 0; +class C { + async *method([...{ x }, y] = [1, 2, 3]) { + + callCount = callCount + 1; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-rest-obj-id.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-rest-obj-id.js new file mode 100644 index 0000000000..94876d16fa --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-rest-obj-id.js @@ -0,0 +1,68 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-id.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-dflt.template +/*--- +description: Rest element containing an object binding pattern (class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ + + +var callCount = 0; +class C { + async *method([...{ length }] = [1, 2, 3]) { + assert.sameValue(length, 3); + callCount = callCount + 1; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-rest-obj-prop-id.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-rest-obj-prop-id.js new file mode 100644 index 0000000000..8ce08c2a48 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-ary-ptrn-rest-obj-prop-id.js @@ -0,0 +1,75 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-prop-id.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-dflt.template +/*--- +description: Rest element containing an object binding pattern (class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ +let length = "outer"; + + +var callCount = 0; +class C { + async *method([...{ 0: v, 1: w, 2: x, 3: y, length: z }] = [7, 8, 9]) { + assert.sameValue(v, 7); + assert.sameValue(w, 8); + assert.sameValue(x, 9); + assert.sameValue(y, undefined); + assert.sameValue(z, 3); + + assert.sameValue(length, "outer", "the length prop is not set as a binding name"); + callCount = callCount + 1; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-init-null.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-init-null.js new file mode 100644 index 0000000000..5fc3947140 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-init-null.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-null.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-dflt.template +/*--- +description: Value specifed for object binding pattern must be object coercible (null) (class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + + +class C { + async *method({} = null) { + + } +}; + +var method = C.prototype.method; + +assert.throws(TypeError, function() { + method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-init-undefined.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-init-undefined.js new file mode 100644 index 0000000000..6502002000 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-init-undefined.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-undefined.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-dflt.template +/*--- +description: Value specifed for object binding pattern must be object coercible (undefined) (class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + + +class C { + async *method({} = undefined) { + + } +}; + +var method = C.prototype.method; + +assert.throws(TypeError, function() { + method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-empty.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-empty.js new file mode 100644 index 0000000000..6248fd6ef2 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-empty.js @@ -0,0 +1,67 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-empty.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-dflt.template +/*--- +description: No property access occurs for an "empty" object binding pattern (class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ +var accessCount = 0; +var obj = Object.defineProperty({}, 'attr', { + get: function() { + accessCount += 1; + } +}); + + +var callCount = 0; +class C { + async *method({} = obj) { + assert.sameValue(accessCount, 0); + callCount = callCount + 1; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-id-get-value-err.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-id-get-value-err.js new file mode 100644 index 0000000000..26412acd49 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-id-get-value-err.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-get-value-err.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-dflt.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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(); + } +}); + + +class C { + async *method({ poisoned } = poisonedProperty) { + + } +}; + +var method = C.prototype.method; + +assert.throws(Test262Error, function() { + method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-id-init-fn-name-arrow.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..18991eefac --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-id-init-fn-name-arrow.js @@ -0,0 +1,68 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-arrow.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-dflt.template +/*--- +description: SingleNameBinding assigns `name` to arrow functions (class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + + +var callCount = 0; +class C { + async *method({ arrow = () => {} } = {}) { + assert.sameValue(arrow.name, 'arrow'); + callCount = callCount + 1; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-id-init-fn-name-class.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-id-init-fn-name-class.js new file mode 100644 index 0000000000..162576df10 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-id-init-fn-name-class.js @@ -0,0 +1,70 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-class.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-dflt.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + + +var callCount = 0; +class C { + async *method({ cls = class {}, xCls = class X {}, xCls2 = class { static name() {} } } = {}) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + assert.notSameValue(xCls2.name, 'xCls2'); + callCount = callCount + 1; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-id-init-fn-name-cover.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-id-init-fn-name-cover.js new file mode 100644 index 0000000000..4332321b44 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-id-init-fn-name-cover.js @@ -0,0 +1,69 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-cover.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-dflt.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" functions "through" cover grammar (class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + + +var callCount = 0; +class C { + async *method({ cover = (function () {}), xCover = (0, function() {}) } = {}) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + callCount = callCount + 1; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-id-init-fn-name-fn.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-id-init-fn-name-fn.js new file mode 100644 index 0000000000..e43bb913bc --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-id-init-fn-name-fn.js @@ -0,0 +1,69 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-fn.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + + +var callCount = 0; +class C { + async *method({ fn = function () {}, xFn = function x() {} } = {}) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + callCount = callCount + 1; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-id-init-fn-name-gen.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-id-init-fn-name-gen.js new file mode 100644 index 0000000000..eb045be12f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-id-init-fn-name-gen.js @@ -0,0 +1,70 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-gen.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). + +---*/ + + +var callCount = 0; +class C { + async *method({ gen = function* () {}, xGen = function* x() {} } = {}) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + callCount = callCount + 1; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-id-init-skipped.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-id-init-skipped.js new file mode 100644 index 0000000000..8f568a542c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-id-init-skipped.js @@ -0,0 +1,72 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-skipped.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-dflt.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + + +var callCount = 0; +class C { + async *method({ w = counter(), x = counter(), y = counter(), z = counter() } = { w: null, x: 0, y: false, z: '' }) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-id-init-throws.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-id-init-throws.js new file mode 100644 index 0000000000..cf7056ea20 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-id-init-throws.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-throws.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-dflt.template +/*--- +description: Error thrown when evaluating the initializer (class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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(); +} + + +class C { + async *method({ x = thrower() } = {}) { + + } +}; + +var method = C.prototype.method; + +assert.throws(Test262Error, function() { + method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-id-init-unresolvable.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-id-init-unresolvable.js new file mode 100644 index 0000000000..5a564f7bec --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-id-init-unresolvable.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-unresolvable.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-dflt.template +/*--- +description: Destructuring initializer is an unresolvable reference (class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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. +---*/ + + +class C { + async *method({ x = unresolvableReference } = {}) { + + } +}; + +var method = C.prototype.method; + +assert.throws(ReferenceError, function() { + method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-id-trailing-comma.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-id-trailing-comma.js new file mode 100644 index 0000000000..10b50bcb3a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-id-trailing-comma.js @@ -0,0 +1,62 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-trailing-comma.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-dflt.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + + +var callCount = 0; +class C { + async *method({ x, } = { x: 23 }) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-list-err.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-list-err.js new file mode 100644 index 0000000000..1b6bff73a6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-list-err.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-list-err.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-dflt.template +/*--- +description: Binding property list evaluation is interrupted by an abrupt completion (class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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(); +} + + +class C { + async *method({ a, b = thrower(), c = ++initCount } = {}) { + + } +}; + +var method = C.prototype.method; + +assert.throws(Test262Error, function() { + method(); +}); + +assert.sameValue(initCount, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-prop-ary-init.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-prop-ary-init.js new file mode 100644 index 0000000000..64dbf4c15e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-prop-ary-init.js @@ -0,0 +1,71 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-init.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-dflt.template +/*--- +description: Object binding pattern with "nested" array binding pattern using initializer (class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 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). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + + +var callCount = 0; +class C { + async *method({ w: [x, y, z] = [4, 5, 6] } = {}) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-prop-ary-trailing-comma.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-prop-ary-trailing-comma.js new file mode 100644 index 0000000000..e04be13381 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-prop-ary-trailing-comma.js @@ -0,0 +1,62 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-trailing-comma.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-dflt.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + + +var callCount = 0; +class C { + async *method({ x: [y], } = { x: [45] }) { + assert.sameValue(y,45); + callCount = callCount + 1; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-prop-ary-value-null.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-prop-ary-value-null.js new file mode 100644 index 0000000000..441f6e316c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-prop-ary-value-null.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-value-null.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-dflt.template +/*--- +description: Object binding pattern with "nested" array binding pattern taking the `null` value (class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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. +---*/ + + +class C { + async *method({ w: [x, y, z] = [4, 5, 6] } = { w: null }) { + + } +}; + +var method = C.prototype.method; + +assert.throws(TypeError, function() { + method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-prop-ary.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-prop-ary.js new file mode 100644 index 0000000000..de82c9e44c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-prop-ary.js @@ -0,0 +1,69 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-dflt.template +/*--- +description: Object binding pattern with "nested" array binding pattern not using initializer (class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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. +---*/ + + +var callCount = 0; +class C { + async *method({ w: [x, y, z] = [4, 5, 6] } = { w: [7, undefined, ] }) { + assert.sameValue(x, 7); + assert.sameValue(y, undefined); + assert.sameValue(z, undefined); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-prop-eval-err.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-prop-eval-err.js new file mode 100644 index 0000000000..6faf6b9799 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-prop-eval-err.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-eval-err.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-dflt.template +/*--- +description: Evaluation of property name returns an abrupt completion (class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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(); +} + + +class C { + async *method({ [thrower()]: x } = {}) { + + } +}; + +var method = C.prototype.method; + +assert.throws(Test262Error, function() { + method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-prop-id-get-value-err.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-prop-id-get-value-err.js new file mode 100644 index 0000000000..658645d003 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-prop-id-get-value-err.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-get-value-err.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-dflt.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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(); + } +}); + + +class C { + async *method({ poisoned: x = ++initEvalCount } = poisonedProperty) { + + } +}; + +var method = C.prototype.method; + +assert.throws(Test262Error, function() { + method(); +}); + +assert.sameValue(initEvalCount, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-prop-id-init-skipped.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-prop-id-init-skipped.js new file mode 100644 index 0000000000..2f026aa34c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-prop-id-init-skipped.js @@ -0,0 +1,84 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-skipped.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-dflt.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + + +var callCount = 0; +class C { + async *method({ s: t = counter(), u: v = counter(), w: x = counter(), y: z = counter() } = { s: null, u: 0, w: false, y: '' }) { + assert.sameValue(t, null); + assert.sameValue(v, 0); + assert.sameValue(x, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + + assert.throws(ReferenceError, function() { + s; + }); + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-prop-id-init-throws.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-prop-id-init-throws.js new file mode 100644 index 0000000000..22bdd6f755 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-prop-id-init-throws.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-throws.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-dflt.template +/*--- +description: Error thrown when evaluating the initializer (class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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(); +} + + +class C { + async *method({ x: y = thrower() } = {}) { + + } +}; + +var method = C.prototype.method; + +assert.throws(Test262Error, function() { + method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-prop-id-init-unresolvable.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-prop-id-init-unresolvable.js new file mode 100644 index 0000000000..d6890f7930 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-prop-id-init-unresolvable.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-unresolvable.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-dflt.template +/*--- +description: Destructuring initializer is an unresolvable reference (class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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. +---*/ + + +class C { + async *method({ x: y = unresolvableReference } = {}) { + + } +}; + +var method = C.prototype.method; + +assert.throws(ReferenceError, function() { + method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-prop-id-init.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-prop-id-init.js new file mode 100644 index 0000000000..dc09c1a1dd --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-prop-id-init.js @@ -0,0 +1,65 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-dflt.template +/*--- +description: Binding as specified via property name, identifier, and initializer (class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +class C { + async *method({ x: y = 33 } = { }) { + assert.sameValue(y, 33); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-prop-id-trailing-comma.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-prop-id-trailing-comma.js new file mode 100644 index 0000000000..c3eb6f0665 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-prop-id-trailing-comma.js @@ -0,0 +1,66 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-trailing-comma.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-dflt.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + + +var callCount = 0; +class C { + async *method({ x: y, } = { x: 23 }) { + assert.sameValue(y, 23); + + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-prop-id.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-prop-id.js new file mode 100644 index 0000000000..22354b9a40 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-prop-id.js @@ -0,0 +1,65 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-dflt.template +/*--- +description: Binding as specified via property name and identifier (class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +class C { + async *method({ x: y } = { x: 23 }) { + assert.sameValue(y, 23); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-prop-obj-init.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-prop-obj-init.js new file mode 100644 index 0000000000..0f0870753a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-prop-obj-init.js @@ -0,0 +1,71 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-init.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern using initializer (class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 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). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + + +var callCount = 0; +class C { + async *method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } } = { w: undefined }) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-prop-obj-value-null.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-prop-obj-value-null.js new file mode 100644 index 0000000000..e451ff0189 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-prop-obj-value-null.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-null.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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. +---*/ + + +class C { + async *method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } } = { w: null }) { + + } +}; + +var method = C.prototype.method; + +assert.throws(TypeError, function() { + method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-prop-obj-value-undef.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-prop-obj-value-undef.js new file mode 100644 index 0000000000..142c493f7a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-prop-obj-value-undef.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-undef.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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. +---*/ + + +class C { + async *method({ w: { x, y, z } = undefined } = { }) { + + } +}; + +var method = C.prototype.method; + +assert.throws(TypeError, function() { + method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-prop-obj.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-prop-obj.js new file mode 100644 index 0000000000..91b9319bf1 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-prop-obj.js @@ -0,0 +1,69 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern not using initializer (class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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. +---*/ + + +var callCount = 0; +class C { + async *method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } } = { w: { x: undefined, z: 7 } }) { + assert.sameValue(x, undefined); + assert.sameValue(y, undefined); + assert.sameValue(z, 7); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-rest-getter.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-rest-getter.js new file mode 100644 index 0000000000..2d58553a9a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-rest-getter.js @@ -0,0 +1,64 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-getter.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-dflt.template +/*--- +description: Getter is called when obj is being deconstructed to a rest Object (class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [object-rest, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + +---*/ +var count = 0; + + +var callCount = 0; +class C { + async *method({...x} = { get v() { count++; return 2; } }) { + assert.sameValue(count, 1); + + verifyProperty(x, "v", { + enumerable: true, + writable: true, + configurable: true, + value: 2 + }); + callCount = callCount + 1; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-rest-skip-non-enumerable.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-rest-skip-non-enumerable.js new file mode 100644 index 0000000000..63103c4019 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-rest-skip-non-enumerable.js @@ -0,0 +1,72 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-skip-non-enumerable.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-dflt.template +/*--- +description: Rest object doesn't contain non-enumerable properties (class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [object-rest, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + +---*/ +var o = {a: 3, b: 4}; +Object.defineProperty(o, "x", { value: 4, enumerable: false }); + + +var callCount = 0; +class C { + async *method({...rest} = o) { + assert.sameValue(rest.x, undefined); + + verifyProperty(rest, "a", { + enumerable: true, + writable: true, + configurable: true, + value: 3 + }); + + verifyProperty(rest, "b", { + enumerable: true, + writable: true, + configurable: true, + value: 4 + }); + callCount = callCount + 1; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-rest-val-obj.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-rest-val-obj.js new file mode 100644 index 0000000000..f9764b2671 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-dflt-obj-ptrn-rest-val-obj.js @@ -0,0 +1,71 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-val-obj.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-dflt.template +/*--- +description: Rest object contains just unextracted data (class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [object-rest, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + +---*/ + + +var callCount = 0; +class C { + async *method({a, b, ...rest} = {x: 1, y: 2, a: 5, b: 3}) { + assert.sameValue(rest.a, undefined); + assert.sameValue(rest.b, undefined); + + verifyProperty(rest, "x", { + enumerable: true, + writable: true, + configurable: true, + value: 1 + }); + + verifyProperty(rest, "y", { + enumerable: true, + writable: true, + configurable: true, + value: 2 + }); + callCount = callCount + 1; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-init-null.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-init-null.js new file mode 100644 index 0000000000..a9e32f626b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-init-null.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-null.case +// - src/dstr-binding/error/cls-decl-async-gen-meth.template +/*--- +description: Value specifed for object binding pattern must be object coercible (null) (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + + +class C { + async *method({}) { + + } +}; + +var method = C.prototype.method; + +assert.throws(TypeError, function() { + method(null); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-init-undefined.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-init-undefined.js new file mode 100644 index 0000000000..325cc00c3e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-init-undefined.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-undefined.case +// - src/dstr-binding/error/cls-decl-async-gen-meth.template +/*--- +description: Value specifed for object binding pattern must be object coercible (undefined) (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + + +class C { + async *method({}) { + + } +}; + +var method = C.prototype.method; + +assert.throws(TypeError, function() { + method(undefined); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-empty.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-empty.js new file mode 100644 index 0000000000..d1e1606f13 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-empty.js @@ -0,0 +1,67 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-empty.case +// - src/dstr-binding/default/cls-decl-async-gen-meth.template +/*--- +description: No property access occurs for an "empty" object binding pattern (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ +var accessCount = 0; +var obj = Object.defineProperty({}, 'attr', { + get: function() { + accessCount += 1; + } +}); + + +var callCount = 0; +class C { + async *method({}) { + assert.sameValue(accessCount, 0); + callCount = callCount + 1; + } +}; + +new C().method(obj).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-id-get-value-err.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-id-get-value-err.js new file mode 100644 index 0000000000..ae3744f57d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-id-get-value-err.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-get-value-err.case +// - src/dstr-binding/error/cls-decl-async-gen-meth.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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(); + } +}); + + +class C { + async *method({ poisoned }) { + + } +}; + +var method = C.prototype.method; + +assert.throws(Test262Error, function() { + method(poisonedProperty); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-id-init-fn-name-arrow.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..96fa1aa0cd --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-id-init-fn-name-arrow.js @@ -0,0 +1,68 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-arrow.case +// - src/dstr-binding/default/cls-decl-async-gen-meth.template +/*--- +description: SingleNameBinding assigns `name` to arrow functions (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + + +var callCount = 0; +class C { + async *method({ arrow = () => {} }) { + assert.sameValue(arrow.name, 'arrow'); + callCount = callCount + 1; + } +}; + +new C().method({}).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-id-init-fn-name-class.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-id-init-fn-name-class.js new file mode 100644 index 0000000000..83429e1d61 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-id-init-fn-name-class.js @@ -0,0 +1,70 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-class.case +// - src/dstr-binding/default/cls-decl-async-gen-meth.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + + +var callCount = 0; +class C { + async *method({ cls = class {}, xCls = class X {}, xCls2 = class { static name() {} } }) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + assert.notSameValue(xCls2.name, 'xCls2'); + callCount = callCount + 1; + } +}; + +new C().method({}).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-id-init-fn-name-cover.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-id-init-fn-name-cover.js new file mode 100644 index 0000000000..e35fd0a17c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-id-init-fn-name-cover.js @@ -0,0 +1,69 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-cover.case +// - src/dstr-binding/default/cls-decl-async-gen-meth.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" functions "through" cover grammar (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + + +var callCount = 0; +class C { + async *method({ cover = (function () {}), xCover = (0, function() {}) }) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + callCount = callCount + 1; + } +}; + +new C().method({}).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-id-init-fn-name-fn.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-id-init-fn-name-fn.js new file mode 100644 index 0000000000..19e34a34c7 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-id-init-fn-name-fn.js @@ -0,0 +1,69 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-fn.case +// - src/dstr-binding/default/cls-decl-async-gen-meth.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + + +var callCount = 0; +class C { + async *method({ fn = function () {}, xFn = function x() {} }) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + callCount = callCount + 1; + } +}; + +new C().method({}).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-id-init-fn-name-gen.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-id-init-fn-name-gen.js new file mode 100644 index 0000000000..d5105aee06 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-id-init-fn-name-gen.js @@ -0,0 +1,70 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-gen.case +// - src/dstr-binding/default/cls-decl-async-gen-meth.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). + +---*/ + + +var callCount = 0; +class C { + async *method({ gen = function* () {}, xGen = function* x() {} }) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + callCount = callCount + 1; + } +}; + +new C().method({}).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-id-init-skipped.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-id-init-skipped.js new file mode 100644 index 0000000000..cd15b40515 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-id-init-skipped.js @@ -0,0 +1,72 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-skipped.case +// - src/dstr-binding/default/cls-decl-async-gen-meth.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + + +var callCount = 0; +class C { + async *method({ w = counter(), x = counter(), y = counter(), z = counter() }) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +new C().method({ w: null, x: 0, y: false, z: '' }).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-id-init-throws.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-id-init-throws.js new file mode 100644 index 0000000000..2e9f281940 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-id-init-throws.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-throws.case +// - src/dstr-binding/error/cls-decl-async-gen-meth.template +/*--- +description: Error thrown when evaluating the initializer (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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(); +} + + +class C { + async *method({ x = thrower() }) { + + } +}; + +var method = C.prototype.method; + +assert.throws(Test262Error, function() { + method({}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-id-init-unresolvable.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-id-init-unresolvable.js new file mode 100644 index 0000000000..ef6e4e26ec --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-id-init-unresolvable.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-unresolvable.case +// - src/dstr-binding/error/cls-decl-async-gen-meth.template +/*--- +description: Destructuring initializer is an unresolvable reference (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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. +---*/ + + +class C { + async *method({ x = unresolvableReference }) { + + } +}; + +var method = C.prototype.method; + +assert.throws(ReferenceError, function() { + method({}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-id-trailing-comma.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-id-trailing-comma.js new file mode 100644 index 0000000000..3d4614787b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-id-trailing-comma.js @@ -0,0 +1,62 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-trailing-comma.case +// - src/dstr-binding/default/cls-decl-async-gen-meth.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + + +var callCount = 0; +class C { + async *method({ x, }) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } +}; + +new C().method({ x: 23 }).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-list-err.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-list-err.js new file mode 100644 index 0000000000..139a9d575e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-list-err.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-list-err.case +// - src/dstr-binding/error/cls-decl-async-gen-meth.template +/*--- +description: Binding property list evaluation is interrupted by an abrupt completion (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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(); +} + + +class C { + async *method({ a, b = thrower(), c = ++initCount }) { + + } +}; + +var method = C.prototype.method; + +assert.throws(Test262Error, function() { + method({}); +}); + +assert.sameValue(initCount, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-prop-ary-init.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-prop-ary-init.js new file mode 100644 index 0000000000..5d4a2b7024 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-prop-ary-init.js @@ -0,0 +1,71 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-init.case +// - src/dstr-binding/default/cls-decl-async-gen-meth.template +/*--- +description: Object binding pattern with "nested" array binding pattern using initializer (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 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). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + + +var callCount = 0; +class C { + async *method({ w: [x, y, z] = [4, 5, 6] }) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } +}; + +new C().method({}).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-prop-ary-trailing-comma.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-prop-ary-trailing-comma.js new file mode 100644 index 0000000000..20c2f315a7 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-prop-ary-trailing-comma.js @@ -0,0 +1,62 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-trailing-comma.case +// - src/dstr-binding/default/cls-decl-async-gen-meth.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + + +var callCount = 0; +class C { + async *method({ x: [y], }) { + assert.sameValue(y,45); + callCount = callCount + 1; + } +}; + +new C().method({ x: [45] }).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-prop-ary-value-null.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-prop-ary-value-null.js new file mode 100644 index 0000000000..50e63756bd --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-prop-ary-value-null.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-value-null.case +// - src/dstr-binding/error/cls-decl-async-gen-meth.template +/*--- +description: Object binding pattern with "nested" array binding pattern taking the `null` value (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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. +---*/ + + +class C { + async *method({ w: [x, y, z] = [4, 5, 6] }) { + + } +}; + +var method = C.prototype.method; + +assert.throws(TypeError, function() { + method({ w: null }); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-prop-ary.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-prop-ary.js new file mode 100644 index 0000000000..0c74e8bdb7 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-prop-ary.js @@ -0,0 +1,69 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary.case +// - src/dstr-binding/default/cls-decl-async-gen-meth.template +/*--- +description: Object binding pattern with "nested" array binding pattern not using initializer (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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. +---*/ + + +var callCount = 0; +class C { + async *method({ w: [x, y, z] = [4, 5, 6] }) { + assert.sameValue(x, 7); + assert.sameValue(y, undefined); + assert.sameValue(z, undefined); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } +}; + +new C().method({ w: [7, undefined, ] }).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-prop-eval-err.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-prop-eval-err.js new file mode 100644 index 0000000000..4b4c336319 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-prop-eval-err.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-eval-err.case +// - src/dstr-binding/error/cls-decl-async-gen-meth.template +/*--- +description: Evaluation of property name returns an abrupt completion (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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(); +} + + +class C { + async *method({ [thrower()]: x }) { + + } +}; + +var method = C.prototype.method; + +assert.throws(Test262Error, function() { + method({}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-prop-id-get-value-err.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-prop-id-get-value-err.js new file mode 100644 index 0000000000..5959bd5a73 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-prop-id-get-value-err.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-get-value-err.case +// - src/dstr-binding/error/cls-decl-async-gen-meth.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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(); + } +}); + + +class C { + async *method({ poisoned: x = ++initEvalCount }) { + + } +}; + +var method = C.prototype.method; + +assert.throws(Test262Error, function() { + method(poisonedProperty); +}); + +assert.sameValue(initEvalCount, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-prop-id-init-skipped.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-prop-id-init-skipped.js new file mode 100644 index 0000000000..969a368938 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-prop-id-init-skipped.js @@ -0,0 +1,84 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-skipped.case +// - src/dstr-binding/default/cls-decl-async-gen-meth.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + + +var callCount = 0; +class C { + async *method({ s: t = counter(), u: v = counter(), w: x = counter(), y: z = counter() }) { + assert.sameValue(t, null); + assert.sameValue(v, 0); + assert.sameValue(x, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + + assert.throws(ReferenceError, function() { + s; + }); + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } +}; + +new C().method({ s: null, u: 0, w: false, y: '' }).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-prop-id-init-throws.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-prop-id-init-throws.js new file mode 100644 index 0000000000..7419a220df --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-prop-id-init-throws.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-throws.case +// - src/dstr-binding/error/cls-decl-async-gen-meth.template +/*--- +description: Error thrown when evaluating the initializer (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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(); +} + + +class C { + async *method({ x: y = thrower() }) { + + } +}; + +var method = C.prototype.method; + +assert.throws(Test262Error, function() { + method({}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-prop-id-init-unresolvable.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-prop-id-init-unresolvable.js new file mode 100644 index 0000000000..f513d7dd05 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-prop-id-init-unresolvable.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-unresolvable.case +// - src/dstr-binding/error/cls-decl-async-gen-meth.template +/*--- +description: Destructuring initializer is an unresolvable reference (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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. +---*/ + + +class C { + async *method({ x: y = unresolvableReference }) { + + } +}; + +var method = C.prototype.method; + +assert.throws(ReferenceError, function() { + method({}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-prop-id-init.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-prop-id-init.js new file mode 100644 index 0000000000..b5117c66e4 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-prop-id-init.js @@ -0,0 +1,65 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init.case +// - src/dstr-binding/default/cls-decl-async-gen-meth.template +/*--- +description: Binding as specified via property name, identifier, and initializer (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +class C { + async *method({ x: y = 33 }) { + assert.sameValue(y, 33); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } +}; + +new C().method({ }).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-prop-id-trailing-comma.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-prop-id-trailing-comma.js new file mode 100644 index 0000000000..8a94cff2f0 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-prop-id-trailing-comma.js @@ -0,0 +1,66 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-trailing-comma.case +// - src/dstr-binding/default/cls-decl-async-gen-meth.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + + +var callCount = 0; +class C { + async *method({ x: y, }) { + assert.sameValue(y, 23); + + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } +}; + +new C().method({ x: 23 }).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-prop-id.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-prop-id.js new file mode 100644 index 0000000000..4a3f8f7e97 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-prop-id.js @@ -0,0 +1,65 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id.case +// - src/dstr-binding/default/cls-decl-async-gen-meth.template +/*--- +description: Binding as specified via property name and identifier (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +class C { + async *method({ x: y }) { + assert.sameValue(y, 23); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } +}; + +new C().method({ x: 23 }).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-prop-obj-init.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-prop-obj-init.js new file mode 100644 index 0000000000..fc8be8bf01 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-prop-obj-init.js @@ -0,0 +1,71 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-init.case +// - src/dstr-binding/default/cls-decl-async-gen-meth.template +/*--- +description: Object binding pattern with "nested" object binding pattern using initializer (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 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). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + + +var callCount = 0; +class C { + async *method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } }) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } +}; + +new C().method({ w: undefined }).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-prop-obj-value-null.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-prop-obj-value-null.js new file mode 100644 index 0000000000..d0f6f94b3b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-prop-obj-value-null.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-null.case +// - src/dstr-binding/error/cls-decl-async-gen-meth.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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. +---*/ + + +class C { + async *method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } }) { + + } +}; + +var method = C.prototype.method; + +assert.throws(TypeError, function() { + method({ w: null }); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-prop-obj-value-undef.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-prop-obj-value-undef.js new file mode 100644 index 0000000000..7afbbc89dd --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-prop-obj-value-undef.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-undef.case +// - src/dstr-binding/error/cls-decl-async-gen-meth.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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. +---*/ + + +class C { + async *method({ w: { x, y, z } = undefined }) { + + } +}; + +var method = C.prototype.method; + +assert.throws(TypeError, function() { + method({ }); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-prop-obj.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-prop-obj.js new file mode 100644 index 0000000000..8f14e47aef --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-prop-obj.js @@ -0,0 +1,69 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj.case +// - src/dstr-binding/default/cls-decl-async-gen-meth.template +/*--- +description: Object binding pattern with "nested" object binding pattern not using initializer (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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. +---*/ + + +var callCount = 0; +class C { + async *method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } }) { + assert.sameValue(x, undefined); + assert.sameValue(y, undefined); + assert.sameValue(z, 7); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } +}; + +new C().method({ w: { x: undefined, z: 7 } }).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-rest-getter.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-rest-getter.js new file mode 100644 index 0000000000..e89218806a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-rest-getter.js @@ -0,0 +1,64 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-getter.case +// - src/dstr-binding/default/cls-decl-async-gen-meth.template +/*--- +description: Getter is called when obj is being deconstructed to a rest Object (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [object-rest, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + +---*/ +var count = 0; + + +var callCount = 0; +class C { + async *method({...x}) { + assert.sameValue(count, 1); + + verifyProperty(x, "v", { + enumerable: true, + writable: true, + configurable: true, + value: 2 + }); + callCount = callCount + 1; + } +}; + +new C().method({ get v() { count++; return 2; } }).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-rest-skip-non-enumerable.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-rest-skip-non-enumerable.js new file mode 100644 index 0000000000..18fce78018 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-rest-skip-non-enumerable.js @@ -0,0 +1,72 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-skip-non-enumerable.case +// - src/dstr-binding/default/cls-decl-async-gen-meth.template +/*--- +description: Rest object doesn't contain non-enumerable properties (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [object-rest, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + +---*/ +var o = {a: 3, b: 4}; +Object.defineProperty(o, "x", { value: 4, enumerable: false }); + + +var callCount = 0; +class C { + async *method({...rest}) { + assert.sameValue(rest.x, undefined); + + verifyProperty(rest, "a", { + enumerable: true, + writable: true, + configurable: true, + value: 3 + }); + + verifyProperty(rest, "b", { + enumerable: true, + writable: true, + configurable: true, + value: 4 + }); + callCount = callCount + 1; + } +}; + +new C().method(o).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-rest-val-obj.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-rest-val-obj.js new file mode 100644 index 0000000000..420b69863e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-obj-ptrn-rest-val-obj.js @@ -0,0 +1,71 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-val-obj.case +// - src/dstr-binding/default/cls-decl-async-gen-meth.template +/*--- +description: Rest object contains just unextracted data (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [object-rest, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + +---*/ + + +var callCount = 0; +class C { + async *method({a, b, ...rest}) { + assert.sameValue(rest.a, undefined); + assert.sameValue(rest.b, undefined); + + verifyProperty(rest, "x", { + enumerable: true, + writable: true, + configurable: true, + value: 1 + }); + + verifyProperty(rest, "y", { + enumerable: true, + writable: true, + configurable: true, + value: 2 + }); + callCount = callCount + 1; + } +}; + +new C().method({x: 1, y: 2, a: 5, b: 3}).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-init-iter-close.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-init-iter-close.js new file mode 100644 index 0000000000..264fc3650d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-init-iter-close.js @@ -0,0 +1,78 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-close.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static.template +/*--- +description: Iterator is closed when not exhausted by pattern evaluation (static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [Symbol.iterator, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: false }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + + +var callCount = 0; +class C { + static async *method([x]) { + assert.sameValue(doneCallCount, 1); + callCount = callCount + 1; + } +}; + +C.method(iter).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-init-iter-get-err-array-prototype.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-init-iter-get-err-array-prototype.js new file mode 100644 index 0000000000..83ff3cd622 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-init-iter-get-err-array-prototype.js @@ -0,0 +1,73 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-get-err-array-prototype.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-static.template +/*--- +description: Abrupt completion returned by GetIterator (static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [Symbol.iterator, async-iteration] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iteratorRecord be ? GetIterator(value). + + GetIterator ( obj [ , hint [ , method ] ] ) + + [...] + 4. Let iterator be ? Call(method, obj). + + Call ( F, V [ , argumentsList ] ) + + [...] + 2. If IsCallable(F) is false, throw a TypeError exception. + +---*/ +delete Array.prototype[Symbol.iterator]; + + +class C { + static async *method([x, y, z]) { + + } +}; + +var method = C.method; + +assert.throws(TypeError, function() { + method([1, 2, 3]); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-init-iter-get-err.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-init-iter-get-err.js new file mode 100644 index 0000000000..f1e480eb36 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-init-iter-get-err.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-get-err.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-static.template +/*--- +description: Abrupt completion returned by GetIterator (static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [Symbol.iterator, async-iteration] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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(); +}; + + +class C { + static async *method([x]) { + + } +}; + +var method = C.method; + +assert.throws(Test262Error, function() { + method(iter); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-init-iter-no-close.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-init-iter-no-close.js new file mode 100644 index 0000000000..0ba8cda8be --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-init-iter-no-close.js @@ -0,0 +1,78 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-no-close.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static.template +/*--- +description: Iterator is not closed when exhausted by pattern evaluation (static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [Symbol.iterator, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: true }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + + +var callCount = 0; +class C { + static async *method([x]) { + assert.sameValue(doneCallCount, 0); + callCount = callCount + 1; + } +}; + +C.method(iter).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-name-iter-val.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-name-iter-val.js new file mode 100644 index 0000000000..be0ded9375 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-name-iter-val.js @@ -0,0 +1,77 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-name-iter-val.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static.template +/*--- +description: SingleNameBinding with normal value iteration (static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +class C { + static async *method([x, y, z]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; + } +}; + +C.method([1, 2, 3]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-ary-elem-init.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-ary-elem-init.js new file mode 100644 index 0000000000..b4a1c05177 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-ary-elem-init.js @@ -0,0 +1,69 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-init.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static.template +/*--- +description: BindingElement with array binding pattern and initializer is used (static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + + +var callCount = 0; +class C { + static async *method([[x, y, z] = [4, 5, 6]]) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + callCount = callCount + 1; + } +}; + +C.method([]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-ary-elem-iter.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-ary-elem-iter.js new file mode 100644 index 0000000000..3b672fa971 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-ary-elem-iter.js @@ -0,0 +1,70 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-iter.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + + +var callCount = 0; +class C { + static async *method([[x, y, z] = [4, 5, 6]]) { + assert.sameValue(x, 7); + assert.sameValue(y, 8); + assert.sameValue(z, 9); + callCount = callCount + 1; + } +}; + +C.method([[7, 8, 9]]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-ary-elision-init.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-ary-elision-init.js new file mode 100644 index 0000000000..1291b8a61e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-ary-elision-init.js @@ -0,0 +1,76 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-init.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static.template +/*--- +description: BindingElement with array binding pattern and initializer is used (static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + + +var callCount = 0; +class C { + static async *method([[,] = g()]) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; + } +}; + +C.method([]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-ary-elision-iter.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-ary-elision-iter.js new file mode 100644 index 0000000000..22cf0bb1fa --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-ary-elision-iter.js @@ -0,0 +1,73 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-iter.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var callCount = 0; +function* g() { + callCount += 1; +}; + + +var callCount = 0; +class C { + static async *method([[,] = g()]) { + assert.sameValue(callCount, 0); + callCount = callCount + 1; + } +}; + +C.method([[]]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-ary-empty-init.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-ary-empty-init.js new file mode 100644 index 0000000000..fdd08e13de --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-ary-empty-init.js @@ -0,0 +1,72 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-init.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static.template +/*--- +description: BindingElement with array binding pattern and initializer is used (static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var initCount = 0; +var iterCount = 0; +var iter = function*() { iterCount += 1; }(); + + +var callCount = 0; +class C { + static async *method([[] = function() { initCount += 1; return iter; }()]) { + assert.sameValue(initCount, 1); + assert.sameValue(iterCount, 0); + callCount = callCount + 1; + } +}; + +C.method([]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-ary-empty-iter.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-ary-empty-iter.js new file mode 100644 index 0000000000..4c7b96ebf6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-ary-empty-iter.js @@ -0,0 +1,69 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-iter.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var initCount = 0; + + +var callCount = 0; +class C { + static async *method([[] = function() { initCount += 1; }()]) { + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +C.method([[23]]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-ary-rest-init.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-ary-rest-init.js new file mode 100644 index 0000000000..1e83aea613 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-ary-rest-init.js @@ -0,0 +1,73 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-init.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static.template +/*--- +description: BindingElement with array binding pattern and initializer is used (static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; + + +var callCount = 0; +class C { + static async *method([[...x] = values]) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + callCount = callCount + 1; + } +}; + +C.method([]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-ary-rest-iter.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-ary-rest-iter.js new file mode 100644 index 0000000000..a994c08eec --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-ary-rest-iter.js @@ -0,0 +1,76 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-iter.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; +var initCount = 0; + + +var callCount = 0; +class C { + static async *method([[...x] = function() { initCount += 1; }()]) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +C.method([values]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-ary-val-null.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-ary-val-null.js new file mode 100644 index 0000000000..92bccd2f19 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-ary-val-null.js @@ -0,0 +1,74 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-val-null.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-static.template +/*--- +description: Nested array destructuring with a null value (static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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). +---*/ + + +class C { + static async *method([[x]]) { + + } +}; + +var method = C.method; + +assert.throws(TypeError, function() { + method([null]); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-id-init-exhausted.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-id-init-exhausted.js new file mode 100644 index 0000000000..db48fb18f5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-id-init-exhausted.js @@ -0,0 +1,68 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-exhausted.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static.template +/*--- +description: Destructuring initializer with an exhausted iterator (static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +class C { + static async *method([x = 23]) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } +}; + +C.method([]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-id-init-fn-name-arrow.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..f91dae6afe --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-id-init-fn-name-arrow.js @@ -0,0 +1,69 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-arrow.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static.template +/*--- +description: SingleNameBinding does assign name to arrow functions (static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +class C { + static async *method([arrow = () => {}]) { + assert.sameValue(arrow.name, 'arrow'); + callCount = callCount + 1; + } +}; + +C.method([]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-id-init-fn-name-class.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-id-init-fn-name-class.js new file mode 100644 index 0000000000..9883c8793f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-id-init-fn-name-class.js @@ -0,0 +1,71 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-class.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +class C { + static async *method([cls = class {}, xCls = class X {}, xCls2 = class { static name() {} }]) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + assert.notSameValue(xCls2.name, 'xCls2'); + callCount = callCount + 1; + } +}; + +C.method([]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-id-init-fn-name-cover.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-id-init-fn-name-cover.js new file mode 100644 index 0000000000..e2b5985794 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-id-init-fn-name-cover.js @@ -0,0 +1,70 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-cover.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static.template +/*--- +description: SingleNameBinding does assign name to "anonymous" functions "through" cover grammar (static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +class C { + static async *method([cover = (function () {}), xCover = (0, function() {})]) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + callCount = callCount + 1; + } +}; + +C.method([]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-id-init-fn-name-fn.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-id-init-fn-name-fn.js new file mode 100644 index 0000000000..e9e958075a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-id-init-fn-name-fn.js @@ -0,0 +1,70 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-fn.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +class C { + static async *method([fn = function () {}, xFn = function x() {}]) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + callCount = callCount + 1; + } +}; + +C.method([]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-id-init-fn-name-gen.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-id-init-fn-name-gen.js new file mode 100644 index 0000000000..4075c26454 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-id-init-fn-name-gen.js @@ -0,0 +1,71 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-gen.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). + +---*/ + + +var callCount = 0; +class C { + static async *method([gen = function* () {}, xGen = function* x() {}]) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + callCount = callCount + 1; + } +}; + +C.method([]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-id-init-hole.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-id-init-hole.js new file mode 100644 index 0000000000..df73e759f5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-id-init-hole.js @@ -0,0 +1,64 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-hole.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static.template +/*--- +description: Destructuring initializer with a "hole" (static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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). + [...] + 7. If environment is undefined, return PutValue(lhs, v). 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +class C { + static async *method([x = 23]) { + assert.sameValue(x, 23); + // another statement + callCount = callCount + 1; + } +}; + +C.method([,]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-id-init-skipped.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-id-init-skipped.js new file mode 100644 index 0000000000..8033b54a51 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-id-init-skipped.js @@ -0,0 +1,73 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-skipped.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + + +var callCount = 0; +class C { + static async *method([w = counter(), x = counter(), y = counter(), z = counter()]) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +C.method([null, 0, false, '']).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-id-init-throws.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-id-init-throws.js new file mode 100644 index 0000000000..669f46c9ae --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-id-init-throws.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-throws.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-static.template +/*--- +description: Destructuring initializer returns an abrupt completion (static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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). +---*/ + + +class C { + static async *method([x = (function() { throw new Test262Error(); })()]) { + + } +}; + +var method = C.method; + +assert.throws(Test262Error, function() { + method([undefined]); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-id-init-undef.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-id-init-undef.js new file mode 100644 index 0000000000..38590711d3 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-id-init-undef.js @@ -0,0 +1,67 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-undef.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static.template +/*--- +description: Destructuring initializer with an undefined value (static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +class C { + static async *method([x = 23]) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } +}; + +C.method([undefined]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-id-init-unresolvable.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-id-init-unresolvable.js new file mode 100644 index 0000000000..ab2486d02b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-id-init-unresolvable.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-unresolvable.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-static.template +/*--- +description: Destructuring initializer is an unresolvable reference (static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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. +---*/ + + +class C { + static async *method([ x = unresolvableReference ]) { + + } +}; + +var method = C.method; + +assert.throws(ReferenceError, function() { + method([]); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-id-iter-complete.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-id-iter-complete.js new file mode 100644 index 0000000000..e997bec484 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-id-iter-complete.js @@ -0,0 +1,71 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-complete.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static.template +/*--- +description: SingleNameBinding when value iteration completes (static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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, + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +class C { + static async *method([x]) { + assert.sameValue(x, undefined); + callCount = callCount + 1; + } +}; + +C.method([]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-id-iter-done.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-id-iter-done.js new file mode 100644 index 0000000000..8fb843e1b0 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-id-iter-done.js @@ -0,0 +1,66 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-done.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static.template +/*--- +description: SingleNameBinding when value iteration was completed previously (static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +class C { + static async *method([_, x]) { + assert.sameValue(x, undefined); + callCount = callCount + 1; + } +}; + +C.method([]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-id-iter-step-err.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-id-iter-step-err.js new file mode 100644 index 0000000000..7c66ed8916 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-id-iter-step-err.js @@ -0,0 +1,74 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-step-err.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-static.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [Symbol.iterator, async-iteration] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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(); + } + }; +}; + + +class C { + static async *method([x]) { + + } +}; + +var method = C.method; + +assert.throws(Test262Error, function() { + method(g); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-id-iter-val-array-prototype.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-id-iter-val-array-prototype.js new file mode 100644 index 0000000000..adc51fd8f8 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-id-iter-val-array-prototype.js @@ -0,0 +1,87 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val-array-prototype.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static.template +/*--- +description: Array destructuring uses overriden Array.prototype[Symbol.iterator] (static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [Symbol.iterator, generators, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializer_opt + + 1. Let bindingId be StringValue of BindingIdentifier. + 2. Let lhs be ? ResolveBinding(bindingId, environment). + 3. If iteratorRecord.[[Done]] is false, then + a. Let next be IteratorStep(iteratorRecord). + 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). + [...] + 7. Return InitializeReferencedBinding(lhs, v). + +---*/ +Array.prototype[Symbol.iterator] = function* () { + if (this.length > 0) { + yield this[0]; + } + if (this.length > 1) { + yield this[1]; + } + if (this.length > 2) { + yield 42; + } +}; + + +var callCount = 0; +class C { + static async *method([x, y, z]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 42); + callCount = callCount + 1; + } +}; + +C.method([1, 2, 3]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-id-iter-val-err.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-id-iter-val-err.js new file mode 100644 index 0000000000..8bbff5b802 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-id-iter-val-err.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val-err.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-static.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [Symbol.iterator, async-iteration] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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; + } + }; +}; + + +class C { + static async *method([x]) { + + } +}; + +var method = C.method; + +assert.throws(Test262Error, function() { + method(g); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-id-iter-val.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-id-iter-val.js new file mode 100644 index 0000000000..28164141f3 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-id-iter-val.js @@ -0,0 +1,77 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static.template +/*--- +description: SingleNameBinding when value iteration was completed previously (static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +class C { + static async *method([x, y, z]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; + } +}; + +C.method([1, 2, 3]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-obj-id-init.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-obj-id-init.js new file mode 100644 index 0000000000..962c02103c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-obj-id-init.js @@ -0,0 +1,69 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id-init.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static.template +/*--- +description: BindingElement with object binding pattern and initializer is used (static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + + +var callCount = 0; +class C { + static async *method([{ x, y, z } = { x: 44, y: 55, z: 66 }]) { + assert.sameValue(x, 44); + assert.sameValue(y, 55); + assert.sameValue(z, 66); + callCount = callCount + 1; + } +}; + +C.method([]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-obj-id.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-obj-id.js new file mode 100644 index 0000000000..fc3fd08746 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-obj-id.js @@ -0,0 +1,69 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + + +var callCount = 0; +class C { + static async *method([{ x, y, z } = { x: 44, y: 55, z: 66 }]) { + assert.sameValue(x, 11); + assert.sameValue(y, 22); + assert.sameValue(z, 33); + callCount = callCount + 1; + } +}; + +C.method([{ x: 11, y: 22, z: 33 }]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-obj-prop-id-init.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-obj-prop-id-init.js new file mode 100644 index 0000000000..391f6c9d92 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-obj-prop-id-init.js @@ -0,0 +1,79 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id-init.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static.template +/*--- +description: BindingElement with object binding pattern and initializer is used (static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + + +var callCount = 0; +class C { + static async *method([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }]) { + assert.sameValue(v, 444); + assert.sameValue(x, 555); + assert.sameValue(z, 666); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } +}; + +C.method([]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-obj-prop-id.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-obj-prop-id.js new file mode 100644 index 0000000000..608cdcf3b3 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-obj-prop-id.js @@ -0,0 +1,79 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + + +var callCount = 0; +class C { + static async *method([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }]) { + assert.sameValue(v, 777); + assert.sameValue(x, 888); + assert.sameValue(z, 999); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } +}; + +C.method([{ u: 777, w: 888, y: 999 }]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-obj-val-null.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-obj-val-null.js new file mode 100644 index 0000000000..890afb4b54 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-obj-val-null.js @@ -0,0 +1,74 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-null.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-static.template +/*--- +description: Nested object destructuring with a null value (static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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). +---*/ + + +class C { + static async *method([{ x }]) { + + } +}; + +var method = C.method; + +assert.throws(TypeError, function() { + method([null]); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-obj-val-undef.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-obj-val-undef.js new file mode 100644 index 0000000000..1ae4b3664c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elem-obj-val-undef.js @@ -0,0 +1,74 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-undef.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-static.template +/*--- +description: Nested object destructuring with a value of `undefined` (static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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). +---*/ + + +class C { + static async *method([{ x }]) { + + } +}; + +var method = C.method; + +assert.throws(TypeError, function() { + method([]); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elision-exhausted.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elision-exhausted.js new file mode 100644 index 0000000000..28bdcce3ba --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elision-exhausted.js @@ -0,0 +1,74 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-exhausted.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static.template +/*--- +description: Elision accepts exhausted iterator (static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 + [...] + 2. Return NormalCompletion(empty). + +---*/ +var iter = function*() {}(); +iter.next(); + + +var callCount = 0; +class C { + static async *method([,]) { + + callCount = callCount + 1; + } +}; + +C.method(iter).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elision-step-err.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elision-step-err.js new file mode 100644 index 0000000000..15e7202f5a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elision-step-err.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-step-err.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-static.template +/*--- +description: Elision advances iterator and forwards abrupt completions (static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, async-iteration] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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; +}(); + + +class C { + static async *method([,]) { + + } +}; + +var method = C.method; + +assert.throws(Test262Error, function() { + method(iter); +}); + +iter.next(); +assert.sameValue(following, 0, 'Iterator was properly closed.'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elision.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elision.js new file mode 100644 index 0000000000..0c8b703d37 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-elision.js @@ -0,0 +1,83 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static.template +/*--- +description: Elision advances iterator (static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + + +var callCount = 0; +class C { + static async *method([,]) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; + } +}; + +C.method(g()).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-empty.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-empty.js new file mode 100644 index 0000000000..af51f844c0 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-empty.js @@ -0,0 +1,66 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-empty.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static.template +/*--- +description: No iteration occurs for an "empty" array binding pattern (static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + + +var callCount = 0; +class C { + static async *method([]) { + assert.sameValue(iterations, 0); + callCount = callCount + 1; + } +}; + +C.method(iter).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-rest-ary-elem.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-rest-ary-elem.js new file mode 100644 index 0000000000..f77842eeb4 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-rest-ary-elem.js @@ -0,0 +1,90 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elem.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static.template +/*--- +description: Rest element containing an array BindingElementList pattern (static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the 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). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +class C { + static async *method([...[x, y, z]]) { + assert.sameValue(x, 3); + assert.sameValue(y, 4); + assert.sameValue(z, 5); + callCount = callCount + 1; + } +}; + +C.method([3, 4, 5]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-rest-ary-elision.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-rest-ary-elision.js new file mode 100644 index 0000000000..f0694f6b25 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-rest-ary-elision.js @@ -0,0 +1,96 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elision.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static.template +/*--- +description: Rest element containing an elision (static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the 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). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + + +var callCount = 0; +class C { + static async *method([...[,]]) { + assert.sameValue(first, 1); + assert.sameValue(second, 1); + callCount = callCount + 1; + } +}; + +C.method(g()).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-rest-ary-empty.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-rest-ary-empty.js new file mode 100644 index 0000000000..19a9ba4bdb --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-rest-ary-empty.js @@ -0,0 +1,79 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-empty.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static.template +/*--- +description: Rest element containing an "empty" array pattern (static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + + +var callCount = 0; +class C { + static async *method([...[]]) { + assert.sameValue(iterations, 1); + callCount = callCount + 1; + } +}; + +C.method(iter).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-rest-ary-rest.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-rest-ary-rest.js new file mode 100644 index 0000000000..9d13583ead --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-rest-ary-rest.js @@ -0,0 +1,75 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-rest.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static.template +/*--- +description: Rest element containing a rest element (static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ +var values = [1, 2, 3]; + + +var callCount = 0; +class C { + static async *method([...[...x]]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + + callCount = callCount + 1; + } +}; + +C.method(values).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-rest-id-direct.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-rest-id-direct.js new file mode 100644 index 0000000000..a3d0749da5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-rest-id-direct.js @@ -0,0 +1,70 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-direct.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static.template +/*--- +description: Lone rest element (direct binding) (static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated, async] +includes: [compareArray.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingIdentifier + + [...] + 2. Let A be ! ArrayCreate(0). + 3. Let n be 0. + 4. Repeat, + [...] + f. Perform ! CreateDataPropertyOrThrow(A, ! ToString(n), nextValue). + g. Set n to n + 1. + +---*/ + + +var callCount = 0; +class C { + static async *method([...x]) { + assert(Array.isArray(x)); + assert.compareArray(x, [1]); + callCount = callCount + 1; + } +}; + +C.method([1]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-rest-id-elision-next-err.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-rest-id-elision-next-err.js new file mode 100644 index 0000000000..b46b9a32e3 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-rest-id-elision-next-err.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision-next-err.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-static.template +/*--- +description: Rest element following elision elements (static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, async-iteration] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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(); })(); + + +class C { + static async *method([, ...x]) { + + } +}; + +var method = C.method; + +assert.throws(Test262Error, function() { + method(iter); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-rest-id-elision.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-rest-id-elision.js new file mode 100644 index 0000000000..fed54ab1bf --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-rest-id-elision.js @@ -0,0 +1,71 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static.template +/*--- +description: Rest element following elision elements (static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 values = [1, 2, 3, 4, 5]; + + +var callCount = 0; +class C { + static async *method([ , , ...x]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 3); + assert.sameValue(x[1], 4); + assert.sameValue(x[2], 5); + assert.notSameValue(x, values); + callCount = callCount + 1; + } +}; + +C.method(values).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-rest-id-exhausted.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-rest-id-exhausted.js new file mode 100644 index 0000000000..0a7695bfd3 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-rest-id-exhausted.js @@ -0,0 +1,67 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-exhausted.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static.template +/*--- +description: RestElement applied to an exhausted iterator (static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [Symbol.iterator, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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, + [...] + b. If iteratorRecord.[[done]] is true, then + i. If environment is undefined, return PutValue(lhs, A). + ii. Return InitializeReferencedBinding(lhs, A). + +---*/ + + +var callCount = 0; +class C { + static async *method([, , ...x]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 0); + callCount = callCount + 1; + } +}; + +C.method([1, 2]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-rest-id-iter-step-err.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-rest-id-iter-step-err.js new file mode 100644 index 0000000000..ae5b780a95 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-rest-id-iter-step-err.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-step-err.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-static.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, async-iteration] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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; +}(); + + +class C { + static async *method([...x]) { + + } +}; + +var method = C.method; + +assert.throws(Test262Error, function() { + method(iter); +}); + +iter.next(); +assert.sameValue(first, 1); +assert.sameValue(second, 0, 'Iterator is closed following abrupt completion.'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-rest-id-iter-val-err.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-rest-id-iter-val-err.js new file mode 100644 index 0000000000..0cb5f53348 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-rest-id-iter-val-err.js @@ -0,0 +1,80 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-val-err.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-static.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [Symbol.iterator, async-iteration] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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; + } + }; +}; + + +class C { + static async *method([...x]) { + + } +}; + +var method = C.method; + +assert.throws(Test262Error, function() { + method(iter); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-rest-id.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-rest-id.js new file mode 100644 index 0000000000..2943babe60 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-rest-id.js @@ -0,0 +1,68 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static.template +/*--- +description: Lone rest element (static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + [...] 3. Let A be ArrayCreate(0). [...] 5. Repeat + [...] + f. Let status be CreateDataProperty(A, ToString (n), nextValue). + [...] +---*/ +var values = [1, 2, 3]; + + +var callCount = 0; +class C { + static async *method([...x]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + callCount = callCount + 1; + } +}; + +C.method(values).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-rest-init-ary.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-rest-init-ary.js new file mode 100644 index 0000000000..929395eb1f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-rest-init-ary.js @@ -0,0 +1,65 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-ary.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static.template +/*--- +description: Rest element (nested array pattern) does not support initializer (static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + + +var callCount = 0; +class C { + static async *method([...[ x ] = []]) { + + callCount = callCount + 1; + } +}; + +C.method([]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-rest-init-id.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-rest-init-id.js new file mode 100644 index 0000000000..237f12a497 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-rest-init-id.js @@ -0,0 +1,65 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-id.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static.template +/*--- +description: Rest element (identifier) does not support initializer (static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + + +var callCount = 0; +class C { + static async *method([...x = []]) { + + callCount = callCount + 1; + } +}; + +C.method([]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-rest-init-obj.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-rest-init-obj.js new file mode 100644 index 0000000000..ede5a1ca14 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-rest-init-obj.js @@ -0,0 +1,65 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-obj.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static.template +/*--- +description: Rest element (nested object pattern) does not support initializer (static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + + +var callCount = 0; +class C { + static async *method([...{ x } = []]) { + + callCount = callCount + 1; + } +}; + +C.method([]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-rest-not-final-ary.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-rest-not-final-ary.js new file mode 100644 index 0000000000..137caddb0a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-rest-not-final-ary.js @@ -0,0 +1,65 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-ary.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static.template +/*--- +description: Rest element (array binding pattern) may not be followed by any element (static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + + +var callCount = 0; +class C { + static async *method([...[x], y]) { + + callCount = callCount + 1; + } +}; + +C.method([1, 2, 3]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-rest-not-final-id.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-rest-not-final-id.js new file mode 100644 index 0000000000..a10ff3f23c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-rest-not-final-id.js @@ -0,0 +1,65 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-id.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static.template +/*--- +description: Rest element (identifier) may not be followed by any element (static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + + +var callCount = 0; +class C { + static async *method([...x, y]) { + + callCount = callCount + 1; + } +}; + +C.method([1, 2, 3]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-rest-not-final-obj.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-rest-not-final-obj.js new file mode 100644 index 0000000000..c9049f79f7 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-rest-not-final-obj.js @@ -0,0 +1,65 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-obj.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static.template +/*--- +description: Rest element (object binding pattern) may not be followed by any element (static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + + +var callCount = 0; +class C { + static async *method([...{ x }, y]) { + + callCount = callCount + 1; + } +}; + +C.method([1, 2, 3]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-rest-obj-id.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-rest-obj-id.js new file mode 100644 index 0000000000..daa530dcb7 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-rest-obj-id.js @@ -0,0 +1,68 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-id.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static.template +/*--- +description: Rest element containing an object binding pattern (static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ + + +var callCount = 0; +class C { + static async *method([...{ length }]) { + assert.sameValue(length, 3); + callCount = callCount + 1; + } +}; + +C.method([1, 2, 3]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-rest-obj-prop-id.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-rest-obj-prop-id.js new file mode 100644 index 0000000000..51cc05ad01 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-ary-ptrn-rest-obj-prop-id.js @@ -0,0 +1,75 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-prop-id.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static.template +/*--- +description: Rest element containing an object binding pattern (static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ +let length = "outer"; + + +var callCount = 0; +class C { + static async *method([...{ 0: v, 1: w, 2: x, 3: y, length: z }]) { + assert.sameValue(v, 7); + assert.sameValue(w, 8); + assert.sameValue(x, 9); + assert.sameValue(y, undefined); + assert.sameValue(z, 3); + + assert.sameValue(length, "outer", "the length prop is not set as a binding name"); + callCount = callCount + 1; + } +}; + +C.method([7, 8, 9]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-init-iter-close.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-init-iter-close.js new file mode 100644 index 0000000000..99b3888c2a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-init-iter-close.js @@ -0,0 +1,78 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-close.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static-dflt.template +/*--- +description: Iterator is closed when not exhausted by pattern evaluation (static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [Symbol.iterator, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: false }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + + +var callCount = 0; +class C { + static async *method([x] = iter) { + assert.sameValue(doneCallCount, 1); + callCount = callCount + 1; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-init-iter-get-err-array-prototype.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-init-iter-get-err-array-prototype.js new file mode 100644 index 0000000000..26fbf0cc9c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-init-iter-get-err-array-prototype.js @@ -0,0 +1,73 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-get-err-array-prototype.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-static-dflt.template +/*--- +description: Abrupt completion returned by GetIterator (static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [Symbol.iterator, async-iteration] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iteratorRecord be ? GetIterator(value). + + GetIterator ( obj [ , hint [ , method ] ] ) + + [...] + 4. Let iterator be ? Call(method, obj). + + Call ( F, V [ , argumentsList ] ) + + [...] + 2. If IsCallable(F) is false, throw a TypeError exception. + +---*/ +delete Array.prototype[Symbol.iterator]; + + +class C { + static async *method([x, y, z] = [1, 2, 3]) { + + } +}; + +var method = C.method; + +assert.throws(TypeError, function() { + method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-init-iter-get-err.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-init-iter-get-err.js new file mode 100644 index 0000000000..5c964493d9 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-init-iter-get-err.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-get-err.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-static-dflt.template +/*--- +description: Abrupt completion returned by GetIterator (static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [Symbol.iterator, async-iteration] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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(); +}; + + +class C { + static async *method([x] = iter) { + + } +}; + +var method = C.method; + +assert.throws(Test262Error, function() { + method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-init-iter-no-close.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-init-iter-no-close.js new file mode 100644 index 0000000000..289080308e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-init-iter-no-close.js @@ -0,0 +1,78 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-no-close.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static-dflt.template +/*--- +description: Iterator is not closed when exhausted by pattern evaluation (static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [Symbol.iterator, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: true }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + + +var callCount = 0; +class C { + static async *method([x] = iter) { + assert.sameValue(doneCallCount, 0); + callCount = callCount + 1; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-name-iter-val.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-name-iter-val.js new file mode 100644 index 0000000000..ac1539d0cc --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-name-iter-val.js @@ -0,0 +1,77 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-name-iter-val.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static-dflt.template +/*--- +description: SingleNameBinding with normal value iteration (static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +class C { + static async *method([x, y, z] = [1, 2, 3]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-ary-elem-init.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-ary-elem-init.js new file mode 100644 index 0000000000..bb4beb7f09 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-ary-elem-init.js @@ -0,0 +1,69 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-init.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + + +var callCount = 0; +class C { + static async *method([[x, y, z] = [4, 5, 6]] = []) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + callCount = callCount + 1; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-ary-elem-iter.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-ary-elem-iter.js new file mode 100644 index 0000000000..706041e007 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-ary-elem-iter.js @@ -0,0 +1,70 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-iter.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + + +var callCount = 0; +class C { + static async *method([[x, y, z] = [4, 5, 6]] = [[7, 8, 9]]) { + assert.sameValue(x, 7); + assert.sameValue(y, 8); + assert.sameValue(z, 9); + callCount = callCount + 1; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-ary-elision-init.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-ary-elision-init.js new file mode 100644 index 0000000000..68ef8dc464 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-ary-elision-init.js @@ -0,0 +1,76 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-init.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + + +var callCount = 0; +class C { + static async *method([[,] = g()] = []) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-ary-elision-iter.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-ary-elision-iter.js new file mode 100644 index 0000000000..2bd89a1a65 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-ary-elision-iter.js @@ -0,0 +1,73 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-iter.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var callCount = 0; +function* g() { + callCount += 1; +}; + + +var callCount = 0; +class C { + static async *method([[,] = g()] = [[]]) { + assert.sameValue(callCount, 0); + callCount = callCount + 1; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-ary-empty-init.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-ary-empty-init.js new file mode 100644 index 0000000000..f9731d8045 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-ary-empty-init.js @@ -0,0 +1,72 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-init.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var initCount = 0; +var iterCount = 0; +var iter = function*() { iterCount += 1; }(); + + +var callCount = 0; +class C { + static async *method([[] = function() { initCount += 1; return iter; }()] = []) { + assert.sameValue(initCount, 1); + assert.sameValue(iterCount, 0); + callCount = callCount + 1; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-ary-empty-iter.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-ary-empty-iter.js new file mode 100644 index 0000000000..2b6f2152b3 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-ary-empty-iter.js @@ -0,0 +1,69 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-iter.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var initCount = 0; + + +var callCount = 0; +class C { + static async *method([[] = function() { initCount += 1; }()] = [[23]]) { + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-ary-rest-init.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-ary-rest-init.js new file mode 100644 index 0000000000..7a04459d6c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-ary-rest-init.js @@ -0,0 +1,73 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-init.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; + + +var callCount = 0; +class C { + static async *method([[...x] = values] = []) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + callCount = callCount + 1; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-ary-rest-iter.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-ary-rest-iter.js new file mode 100644 index 0000000000..35c05296a0 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-ary-rest-iter.js @@ -0,0 +1,76 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-iter.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; +var initCount = 0; + + +var callCount = 0; +class C { + static async *method([[...x] = function() { initCount += 1; }()] = [values]) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-ary-val-null.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-ary-val-null.js new file mode 100644 index 0000000000..b4501ed495 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-ary-val-null.js @@ -0,0 +1,74 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-val-null.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-static-dflt.template +/*--- +description: Nested array destructuring with a null value (static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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). +---*/ + + +class C { + static async *method([[x]] = [null]) { + + } +}; + +var method = C.method; + +assert.throws(TypeError, function() { + method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-id-init-exhausted.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-id-init-exhausted.js new file mode 100644 index 0000000000..28e8e79396 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-id-init-exhausted.js @@ -0,0 +1,68 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-exhausted.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static-dflt.template +/*--- +description: Destructuring initializer with an exhausted iterator (static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +class C { + static async *method([x = 23] = []) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..2d255dd6d8 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js @@ -0,0 +1,69 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-arrow.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static-dflt.template +/*--- +description: SingleNameBinding does assign name to arrow functions (static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +class C { + static async *method([arrow = () => {}] = []) { + assert.sameValue(arrow.name, 'arrow'); + callCount = callCount + 1; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-class.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-class.js new file mode 100644 index 0000000000..77a3266c18 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-class.js @@ -0,0 +1,71 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-class.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static-dflt.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +class C { + static async *method([cls = class {}, xCls = class X {}, xCls2 = class { static name() {} }] = []) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + assert.notSameValue(xCls2.name, 'xCls2'); + callCount = callCount + 1; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-cover.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-cover.js new file mode 100644 index 0000000000..92478e1c91 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-cover.js @@ -0,0 +1,70 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-cover.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static-dflt.template +/*--- +description: SingleNameBinding does assign name to "anonymous" functions "through" cover grammar (static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +class C { + static async *method([cover = (function () {}), xCover = (0, function() {})] = []) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + callCount = callCount + 1; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-fn.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-fn.js new file mode 100644 index 0000000000..cbd6d5e978 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-fn.js @@ -0,0 +1,70 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-fn.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +class C { + static async *method([fn = function () {}, xFn = function x() {}] = []) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + callCount = callCount + 1; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-gen.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-gen.js new file mode 100644 index 0000000000..ebe90e587b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-gen.js @@ -0,0 +1,71 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-gen.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). + +---*/ + + +var callCount = 0; +class C { + static async *method([gen = function* () {}, xGen = function* x() {}] = []) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + callCount = callCount + 1; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-id-init-hole.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-id-init-hole.js new file mode 100644 index 0000000000..5ca980671f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-id-init-hole.js @@ -0,0 +1,64 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-hole.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static-dflt.template +/*--- +description: Destructuring initializer with a "hole" (static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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). + [...] + 7. If environment is undefined, return PutValue(lhs, v). 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +class C { + static async *method([x = 23] = [,]) { + assert.sameValue(x, 23); + // another statement + callCount = callCount + 1; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-id-init-skipped.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-id-init-skipped.js new file mode 100644 index 0000000000..a25d3f4972 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-id-init-skipped.js @@ -0,0 +1,73 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-skipped.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static-dflt.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + + +var callCount = 0; +class C { + static async *method([w = counter(), x = counter(), y = counter(), z = counter()] = [null, 0, false, '']) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-id-init-throws.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-id-init-throws.js new file mode 100644 index 0000000000..2b2adac10f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-id-init-throws.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-throws.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-static-dflt.template +/*--- +description: Destructuring initializer returns an abrupt completion (static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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). +---*/ + + +class C { + static async *method([x = (function() { throw new Test262Error(); })()] = [undefined]) { + + } +}; + +var method = C.method; + +assert.throws(Test262Error, function() { + method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-id-init-undef.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-id-init-undef.js new file mode 100644 index 0000000000..6c7bf940b7 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-id-init-undef.js @@ -0,0 +1,67 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-undef.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static-dflt.template +/*--- +description: Destructuring initializer with an undefined value (static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +class C { + static async *method([x = 23] = [undefined]) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-id-init-unresolvable.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-id-init-unresolvable.js new file mode 100644 index 0000000000..2a2a0086eb --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-id-init-unresolvable.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-unresolvable.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-static-dflt.template +/*--- +description: Destructuring initializer is an unresolvable reference (static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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. +---*/ + + +class C { + static async *method([ x = unresolvableReference ] = []) { + + } +}; + +var method = C.method; + +assert.throws(ReferenceError, function() { + method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-id-iter-complete.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-id-iter-complete.js new file mode 100644 index 0000000000..f090a1a837 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-id-iter-complete.js @@ -0,0 +1,71 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-complete.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static-dflt.template +/*--- +description: SingleNameBinding when value iteration completes (static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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, + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +class C { + static async *method([x] = []) { + assert.sameValue(x, undefined); + callCount = callCount + 1; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-id-iter-done.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-id-iter-done.js new file mode 100644 index 0000000000..5988258232 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-id-iter-done.js @@ -0,0 +1,66 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-done.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static-dflt.template +/*--- +description: SingleNameBinding when value iteration was completed previously (static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +class C { + static async *method([_, x] = []) { + assert.sameValue(x, undefined); + callCount = callCount + 1; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-id-iter-step-err.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-id-iter-step-err.js new file mode 100644 index 0000000000..e7224906ed --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-id-iter-step-err.js @@ -0,0 +1,74 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-step-err.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-static-dflt.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [Symbol.iterator, async-iteration] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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(); + } + }; +}; + + +class C { + static async *method([x] = g) { + + } +}; + +var method = C.method; + +assert.throws(Test262Error, function() { + method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-id-iter-val-array-prototype.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-id-iter-val-array-prototype.js new file mode 100644 index 0000000000..6f5ec9b021 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-id-iter-val-array-prototype.js @@ -0,0 +1,87 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val-array-prototype.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static-dflt.template +/*--- +description: Array destructuring uses overriden Array.prototype[Symbol.iterator] (static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [Symbol.iterator, generators, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializer_opt + + 1. Let bindingId be StringValue of BindingIdentifier. + 2. Let lhs be ? ResolveBinding(bindingId, environment). + 3. If iteratorRecord.[[Done]] is false, then + a. Let next be IteratorStep(iteratorRecord). + 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). + [...] + 7. Return InitializeReferencedBinding(lhs, v). + +---*/ +Array.prototype[Symbol.iterator] = function* () { + if (this.length > 0) { + yield this[0]; + } + if (this.length > 1) { + yield this[1]; + } + if (this.length > 2) { + yield 42; + } +}; + + +var callCount = 0; +class C { + static async *method([x, y, z] = [1, 2, 3]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 42); + callCount = callCount + 1; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-id-iter-val-err.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-id-iter-val-err.js new file mode 100644 index 0000000000..82883f7c68 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-id-iter-val-err.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val-err.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-static-dflt.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [Symbol.iterator, async-iteration] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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; + } + }; +}; + + +class C { + static async *method([x] = g) { + + } +}; + +var method = C.method; + +assert.throws(Test262Error, function() { + method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-id-iter-val.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-id-iter-val.js new file mode 100644 index 0000000000..f0a07fe7e0 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-id-iter-val.js @@ -0,0 +1,77 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static-dflt.template +/*--- +description: SingleNameBinding when value iteration was completed previously (static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +class C { + static async *method([x, y, z] = [1, 2, 3]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-obj-id-init.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-obj-id-init.js new file mode 100644 index 0000000000..896f137ef1 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-obj-id-init.js @@ -0,0 +1,69 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id-init.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is used (static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + + +var callCount = 0; +class C { + static async *method([{ x, y, z } = { x: 44, y: 55, z: 66 }] = []) { + assert.sameValue(x, 44); + assert.sameValue(y, 55); + assert.sameValue(z, 66); + callCount = callCount + 1; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-obj-id.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-obj-id.js new file mode 100644 index 0000000000..1c6909db21 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-obj-id.js @@ -0,0 +1,69 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + + +var callCount = 0; +class C { + static async *method([{ x, y, z } = { x: 44, y: 55, z: 66 }] = [{ x: 11, y: 22, z: 33 }]) { + assert.sameValue(x, 11); + assert.sameValue(y, 22); + assert.sameValue(z, 33); + callCount = callCount + 1; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-obj-prop-id-init.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-obj-prop-id-init.js new file mode 100644 index 0000000000..5ba5d0ca8a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-obj-prop-id-init.js @@ -0,0 +1,79 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id-init.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is used (static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + + +var callCount = 0; +class C { + static async *method([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] = []) { + assert.sameValue(v, 444); + assert.sameValue(x, 555); + assert.sameValue(z, 666); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-obj-prop-id.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-obj-prop-id.js new file mode 100644 index 0000000000..15691fb960 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-obj-prop-id.js @@ -0,0 +1,79 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + + +var callCount = 0; +class C { + static async *method([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] = [{ u: 777, w: 888, y: 999 }]) { + assert.sameValue(v, 777); + assert.sameValue(x, 888); + assert.sameValue(z, 999); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-obj-val-null.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-obj-val-null.js new file mode 100644 index 0000000000..cff11ddcd1 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-obj-val-null.js @@ -0,0 +1,74 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-null.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-static-dflt.template +/*--- +description: Nested object destructuring with a null value (static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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). +---*/ + + +class C { + static async *method([{ x }] = [null]) { + + } +}; + +var method = C.method; + +assert.throws(TypeError, function() { + method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-obj-val-undef.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-obj-val-undef.js new file mode 100644 index 0000000000..bb9dd84eaa --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elem-obj-val-undef.js @@ -0,0 +1,74 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-undef.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-static-dflt.template +/*--- +description: Nested object destructuring with a value of `undefined` (static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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). +---*/ + + +class C { + static async *method([{ x }] = []) { + + } +}; + +var method = C.method; + +assert.throws(TypeError, function() { + method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elision-exhausted.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elision-exhausted.js new file mode 100644 index 0000000000..aa97ecd0c6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elision-exhausted.js @@ -0,0 +1,74 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-exhausted.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static-dflt.template +/*--- +description: Elision accepts exhausted iterator (static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 + [...] + 2. Return NormalCompletion(empty). + +---*/ +var iter = function*() {}(); +iter.next(); + + +var callCount = 0; +class C { + static async *method([,] = iter) { + + callCount = callCount + 1; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elision-step-err.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elision-step-err.js new file mode 100644 index 0000000000..81eda9cb2a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elision-step-err.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-step-err.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-static-dflt.template +/*--- +description: Elision advances iterator and forwards abrupt completions (static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, async-iteration] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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; +}(); + + +class C { + static async *method([,] = iter) { + + } +}; + +var method = C.method; + +assert.throws(Test262Error, function() { + method(); +}); + +iter.next(); +assert.sameValue(following, 0, 'Iterator was properly closed.'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elision.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elision.js new file mode 100644 index 0000000000..d2f0237750 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-elision.js @@ -0,0 +1,83 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static-dflt.template +/*--- +description: Elision advances iterator (static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + + +var callCount = 0; +class C { + static async *method([,] = g()) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-empty.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-empty.js new file mode 100644 index 0000000000..d401a805b6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-empty.js @@ -0,0 +1,66 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-empty.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static-dflt.template +/*--- +description: No iteration occurs for an "empty" array binding pattern (static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + + +var callCount = 0; +class C { + static async *method([] = iter) { + assert.sameValue(iterations, 0); + callCount = callCount + 1; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-rest-ary-elem.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-rest-ary-elem.js new file mode 100644 index 0000000000..ecda6d24ff --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-rest-ary-elem.js @@ -0,0 +1,90 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elem.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static-dflt.template +/*--- +description: Rest element containing an array BindingElementList pattern (static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the 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). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +class C { + static async *method([...[x, y, z]] = [3, 4, 5]) { + assert.sameValue(x, 3); + assert.sameValue(y, 4); + assert.sameValue(z, 5); + callCount = callCount + 1; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-rest-ary-elision.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-rest-ary-elision.js new file mode 100644 index 0000000000..10c59b812a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-rest-ary-elision.js @@ -0,0 +1,96 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elision.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static-dflt.template +/*--- +description: Rest element containing an elision (static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the 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). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + + +var callCount = 0; +class C { + static async *method([...[,]] = g()) { + assert.sameValue(first, 1); + assert.sameValue(second, 1); + callCount = callCount + 1; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-rest-ary-empty.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-rest-ary-empty.js new file mode 100644 index 0000000000..2f30bb2ef3 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-rest-ary-empty.js @@ -0,0 +1,79 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-empty.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static-dflt.template +/*--- +description: Rest element containing an "empty" array pattern (static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + + +var callCount = 0; +class C { + static async *method([...[]] = iter) { + assert.sameValue(iterations, 1); + callCount = callCount + 1; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-rest-ary-rest.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-rest-ary-rest.js new file mode 100644 index 0000000000..09707435a1 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-rest-ary-rest.js @@ -0,0 +1,75 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-rest.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static-dflt.template +/*--- +description: Rest element containing a rest element (static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ +var values = [1, 2, 3]; + + +var callCount = 0; +class C { + static async *method([...[...x]] = values) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + + callCount = callCount + 1; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-rest-id-direct.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-rest-id-direct.js new file mode 100644 index 0000000000..e537cff630 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-rest-id-direct.js @@ -0,0 +1,70 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-direct.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static-dflt.template +/*--- +description: Lone rest element (direct binding) (static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated, async] +includes: [compareArray.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingIdentifier + + [...] + 2. Let A be ! ArrayCreate(0). + 3. Let n be 0. + 4. Repeat, + [...] + f. Perform ! CreateDataPropertyOrThrow(A, ! ToString(n), nextValue). + g. Set n to n + 1. + +---*/ + + +var callCount = 0; +class C { + static async *method([...x] = [1]) { + assert(Array.isArray(x)); + assert.compareArray(x, [1]); + callCount = callCount + 1; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-rest-id-elision-next-err.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-rest-id-elision-next-err.js new file mode 100644 index 0000000000..423e11010b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-rest-id-elision-next-err.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision-next-err.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-static-dflt.template +/*--- +description: Rest element following elision elements (static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, async-iteration] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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(); })(); + + +class C { + static async *method([, ...x] = iter) { + + } +}; + +var method = C.method; + +assert.throws(Test262Error, function() { + method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-rest-id-elision.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-rest-id-elision.js new file mode 100644 index 0000000000..00869aaa8c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-rest-id-elision.js @@ -0,0 +1,71 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static-dflt.template +/*--- +description: Rest element following elision elements (static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 values = [1, 2, 3, 4, 5]; + + +var callCount = 0; +class C { + static async *method([ , , ...x] = values) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 3); + assert.sameValue(x[1], 4); + assert.sameValue(x[2], 5); + assert.notSameValue(x, values); + callCount = callCount + 1; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-rest-id-exhausted.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-rest-id-exhausted.js new file mode 100644 index 0000000000..b0abbbe2af --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-rest-id-exhausted.js @@ -0,0 +1,67 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-exhausted.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static-dflt.template +/*--- +description: RestElement applied to an exhausted iterator (static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [Symbol.iterator, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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, + [...] + b. If iteratorRecord.[[done]] is true, then + i. If environment is undefined, return PutValue(lhs, A). + ii. Return InitializeReferencedBinding(lhs, A). + +---*/ + + +var callCount = 0; +class C { + static async *method([, , ...x] = [1, 2]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 0); + callCount = callCount + 1; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-rest-id-iter-step-err.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-rest-id-iter-step-err.js new file mode 100644 index 0000000000..0ae2c20d79 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-rest-id-iter-step-err.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-step-err.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-static-dflt.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, async-iteration] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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; +}(); + + +class C { + static async *method([...x] = iter) { + + } +}; + +var method = C.method; + +assert.throws(Test262Error, function() { + method(); +}); + +iter.next(); +assert.sameValue(first, 1); +assert.sameValue(second, 0, 'Iterator is closed following abrupt completion.'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-rest-id-iter-val-err.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-rest-id-iter-val-err.js new file mode 100644 index 0000000000..ae31b2d57d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-rest-id-iter-val-err.js @@ -0,0 +1,80 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-val-err.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-static-dflt.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [Symbol.iterator, async-iteration] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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; + } + }; +}; + + +class C { + static async *method([...x] = iter) { + + } +}; + +var method = C.method; + +assert.throws(Test262Error, function() { + method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-rest-id.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-rest-id.js new file mode 100644 index 0000000000..5b589769a3 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-rest-id.js @@ -0,0 +1,68 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static-dflt.template +/*--- +description: Lone rest element (static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + [...] 3. Let A be ArrayCreate(0). [...] 5. Repeat + [...] + f. Let status be CreateDataProperty(A, ToString (n), nextValue). + [...] +---*/ +var values = [1, 2, 3]; + + +var callCount = 0; +class C { + static async *method([...x] = values) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + callCount = callCount + 1; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-rest-init-ary.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-rest-init-ary.js new file mode 100644 index 0000000000..44044f3eb0 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-rest-init-ary.js @@ -0,0 +1,65 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-ary.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static-dflt.template +/*--- +description: Rest element (nested array pattern) does not support initializer (static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + + +var callCount = 0; +class C { + static async *method([...[ x ] = []] = []) { + + callCount = callCount + 1; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-rest-init-id.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-rest-init-id.js new file mode 100644 index 0000000000..1f4ef2d193 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-rest-init-id.js @@ -0,0 +1,65 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-id.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static-dflt.template +/*--- +description: Rest element (identifier) does not support initializer (static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + + +var callCount = 0; +class C { + static async *method([...x = []] = []) { + + callCount = callCount + 1; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-rest-init-obj.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-rest-init-obj.js new file mode 100644 index 0000000000..69208aad8f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-rest-init-obj.js @@ -0,0 +1,65 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-obj.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static-dflt.template +/*--- +description: Rest element (nested object pattern) does not support initializer (static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + + +var callCount = 0; +class C { + static async *method([...{ x } = []] = []) { + + callCount = callCount + 1; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-rest-not-final-ary.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-rest-not-final-ary.js new file mode 100644 index 0000000000..3bcc910267 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-rest-not-final-ary.js @@ -0,0 +1,65 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-ary.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static-dflt.template +/*--- +description: Rest element (array binding pattern) may not be followed by any element (static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + + +var callCount = 0; +class C { + static async *method([...[x], y] = [1, 2, 3]) { + + callCount = callCount + 1; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-rest-not-final-id.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-rest-not-final-id.js new file mode 100644 index 0000000000..ec1fa94da8 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-rest-not-final-id.js @@ -0,0 +1,65 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-id.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static-dflt.template +/*--- +description: Rest element (identifier) may not be followed by any element (static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + + +var callCount = 0; +class C { + static async *method([...x, y] = [1, 2, 3]) { + + callCount = callCount + 1; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-rest-not-final-obj.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-rest-not-final-obj.js new file mode 100644 index 0000000000..0a29490a51 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-rest-not-final-obj.js @@ -0,0 +1,65 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-obj.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static-dflt.template +/*--- +description: Rest element (object binding pattern) may not be followed by any element (static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + + +var callCount = 0; +class C { + static async *method([...{ x }, y] = [1, 2, 3]) { + + callCount = callCount + 1; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-rest-obj-id.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-rest-obj-id.js new file mode 100644 index 0000000000..20c1d49c0a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-rest-obj-id.js @@ -0,0 +1,68 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-id.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static-dflt.template +/*--- +description: Rest element containing an object binding pattern (static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ + + +var callCount = 0; +class C { + static async *method([...{ length }] = [1, 2, 3]) { + assert.sameValue(length, 3); + callCount = callCount + 1; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-rest-obj-prop-id.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-rest-obj-prop-id.js new file mode 100644 index 0000000000..a4b95d0178 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-ary-ptrn-rest-obj-prop-id.js @@ -0,0 +1,75 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-prop-id.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static-dflt.template +/*--- +description: Rest element containing an object binding pattern (static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ +let length = "outer"; + + +var callCount = 0; +class C { + static async *method([...{ 0: v, 1: w, 2: x, 3: y, length: z }] = [7, 8, 9]) { + assert.sameValue(v, 7); + assert.sameValue(w, 8); + assert.sameValue(x, 9); + assert.sameValue(y, undefined); + assert.sameValue(z, 3); + + assert.sameValue(length, "outer", "the length prop is not set as a binding name"); + callCount = callCount + 1; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-init-null.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-init-null.js new file mode 100644 index 0000000000..f7d708093b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-init-null.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-null.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-static-dflt.template +/*--- +description: Value specifed for object binding pattern must be object coercible (null) (static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + + +class C { + static async *method({} = null) { + + } +}; + +var method = C.method; + +assert.throws(TypeError, function() { + method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-init-undefined.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-init-undefined.js new file mode 100644 index 0000000000..fce7b7bca5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-init-undefined.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-undefined.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-static-dflt.template +/*--- +description: Value specifed for object binding pattern must be object coercible (undefined) (static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + + +class C { + static async *method({} = undefined) { + + } +}; + +var method = C.method; + +assert.throws(TypeError, function() { + method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-empty.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-empty.js new file mode 100644 index 0000000000..8fa75e42e4 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-empty.js @@ -0,0 +1,67 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-empty.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static-dflt.template +/*--- +description: No property access occurs for an "empty" object binding pattern (static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ +var accessCount = 0; +var obj = Object.defineProperty({}, 'attr', { + get: function() { + accessCount += 1; + } +}); + + +var callCount = 0; +class C { + static async *method({} = obj) { + assert.sameValue(accessCount, 0); + callCount = callCount + 1; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-id-get-value-err.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-id-get-value-err.js new file mode 100644 index 0000000000..55ed81fa09 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-id-get-value-err.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-get-value-err.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-static-dflt.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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(); + } +}); + + +class C { + static async *method({ poisoned } = poisonedProperty) { + + } +}; + +var method = C.method; + +assert.throws(Test262Error, function() { + method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-id-init-fn-name-arrow.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..2cff36cace --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-id-init-fn-name-arrow.js @@ -0,0 +1,68 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-arrow.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static-dflt.template +/*--- +description: SingleNameBinding assigns `name` to arrow functions (static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + + +var callCount = 0; +class C { + static async *method({ arrow = () => {} } = {}) { + assert.sameValue(arrow.name, 'arrow'); + callCount = callCount + 1; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-id-init-fn-name-class.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-id-init-fn-name-class.js new file mode 100644 index 0000000000..cdbd26b9f9 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-id-init-fn-name-class.js @@ -0,0 +1,70 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-class.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static-dflt.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + + +var callCount = 0; +class C { + static async *method({ cls = class {}, xCls = class X {}, xCls2 = class { static name() {} } } = {}) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + assert.notSameValue(xCls2.name, 'xCls2'); + callCount = callCount + 1; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-id-init-fn-name-cover.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-id-init-fn-name-cover.js new file mode 100644 index 0000000000..5708745091 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-id-init-fn-name-cover.js @@ -0,0 +1,69 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-cover.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static-dflt.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" functions "through" cover grammar (static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + + +var callCount = 0; +class C { + static async *method({ cover = (function () {}), xCover = (0, function() {}) } = {}) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + callCount = callCount + 1; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-id-init-fn-name-fn.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-id-init-fn-name-fn.js new file mode 100644 index 0000000000..a96d8af870 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-id-init-fn-name-fn.js @@ -0,0 +1,69 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-fn.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + + +var callCount = 0; +class C { + static async *method({ fn = function () {}, xFn = function x() {} } = {}) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + callCount = callCount + 1; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-id-init-fn-name-gen.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-id-init-fn-name-gen.js new file mode 100644 index 0000000000..af20584145 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-id-init-fn-name-gen.js @@ -0,0 +1,70 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-gen.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). + +---*/ + + +var callCount = 0; +class C { + static async *method({ gen = function* () {}, xGen = function* x() {} } = {}) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + callCount = callCount + 1; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-id-init-skipped.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-id-init-skipped.js new file mode 100644 index 0000000000..ca6e9dcd51 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-id-init-skipped.js @@ -0,0 +1,72 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-skipped.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static-dflt.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + + +var callCount = 0; +class C { + static async *method({ w = counter(), x = counter(), y = counter(), z = counter() } = { w: null, x: 0, y: false, z: '' }) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-id-init-throws.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-id-init-throws.js new file mode 100644 index 0000000000..d2b1224a33 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-id-init-throws.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-throws.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-static-dflt.template +/*--- +description: Error thrown when evaluating the initializer (static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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(); +} + + +class C { + static async *method({ x = thrower() } = {}) { + + } +}; + +var method = C.method; + +assert.throws(Test262Error, function() { + method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-id-init-unresolvable.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-id-init-unresolvable.js new file mode 100644 index 0000000000..0d19825c5e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-id-init-unresolvable.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-unresolvable.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-static-dflt.template +/*--- +description: Destructuring initializer is an unresolvable reference (static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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. +---*/ + + +class C { + static async *method({ x = unresolvableReference } = {}) { + + } +}; + +var method = C.method; + +assert.throws(ReferenceError, function() { + method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-id-trailing-comma.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-id-trailing-comma.js new file mode 100644 index 0000000000..0d6894ecc8 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-id-trailing-comma.js @@ -0,0 +1,62 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-trailing-comma.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static-dflt.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + + +var callCount = 0; +class C { + static async *method({ x, } = { x: 23 }) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-list-err.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-list-err.js new file mode 100644 index 0000000000..03cba933f5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-list-err.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-list-err.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-static-dflt.template +/*--- +description: Binding property list evaluation is interrupted by an abrupt completion (static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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(); +} + + +class C { + static async *method({ a, b = thrower(), c = ++initCount } = {}) { + + } +}; + +var method = C.method; + +assert.throws(Test262Error, function() { + method(); +}); + +assert.sameValue(initCount, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-prop-ary-init.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-prop-ary-init.js new file mode 100644 index 0000000000..ef3df6831a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-prop-ary-init.js @@ -0,0 +1,71 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-init.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static-dflt.template +/*--- +description: Object binding pattern with "nested" array binding pattern using initializer (static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 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). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + + +var callCount = 0; +class C { + static async *method({ w: [x, y, z] = [4, 5, 6] } = {}) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-prop-ary-trailing-comma.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-prop-ary-trailing-comma.js new file mode 100644 index 0000000000..bd79302bf9 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-prop-ary-trailing-comma.js @@ -0,0 +1,62 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-trailing-comma.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static-dflt.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + + +var callCount = 0; +class C { + static async *method({ x: [y], } = { x: [45] }) { + assert.sameValue(y,45); + callCount = callCount + 1; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-prop-ary-value-null.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-prop-ary-value-null.js new file mode 100644 index 0000000000..9ecc524d73 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-prop-ary-value-null.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-value-null.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-static-dflt.template +/*--- +description: Object binding pattern with "nested" array binding pattern taking the `null` value (static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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. +---*/ + + +class C { + static async *method({ w: [x, y, z] = [4, 5, 6] } = { w: null }) { + + } +}; + +var method = C.method; + +assert.throws(TypeError, function() { + method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-prop-ary.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-prop-ary.js new file mode 100644 index 0000000000..3188294db9 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-prop-ary.js @@ -0,0 +1,69 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static-dflt.template +/*--- +description: Object binding pattern with "nested" array binding pattern not using initializer (static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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. +---*/ + + +var callCount = 0; +class C { + static async *method({ w: [x, y, z] = [4, 5, 6] } = { w: [7, undefined, ] }) { + assert.sameValue(x, 7); + assert.sameValue(y, undefined); + assert.sameValue(z, undefined); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-prop-eval-err.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-prop-eval-err.js new file mode 100644 index 0000000000..86a97070e9 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-prop-eval-err.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-eval-err.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-static-dflt.template +/*--- +description: Evaluation of property name returns an abrupt completion (static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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(); +} + + +class C { + static async *method({ [thrower()]: x } = {}) { + + } +}; + +var method = C.method; + +assert.throws(Test262Error, function() { + method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-prop-id-get-value-err.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-prop-id-get-value-err.js new file mode 100644 index 0000000000..0f81e66f30 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-prop-id-get-value-err.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-get-value-err.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-static-dflt.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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(); + } +}); + + +class C { + static async *method({ poisoned: x = ++initEvalCount } = poisonedProperty) { + + } +}; + +var method = C.method; + +assert.throws(Test262Error, function() { + method(); +}); + +assert.sameValue(initEvalCount, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-prop-id-init-skipped.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-prop-id-init-skipped.js new file mode 100644 index 0000000000..d2451af9dc --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-prop-id-init-skipped.js @@ -0,0 +1,84 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-skipped.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static-dflt.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + + +var callCount = 0; +class C { + static async *method({ s: t = counter(), u: v = counter(), w: x = counter(), y: z = counter() } = { s: null, u: 0, w: false, y: '' }) { + assert.sameValue(t, null); + assert.sameValue(v, 0); + assert.sameValue(x, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + + assert.throws(ReferenceError, function() { + s; + }); + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-prop-id-init-throws.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-prop-id-init-throws.js new file mode 100644 index 0000000000..19a9bae376 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-prop-id-init-throws.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-throws.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-static-dflt.template +/*--- +description: Error thrown when evaluating the initializer (static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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(); +} + + +class C { + static async *method({ x: y = thrower() } = {}) { + + } +}; + +var method = C.method; + +assert.throws(Test262Error, function() { + method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-prop-id-init-unresolvable.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-prop-id-init-unresolvable.js new file mode 100644 index 0000000000..d7991065a5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-prop-id-init-unresolvable.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-unresolvable.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-static-dflt.template +/*--- +description: Destructuring initializer is an unresolvable reference (static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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. +---*/ + + +class C { + static async *method({ x: y = unresolvableReference } = {}) { + + } +}; + +var method = C.method; + +assert.throws(ReferenceError, function() { + method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-prop-id-init.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-prop-id-init.js new file mode 100644 index 0000000000..0c37300bc1 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-prop-id-init.js @@ -0,0 +1,65 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static-dflt.template +/*--- +description: Binding as specified via property name, identifier, and initializer (static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +class C { + static async *method({ x: y = 33 } = { }) { + assert.sameValue(y, 33); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-prop-id-trailing-comma.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-prop-id-trailing-comma.js new file mode 100644 index 0000000000..c1d6d17e58 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-prop-id-trailing-comma.js @@ -0,0 +1,66 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-trailing-comma.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static-dflt.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + + +var callCount = 0; +class C { + static async *method({ x: y, } = { x: 23 }) { + assert.sameValue(y, 23); + + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-prop-id.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-prop-id.js new file mode 100644 index 0000000000..a0230cf9c9 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-prop-id.js @@ -0,0 +1,65 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static-dflt.template +/*--- +description: Binding as specified via property name and identifier (static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +class C { + static async *method({ x: y } = { x: 23 }) { + assert.sameValue(y, 23); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-prop-obj-init.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-prop-obj-init.js new file mode 100644 index 0000000000..073fa8b160 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-prop-obj-init.js @@ -0,0 +1,71 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-init.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern using initializer (static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 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). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + + +var callCount = 0; +class C { + static async *method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } } = { w: undefined }) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-prop-obj-value-null.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-prop-obj-value-null.js new file mode 100644 index 0000000000..01294eb59d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-prop-obj-value-null.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-null.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-static-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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. +---*/ + + +class C { + static async *method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } } = { w: null }) { + + } +}; + +var method = C.method; + +assert.throws(TypeError, function() { + method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-prop-obj-value-undef.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-prop-obj-value-undef.js new file mode 100644 index 0000000000..98d4fb877a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-prop-obj-value-undef.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-undef.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-static-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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. +---*/ + + +class C { + static async *method({ w: { x, y, z } = undefined } = { }) { + + } +}; + +var method = C.method; + +assert.throws(TypeError, function() { + method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-prop-obj.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-prop-obj.js new file mode 100644 index 0000000000..2eb83ddd26 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-prop-obj.js @@ -0,0 +1,69 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern not using initializer (static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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. +---*/ + + +var callCount = 0; +class C { + static async *method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } } = { w: { x: undefined, z: 7 } }) { + assert.sameValue(x, undefined); + assert.sameValue(y, undefined); + assert.sameValue(z, 7); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-rest-getter.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-rest-getter.js new file mode 100644 index 0000000000..1699c9ccce --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-rest-getter.js @@ -0,0 +1,64 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-getter.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static-dflt.template +/*--- +description: Getter is called when obj is being deconstructed to a rest Object (static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [object-rest, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + +---*/ +var count = 0; + + +var callCount = 0; +class C { + static async *method({...x} = { get v() { count++; return 2; } }) { + assert.sameValue(count, 1); + + verifyProperty(x, "v", { + enumerable: true, + writable: true, + configurable: true, + value: 2 + }); + callCount = callCount + 1; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-rest-skip-non-enumerable.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-rest-skip-non-enumerable.js new file mode 100644 index 0000000000..76b2c8c842 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-rest-skip-non-enumerable.js @@ -0,0 +1,72 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-skip-non-enumerable.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static-dflt.template +/*--- +description: Rest object doesn't contain non-enumerable properties (static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [object-rest, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + +---*/ +var o = {a: 3, b: 4}; +Object.defineProperty(o, "x", { value: 4, enumerable: false }); + + +var callCount = 0; +class C { + static async *method({...rest} = o) { + assert.sameValue(rest.x, undefined); + + verifyProperty(rest, "a", { + enumerable: true, + writable: true, + configurable: true, + value: 3 + }); + + verifyProperty(rest, "b", { + enumerable: true, + writable: true, + configurable: true, + value: 4 + }); + callCount = callCount + 1; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-rest-val-obj.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-rest-val-obj.js new file mode 100644 index 0000000000..194ab1b44d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-dflt-obj-ptrn-rest-val-obj.js @@ -0,0 +1,71 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-val-obj.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static-dflt.template +/*--- +description: Rest object contains just unextracted data (static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [object-rest, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + +---*/ + + +var callCount = 0; +class C { + static async *method({a, b, ...rest} = {x: 1, y: 2, a: 5, b: 3}) { + assert.sameValue(rest.a, undefined); + assert.sameValue(rest.b, undefined); + + verifyProperty(rest, "x", { + enumerable: true, + writable: true, + configurable: true, + value: 1 + }); + + verifyProperty(rest, "y", { + enumerable: true, + writable: true, + configurable: true, + value: 2 + }); + callCount = callCount + 1; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-init-null.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-init-null.js new file mode 100644 index 0000000000..4a6f5b4aa4 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-init-null.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-null.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-static.template +/*--- +description: Value specifed for object binding pattern must be object coercible (null) (static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + + +class C { + static async *method({}) { + + } +}; + +var method = C.method; + +assert.throws(TypeError, function() { + method(null); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-init-undefined.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-init-undefined.js new file mode 100644 index 0000000000..ac8d57a607 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-init-undefined.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-undefined.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-static.template +/*--- +description: Value specifed for object binding pattern must be object coercible (undefined) (static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + + +class C { + static async *method({}) { + + } +}; + +var method = C.method; + +assert.throws(TypeError, function() { + method(undefined); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-empty.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-empty.js new file mode 100644 index 0000000000..ce0ebbb71e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-empty.js @@ -0,0 +1,67 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-empty.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static.template +/*--- +description: No property access occurs for an "empty" object binding pattern (static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ +var accessCount = 0; +var obj = Object.defineProperty({}, 'attr', { + get: function() { + accessCount += 1; + } +}); + + +var callCount = 0; +class C { + static async *method({}) { + assert.sameValue(accessCount, 0); + callCount = callCount + 1; + } +}; + +C.method(obj).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-id-get-value-err.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-id-get-value-err.js new file mode 100644 index 0000000000..1d626564fa --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-id-get-value-err.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-get-value-err.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-static.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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(); + } +}); + + +class C { + static async *method({ poisoned }) { + + } +}; + +var method = C.method; + +assert.throws(Test262Error, function() { + method(poisonedProperty); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-id-init-fn-name-arrow.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..9b0b599f1c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-id-init-fn-name-arrow.js @@ -0,0 +1,68 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-arrow.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static.template +/*--- +description: SingleNameBinding assigns `name` to arrow functions (static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + + +var callCount = 0; +class C { + static async *method({ arrow = () => {} }) { + assert.sameValue(arrow.name, 'arrow'); + callCount = callCount + 1; + } +}; + +C.method({}).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-id-init-fn-name-class.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-id-init-fn-name-class.js new file mode 100644 index 0000000000..9dc36e1874 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-id-init-fn-name-class.js @@ -0,0 +1,70 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-class.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + + +var callCount = 0; +class C { + static async *method({ cls = class {}, xCls = class X {}, xCls2 = class { static name() {} } }) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + assert.notSameValue(xCls2.name, 'xCls2'); + callCount = callCount + 1; + } +}; + +C.method({}).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-id-init-fn-name-cover.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-id-init-fn-name-cover.js new file mode 100644 index 0000000000..0e684035fe --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-id-init-fn-name-cover.js @@ -0,0 +1,69 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-cover.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" functions "through" cover grammar (static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + + +var callCount = 0; +class C { + static async *method({ cover = (function () {}), xCover = (0, function() {}) }) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + callCount = callCount + 1; + } +}; + +C.method({}).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-id-init-fn-name-fn.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-id-init-fn-name-fn.js new file mode 100644 index 0000000000..d635b0ce41 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-id-init-fn-name-fn.js @@ -0,0 +1,69 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-fn.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + + +var callCount = 0; +class C { + static async *method({ fn = function () {}, xFn = function x() {} }) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + callCount = callCount + 1; + } +}; + +C.method({}).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-id-init-fn-name-gen.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-id-init-fn-name-gen.js new file mode 100644 index 0000000000..533c81af0e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-id-init-fn-name-gen.js @@ -0,0 +1,70 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-gen.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). + +---*/ + + +var callCount = 0; +class C { + static async *method({ gen = function* () {}, xGen = function* x() {} }) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + callCount = callCount + 1; + } +}; + +C.method({}).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-id-init-skipped.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-id-init-skipped.js new file mode 100644 index 0000000000..03b6e64266 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-id-init-skipped.js @@ -0,0 +1,72 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-skipped.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + + +var callCount = 0; +class C { + static async *method({ w = counter(), x = counter(), y = counter(), z = counter() }) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +C.method({ w: null, x: 0, y: false, z: '' }).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-id-init-throws.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-id-init-throws.js new file mode 100644 index 0000000000..1dcc2f6b66 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-id-init-throws.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-throws.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-static.template +/*--- +description: Error thrown when evaluating the initializer (static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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(); +} + + +class C { + static async *method({ x = thrower() }) { + + } +}; + +var method = C.method; + +assert.throws(Test262Error, function() { + method({}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-id-init-unresolvable.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-id-init-unresolvable.js new file mode 100644 index 0000000000..fe893ae967 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-id-init-unresolvable.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-unresolvable.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-static.template +/*--- +description: Destructuring initializer is an unresolvable reference (static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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. +---*/ + + +class C { + static async *method({ x = unresolvableReference }) { + + } +}; + +var method = C.method; + +assert.throws(ReferenceError, function() { + method({}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-id-trailing-comma.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-id-trailing-comma.js new file mode 100644 index 0000000000..89465e0b5b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-id-trailing-comma.js @@ -0,0 +1,62 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-trailing-comma.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + + +var callCount = 0; +class C { + static async *method({ x, }) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } +}; + +C.method({ x: 23 }).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-list-err.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-list-err.js new file mode 100644 index 0000000000..61738dde65 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-list-err.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-list-err.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-static.template +/*--- +description: Binding property list evaluation is interrupted by an abrupt completion (static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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(); +} + + +class C { + static async *method({ a, b = thrower(), c = ++initCount }) { + + } +}; + +var method = C.method; + +assert.throws(Test262Error, function() { + method({}); +}); + +assert.sameValue(initCount, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-prop-ary-init.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-prop-ary-init.js new file mode 100644 index 0000000000..6f1defad0c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-prop-ary-init.js @@ -0,0 +1,71 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-init.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static.template +/*--- +description: Object binding pattern with "nested" array binding pattern using initializer (static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 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). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + + +var callCount = 0; +class C { + static async *method({ w: [x, y, z] = [4, 5, 6] }) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } +}; + +C.method({}).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-prop-ary-trailing-comma.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-prop-ary-trailing-comma.js new file mode 100644 index 0000000000..b558efeed2 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-prop-ary-trailing-comma.js @@ -0,0 +1,62 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-trailing-comma.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + + +var callCount = 0; +class C { + static async *method({ x: [y], }) { + assert.sameValue(y,45); + callCount = callCount + 1; + } +}; + +C.method({ x: [45] }).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-prop-ary-value-null.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-prop-ary-value-null.js new file mode 100644 index 0000000000..282fd957f2 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-prop-ary-value-null.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-value-null.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-static.template +/*--- +description: Object binding pattern with "nested" array binding pattern taking the `null` value (static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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. +---*/ + + +class C { + static async *method({ w: [x, y, z] = [4, 5, 6] }) { + + } +}; + +var method = C.method; + +assert.throws(TypeError, function() { + method({ w: null }); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-prop-ary.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-prop-ary.js new file mode 100644 index 0000000000..2df85585ac --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-prop-ary.js @@ -0,0 +1,69 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static.template +/*--- +description: Object binding pattern with "nested" array binding pattern not using initializer (static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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. +---*/ + + +var callCount = 0; +class C { + static async *method({ w: [x, y, z] = [4, 5, 6] }) { + assert.sameValue(x, 7); + assert.sameValue(y, undefined); + assert.sameValue(z, undefined); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } +}; + +C.method({ w: [7, undefined, ] }).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-prop-eval-err.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-prop-eval-err.js new file mode 100644 index 0000000000..a4148bacb8 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-prop-eval-err.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-eval-err.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-static.template +/*--- +description: Evaluation of property name returns an abrupt completion (static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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(); +} + + +class C { + static async *method({ [thrower()]: x }) { + + } +}; + +var method = C.method; + +assert.throws(Test262Error, function() { + method({}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-prop-id-get-value-err.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-prop-id-get-value-err.js new file mode 100644 index 0000000000..5f461c108c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-prop-id-get-value-err.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-get-value-err.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-static.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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(); + } +}); + + +class C { + static async *method({ poisoned: x = ++initEvalCount }) { + + } +}; + +var method = C.method; + +assert.throws(Test262Error, function() { + method(poisonedProperty); +}); + +assert.sameValue(initEvalCount, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-prop-id-init-skipped.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-prop-id-init-skipped.js new file mode 100644 index 0000000000..def869a0ff --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-prop-id-init-skipped.js @@ -0,0 +1,84 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-skipped.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + + +var callCount = 0; +class C { + static async *method({ s: t = counter(), u: v = counter(), w: x = counter(), y: z = counter() }) { + assert.sameValue(t, null); + assert.sameValue(v, 0); + assert.sameValue(x, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + + assert.throws(ReferenceError, function() { + s; + }); + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } +}; + +C.method({ s: null, u: 0, w: false, y: '' }).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-prop-id-init-throws.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-prop-id-init-throws.js new file mode 100644 index 0000000000..b7e27bc6e3 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-prop-id-init-throws.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-throws.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-static.template +/*--- +description: Error thrown when evaluating the initializer (static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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(); +} + + +class C { + static async *method({ x: y = thrower() }) { + + } +}; + +var method = C.method; + +assert.throws(Test262Error, function() { + method({}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-prop-id-init-unresolvable.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-prop-id-init-unresolvable.js new file mode 100644 index 0000000000..e7a8ab369a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-prop-id-init-unresolvable.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-unresolvable.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-static.template +/*--- +description: Destructuring initializer is an unresolvable reference (static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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. +---*/ + + +class C { + static async *method({ x: y = unresolvableReference }) { + + } +}; + +var method = C.method; + +assert.throws(ReferenceError, function() { + method({}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-prop-id-init.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-prop-id-init.js new file mode 100644 index 0000000000..ce52efd73e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-prop-id-init.js @@ -0,0 +1,65 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static.template +/*--- +description: Binding as specified via property name, identifier, and initializer (static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +class C { + static async *method({ x: y = 33 }) { + assert.sameValue(y, 33); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } +}; + +C.method({ }).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-prop-id-trailing-comma.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-prop-id-trailing-comma.js new file mode 100644 index 0000000000..c6d8e8be1b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-prop-id-trailing-comma.js @@ -0,0 +1,66 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-trailing-comma.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + + +var callCount = 0; +class C { + static async *method({ x: y, }) { + assert.sameValue(y, 23); + + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } +}; + +C.method({ x: 23 }).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-prop-id.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-prop-id.js new file mode 100644 index 0000000000..64293ac1a6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-prop-id.js @@ -0,0 +1,65 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static.template +/*--- +description: Binding as specified via property name and identifier (static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +class C { + static async *method({ x: y }) { + assert.sameValue(y, 23); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } +}; + +C.method({ x: 23 }).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-prop-obj-init.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-prop-obj-init.js new file mode 100644 index 0000000000..3c7522b6a5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-prop-obj-init.js @@ -0,0 +1,71 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-init.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static.template +/*--- +description: Object binding pattern with "nested" object binding pattern using initializer (static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 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). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + + +var callCount = 0; +class C { + static async *method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } }) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } +}; + +C.method({ w: undefined }).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-prop-obj-value-null.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-prop-obj-value-null.js new file mode 100644 index 0000000000..ae4da3648a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-prop-obj-value-null.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-null.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-static.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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. +---*/ + + +class C { + static async *method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } }) { + + } +}; + +var method = C.method; + +assert.throws(TypeError, function() { + method({ w: null }); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-prop-obj-value-undef.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-prop-obj-value-undef.js new file mode 100644 index 0000000000..cc6e3d1357 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-prop-obj-value-undef.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-undef.case +// - src/dstr-binding/error/cls-decl-async-gen-meth-static.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + 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. +---*/ + + +class C { + static async *method({ w: { x, y, z } = undefined }) { + + } +}; + +var method = C.method; + +assert.throws(TypeError, function() { + method({ }); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-prop-obj.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-prop-obj.js new file mode 100644 index 0000000000..3d2294027f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-prop-obj.js @@ -0,0 +1,69 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static.template +/*--- +description: Object binding pattern with "nested" object binding pattern not using initializer (static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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. +---*/ + + +var callCount = 0; +class C { + static async *method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } }) { + assert.sameValue(x, undefined); + assert.sameValue(y, undefined); + assert.sameValue(z, 7); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } +}; + +C.method({ w: { x: undefined, z: 7 } }).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-rest-getter.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-rest-getter.js new file mode 100644 index 0000000000..38dcd2d773 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-rest-getter.js @@ -0,0 +1,64 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-getter.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static.template +/*--- +description: Getter is called when obj is being deconstructed to a rest Object (static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [object-rest, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + +---*/ +var count = 0; + + +var callCount = 0; +class C { + static async *method({...x}) { + assert.sameValue(count, 1); + + verifyProperty(x, "v", { + enumerable: true, + writable: true, + configurable: true, + value: 2 + }); + callCount = callCount + 1; + } +}; + +C.method({ get v() { count++; return 2; } }).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-rest-skip-non-enumerable.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-rest-skip-non-enumerable.js new file mode 100644 index 0000000000..5143f9a9f8 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-rest-skip-non-enumerable.js @@ -0,0 +1,72 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-skip-non-enumerable.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static.template +/*--- +description: Rest object doesn't contain non-enumerable properties (static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [object-rest, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + +---*/ +var o = {a: 3, b: 4}; +Object.defineProperty(o, "x", { value: 4, enumerable: false }); + + +var callCount = 0; +class C { + static async *method({...rest}) { + assert.sameValue(rest.x, undefined); + + verifyProperty(rest, "a", { + enumerable: true, + writable: true, + configurable: true, + value: 3 + }); + + verifyProperty(rest, "b", { + enumerable: true, + writable: true, + configurable: true, + value: 4 + }); + callCount = callCount + 1; + } +}; + +C.method(o).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-rest-val-obj.js b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-rest-val-obj.js new file mode 100644 index 0000000000..5ebfa1d74f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-gen-meth-static-obj-ptrn-rest-val-obj.js @@ -0,0 +1,71 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-val-obj.case +// - src/dstr-binding/default/cls-decl-async-gen-meth-static.template +/*--- +description: Rest object contains just unextracted data (static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [object-rest, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + +---*/ + + +var callCount = 0; +class C { + static async *method({a, b, ...rest}) { + assert.sameValue(rest.a, undefined); + assert.sameValue(rest.b, undefined); + + verifyProperty(rest, "x", { + enumerable: true, + writable: true, + configurable: true, + value: 1 + }); + + verifyProperty(rest, "y", { + enumerable: true, + writable: true, + configurable: true, + value: 2 + }); + callCount = callCount + 1; + } +}; + +C.method({x: 1, y: 2, a: 5, b: 3}).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-init-iter-close.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-init-iter-close.js new file mode 100644 index 0000000000..19a24ded09 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-init-iter-close.js @@ -0,0 +1,82 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-close.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth.template +/*--- +description: Iterator is closed when not exhausted by pattern evaluation (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [Symbol.iterator, class, class-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: false }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + + +var callCount = 0; +class C { + async * #method([x]) { + assert.sameValue(doneCallCount, 1); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method(iter).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-init-iter-no-close.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-init-iter-no-close.js new file mode 100644 index 0000000000..03e28fa087 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-init-iter-no-close.js @@ -0,0 +1,82 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-no-close.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth.template +/*--- +description: Iterator is not closed when exhausted by pattern evaluation (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [Symbol.iterator, class, class-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: true }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + + +var callCount = 0; +class C { + async * #method([x]) { + assert.sameValue(doneCallCount, 0); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method(iter).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-name-iter-val.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-name-iter-val.js new file mode 100644 index 0000000000..410e8902a4 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-name-iter-val.js @@ -0,0 +1,81 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-name-iter-val.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth.template +/*--- +description: SingleNameBinding with normal value iteration (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +class C { + async * #method([x, y, z]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method([1, 2, 3]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-elem-ary-elem-init.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-elem-ary-elem-init.js new file mode 100644 index 0000000000..5b9050bf5d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-elem-ary-elem-init.js @@ -0,0 +1,73 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-init.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth.template +/*--- +description: BindingElement with array binding pattern and initializer is used (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + + +var callCount = 0; +class C { + async * #method([[x, y, z] = [4, 5, 6]]) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method([]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-elem-ary-elem-iter.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-elem-ary-elem-iter.js new file mode 100644 index 0000000000..41844de008 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-elem-ary-elem-iter.js @@ -0,0 +1,74 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-iter.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + + +var callCount = 0; +class C { + async * #method([[x, y, z] = [4, 5, 6]]) { + assert.sameValue(x, 7); + assert.sameValue(y, 8); + assert.sameValue(z, 9); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method([[7, 8, 9]]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-elem-ary-elision-init.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-elem-ary-elision-init.js new file mode 100644 index 0000000000..5520244e7d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-elem-ary-elision-init.js @@ -0,0 +1,80 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-init.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth.template +/*--- +description: BindingElement with array binding pattern and initializer is used (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, class, class-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + + +var callCount = 0; +class C { + async * #method([[,] = g()]) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method([]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-elem-ary-elision-iter.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-elem-ary-elision-iter.js new file mode 100644 index 0000000000..8d993e9bbd --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-elem-ary-elision-iter.js @@ -0,0 +1,77 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-iter.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, class, class-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var callCount = 0; +function* g() { + callCount += 1; +}; + + +var callCount = 0; +class C { + async * #method([[,] = g()]) { + assert.sameValue(callCount, 0); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method([[]]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-elem-ary-empty-init.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-elem-ary-empty-init.js new file mode 100644 index 0000000000..9fde66c362 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-elem-ary-empty-init.js @@ -0,0 +1,76 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-init.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth.template +/*--- +description: BindingElement with array binding pattern and initializer is used (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, class, class-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var initCount = 0; +var iterCount = 0; +var iter = function*() { iterCount += 1; }(); + + +var callCount = 0; +class C { + async * #method([[] = function() { initCount += 1; return iter; }()]) { + assert.sameValue(initCount, 1); + assert.sameValue(iterCount, 0); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method([]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-elem-ary-empty-iter.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-elem-ary-empty-iter.js new file mode 100644 index 0000000000..cb066b1376 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-elem-ary-empty-iter.js @@ -0,0 +1,73 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-iter.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var initCount = 0; + + +var callCount = 0; +class C { + async * #method([[] = function() { initCount += 1; }()]) { + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method([[23]]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-elem-ary-rest-init.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-elem-ary-rest-init.js new file mode 100644 index 0000000000..dd12f44406 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-elem-ary-rest-init.js @@ -0,0 +1,77 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-init.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth.template +/*--- +description: BindingElement with array binding pattern and initializer is used (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; + + +var callCount = 0; +class C { + async * #method([[...x] = values]) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method([]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-elem-ary-rest-iter.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-elem-ary-rest-iter.js new file mode 100644 index 0000000000..20b151978e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-elem-ary-rest-iter.js @@ -0,0 +1,80 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-iter.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; +var initCount = 0; + + +var callCount = 0; +class C { + async * #method([[...x] = function() { initCount += 1; }()]) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method([values]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-elem-id-init-exhausted.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-elem-id-init-exhausted.js new file mode 100644 index 0000000000..5496a30304 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-elem-id-init-exhausted.js @@ -0,0 +1,72 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-exhausted.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth.template +/*--- +description: Destructuring initializer with an exhausted iterator (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +class C { + async * #method([x = 23]) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method([]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-elem-id-init-fn-name-arrow.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-elem-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..6a3470a3fa --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-elem-id-init-fn-name-arrow.js @@ -0,0 +1,73 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-arrow.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth.template +/*--- +description: SingleNameBinding does assign name to arrow functions (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +class C { + async * #method([arrow = () => {}]) { + assert.sameValue(arrow.name, 'arrow'); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method([]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-elem-id-init-fn-name-class.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-elem-id-init-fn-name-class.js new file mode 100644 index 0000000000..2ca0c5e3e1 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-elem-id-init-fn-name-class.js @@ -0,0 +1,75 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-class.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +class C { + async * #method([cls = class {}, xCls = class X {}, xCls2 = class { static name() {} }]) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + assert.notSameValue(xCls2.name, 'xCls2'); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method([]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-elem-id-init-fn-name-cover.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-elem-id-init-fn-name-cover.js new file mode 100644 index 0000000000..529e0a93b6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-elem-id-init-fn-name-cover.js @@ -0,0 +1,74 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-cover.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth.template +/*--- +description: SingleNameBinding does assign name to "anonymous" functions "through" cover grammar (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +class C { + async * #method([cover = (function () {}), xCover = (0, function() {})]) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method([]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-elem-id-init-fn-name-fn.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-elem-id-init-fn-name-fn.js new file mode 100644 index 0000000000..c06b4c9979 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-elem-id-init-fn-name-fn.js @@ -0,0 +1,74 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-fn.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +class C { + async * #method([fn = function () {}, xFn = function x() {}]) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method([]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-elem-id-init-fn-name-gen.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-elem-id-init-fn-name-gen.js new file mode 100644 index 0000000000..7dd6dfa167 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-elem-id-init-fn-name-gen.js @@ -0,0 +1,75 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-gen.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, class, class-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). + +---*/ + + +var callCount = 0; +class C { + async * #method([gen = function* () {}, xGen = function* x() {}]) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method([]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-elem-id-init-hole.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-elem-id-init-hole.js new file mode 100644 index 0000000000..b352098f81 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-elem-id-init-hole.js @@ -0,0 +1,68 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-hole.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth.template +/*--- +description: Destructuring initializer with a "hole" (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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). + [...] + 7. If environment is undefined, return PutValue(lhs, v). 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +class C { + async * #method([x = 23]) { + assert.sameValue(x, 23); + // another statement + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method([,]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-elem-id-init-skipped.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-elem-id-init-skipped.js new file mode 100644 index 0000000000..3f9c1bcec0 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-elem-id-init-skipped.js @@ -0,0 +1,77 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-skipped.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + + +var callCount = 0; +class C { + async * #method([w = counter(), x = counter(), y = counter(), z = counter()]) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method([null, 0, false, '']).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-elem-id-init-undef.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-elem-id-init-undef.js new file mode 100644 index 0000000000..0c3ab10e36 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-elem-id-init-undef.js @@ -0,0 +1,71 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-undef.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth.template +/*--- +description: Destructuring initializer with an undefined value (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +class C { + async * #method([x = 23]) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method([undefined]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-elem-id-iter-complete.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-elem-id-iter-complete.js new file mode 100644 index 0000000000..bff211d1be --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-elem-id-iter-complete.js @@ -0,0 +1,75 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-complete.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth.template +/*--- +description: SingleNameBinding when value iteration completes (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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, + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +class C { + async * #method([x]) { + assert.sameValue(x, undefined); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method([]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-elem-id-iter-done.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-elem-id-iter-done.js new file mode 100644 index 0000000000..c8b73f1cd3 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-elem-id-iter-done.js @@ -0,0 +1,70 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-done.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth.template +/*--- +description: SingleNameBinding when value iteration was completed previously (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +class C { + async * #method([_, x]) { + assert.sameValue(x, undefined); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method([]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-elem-id-iter-val-array-prototype.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-elem-id-iter-val-array-prototype.js new file mode 100644 index 0000000000..78b68a7461 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-elem-id-iter-val-array-prototype.js @@ -0,0 +1,91 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val-array-prototype.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth.template +/*--- +description: Array destructuring uses overriden Array.prototype[Symbol.iterator] (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [Symbol.iterator, generators, class, class-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializer_opt + + 1. Let bindingId be StringValue of BindingIdentifier. + 2. Let lhs be ? ResolveBinding(bindingId, environment). + 3. If iteratorRecord.[[Done]] is false, then + a. Let next be IteratorStep(iteratorRecord). + 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). + [...] + 7. Return InitializeReferencedBinding(lhs, v). + +---*/ +Array.prototype[Symbol.iterator] = function* () { + if (this.length > 0) { + yield this[0]; + } + if (this.length > 1) { + yield this[1]; + } + if (this.length > 2) { + yield 42; + } +}; + + +var callCount = 0; +class C { + async * #method([x, y, z]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 42); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method([1, 2, 3]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-elem-id-iter-val.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-elem-id-iter-val.js new file mode 100644 index 0000000000..c28800c85e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-elem-id-iter-val.js @@ -0,0 +1,81 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth.template +/*--- +description: SingleNameBinding when value iteration was completed previously (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +class C { + async * #method([x, y, z]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method([1, 2, 3]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-elem-obj-id-init.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-elem-obj-id-init.js new file mode 100644 index 0000000000..622a8bd8c4 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-elem-obj-id-init.js @@ -0,0 +1,73 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id-init.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth.template +/*--- +description: BindingElement with object binding pattern and initializer is used (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + + +var callCount = 0; +class C { + async * #method([{ x, y, z } = { x: 44, y: 55, z: 66 }]) { + assert.sameValue(x, 44); + assert.sameValue(y, 55); + assert.sameValue(z, 66); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method([]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-elem-obj-id.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-elem-obj-id.js new file mode 100644 index 0000000000..e00fd0737f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-elem-obj-id.js @@ -0,0 +1,73 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + + +var callCount = 0; +class C { + async * #method([{ x, y, z } = { x: 44, y: 55, z: 66 }]) { + assert.sameValue(x, 11); + assert.sameValue(y, 22); + assert.sameValue(z, 33); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method([{ x: 11, y: 22, z: 33 }]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-elem-obj-prop-id-init.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-elem-obj-prop-id-init.js new file mode 100644 index 0000000000..1efefe8023 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-elem-obj-prop-id-init.js @@ -0,0 +1,83 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id-init.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth.template +/*--- +description: BindingElement with object binding pattern and initializer is used (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + + +var callCount = 0; +class C { + async * #method([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }]) { + assert.sameValue(v, 444); + assert.sameValue(x, 555); + assert.sameValue(z, 666); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method([]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-elem-obj-prop-id.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-elem-obj-prop-id.js new file mode 100644 index 0000000000..17fa349cc0 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-elem-obj-prop-id.js @@ -0,0 +1,83 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + + +var callCount = 0; +class C { + async * #method([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }]) { + assert.sameValue(v, 777); + assert.sameValue(x, 888); + assert.sameValue(z, 999); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method([{ u: 777, w: 888, y: 999 }]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-elision-exhausted.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-elision-exhausted.js new file mode 100644 index 0000000000..9329d9ee2d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-elision-exhausted.js @@ -0,0 +1,78 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-exhausted.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth.template +/*--- +description: Elision accepts exhausted iterator (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, class, class-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 + [...] + 2. Return NormalCompletion(empty). + +---*/ +var iter = function*() {}(); +iter.next(); + + +var callCount = 0; +class C { + async * #method([,]) { + + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method(iter).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-elision.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-elision.js new file mode 100644 index 0000000000..59ddb2ba59 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-elision.js @@ -0,0 +1,87 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth.template +/*--- +description: Elision advances iterator (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, class, class-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + + +var callCount = 0; +class C { + async * #method([,]) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method(g()).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-empty.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-empty.js new file mode 100644 index 0000000000..127a9cf0a5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-empty.js @@ -0,0 +1,70 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-empty.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth.template +/*--- +description: No iteration occurs for an "empty" array binding pattern (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, class, class-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + + +var callCount = 0; +class C { + async * #method([]) { + assert.sameValue(iterations, 0); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method(iter).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-rest-ary-elem.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-rest-ary-elem.js new file mode 100644 index 0000000000..1763b65583 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-rest-ary-elem.js @@ -0,0 +1,94 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elem.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth.template +/*--- +description: Rest element containing an array BindingElementList pattern (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the 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). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +class C { + async * #method([...[x, y, z]]) { + assert.sameValue(x, 3); + assert.sameValue(y, 4); + assert.sameValue(z, 5); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method([3, 4, 5]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-rest-ary-elision.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-rest-ary-elision.js new file mode 100644 index 0000000000..7b5a1d1863 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-rest-ary-elision.js @@ -0,0 +1,100 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elision.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth.template +/*--- +description: Rest element containing an elision (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, class, class-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the 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). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + + +var callCount = 0; +class C { + async * #method([...[,]]) { + assert.sameValue(first, 1); + assert.sameValue(second, 1); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method(g()).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-rest-ary-empty.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-rest-ary-empty.js new file mode 100644 index 0000000000..bf6b4a50a6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-rest-ary-empty.js @@ -0,0 +1,83 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-empty.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth.template +/*--- +description: Rest element containing an "empty" array pattern (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, class, class-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + + +var callCount = 0; +class C { + async * #method([...[]]) { + assert.sameValue(iterations, 1); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method(iter).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-rest-ary-rest.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-rest-ary-rest.js new file mode 100644 index 0000000000..f2d040c084 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-rest-ary-rest.js @@ -0,0 +1,79 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-rest.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth.template +/*--- +description: Rest element containing a rest element (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ +var values = [1, 2, 3]; + + +var callCount = 0; +class C { + async * #method([...[...x]]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method(values).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-rest-id-direct.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-rest-id-direct.js new file mode 100644 index 0000000000..996e20e05f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-rest-id-direct.js @@ -0,0 +1,74 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-direct.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth.template +/*--- +description: Lone rest element (direct binding) (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, async-iteration] +flags: [generated, async] +includes: [compareArray.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingIdentifier + + [...] + 2. Let A be ! ArrayCreate(0). + 3. Let n be 0. + 4. Repeat, + [...] + f. Perform ! CreateDataPropertyOrThrow(A, ! ToString(n), nextValue). + g. Set n to n + 1. + +---*/ + + +var callCount = 0; +class C { + async * #method([...x]) { + assert(Array.isArray(x)); + assert.compareArray(x, [1]); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method([1]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-rest-id-elision.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-rest-id-elision.js new file mode 100644 index 0000000000..7a70484532 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-rest-id-elision.js @@ -0,0 +1,75 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth.template +/*--- +description: Rest element following elision elements (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 values = [1, 2, 3, 4, 5]; + + +var callCount = 0; +class C { + async * #method([ , , ...x]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 3); + assert.sameValue(x[1], 4); + assert.sameValue(x[2], 5); + assert.notSameValue(x, values); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method(values).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-rest-id-exhausted.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-rest-id-exhausted.js new file mode 100644 index 0000000000..babfadc7ea --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-rest-id-exhausted.js @@ -0,0 +1,71 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-exhausted.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth.template +/*--- +description: RestElement applied to an exhausted iterator (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [Symbol.iterator, class, class-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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, + [...] + b. If iteratorRecord.[[done]] is true, then + i. If environment is undefined, return PutValue(lhs, A). + ii. Return InitializeReferencedBinding(lhs, A). + +---*/ + + +var callCount = 0; +class C { + async * #method([, , ...x]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 0); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method([1, 2]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-rest-id.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-rest-id.js new file mode 100644 index 0000000000..3cf9745d9c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-rest-id.js @@ -0,0 +1,72 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth.template +/*--- +description: Lone rest element (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + [...] 3. Let A be ArrayCreate(0). [...] 5. Repeat + [...] + f. Let status be CreateDataProperty(A, ToString (n), nextValue). + [...] +---*/ +var values = [1, 2, 3]; + + +var callCount = 0; +class C { + async * #method([...x]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method(values).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-rest-init-ary.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-rest-init-ary.js new file mode 100644 index 0000000000..8173c0d217 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-rest-init-ary.js @@ -0,0 +1,69 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-ary.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth.template +/*--- +description: Rest element (nested array pattern) does not support initializer (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + + +var callCount = 0; +class C { + async * #method([...[ x ] = []]) { + + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method([]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-rest-init-id.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-rest-init-id.js new file mode 100644 index 0000000000..8e5b3fc77f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-rest-init-id.js @@ -0,0 +1,69 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-id.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth.template +/*--- +description: Rest element (identifier) does not support initializer (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + + +var callCount = 0; +class C { + async * #method([...x = []]) { + + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method([]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-rest-init-obj.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-rest-init-obj.js new file mode 100644 index 0000000000..d885c8e0d1 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-rest-init-obj.js @@ -0,0 +1,69 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-obj.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth.template +/*--- +description: Rest element (nested object pattern) does not support initializer (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + + +var callCount = 0; +class C { + async * #method([...{ x } = []]) { + + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method([]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-rest-not-final-ary.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-rest-not-final-ary.js new file mode 100644 index 0000000000..575416a727 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-rest-not-final-ary.js @@ -0,0 +1,69 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-ary.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth.template +/*--- +description: Rest element (array binding pattern) may not be followed by any element (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + + +var callCount = 0; +class C { + async * #method([...[x], y]) { + + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method([1, 2, 3]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-rest-not-final-id.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-rest-not-final-id.js new file mode 100644 index 0000000000..644df958f9 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-rest-not-final-id.js @@ -0,0 +1,69 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-id.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth.template +/*--- +description: Rest element (identifier) may not be followed by any element (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + + +var callCount = 0; +class C { + async * #method([...x, y]) { + + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method([1, 2, 3]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-rest-not-final-obj.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-rest-not-final-obj.js new file mode 100644 index 0000000000..61b0792d2e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-rest-not-final-obj.js @@ -0,0 +1,69 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-obj.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth.template +/*--- +description: Rest element (object binding pattern) may not be followed by any element (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + + +var callCount = 0; +class C { + async * #method([...{ x }, y]) { + + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method([1, 2, 3]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-rest-obj-id.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-rest-obj-id.js new file mode 100644 index 0000000000..177f8bd1f6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-rest-obj-id.js @@ -0,0 +1,72 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-id.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth.template +/*--- +description: Rest element containing an object binding pattern (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ + + +var callCount = 0; +class C { + async * #method([...{ length }]) { + assert.sameValue(length, 3); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method([1, 2, 3]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-rest-obj-prop-id.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-rest-obj-prop-id.js new file mode 100644 index 0000000000..1a3bd5ce97 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-ary-ptrn-rest-obj-prop-id.js @@ -0,0 +1,79 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-prop-id.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth.template +/*--- +description: Rest element containing an object binding pattern (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ +let length = "outer"; + + +var callCount = 0; +class C { + async * #method([...{ 0: v, 1: w, 2: x, 3: y, length: z }]) { + assert.sameValue(v, 7); + assert.sameValue(w, 8); + assert.sameValue(x, 9); + assert.sameValue(y, undefined); + assert.sameValue(z, 3); + + assert.sameValue(length, "outer", "the length prop is not set as a binding name"); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method([7, 8, 9]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-init-iter-close.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-init-iter-close.js new file mode 100644 index 0000000000..e7802751a4 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-init-iter-close.js @@ -0,0 +1,82 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-close.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-dflt.template +/*--- +description: Iterator is closed when not exhausted by pattern evaluation (private class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [Symbol.iterator, class, class-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: false }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + + +var callCount = 0; +class C { + async * #method([x] = iter) { + assert.sameValue(doneCallCount, 1); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-init-iter-no-close.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-init-iter-no-close.js new file mode 100644 index 0000000000..4d8454731f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-init-iter-no-close.js @@ -0,0 +1,82 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-no-close.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-dflt.template +/*--- +description: Iterator is not closed when exhausted by pattern evaluation (private class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [Symbol.iterator, class, class-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: true }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + + +var callCount = 0; +class C { + async * #method([x] = iter) { + assert.sameValue(doneCallCount, 0); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-name-iter-val.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-name-iter-val.js new file mode 100644 index 0000000000..aa340a7755 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-name-iter-val.js @@ -0,0 +1,81 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-name-iter-val.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-dflt.template +/*--- +description: SingleNameBinding with normal value iteration (private class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +class C { + async * #method([x, y, z] = [1, 2, 3]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-elem-ary-elem-init.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-elem-ary-elem-init.js new file mode 100644 index 0000000000..52852c8b6b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-elem-ary-elem-init.js @@ -0,0 +1,73 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-init.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (private class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + + +var callCount = 0; +class C { + async * #method([[x, y, z] = [4, 5, 6]] = []) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-elem-ary-elem-iter.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-elem-ary-elem-iter.js new file mode 100644 index 0000000000..e567750f7e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-elem-ary-elem-iter.js @@ -0,0 +1,74 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-iter.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (private class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + + +var callCount = 0; +class C { + async * #method([[x, y, z] = [4, 5, 6]] = [[7, 8, 9]]) { + assert.sameValue(x, 7); + assert.sameValue(y, 8); + assert.sameValue(z, 9); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-elem-ary-elision-init.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-elem-ary-elision-init.js new file mode 100644 index 0000000000..40f784086a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-elem-ary-elision-init.js @@ -0,0 +1,80 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-init.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (private class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, class, class-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + + +var callCount = 0; +class C { + async * #method([[,] = g()] = []) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-elem-ary-elision-iter.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-elem-ary-elision-iter.js new file mode 100644 index 0000000000..c1b2f5da1d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-elem-ary-elision-iter.js @@ -0,0 +1,77 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-iter.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (private class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, class, class-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var callCount = 0; +function* g() { + callCount += 1; +}; + + +var callCount = 0; +class C { + async * #method([[,] = g()] = [[]]) { + assert.sameValue(callCount, 0); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-elem-ary-empty-init.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-elem-ary-empty-init.js new file mode 100644 index 0000000000..b68b78d842 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-elem-ary-empty-init.js @@ -0,0 +1,76 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-init.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (private class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, class, class-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var initCount = 0; +var iterCount = 0; +var iter = function*() { iterCount += 1; }(); + + +var callCount = 0; +class C { + async * #method([[] = function() { initCount += 1; return iter; }()] = []) { + assert.sameValue(initCount, 1); + assert.sameValue(iterCount, 0); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-elem-ary-empty-iter.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-elem-ary-empty-iter.js new file mode 100644 index 0000000000..9d94e82d62 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-elem-ary-empty-iter.js @@ -0,0 +1,73 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-iter.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (private class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var initCount = 0; + + +var callCount = 0; +class C { + async * #method([[] = function() { initCount += 1; }()] = [[23]]) { + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-elem-ary-rest-init.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-elem-ary-rest-init.js new file mode 100644 index 0000000000..9abfa99a2d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-elem-ary-rest-init.js @@ -0,0 +1,77 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-init.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (private class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; + + +var callCount = 0; +class C { + async * #method([[...x] = values] = []) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-elem-ary-rest-iter.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-elem-ary-rest-iter.js new file mode 100644 index 0000000000..b8c1f86af1 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-elem-ary-rest-iter.js @@ -0,0 +1,80 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-iter.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (private class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; +var initCount = 0; + + +var callCount = 0; +class C { + async * #method([[...x] = function() { initCount += 1; }()] = [values]) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-elem-id-init-exhausted.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-elem-id-init-exhausted.js new file mode 100644 index 0000000000..904198433c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-elem-id-init-exhausted.js @@ -0,0 +1,72 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-exhausted.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-dflt.template +/*--- +description: Destructuring initializer with an exhausted iterator (private class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +class C { + async * #method([x = 23] = []) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..7a25e06852 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js @@ -0,0 +1,73 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-arrow.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-dflt.template +/*--- +description: SingleNameBinding does assign name to arrow functions (private class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +class C { + async * #method([arrow = () => {}] = []) { + assert.sameValue(arrow.name, 'arrow'); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-class.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-class.js new file mode 100644 index 0000000000..00bdef46f3 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-class.js @@ -0,0 +1,75 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-class.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-dflt.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (private class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +class C { + async * #method([cls = class {}, xCls = class X {}, xCls2 = class { static name() {} }] = []) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + assert.notSameValue(xCls2.name, 'xCls2'); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-cover.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-cover.js new file mode 100644 index 0000000000..6c0f3b4422 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-cover.js @@ -0,0 +1,74 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-cover.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-dflt.template +/*--- +description: SingleNameBinding does assign name to "anonymous" functions "through" cover grammar (private class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +class C { + async * #method([cover = (function () {}), xCover = (0, function() {})] = []) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-fn.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-fn.js new file mode 100644 index 0000000000..f81e864f80 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-fn.js @@ -0,0 +1,74 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-fn.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (private class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +class C { + async * #method([fn = function () {}, xFn = function x() {}] = []) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-gen.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-gen.js new file mode 100644 index 0000000000..4bb0e06d85 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-gen.js @@ -0,0 +1,75 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-gen.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (private class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, class, class-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). + +---*/ + + +var callCount = 0; +class C { + async * #method([gen = function* () {}, xGen = function* x() {}] = []) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-elem-id-init-hole.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-elem-id-init-hole.js new file mode 100644 index 0000000000..3f519190a4 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-elem-id-init-hole.js @@ -0,0 +1,68 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-hole.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-dflt.template +/*--- +description: Destructuring initializer with a "hole" (private class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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). + [...] + 7. If environment is undefined, return PutValue(lhs, v). 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +class C { + async * #method([x = 23] = [,]) { + assert.sameValue(x, 23); + // another statement + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-elem-id-init-skipped.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-elem-id-init-skipped.js new file mode 100644 index 0000000000..fc2aa2375b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-elem-id-init-skipped.js @@ -0,0 +1,77 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-skipped.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-dflt.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (private class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + + +var callCount = 0; +class C { + async * #method([w = counter(), x = counter(), y = counter(), z = counter()] = [null, 0, false, '']) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-elem-id-init-undef.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-elem-id-init-undef.js new file mode 100644 index 0000000000..a79633a795 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-elem-id-init-undef.js @@ -0,0 +1,71 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-undef.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-dflt.template +/*--- +description: Destructuring initializer with an undefined value (private class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +class C { + async * #method([x = 23] = [undefined]) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-elem-id-iter-complete.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-elem-id-iter-complete.js new file mode 100644 index 0000000000..6fb0aed962 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-elem-id-iter-complete.js @@ -0,0 +1,75 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-complete.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-dflt.template +/*--- +description: SingleNameBinding when value iteration completes (private class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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, + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +class C { + async * #method([x] = []) { + assert.sameValue(x, undefined); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-elem-id-iter-done.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-elem-id-iter-done.js new file mode 100644 index 0000000000..fcad842088 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-elem-id-iter-done.js @@ -0,0 +1,70 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-done.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-dflt.template +/*--- +description: SingleNameBinding when value iteration was completed previously (private class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +class C { + async * #method([_, x] = []) { + assert.sameValue(x, undefined); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-elem-id-iter-val-array-prototype.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-elem-id-iter-val-array-prototype.js new file mode 100644 index 0000000000..b48b5f926e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-elem-id-iter-val-array-prototype.js @@ -0,0 +1,91 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val-array-prototype.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-dflt.template +/*--- +description: Array destructuring uses overriden Array.prototype[Symbol.iterator] (private class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [Symbol.iterator, generators, class, class-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializer_opt + + 1. Let bindingId be StringValue of BindingIdentifier. + 2. Let lhs be ? ResolveBinding(bindingId, environment). + 3. If iteratorRecord.[[Done]] is false, then + a. Let next be IteratorStep(iteratorRecord). + 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). + [...] + 7. Return InitializeReferencedBinding(lhs, v). + +---*/ +Array.prototype[Symbol.iterator] = function* () { + if (this.length > 0) { + yield this[0]; + } + if (this.length > 1) { + yield this[1]; + } + if (this.length > 2) { + yield 42; + } +}; + + +var callCount = 0; +class C { + async * #method([x, y, z] = [1, 2, 3]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 42); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-elem-id-iter-val.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-elem-id-iter-val.js new file mode 100644 index 0000000000..d549b378de --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-elem-id-iter-val.js @@ -0,0 +1,81 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-dflt.template +/*--- +description: SingleNameBinding when value iteration was completed previously (private class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +class C { + async * #method([x, y, z] = [1, 2, 3]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-elem-obj-id-init.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-elem-obj-id-init.js new file mode 100644 index 0000000000..77dfeffcc9 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-elem-obj-id-init.js @@ -0,0 +1,73 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id-init.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is used (private class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + + +var callCount = 0; +class C { + async * #method([{ x, y, z } = { x: 44, y: 55, z: 66 }] = []) { + assert.sameValue(x, 44); + assert.sameValue(y, 55); + assert.sameValue(z, 66); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-elem-obj-id.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-elem-obj-id.js new file mode 100644 index 0000000000..4afeb42775 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-elem-obj-id.js @@ -0,0 +1,73 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (private class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + + +var callCount = 0; +class C { + async * #method([{ x, y, z } = { x: 44, y: 55, z: 66 }] = [{ x: 11, y: 22, z: 33 }]) { + assert.sameValue(x, 11); + assert.sameValue(y, 22); + assert.sameValue(z, 33); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-elem-obj-prop-id-init.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-elem-obj-prop-id-init.js new file mode 100644 index 0000000000..a8ca812ea5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-elem-obj-prop-id-init.js @@ -0,0 +1,83 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id-init.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is used (private class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + + +var callCount = 0; +class C { + async * #method([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] = []) { + assert.sameValue(v, 444); + assert.sameValue(x, 555); + assert.sameValue(z, 666); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-elem-obj-prop-id.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-elem-obj-prop-id.js new file mode 100644 index 0000000000..e93618201b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-elem-obj-prop-id.js @@ -0,0 +1,83 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (private class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + + +var callCount = 0; +class C { + async * #method([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] = [{ u: 777, w: 888, y: 999 }]) { + assert.sameValue(v, 777); + assert.sameValue(x, 888); + assert.sameValue(z, 999); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-elision-exhausted.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-elision-exhausted.js new file mode 100644 index 0000000000..0a9e02aaac --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-elision-exhausted.js @@ -0,0 +1,78 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-exhausted.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-dflt.template +/*--- +description: Elision accepts exhausted iterator (private class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, class, class-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 + [...] + 2. Return NormalCompletion(empty). + +---*/ +var iter = function*() {}(); +iter.next(); + + +var callCount = 0; +class C { + async * #method([,] = iter) { + + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-elision.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-elision.js new file mode 100644 index 0000000000..679d0d7712 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-elision.js @@ -0,0 +1,87 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-dflt.template +/*--- +description: Elision advances iterator (private class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, class, class-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + + +var callCount = 0; +class C { + async * #method([,] = g()) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-empty.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-empty.js new file mode 100644 index 0000000000..ccb5fe4d87 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-empty.js @@ -0,0 +1,70 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-empty.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-dflt.template +/*--- +description: No iteration occurs for an "empty" array binding pattern (private class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, class, class-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + + +var callCount = 0; +class C { + async * #method([] = iter) { + assert.sameValue(iterations, 0); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-rest-ary-elem.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-rest-ary-elem.js new file mode 100644 index 0000000000..fec42478c4 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-rest-ary-elem.js @@ -0,0 +1,94 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elem.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-dflt.template +/*--- +description: Rest element containing an array BindingElementList pattern (private class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the 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). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +class C { + async * #method([...[x, y, z]] = [3, 4, 5]) { + assert.sameValue(x, 3); + assert.sameValue(y, 4); + assert.sameValue(z, 5); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-rest-ary-elision.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-rest-ary-elision.js new file mode 100644 index 0000000000..fd6a038345 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-rest-ary-elision.js @@ -0,0 +1,100 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elision.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-dflt.template +/*--- +description: Rest element containing an elision (private class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, class, class-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the 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). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + + +var callCount = 0; +class C { + async * #method([...[,]] = g()) { + assert.sameValue(first, 1); + assert.sameValue(second, 1); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-rest-ary-empty.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-rest-ary-empty.js new file mode 100644 index 0000000000..0ac607d8f1 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-rest-ary-empty.js @@ -0,0 +1,83 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-empty.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-dflt.template +/*--- +description: Rest element containing an "empty" array pattern (private class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, class, class-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + + +var callCount = 0; +class C { + async * #method([...[]] = iter) { + assert.sameValue(iterations, 1); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-rest-ary-rest.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-rest-ary-rest.js new file mode 100644 index 0000000000..d45f6b8ae1 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-rest-ary-rest.js @@ -0,0 +1,79 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-rest.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-dflt.template +/*--- +description: Rest element containing a rest element (private class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ +var values = [1, 2, 3]; + + +var callCount = 0; +class C { + async * #method([...[...x]] = values) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-rest-id-direct.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-rest-id-direct.js new file mode 100644 index 0000000000..74daeb06a6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-rest-id-direct.js @@ -0,0 +1,74 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-direct.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-dflt.template +/*--- +description: Lone rest element (direct binding) (private class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, async-iteration] +flags: [generated, async] +includes: [compareArray.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingIdentifier + + [...] + 2. Let A be ! ArrayCreate(0). + 3. Let n be 0. + 4. Repeat, + [...] + f. Perform ! CreateDataPropertyOrThrow(A, ! ToString(n), nextValue). + g. Set n to n + 1. + +---*/ + + +var callCount = 0; +class C { + async * #method([...x] = [1]) { + assert(Array.isArray(x)); + assert.compareArray(x, [1]); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-rest-id-elision.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-rest-id-elision.js new file mode 100644 index 0000000000..b8518cd2f5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-rest-id-elision.js @@ -0,0 +1,75 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-dflt.template +/*--- +description: Rest element following elision elements (private class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 values = [1, 2, 3, 4, 5]; + + +var callCount = 0; +class C { + async * #method([ , , ...x] = values) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 3); + assert.sameValue(x[1], 4); + assert.sameValue(x[2], 5); + assert.notSameValue(x, values); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-rest-id-exhausted.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-rest-id-exhausted.js new file mode 100644 index 0000000000..b0cae39208 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-rest-id-exhausted.js @@ -0,0 +1,71 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-exhausted.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-dflt.template +/*--- +description: RestElement applied to an exhausted iterator (private class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [Symbol.iterator, class, class-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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, + [...] + b. If iteratorRecord.[[done]] is true, then + i. If environment is undefined, return PutValue(lhs, A). + ii. Return InitializeReferencedBinding(lhs, A). + +---*/ + + +var callCount = 0; +class C { + async * #method([, , ...x] = [1, 2]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 0); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-rest-id.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-rest-id.js new file mode 100644 index 0000000000..16fd9b9b2f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-rest-id.js @@ -0,0 +1,72 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-dflt.template +/*--- +description: Lone rest element (private class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + [...] 3. Let A be ArrayCreate(0). [...] 5. Repeat + [...] + f. Let status be CreateDataProperty(A, ToString (n), nextValue). + [...] +---*/ +var values = [1, 2, 3]; + + +var callCount = 0; +class C { + async * #method([...x] = values) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-rest-init-ary.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-rest-init-ary.js new file mode 100644 index 0000000000..908d9daf18 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-rest-init-ary.js @@ -0,0 +1,69 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-ary.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-dflt.template +/*--- +description: Rest element (nested array pattern) does not support initializer (private class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + + +var callCount = 0; +class C { + async * #method([...[ x ] = []] = []) { + + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-rest-init-id.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-rest-init-id.js new file mode 100644 index 0000000000..b9ab976e1e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-rest-init-id.js @@ -0,0 +1,69 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-id.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-dflt.template +/*--- +description: Rest element (identifier) does not support initializer (private class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + + +var callCount = 0; +class C { + async * #method([...x = []] = []) { + + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-rest-init-obj.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-rest-init-obj.js new file mode 100644 index 0000000000..6c7606de6d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-rest-init-obj.js @@ -0,0 +1,69 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-obj.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-dflt.template +/*--- +description: Rest element (nested object pattern) does not support initializer (private class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + + +var callCount = 0; +class C { + async * #method([...{ x } = []] = []) { + + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-rest-not-final-ary.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-rest-not-final-ary.js new file mode 100644 index 0000000000..1aa6beda6d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-rest-not-final-ary.js @@ -0,0 +1,69 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-ary.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-dflt.template +/*--- +description: Rest element (array binding pattern) may not be followed by any element (private class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + + +var callCount = 0; +class C { + async * #method([...[x], y] = [1, 2, 3]) { + + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-rest-not-final-id.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-rest-not-final-id.js new file mode 100644 index 0000000000..de0c49ee6f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-rest-not-final-id.js @@ -0,0 +1,69 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-id.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-dflt.template +/*--- +description: Rest element (identifier) may not be followed by any element (private class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + + +var callCount = 0; +class C { + async * #method([...x, y] = [1, 2, 3]) { + + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-rest-not-final-obj.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-rest-not-final-obj.js new file mode 100644 index 0000000000..0087343fe4 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-rest-not-final-obj.js @@ -0,0 +1,69 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-obj.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-dflt.template +/*--- +description: Rest element (object binding pattern) may not be followed by any element (private class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + + +var callCount = 0; +class C { + async * #method([...{ x }, y] = [1, 2, 3]) { + + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-rest-obj-id.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-rest-obj-id.js new file mode 100644 index 0000000000..b2fe912932 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-rest-obj-id.js @@ -0,0 +1,72 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-id.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-dflt.template +/*--- +description: Rest element containing an object binding pattern (private class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ + + +var callCount = 0; +class C { + async * #method([...{ length }] = [1, 2, 3]) { + assert.sameValue(length, 3); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-rest-obj-prop-id.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-rest-obj-prop-id.js new file mode 100644 index 0000000000..ca4df07606 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-ary-ptrn-rest-obj-prop-id.js @@ -0,0 +1,79 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-prop-id.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-dflt.template +/*--- +description: Rest element containing an object binding pattern (private class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ +let length = "outer"; + + +var callCount = 0; +class C { + async * #method([...{ 0: v, 1: w, 2: x, 3: y, length: z }] = [7, 8, 9]) { + assert.sameValue(v, 7); + assert.sameValue(w, 8); + assert.sameValue(x, 9); + assert.sameValue(y, undefined); + assert.sameValue(z, 3); + + assert.sameValue(length, "outer", "the length prop is not set as a binding name"); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-obj-ptrn-empty.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-obj-ptrn-empty.js new file mode 100644 index 0000000000..6cfe0efc2a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-obj-ptrn-empty.js @@ -0,0 +1,71 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-empty.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-dflt.template +/*--- +description: No property access occurs for an "empty" object binding pattern (private class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ +var accessCount = 0; +var obj = Object.defineProperty({}, 'attr', { + get: function() { + accessCount += 1; + } +}); + + +var callCount = 0; +class C { + async * #method({} = obj) { + assert.sameValue(accessCount, 0); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-obj-ptrn-id-init-fn-name-arrow.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-obj-ptrn-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..7210a2fc8b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-obj-ptrn-id-init-fn-name-arrow.js @@ -0,0 +1,72 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-arrow.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-dflt.template +/*--- +description: SingleNameBinding assigns `name` to arrow functions (private class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + + +var callCount = 0; +class C { + async * #method({ arrow = () => {} } = {}) { + assert.sameValue(arrow.name, 'arrow'); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-obj-ptrn-id-init-fn-name-class.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-obj-ptrn-id-init-fn-name-class.js new file mode 100644 index 0000000000..b5e1486c4e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-obj-ptrn-id-init-fn-name-class.js @@ -0,0 +1,74 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-class.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-dflt.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (private class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + + +var callCount = 0; +class C { + async * #method({ cls = class {}, xCls = class X {}, xCls2 = class { static name() {} } } = {}) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + assert.notSameValue(xCls2.name, 'xCls2'); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-obj-ptrn-id-init-fn-name-cover.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-obj-ptrn-id-init-fn-name-cover.js new file mode 100644 index 0000000000..0a179ba8f7 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-obj-ptrn-id-init-fn-name-cover.js @@ -0,0 +1,73 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-cover.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-dflt.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" functions "through" cover grammar (private class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + + +var callCount = 0; +class C { + async * #method({ cover = (function () {}), xCover = (0, function() {}) } = {}) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-obj-ptrn-id-init-fn-name-fn.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-obj-ptrn-id-init-fn-name-fn.js new file mode 100644 index 0000000000..b7922da54b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-obj-ptrn-id-init-fn-name-fn.js @@ -0,0 +1,73 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-fn.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (private class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + + +var callCount = 0; +class C { + async * #method({ fn = function () {}, xFn = function x() {} } = {}) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-obj-ptrn-id-init-fn-name-gen.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-obj-ptrn-id-init-fn-name-gen.js new file mode 100644 index 0000000000..41bee58fde --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-obj-ptrn-id-init-fn-name-gen.js @@ -0,0 +1,74 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-gen.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (private class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, class, class-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). + +---*/ + + +var callCount = 0; +class C { + async * #method({ gen = function* () {}, xGen = function* x() {} } = {}) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-obj-ptrn-id-init-skipped.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-obj-ptrn-id-init-skipped.js new file mode 100644 index 0000000000..2dc7b1da97 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-obj-ptrn-id-init-skipped.js @@ -0,0 +1,76 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-skipped.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-dflt.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (private class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + + +var callCount = 0; +class C { + async * #method({ w = counter(), x = counter(), y = counter(), z = counter() } = { w: null, x: 0, y: false, z: '' }) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-obj-ptrn-id-trailing-comma.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-obj-ptrn-id-trailing-comma.js new file mode 100644 index 0000000000..658536a8ad --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-obj-ptrn-id-trailing-comma.js @@ -0,0 +1,66 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-trailing-comma.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-dflt.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (private class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + + +var callCount = 0; +class C { + async * #method({ x, } = { x: 23 }) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-obj-ptrn-prop-ary-init.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-obj-ptrn-prop-ary-init.js new file mode 100644 index 0000000000..8f487d0075 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-obj-ptrn-prop-ary-init.js @@ -0,0 +1,75 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-init.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-dflt.template +/*--- +description: Object binding pattern with "nested" array binding pattern using initializer (private class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 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). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + + +var callCount = 0; +class C { + async * #method({ w: [x, y, z] = [4, 5, 6] } = {}) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-obj-ptrn-prop-ary-trailing-comma.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-obj-ptrn-prop-ary-trailing-comma.js new file mode 100644 index 0000000000..3039764b91 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-obj-ptrn-prop-ary-trailing-comma.js @@ -0,0 +1,66 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-trailing-comma.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-dflt.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (private class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + + +var callCount = 0; +class C { + async * #method({ x: [y], } = { x: [45] }) { + assert.sameValue(y,45); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-obj-ptrn-prop-ary.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-obj-ptrn-prop-ary.js new file mode 100644 index 0000000000..1f1ac22b38 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-obj-ptrn-prop-ary.js @@ -0,0 +1,73 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-dflt.template +/*--- +description: Object binding pattern with "nested" array binding pattern not using initializer (private class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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. +---*/ + + +var callCount = 0; +class C { + async * #method({ w: [x, y, z] = [4, 5, 6] } = { w: [7, undefined, ] }) { + assert.sameValue(x, 7); + assert.sameValue(y, undefined); + assert.sameValue(z, undefined); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-obj-ptrn-prop-id-init-skipped.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-obj-ptrn-prop-id-init-skipped.js new file mode 100644 index 0000000000..767b3ca69f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-obj-ptrn-prop-id-init-skipped.js @@ -0,0 +1,88 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-skipped.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-dflt.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (private class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + + +var callCount = 0; +class C { + async * #method({ s: t = counter(), u: v = counter(), w: x = counter(), y: z = counter() } = { s: null, u: 0, w: false, y: '' }) { + assert.sameValue(t, null); + assert.sameValue(v, 0); + assert.sameValue(x, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + + assert.throws(ReferenceError, function() { + s; + }); + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-obj-ptrn-prop-id-init.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-obj-ptrn-prop-id-init.js new file mode 100644 index 0000000000..2bb4af2d67 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-obj-ptrn-prop-id-init.js @@ -0,0 +1,69 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-dflt.template +/*--- +description: Binding as specified via property name, identifier, and initializer (private class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +class C { + async * #method({ x: y = 33 } = { }) { + assert.sameValue(y, 33); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-obj-ptrn-prop-id-trailing-comma.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-obj-ptrn-prop-id-trailing-comma.js new file mode 100644 index 0000000000..bcf99d52d2 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-obj-ptrn-prop-id-trailing-comma.js @@ -0,0 +1,70 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-trailing-comma.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-dflt.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (private class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + + +var callCount = 0; +class C { + async * #method({ x: y, } = { x: 23 }) { + assert.sameValue(y, 23); + + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-obj-ptrn-prop-id.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-obj-ptrn-prop-id.js new file mode 100644 index 0000000000..5ef002c189 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-obj-ptrn-prop-id.js @@ -0,0 +1,69 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-dflt.template +/*--- +description: Binding as specified via property name and identifier (private class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +class C { + async * #method({ x: y } = { x: 23 }) { + assert.sameValue(y, 23); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-obj-ptrn-prop-obj-init.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-obj-ptrn-prop-obj-init.js new file mode 100644 index 0000000000..94b88cef28 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-obj-ptrn-prop-obj-init.js @@ -0,0 +1,75 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-init.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern using initializer (private class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 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). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + + +var callCount = 0; +class C { + async * #method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } } = { w: undefined }) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-obj-ptrn-prop-obj.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-obj-ptrn-prop-obj.js new file mode 100644 index 0000000000..67a318fdee --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-obj-ptrn-prop-obj.js @@ -0,0 +1,73 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern not using initializer (private class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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. +---*/ + + +var callCount = 0; +class C { + async * #method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } } = { w: { x: undefined, z: 7 } }) { + assert.sameValue(x, undefined); + assert.sameValue(y, undefined); + assert.sameValue(z, 7); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-obj-ptrn-rest-getter.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-obj-ptrn-rest-getter.js new file mode 100644 index 0000000000..fe3c5ffc6a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-obj-ptrn-rest-getter.js @@ -0,0 +1,68 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-getter.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-dflt.template +/*--- +description: Getter is called when obj is being deconstructed to a rest Object (private class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [object-rest, class, class-methods-private, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + +---*/ +var count = 0; + + +var callCount = 0; +class C { + async * #method({...x} = { get v() { count++; return 2; } }) { + assert.sameValue(count, 1); + + verifyProperty(x, "v", { + enumerable: true, + writable: true, + configurable: true, + value: 2 + }); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-obj-ptrn-rest-skip-non-enumerable.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-obj-ptrn-rest-skip-non-enumerable.js new file mode 100644 index 0000000000..442f06f168 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-obj-ptrn-rest-skip-non-enumerable.js @@ -0,0 +1,76 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-skip-non-enumerable.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-dflt.template +/*--- +description: Rest object doesn't contain non-enumerable properties (private class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [object-rest, class, class-methods-private, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + +---*/ +var o = {a: 3, b: 4}; +Object.defineProperty(o, "x", { value: 4, enumerable: false }); + + +var callCount = 0; +class C { + async * #method({...rest} = o) { + assert.sameValue(rest.x, undefined); + + verifyProperty(rest, "a", { + enumerable: true, + writable: true, + configurable: true, + value: 3 + }); + + verifyProperty(rest, "b", { + enumerable: true, + writable: true, + configurable: true, + value: 4 + }); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-obj-ptrn-rest-val-obj.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-obj-ptrn-rest-val-obj.js new file mode 100644 index 0000000000..e5c559f729 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-dflt-obj-ptrn-rest-val-obj.js @@ -0,0 +1,75 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-val-obj.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-dflt.template +/*--- +description: Rest object contains just unextracted data (private class expression async generator method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [object-rest, class, class-methods-private, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + +---*/ + + +var callCount = 0; +class C { + async * #method({a, b, ...rest} = {x: 1, y: 2, a: 5, b: 3}) { + assert.sameValue(rest.a, undefined); + assert.sameValue(rest.b, undefined); + + verifyProperty(rest, "x", { + enumerable: true, + writable: true, + configurable: true, + value: 1 + }); + + verifyProperty(rest, "y", { + enumerable: true, + writable: true, + configurable: true, + value: 2 + }); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-obj-ptrn-empty.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-obj-ptrn-empty.js new file mode 100644 index 0000000000..61d4d48861 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-obj-ptrn-empty.js @@ -0,0 +1,71 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-empty.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth.template +/*--- +description: No property access occurs for an "empty" object binding pattern (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ +var accessCount = 0; +var obj = Object.defineProperty({}, 'attr', { + get: function() { + accessCount += 1; + } +}); + + +var callCount = 0; +class C { + async * #method({}) { + assert.sameValue(accessCount, 0); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method(obj).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-obj-ptrn-id-init-fn-name-arrow.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-obj-ptrn-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..50f6297ec2 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-obj-ptrn-id-init-fn-name-arrow.js @@ -0,0 +1,72 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-arrow.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth.template +/*--- +description: SingleNameBinding assigns `name` to arrow functions (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + + +var callCount = 0; +class C { + async * #method({ arrow = () => {} }) { + assert.sameValue(arrow.name, 'arrow'); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method({}).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-obj-ptrn-id-init-fn-name-class.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-obj-ptrn-id-init-fn-name-class.js new file mode 100644 index 0000000000..e9948991f1 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-obj-ptrn-id-init-fn-name-class.js @@ -0,0 +1,74 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-class.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + + +var callCount = 0; +class C { + async * #method({ cls = class {}, xCls = class X {}, xCls2 = class { static name() {} } }) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + assert.notSameValue(xCls2.name, 'xCls2'); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method({}).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-obj-ptrn-id-init-fn-name-cover.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-obj-ptrn-id-init-fn-name-cover.js new file mode 100644 index 0000000000..2f21f174da --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-obj-ptrn-id-init-fn-name-cover.js @@ -0,0 +1,73 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-cover.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" functions "through" cover grammar (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + + +var callCount = 0; +class C { + async * #method({ cover = (function () {}), xCover = (0, function() {}) }) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method({}).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-obj-ptrn-id-init-fn-name-fn.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-obj-ptrn-id-init-fn-name-fn.js new file mode 100644 index 0000000000..f75b183ff7 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-obj-ptrn-id-init-fn-name-fn.js @@ -0,0 +1,73 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-fn.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + + +var callCount = 0; +class C { + async * #method({ fn = function () {}, xFn = function x() {} }) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method({}).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-obj-ptrn-id-init-fn-name-gen.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-obj-ptrn-id-init-fn-name-gen.js new file mode 100644 index 0000000000..92a1366562 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-obj-ptrn-id-init-fn-name-gen.js @@ -0,0 +1,74 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-gen.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, class, class-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). + +---*/ + + +var callCount = 0; +class C { + async * #method({ gen = function* () {}, xGen = function* x() {} }) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method({}).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-obj-ptrn-id-init-skipped.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-obj-ptrn-id-init-skipped.js new file mode 100644 index 0000000000..96c193c3ad --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-obj-ptrn-id-init-skipped.js @@ -0,0 +1,76 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-skipped.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + + +var callCount = 0; +class C { + async * #method({ w = counter(), x = counter(), y = counter(), z = counter() }) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method({ w: null, x: 0, y: false, z: '' }).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-obj-ptrn-id-trailing-comma.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-obj-ptrn-id-trailing-comma.js new file mode 100644 index 0000000000..244c353400 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-obj-ptrn-id-trailing-comma.js @@ -0,0 +1,66 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-trailing-comma.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + + +var callCount = 0; +class C { + async * #method({ x, }) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method({ x: 23 }).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-obj-ptrn-prop-ary-init.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-obj-ptrn-prop-ary-init.js new file mode 100644 index 0000000000..d6c07d1864 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-obj-ptrn-prop-ary-init.js @@ -0,0 +1,75 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-init.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth.template +/*--- +description: Object binding pattern with "nested" array binding pattern using initializer (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 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). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + + +var callCount = 0; +class C { + async * #method({ w: [x, y, z] = [4, 5, 6] }) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method({}).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-obj-ptrn-prop-ary-trailing-comma.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-obj-ptrn-prop-ary-trailing-comma.js new file mode 100644 index 0000000000..e0dda00e3f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-obj-ptrn-prop-ary-trailing-comma.js @@ -0,0 +1,66 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-trailing-comma.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + + +var callCount = 0; +class C { + async * #method({ x: [y], }) { + assert.sameValue(y,45); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method({ x: [45] }).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-obj-ptrn-prop-ary.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-obj-ptrn-prop-ary.js new file mode 100644 index 0000000000..297066a35a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-obj-ptrn-prop-ary.js @@ -0,0 +1,73 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth.template +/*--- +description: Object binding pattern with "nested" array binding pattern not using initializer (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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. +---*/ + + +var callCount = 0; +class C { + async * #method({ w: [x, y, z] = [4, 5, 6] }) { + assert.sameValue(x, 7); + assert.sameValue(y, undefined); + assert.sameValue(z, undefined); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method({ w: [7, undefined, ] }).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-obj-ptrn-prop-id-init-skipped.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-obj-ptrn-prop-id-init-skipped.js new file mode 100644 index 0000000000..903b371b5a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-obj-ptrn-prop-id-init-skipped.js @@ -0,0 +1,88 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-skipped.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + + +var callCount = 0; +class C { + async * #method({ s: t = counter(), u: v = counter(), w: x = counter(), y: z = counter() }) { + assert.sameValue(t, null); + assert.sameValue(v, 0); + assert.sameValue(x, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + + assert.throws(ReferenceError, function() { + s; + }); + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method({ s: null, u: 0, w: false, y: '' }).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-obj-ptrn-prop-id-init.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-obj-ptrn-prop-id-init.js new file mode 100644 index 0000000000..665d55bc64 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-obj-ptrn-prop-id-init.js @@ -0,0 +1,69 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth.template +/*--- +description: Binding as specified via property name, identifier, and initializer (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +class C { + async * #method({ x: y = 33 }) { + assert.sameValue(y, 33); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method({ }).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-obj-ptrn-prop-id-trailing-comma.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-obj-ptrn-prop-id-trailing-comma.js new file mode 100644 index 0000000000..5aad3d9a13 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-obj-ptrn-prop-id-trailing-comma.js @@ -0,0 +1,70 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-trailing-comma.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + + +var callCount = 0; +class C { + async * #method({ x: y, }) { + assert.sameValue(y, 23); + + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method({ x: 23 }).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-obj-ptrn-prop-id.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-obj-ptrn-prop-id.js new file mode 100644 index 0000000000..5cad542b70 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-obj-ptrn-prop-id.js @@ -0,0 +1,69 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth.template +/*--- +description: Binding as specified via property name and identifier (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +class C { + async * #method({ x: y }) { + assert.sameValue(y, 23); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method({ x: 23 }).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-obj-ptrn-prop-obj-init.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-obj-ptrn-prop-obj-init.js new file mode 100644 index 0000000000..3037b1934a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-obj-ptrn-prop-obj-init.js @@ -0,0 +1,75 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-init.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth.template +/*--- +description: Object binding pattern with "nested" object binding pattern using initializer (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 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). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + + +var callCount = 0; +class C { + async * #method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } }) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method({ w: undefined }).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-obj-ptrn-prop-obj.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-obj-ptrn-prop-obj.js new file mode 100644 index 0000000000..c1fa963d96 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-obj-ptrn-prop-obj.js @@ -0,0 +1,73 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth.template +/*--- +description: Object binding pattern with "nested" object binding pattern not using initializer (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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. +---*/ + + +var callCount = 0; +class C { + async * #method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } }) { + assert.sameValue(x, undefined); + assert.sameValue(y, undefined); + assert.sameValue(z, 7); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method({ w: { x: undefined, z: 7 } }).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-obj-ptrn-rest-getter.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-obj-ptrn-rest-getter.js new file mode 100644 index 0000000000..054aef19b5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-obj-ptrn-rest-getter.js @@ -0,0 +1,68 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-getter.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth.template +/*--- +description: Getter is called when obj is being deconstructed to a rest Object (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [object-rest, class, class-methods-private, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + +---*/ +var count = 0; + + +var callCount = 0; +class C { + async * #method({...x}) { + assert.sameValue(count, 1); + + verifyProperty(x, "v", { + enumerable: true, + writable: true, + configurable: true, + value: 2 + }); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method({ get v() { count++; return 2; } }).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-obj-ptrn-rest-skip-non-enumerable.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-obj-ptrn-rest-skip-non-enumerable.js new file mode 100644 index 0000000000..46cda116e9 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-obj-ptrn-rest-skip-non-enumerable.js @@ -0,0 +1,76 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-skip-non-enumerable.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth.template +/*--- +description: Rest object doesn't contain non-enumerable properties (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [object-rest, class, class-methods-private, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + +---*/ +var o = {a: 3, b: 4}; +Object.defineProperty(o, "x", { value: 4, enumerable: false }); + + +var callCount = 0; +class C { + async * #method({...rest}) { + assert.sameValue(rest.x, undefined); + + verifyProperty(rest, "a", { + enumerable: true, + writable: true, + configurable: true, + value: 3 + }); + + verifyProperty(rest, "b", { + enumerable: true, + writable: true, + configurable: true, + value: 4 + }); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method(o).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-obj-ptrn-rest-val-obj.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-obj-ptrn-rest-val-obj.js new file mode 100644 index 0000000000..240351f74b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-obj-ptrn-rest-val-obj.js @@ -0,0 +1,75 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-val-obj.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth.template +/*--- +description: Rest object contains just unextracted data (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [object-rest, class, class-methods-private, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + +---*/ + + +var callCount = 0; +class C { + async * #method({a, b, ...rest}) { + assert.sameValue(rest.a, undefined); + assert.sameValue(rest.b, undefined); + + verifyProperty(rest, "x", { + enumerable: true, + writable: true, + configurable: true, + value: 1 + }); + + verifyProperty(rest, "y", { + enumerable: true, + writable: true, + configurable: true, + value: 2 + }); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method({x: 1, y: 2, a: 5, b: 3}).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-init-iter-close.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-init-iter-close.js new file mode 100644 index 0000000000..66a972d383 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-init-iter-close.js @@ -0,0 +1,82 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-close.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static.template +/*--- +description: Iterator is closed when not exhausted by pattern evaluation (private static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [Symbol.iterator, class, class-static-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: false }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + + +var callCount = 0; +class C { + static async * #method([x]) { + assert.sameValue(doneCallCount, 1); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method(iter).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-init-iter-no-close.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-init-iter-no-close.js new file mode 100644 index 0000000000..fd7ebdf0c8 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-init-iter-no-close.js @@ -0,0 +1,82 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-no-close.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static.template +/*--- +description: Iterator is not closed when exhausted by pattern evaluation (private static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [Symbol.iterator, class, class-static-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: true }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + + +var callCount = 0; +class C { + static async * #method([x]) { + assert.sameValue(doneCallCount, 0); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method(iter).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-name-iter-val.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-name-iter-val.js new file mode 100644 index 0000000000..9abdc616de --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-name-iter-val.js @@ -0,0 +1,81 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-name-iter-val.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static.template +/*--- +description: SingleNameBinding with normal value iteration (private static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +class C { + static async * #method([x, y, z]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method([1, 2, 3]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-elem-ary-elem-init.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-elem-ary-elem-init.js new file mode 100644 index 0000000000..bb2ba2f067 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-elem-ary-elem-init.js @@ -0,0 +1,73 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-init.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static.template +/*--- +description: BindingElement with array binding pattern and initializer is used (private static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + + +var callCount = 0; +class C { + static async * #method([[x, y, z] = [4, 5, 6]]) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method([]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-elem-ary-elem-iter.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-elem-ary-elem-iter.js new file mode 100644 index 0000000000..84915cb853 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-elem-ary-elem-iter.js @@ -0,0 +1,74 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-iter.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (private static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + + +var callCount = 0; +class C { + static async * #method([[x, y, z] = [4, 5, 6]]) { + assert.sameValue(x, 7); + assert.sameValue(y, 8); + assert.sameValue(z, 9); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method([[7, 8, 9]]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-elem-ary-elision-init.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-elem-ary-elision-init.js new file mode 100644 index 0000000000..8dc61c0f97 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-elem-ary-elision-init.js @@ -0,0 +1,80 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-init.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static.template +/*--- +description: BindingElement with array binding pattern and initializer is used (private static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, class, class-static-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + + +var callCount = 0; +class C { + static async * #method([[,] = g()]) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method([]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-elem-ary-elision-iter.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-elem-ary-elision-iter.js new file mode 100644 index 0000000000..3bd83f8ad1 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-elem-ary-elision-iter.js @@ -0,0 +1,77 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-iter.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (private static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, class, class-static-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var callCount = 0; +function* g() { + callCount += 1; +}; + + +var callCount = 0; +class C { + static async * #method([[,] = g()]) { + assert.sameValue(callCount, 0); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method([[]]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-elem-ary-empty-init.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-elem-ary-empty-init.js new file mode 100644 index 0000000000..028c11548f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-elem-ary-empty-init.js @@ -0,0 +1,76 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-init.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static.template +/*--- +description: BindingElement with array binding pattern and initializer is used (private static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, class, class-static-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var initCount = 0; +var iterCount = 0; +var iter = function*() { iterCount += 1; }(); + + +var callCount = 0; +class C { + static async * #method([[] = function() { initCount += 1; return iter; }()]) { + assert.sameValue(initCount, 1); + assert.sameValue(iterCount, 0); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method([]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-elem-ary-empty-iter.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-elem-ary-empty-iter.js new file mode 100644 index 0000000000..81e33ffeba --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-elem-ary-empty-iter.js @@ -0,0 +1,73 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-iter.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (private static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var initCount = 0; + + +var callCount = 0; +class C { + static async * #method([[] = function() { initCount += 1; }()]) { + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method([[23]]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-elem-ary-rest-init.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-elem-ary-rest-init.js new file mode 100644 index 0000000000..f79eb67627 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-elem-ary-rest-init.js @@ -0,0 +1,77 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-init.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static.template +/*--- +description: BindingElement with array binding pattern and initializer is used (private static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; + + +var callCount = 0; +class C { + static async * #method([[...x] = values]) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method([]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-elem-ary-rest-iter.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-elem-ary-rest-iter.js new file mode 100644 index 0000000000..e5487f3f69 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-elem-ary-rest-iter.js @@ -0,0 +1,80 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-iter.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (private static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; +var initCount = 0; + + +var callCount = 0; +class C { + static async * #method([[...x] = function() { initCount += 1; }()]) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method([values]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-elem-id-init-exhausted.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-elem-id-init-exhausted.js new file mode 100644 index 0000000000..e206146701 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-elem-id-init-exhausted.js @@ -0,0 +1,72 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-exhausted.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static.template +/*--- +description: Destructuring initializer with an exhausted iterator (private static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +class C { + static async * #method([x = 23]) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method([]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-elem-id-init-fn-name-arrow.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-elem-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..36f5c9b13d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-elem-id-init-fn-name-arrow.js @@ -0,0 +1,73 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-arrow.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static.template +/*--- +description: SingleNameBinding does assign name to arrow functions (private static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +class C { + static async * #method([arrow = () => {}]) { + assert.sameValue(arrow.name, 'arrow'); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method([]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-elem-id-init-fn-name-class.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-elem-id-init-fn-name-class.js new file mode 100644 index 0000000000..9f59830c46 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-elem-id-init-fn-name-class.js @@ -0,0 +1,75 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-class.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (private static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +class C { + static async * #method([cls = class {}, xCls = class X {}, xCls2 = class { static name() {} }]) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + assert.notSameValue(xCls2.name, 'xCls2'); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method([]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-elem-id-init-fn-name-cover.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-elem-id-init-fn-name-cover.js new file mode 100644 index 0000000000..61b74f9d51 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-elem-id-init-fn-name-cover.js @@ -0,0 +1,74 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-cover.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static.template +/*--- +description: SingleNameBinding does assign name to "anonymous" functions "through" cover grammar (private static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +class C { + static async * #method([cover = (function () {}), xCover = (0, function() {})]) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method([]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-elem-id-init-fn-name-fn.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-elem-id-init-fn-name-fn.js new file mode 100644 index 0000000000..c55a90eebb --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-elem-id-init-fn-name-fn.js @@ -0,0 +1,74 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-fn.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (private static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +class C { + static async * #method([fn = function () {}, xFn = function x() {}]) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method([]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-elem-id-init-fn-name-gen.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-elem-id-init-fn-name-gen.js new file mode 100644 index 0000000000..5d212cdf6b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-elem-id-init-fn-name-gen.js @@ -0,0 +1,75 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-gen.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (private static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, class, class-static-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). + +---*/ + + +var callCount = 0; +class C { + static async * #method([gen = function* () {}, xGen = function* x() {}]) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method([]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-elem-id-init-hole.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-elem-id-init-hole.js new file mode 100644 index 0000000000..2239a72507 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-elem-id-init-hole.js @@ -0,0 +1,68 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-hole.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static.template +/*--- +description: Destructuring initializer with a "hole" (private static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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). + [...] + 7. If environment is undefined, return PutValue(lhs, v). 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +class C { + static async * #method([x = 23]) { + assert.sameValue(x, 23); + // another statement + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method([,]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-elem-id-init-skipped.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-elem-id-init-skipped.js new file mode 100644 index 0000000000..4bb0151085 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-elem-id-init-skipped.js @@ -0,0 +1,77 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-skipped.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (private static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + + +var callCount = 0; +class C { + static async * #method([w = counter(), x = counter(), y = counter(), z = counter()]) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method([null, 0, false, '']).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-elem-id-init-undef.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-elem-id-init-undef.js new file mode 100644 index 0000000000..536c0b3e27 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-elem-id-init-undef.js @@ -0,0 +1,71 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-undef.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static.template +/*--- +description: Destructuring initializer with an undefined value (private static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +class C { + static async * #method([x = 23]) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method([undefined]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-elem-id-iter-complete.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-elem-id-iter-complete.js new file mode 100644 index 0000000000..24bc7cc81d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-elem-id-iter-complete.js @@ -0,0 +1,75 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-complete.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static.template +/*--- +description: SingleNameBinding when value iteration completes (private static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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, + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +class C { + static async * #method([x]) { + assert.sameValue(x, undefined); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method([]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-elem-id-iter-done.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-elem-id-iter-done.js new file mode 100644 index 0000000000..35dc2af10b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-elem-id-iter-done.js @@ -0,0 +1,70 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-done.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static.template +/*--- +description: SingleNameBinding when value iteration was completed previously (private static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +class C { + static async * #method([_, x]) { + assert.sameValue(x, undefined); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method([]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-elem-id-iter-val-array-prototype.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-elem-id-iter-val-array-prototype.js new file mode 100644 index 0000000000..b019de73d0 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-elem-id-iter-val-array-prototype.js @@ -0,0 +1,91 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val-array-prototype.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static.template +/*--- +description: Array destructuring uses overriden Array.prototype[Symbol.iterator] (private static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [Symbol.iterator, generators, class, class-static-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializer_opt + + 1. Let bindingId be StringValue of BindingIdentifier. + 2. Let lhs be ? ResolveBinding(bindingId, environment). + 3. If iteratorRecord.[[Done]] is false, then + a. Let next be IteratorStep(iteratorRecord). + 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). + [...] + 7. Return InitializeReferencedBinding(lhs, v). + +---*/ +Array.prototype[Symbol.iterator] = function* () { + if (this.length > 0) { + yield this[0]; + } + if (this.length > 1) { + yield this[1]; + } + if (this.length > 2) { + yield 42; + } +}; + + +var callCount = 0; +class C { + static async * #method([x, y, z]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 42); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method([1, 2, 3]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-elem-id-iter-val.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-elem-id-iter-val.js new file mode 100644 index 0000000000..8c0f250c87 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-elem-id-iter-val.js @@ -0,0 +1,81 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static.template +/*--- +description: SingleNameBinding when value iteration was completed previously (private static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +class C { + static async * #method([x, y, z]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method([1, 2, 3]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-elem-obj-id-init.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-elem-obj-id-init.js new file mode 100644 index 0000000000..0e4dc249a8 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-elem-obj-id-init.js @@ -0,0 +1,73 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id-init.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static.template +/*--- +description: BindingElement with object binding pattern and initializer is used (private static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + + +var callCount = 0; +class C { + static async * #method([{ x, y, z } = { x: 44, y: 55, z: 66 }]) { + assert.sameValue(x, 44); + assert.sameValue(y, 55); + assert.sameValue(z, 66); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method([]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-elem-obj-id.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-elem-obj-id.js new file mode 100644 index 0000000000..a7bcfa0be6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-elem-obj-id.js @@ -0,0 +1,73 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (private static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + + +var callCount = 0; +class C { + static async * #method([{ x, y, z } = { x: 44, y: 55, z: 66 }]) { + assert.sameValue(x, 11); + assert.sameValue(y, 22); + assert.sameValue(z, 33); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method([{ x: 11, y: 22, z: 33 }]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-elem-obj-prop-id-init.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-elem-obj-prop-id-init.js new file mode 100644 index 0000000000..f925a3978f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-elem-obj-prop-id-init.js @@ -0,0 +1,83 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id-init.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static.template +/*--- +description: BindingElement with object binding pattern and initializer is used (private static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + + +var callCount = 0; +class C { + static async * #method([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }]) { + assert.sameValue(v, 444); + assert.sameValue(x, 555); + assert.sameValue(z, 666); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method([]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-elem-obj-prop-id.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-elem-obj-prop-id.js new file mode 100644 index 0000000000..572361b5b3 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-elem-obj-prop-id.js @@ -0,0 +1,83 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (private static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + + +var callCount = 0; +class C { + static async * #method([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }]) { + assert.sameValue(v, 777); + assert.sameValue(x, 888); + assert.sameValue(z, 999); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method([{ u: 777, w: 888, y: 999 }]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-elision-exhausted.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-elision-exhausted.js new file mode 100644 index 0000000000..23311821c1 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-elision-exhausted.js @@ -0,0 +1,78 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-exhausted.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static.template +/*--- +description: Elision accepts exhausted iterator (private static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, class, class-static-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 + [...] + 2. Return NormalCompletion(empty). + +---*/ +var iter = function*() {}(); +iter.next(); + + +var callCount = 0; +class C { + static async * #method([,]) { + + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method(iter).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-elision.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-elision.js new file mode 100644 index 0000000000..55759400ee --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-elision.js @@ -0,0 +1,87 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static.template +/*--- +description: Elision advances iterator (private static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, class, class-static-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + + +var callCount = 0; +class C { + static async * #method([,]) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method(g()).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-empty.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-empty.js new file mode 100644 index 0000000000..432da14434 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-empty.js @@ -0,0 +1,70 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-empty.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static.template +/*--- +description: No iteration occurs for an "empty" array binding pattern (private static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, class, class-static-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + + +var callCount = 0; +class C { + static async * #method([]) { + assert.sameValue(iterations, 0); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method(iter).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-rest-ary-elem.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-rest-ary-elem.js new file mode 100644 index 0000000000..808fe116ff --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-rest-ary-elem.js @@ -0,0 +1,94 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elem.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static.template +/*--- +description: Rest element containing an array BindingElementList pattern (private static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the 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). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +class C { + static async * #method([...[x, y, z]]) { + assert.sameValue(x, 3); + assert.sameValue(y, 4); + assert.sameValue(z, 5); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method([3, 4, 5]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-rest-ary-elision.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-rest-ary-elision.js new file mode 100644 index 0000000000..95d2e48743 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-rest-ary-elision.js @@ -0,0 +1,100 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elision.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static.template +/*--- +description: Rest element containing an elision (private static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, class, class-static-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the 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). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + + +var callCount = 0; +class C { + static async * #method([...[,]]) { + assert.sameValue(first, 1); + assert.sameValue(second, 1); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method(g()).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-rest-ary-empty.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-rest-ary-empty.js new file mode 100644 index 0000000000..2682225934 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-rest-ary-empty.js @@ -0,0 +1,83 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-empty.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static.template +/*--- +description: Rest element containing an "empty" array pattern (private static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, class, class-static-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + + +var callCount = 0; +class C { + static async * #method([...[]]) { + assert.sameValue(iterations, 1); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method(iter).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-rest-ary-rest.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-rest-ary-rest.js new file mode 100644 index 0000000000..35c78d5e2f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-rest-ary-rest.js @@ -0,0 +1,79 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-rest.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static.template +/*--- +description: Rest element containing a rest element (private static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ +var values = [1, 2, 3]; + + +var callCount = 0; +class C { + static async * #method([...[...x]]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method(values).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-rest-id-direct.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-rest-id-direct.js new file mode 100644 index 0000000000..ada04375e4 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-rest-id-direct.js @@ -0,0 +1,74 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-direct.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static.template +/*--- +description: Lone rest element (direct binding) (private static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, async-iteration] +flags: [generated, async] +includes: [compareArray.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingIdentifier + + [...] + 2. Let A be ! ArrayCreate(0). + 3. Let n be 0. + 4. Repeat, + [...] + f. Perform ! CreateDataPropertyOrThrow(A, ! ToString(n), nextValue). + g. Set n to n + 1. + +---*/ + + +var callCount = 0; +class C { + static async * #method([...x]) { + assert(Array.isArray(x)); + assert.compareArray(x, [1]); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method([1]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-rest-id-elision.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-rest-id-elision.js new file mode 100644 index 0000000000..a55d278363 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-rest-id-elision.js @@ -0,0 +1,75 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static.template +/*--- +description: Rest element following elision elements (private static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 values = [1, 2, 3, 4, 5]; + + +var callCount = 0; +class C { + static async * #method([ , , ...x]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 3); + assert.sameValue(x[1], 4); + assert.sameValue(x[2], 5); + assert.notSameValue(x, values); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method(values).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-rest-id-exhausted.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-rest-id-exhausted.js new file mode 100644 index 0000000000..bc1e06fd64 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-rest-id-exhausted.js @@ -0,0 +1,71 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-exhausted.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static.template +/*--- +description: RestElement applied to an exhausted iterator (private static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [Symbol.iterator, class, class-static-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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, + [...] + b. If iteratorRecord.[[done]] is true, then + i. If environment is undefined, return PutValue(lhs, A). + ii. Return InitializeReferencedBinding(lhs, A). + +---*/ + + +var callCount = 0; +class C { + static async * #method([, , ...x]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 0); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method([1, 2]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-rest-id.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-rest-id.js new file mode 100644 index 0000000000..5edb8a8c64 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-rest-id.js @@ -0,0 +1,72 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static.template +/*--- +description: Lone rest element (private static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + [...] 3. Let A be ArrayCreate(0). [...] 5. Repeat + [...] + f. Let status be CreateDataProperty(A, ToString (n), nextValue). + [...] +---*/ +var values = [1, 2, 3]; + + +var callCount = 0; +class C { + static async * #method([...x]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method(values).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-rest-init-ary.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-rest-init-ary.js new file mode 100644 index 0000000000..fdad69769b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-rest-init-ary.js @@ -0,0 +1,69 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-ary.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static.template +/*--- +description: Rest element (nested array pattern) does not support initializer (private static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + + +var callCount = 0; +class C { + static async * #method([...[ x ] = []]) { + + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method([]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-rest-init-id.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-rest-init-id.js new file mode 100644 index 0000000000..1273c42bbe --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-rest-init-id.js @@ -0,0 +1,69 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-id.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static.template +/*--- +description: Rest element (identifier) does not support initializer (private static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + + +var callCount = 0; +class C { + static async * #method([...x = []]) { + + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method([]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-rest-init-obj.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-rest-init-obj.js new file mode 100644 index 0000000000..7d95130a27 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-rest-init-obj.js @@ -0,0 +1,69 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-obj.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static.template +/*--- +description: Rest element (nested object pattern) does not support initializer (private static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + + +var callCount = 0; +class C { + static async * #method([...{ x } = []]) { + + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method([]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-rest-not-final-ary.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-rest-not-final-ary.js new file mode 100644 index 0000000000..ba3efaaed1 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-rest-not-final-ary.js @@ -0,0 +1,69 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-ary.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static.template +/*--- +description: Rest element (array binding pattern) may not be followed by any element (private static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + + +var callCount = 0; +class C { + static async * #method([...[x], y]) { + + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method([1, 2, 3]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-rest-not-final-id.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-rest-not-final-id.js new file mode 100644 index 0000000000..8def309cf6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-rest-not-final-id.js @@ -0,0 +1,69 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-id.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static.template +/*--- +description: Rest element (identifier) may not be followed by any element (private static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + + +var callCount = 0; +class C { + static async * #method([...x, y]) { + + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method([1, 2, 3]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-rest-not-final-obj.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-rest-not-final-obj.js new file mode 100644 index 0000000000..af8f46ec29 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-rest-not-final-obj.js @@ -0,0 +1,69 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-obj.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static.template +/*--- +description: Rest element (object binding pattern) may not be followed by any element (private static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + + +var callCount = 0; +class C { + static async * #method([...{ x }, y]) { + + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method([1, 2, 3]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-rest-obj-id.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-rest-obj-id.js new file mode 100644 index 0000000000..e582e00655 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-rest-obj-id.js @@ -0,0 +1,72 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-id.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static.template +/*--- +description: Rest element containing an object binding pattern (private static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ + + +var callCount = 0; +class C { + static async * #method([...{ length }]) { + assert.sameValue(length, 3); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method([1, 2, 3]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-rest-obj-prop-id.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-rest-obj-prop-id.js new file mode 100644 index 0000000000..2138358f15 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-ary-ptrn-rest-obj-prop-id.js @@ -0,0 +1,79 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-prop-id.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static.template +/*--- +description: Rest element containing an object binding pattern (private static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ +let length = "outer"; + + +var callCount = 0; +class C { + static async * #method([...{ 0: v, 1: w, 2: x, 3: y, length: z }]) { + assert.sameValue(v, 7); + assert.sameValue(w, 8); + assert.sameValue(x, 9); + assert.sameValue(y, undefined); + assert.sameValue(z, 3); + + assert.sameValue(length, "outer", "the length prop is not set as a binding name"); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method([7, 8, 9]).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-init-iter-close.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-init-iter-close.js new file mode 100644 index 0000000000..28a6af3211 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-init-iter-close.js @@ -0,0 +1,82 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-close.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static-dflt.template +/*--- +description: Iterator is closed when not exhausted by pattern evaluation (private static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [Symbol.iterator, class, class-static-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: false }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + + +var callCount = 0; +class C { + static async * #method([x] = iter) { + assert.sameValue(doneCallCount, 1); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-init-iter-no-close.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-init-iter-no-close.js new file mode 100644 index 0000000000..81970976b1 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-init-iter-no-close.js @@ -0,0 +1,82 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-no-close.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static-dflt.template +/*--- +description: Iterator is not closed when exhausted by pattern evaluation (private static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [Symbol.iterator, class, class-static-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: true }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + + +var callCount = 0; +class C { + static async * #method([x] = iter) { + assert.sameValue(doneCallCount, 0); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-name-iter-val.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-name-iter-val.js new file mode 100644 index 0000000000..da5e4e4d2c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-name-iter-val.js @@ -0,0 +1,81 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-name-iter-val.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static-dflt.template +/*--- +description: SingleNameBinding with normal value iteration (private static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +class C { + static async * #method([x, y, z] = [1, 2, 3]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-elem-ary-elem-init.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-elem-ary-elem-init.js new file mode 100644 index 0000000000..6e23720a1d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-elem-ary-elem-init.js @@ -0,0 +1,73 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-init.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (private static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + + +var callCount = 0; +class C { + static async * #method([[x, y, z] = [4, 5, 6]] = []) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-elem-ary-elem-iter.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-elem-ary-elem-iter.js new file mode 100644 index 0000000000..2669c6b221 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-elem-ary-elem-iter.js @@ -0,0 +1,74 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-iter.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (private static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + + +var callCount = 0; +class C { + static async * #method([[x, y, z] = [4, 5, 6]] = [[7, 8, 9]]) { + assert.sameValue(x, 7); + assert.sameValue(y, 8); + assert.sameValue(z, 9); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-elem-ary-elision-init.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-elem-ary-elision-init.js new file mode 100644 index 0000000000..1968c9e22a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-elem-ary-elision-init.js @@ -0,0 +1,80 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-init.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (private static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, class, class-static-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + + +var callCount = 0; +class C { + static async * #method([[,] = g()] = []) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-elem-ary-elision-iter.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-elem-ary-elision-iter.js new file mode 100644 index 0000000000..dfa634b0d7 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-elem-ary-elision-iter.js @@ -0,0 +1,77 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-iter.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (private static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, class, class-static-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var callCount = 0; +function* g() { + callCount += 1; +}; + + +var callCount = 0; +class C { + static async * #method([[,] = g()] = [[]]) { + assert.sameValue(callCount, 0); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-elem-ary-empty-init.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-elem-ary-empty-init.js new file mode 100644 index 0000000000..d5ebfdf456 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-elem-ary-empty-init.js @@ -0,0 +1,76 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-init.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (private static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, class, class-static-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var initCount = 0; +var iterCount = 0; +var iter = function*() { iterCount += 1; }(); + + +var callCount = 0; +class C { + static async * #method([[] = function() { initCount += 1; return iter; }()] = []) { + assert.sameValue(initCount, 1); + assert.sameValue(iterCount, 0); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-elem-ary-empty-iter.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-elem-ary-empty-iter.js new file mode 100644 index 0000000000..5fea8f88b7 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-elem-ary-empty-iter.js @@ -0,0 +1,73 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-iter.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (private static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var initCount = 0; + + +var callCount = 0; +class C { + static async * #method([[] = function() { initCount += 1; }()] = [[23]]) { + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-elem-ary-rest-init.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-elem-ary-rest-init.js new file mode 100644 index 0000000000..1ae393ea4a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-elem-ary-rest-init.js @@ -0,0 +1,77 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-init.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (private static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; + + +var callCount = 0; +class C { + static async * #method([[...x] = values] = []) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-elem-ary-rest-iter.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-elem-ary-rest-iter.js new file mode 100644 index 0000000000..931019587f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-elem-ary-rest-iter.js @@ -0,0 +1,80 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-iter.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (private static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; +var initCount = 0; + + +var callCount = 0; +class C { + static async * #method([[...x] = function() { initCount += 1; }()] = [values]) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-elem-id-init-exhausted.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-elem-id-init-exhausted.js new file mode 100644 index 0000000000..d447402f19 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-elem-id-init-exhausted.js @@ -0,0 +1,72 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-exhausted.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static-dflt.template +/*--- +description: Destructuring initializer with an exhausted iterator (private static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +class C { + static async * #method([x = 23] = []) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..56d87f8a92 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js @@ -0,0 +1,73 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-arrow.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static-dflt.template +/*--- +description: SingleNameBinding does assign name to arrow functions (private static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +class C { + static async * #method([arrow = () => {}] = []) { + assert.sameValue(arrow.name, 'arrow'); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-class.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-class.js new file mode 100644 index 0000000000..f649f6ef50 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-class.js @@ -0,0 +1,75 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-class.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static-dflt.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (private static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +class C { + static async * #method([cls = class {}, xCls = class X {}, xCls2 = class { static name() {} }] = []) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + assert.notSameValue(xCls2.name, 'xCls2'); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-cover.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-cover.js new file mode 100644 index 0000000000..0a3e35af26 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-cover.js @@ -0,0 +1,74 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-cover.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static-dflt.template +/*--- +description: SingleNameBinding does assign name to "anonymous" functions "through" cover grammar (private static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +class C { + static async * #method([cover = (function () {}), xCover = (0, function() {})] = []) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-fn.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-fn.js new file mode 100644 index 0000000000..2cf6c7f89e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-fn.js @@ -0,0 +1,74 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-fn.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (private static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +class C { + static async * #method([fn = function () {}, xFn = function x() {}] = []) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-gen.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-gen.js new file mode 100644 index 0000000000..b284579b73 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-gen.js @@ -0,0 +1,75 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-gen.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (private static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, class, class-static-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). + +---*/ + + +var callCount = 0; +class C { + static async * #method([gen = function* () {}, xGen = function* x() {}] = []) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-elem-id-init-hole.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-elem-id-init-hole.js new file mode 100644 index 0000000000..936674029a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-elem-id-init-hole.js @@ -0,0 +1,68 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-hole.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static-dflt.template +/*--- +description: Destructuring initializer with a "hole" (private static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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). + [...] + 7. If environment is undefined, return PutValue(lhs, v). 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +class C { + static async * #method([x = 23] = [,]) { + assert.sameValue(x, 23); + // another statement + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-elem-id-init-skipped.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-elem-id-init-skipped.js new file mode 100644 index 0000000000..28f90531cf --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-elem-id-init-skipped.js @@ -0,0 +1,77 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-skipped.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static-dflt.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (private static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + + +var callCount = 0; +class C { + static async * #method([w = counter(), x = counter(), y = counter(), z = counter()] = [null, 0, false, '']) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-elem-id-init-undef.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-elem-id-init-undef.js new file mode 100644 index 0000000000..1df59acff9 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-elem-id-init-undef.js @@ -0,0 +1,71 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-undef.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static-dflt.template +/*--- +description: Destructuring initializer with an undefined value (private static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +class C { + static async * #method([x = 23] = [undefined]) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-elem-id-iter-complete.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-elem-id-iter-complete.js new file mode 100644 index 0000000000..e7a12e886f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-elem-id-iter-complete.js @@ -0,0 +1,75 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-complete.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static-dflt.template +/*--- +description: SingleNameBinding when value iteration completes (private static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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, + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +class C { + static async * #method([x] = []) { + assert.sameValue(x, undefined); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-elem-id-iter-done.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-elem-id-iter-done.js new file mode 100644 index 0000000000..53b706eabc --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-elem-id-iter-done.js @@ -0,0 +1,70 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-done.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static-dflt.template +/*--- +description: SingleNameBinding when value iteration was completed previously (private static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +class C { + static async * #method([_, x] = []) { + assert.sameValue(x, undefined); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-elem-id-iter-val-array-prototype.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-elem-id-iter-val-array-prototype.js new file mode 100644 index 0000000000..311051b6a6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-elem-id-iter-val-array-prototype.js @@ -0,0 +1,91 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val-array-prototype.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static-dflt.template +/*--- +description: Array destructuring uses overriden Array.prototype[Symbol.iterator] (private static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [Symbol.iterator, generators, class, class-static-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializer_opt + + 1. Let bindingId be StringValue of BindingIdentifier. + 2. Let lhs be ? ResolveBinding(bindingId, environment). + 3. If iteratorRecord.[[Done]] is false, then + a. Let next be IteratorStep(iteratorRecord). + 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). + [...] + 7. Return InitializeReferencedBinding(lhs, v). + +---*/ +Array.prototype[Symbol.iterator] = function* () { + if (this.length > 0) { + yield this[0]; + } + if (this.length > 1) { + yield this[1]; + } + if (this.length > 2) { + yield 42; + } +}; + + +var callCount = 0; +class C { + static async * #method([x, y, z] = [1, 2, 3]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 42); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-elem-id-iter-val.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-elem-id-iter-val.js new file mode 100644 index 0000000000..4173a19f99 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-elem-id-iter-val.js @@ -0,0 +1,81 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static-dflt.template +/*--- +description: SingleNameBinding when value iteration was completed previously (private static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +class C { + static async * #method([x, y, z] = [1, 2, 3]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-elem-obj-id-init.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-elem-obj-id-init.js new file mode 100644 index 0000000000..b0678e4e9c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-elem-obj-id-init.js @@ -0,0 +1,73 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id-init.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is used (private static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + + +var callCount = 0; +class C { + static async * #method([{ x, y, z } = { x: 44, y: 55, z: 66 }] = []) { + assert.sameValue(x, 44); + assert.sameValue(y, 55); + assert.sameValue(z, 66); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-elem-obj-id.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-elem-obj-id.js new file mode 100644 index 0000000000..246b8f2e77 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-elem-obj-id.js @@ -0,0 +1,73 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (private static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + + +var callCount = 0; +class C { + static async * #method([{ x, y, z } = { x: 44, y: 55, z: 66 }] = [{ x: 11, y: 22, z: 33 }]) { + assert.sameValue(x, 11); + assert.sameValue(y, 22); + assert.sameValue(z, 33); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-elem-obj-prop-id-init.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-elem-obj-prop-id-init.js new file mode 100644 index 0000000000..092e48c799 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-elem-obj-prop-id-init.js @@ -0,0 +1,83 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id-init.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is used (private static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + + +var callCount = 0; +class C { + static async * #method([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] = []) { + assert.sameValue(v, 444); + assert.sameValue(x, 555); + assert.sameValue(z, 666); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-elem-obj-prop-id.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-elem-obj-prop-id.js new file mode 100644 index 0000000000..e4f6807b5a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-elem-obj-prop-id.js @@ -0,0 +1,83 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (private static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + + +var callCount = 0; +class C { + static async * #method([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] = [{ u: 777, w: 888, y: 999 }]) { + assert.sameValue(v, 777); + assert.sameValue(x, 888); + assert.sameValue(z, 999); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-elision-exhausted.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-elision-exhausted.js new file mode 100644 index 0000000000..afa632e671 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-elision-exhausted.js @@ -0,0 +1,78 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-exhausted.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static-dflt.template +/*--- +description: Elision accepts exhausted iterator (private static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, class, class-static-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 + [...] + 2. Return NormalCompletion(empty). + +---*/ +var iter = function*() {}(); +iter.next(); + + +var callCount = 0; +class C { + static async * #method([,] = iter) { + + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-elision.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-elision.js new file mode 100644 index 0000000000..526a289070 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-elision.js @@ -0,0 +1,87 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static-dflt.template +/*--- +description: Elision advances iterator (private static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, class, class-static-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + + +var callCount = 0; +class C { + static async * #method([,] = g()) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-empty.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-empty.js new file mode 100644 index 0000000000..e2ecdcd8cc --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-empty.js @@ -0,0 +1,70 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-empty.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static-dflt.template +/*--- +description: No iteration occurs for an "empty" array binding pattern (private static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, class, class-static-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + + +var callCount = 0; +class C { + static async * #method([] = iter) { + assert.sameValue(iterations, 0); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-rest-ary-elem.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-rest-ary-elem.js new file mode 100644 index 0000000000..8ee224c8b5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-rest-ary-elem.js @@ -0,0 +1,94 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elem.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static-dflt.template +/*--- +description: Rest element containing an array BindingElementList pattern (private static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the 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). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +class C { + static async * #method([...[x, y, z]] = [3, 4, 5]) { + assert.sameValue(x, 3); + assert.sameValue(y, 4); + assert.sameValue(z, 5); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-rest-ary-elision.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-rest-ary-elision.js new file mode 100644 index 0000000000..fb1fdb9163 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-rest-ary-elision.js @@ -0,0 +1,100 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elision.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static-dflt.template +/*--- +description: Rest element containing an elision (private static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, class, class-static-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the 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). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + + +var callCount = 0; +class C { + static async * #method([...[,]] = g()) { + assert.sameValue(first, 1); + assert.sameValue(second, 1); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-rest-ary-empty.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-rest-ary-empty.js new file mode 100644 index 0000000000..6e8d7be1f6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-rest-ary-empty.js @@ -0,0 +1,83 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-empty.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static-dflt.template +/*--- +description: Rest element containing an "empty" array pattern (private static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, class, class-static-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + + +var callCount = 0; +class C { + static async * #method([...[]] = iter) { + assert.sameValue(iterations, 1); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-rest-ary-rest.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-rest-ary-rest.js new file mode 100644 index 0000000000..b6e5e406eb --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-rest-ary-rest.js @@ -0,0 +1,79 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-rest.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static-dflt.template +/*--- +description: Rest element containing a rest element (private static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ +var values = [1, 2, 3]; + + +var callCount = 0; +class C { + static async * #method([...[...x]] = values) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-rest-id-direct.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-rest-id-direct.js new file mode 100644 index 0000000000..704abfad48 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-rest-id-direct.js @@ -0,0 +1,74 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-direct.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static-dflt.template +/*--- +description: Lone rest element (direct binding) (private static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, async-iteration] +flags: [generated, async] +includes: [compareArray.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingIdentifier + + [...] + 2. Let A be ! ArrayCreate(0). + 3. Let n be 0. + 4. Repeat, + [...] + f. Perform ! CreateDataPropertyOrThrow(A, ! ToString(n), nextValue). + g. Set n to n + 1. + +---*/ + + +var callCount = 0; +class C { + static async * #method([...x] = [1]) { + assert(Array.isArray(x)); + assert.compareArray(x, [1]); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-rest-id-elision.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-rest-id-elision.js new file mode 100644 index 0000000000..57c15a4170 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-rest-id-elision.js @@ -0,0 +1,75 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static-dflt.template +/*--- +description: Rest element following elision elements (private static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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 values = [1, 2, 3, 4, 5]; + + +var callCount = 0; +class C { + static async * #method([ , , ...x] = values) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 3); + assert.sameValue(x[1], 4); + assert.sameValue(x[2], 5); + assert.notSameValue(x, values); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-rest-id-exhausted.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-rest-id-exhausted.js new file mode 100644 index 0000000000..d5ce0307a0 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-rest-id-exhausted.js @@ -0,0 +1,71 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-exhausted.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static-dflt.template +/*--- +description: RestElement applied to an exhausted iterator (private static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [Symbol.iterator, class, class-static-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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, + [...] + b. If iteratorRecord.[[done]] is true, then + i. If environment is undefined, return PutValue(lhs, A). + ii. Return InitializeReferencedBinding(lhs, A). + +---*/ + + +var callCount = 0; +class C { + static async * #method([, , ...x] = [1, 2]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 0); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-rest-id.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-rest-id.js new file mode 100644 index 0000000000..865ebc51dc --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-rest-id.js @@ -0,0 +1,72 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static-dflt.template +/*--- +description: Lone rest element (private static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + [...] 3. Let A be ArrayCreate(0). [...] 5. Repeat + [...] + f. Let status be CreateDataProperty(A, ToString (n), nextValue). + [...] +---*/ +var values = [1, 2, 3]; + + +var callCount = 0; +class C { + static async * #method([...x] = values) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-rest-init-ary.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-rest-init-ary.js new file mode 100644 index 0000000000..a4d551ad4f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-rest-init-ary.js @@ -0,0 +1,69 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-ary.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static-dflt.template +/*--- +description: Rest element (nested array pattern) does not support initializer (private static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + + +var callCount = 0; +class C { + static async * #method([...[ x ] = []] = []) { + + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-rest-init-id.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-rest-init-id.js new file mode 100644 index 0000000000..98737ae8b7 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-rest-init-id.js @@ -0,0 +1,69 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-id.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static-dflt.template +/*--- +description: Rest element (identifier) does not support initializer (private static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + + +var callCount = 0; +class C { + static async * #method([...x = []] = []) { + + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-rest-init-obj.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-rest-init-obj.js new file mode 100644 index 0000000000..75c51f5725 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-rest-init-obj.js @@ -0,0 +1,69 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-obj.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static-dflt.template +/*--- +description: Rest element (nested object pattern) does not support initializer (private static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + + +var callCount = 0; +class C { + static async * #method([...{ x } = []] = []) { + + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-rest-not-final-ary.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-rest-not-final-ary.js new file mode 100644 index 0000000000..56c522be3d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-rest-not-final-ary.js @@ -0,0 +1,69 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-ary.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static-dflt.template +/*--- +description: Rest element (array binding pattern) may not be followed by any element (private static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + + +var callCount = 0; +class C { + static async * #method([...[x], y] = [1, 2, 3]) { + + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-rest-not-final-id.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-rest-not-final-id.js new file mode 100644 index 0000000000..15a5482253 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-rest-not-final-id.js @@ -0,0 +1,69 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-id.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static-dflt.template +/*--- +description: Rest element (identifier) may not be followed by any element (private static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + + +var callCount = 0; +class C { + static async * #method([...x, y] = [1, 2, 3]) { + + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-rest-not-final-obj.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-rest-not-final-obj.js new file mode 100644 index 0000000000..8dd17cbcf7 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-rest-not-final-obj.js @@ -0,0 +1,69 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-obj.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static-dflt.template +/*--- +description: Rest element (object binding pattern) may not be followed by any element (private static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, async-iteration] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + + +var callCount = 0; +class C { + static async * #method([...{ x }, y] = [1, 2, 3]) { + + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-rest-obj-id.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-rest-obj-id.js new file mode 100644 index 0000000000..e5f5eb8a37 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-rest-obj-id.js @@ -0,0 +1,72 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-id.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static-dflt.template +/*--- +description: Rest element containing an object binding pattern (private static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ + + +var callCount = 0; +class C { + static async * #method([...{ length }] = [1, 2, 3]) { + assert.sameValue(length, 3); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-rest-obj-prop-id.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-rest-obj-prop-id.js new file mode 100644 index 0000000000..a7b3375013 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-ary-ptrn-rest-obj-prop-id.js @@ -0,0 +1,79 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-prop-id.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static-dflt.template +/*--- +description: Rest element containing an object binding pattern (private static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ +let length = "outer"; + + +var callCount = 0; +class C { + static async * #method([...{ 0: v, 1: w, 2: x, 3: y, length: z }] = [7, 8, 9]) { + assert.sameValue(v, 7); + assert.sameValue(w, 8); + assert.sameValue(x, 9); + assert.sameValue(y, undefined); + assert.sameValue(z, 3); + + assert.sameValue(length, "outer", "the length prop is not set as a binding name"); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-obj-ptrn-empty.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-obj-ptrn-empty.js new file mode 100644 index 0000000000..ea9d36dbfe --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-obj-ptrn-empty.js @@ -0,0 +1,71 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-empty.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static-dflt.template +/*--- +description: No property access occurs for an "empty" object binding pattern (private static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ +var accessCount = 0; +var obj = Object.defineProperty({}, 'attr', { + get: function() { + accessCount += 1; + } +}); + + +var callCount = 0; +class C { + static async * #method({} = obj) { + assert.sameValue(accessCount, 0); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-obj-ptrn-id-init-fn-name-arrow.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-obj-ptrn-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..eb613df976 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-obj-ptrn-id-init-fn-name-arrow.js @@ -0,0 +1,72 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-arrow.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static-dflt.template +/*--- +description: SingleNameBinding assigns `name` to arrow functions (private static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + + +var callCount = 0; +class C { + static async * #method({ arrow = () => {} } = {}) { + assert.sameValue(arrow.name, 'arrow'); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-obj-ptrn-id-init-fn-name-class.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-obj-ptrn-id-init-fn-name-class.js new file mode 100644 index 0000000000..f00a43e200 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-obj-ptrn-id-init-fn-name-class.js @@ -0,0 +1,74 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-class.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static-dflt.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (private static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + + +var callCount = 0; +class C { + static async * #method({ cls = class {}, xCls = class X {}, xCls2 = class { static name() {} } } = {}) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + assert.notSameValue(xCls2.name, 'xCls2'); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-obj-ptrn-id-init-fn-name-cover.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-obj-ptrn-id-init-fn-name-cover.js new file mode 100644 index 0000000000..1f39ccad4e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-obj-ptrn-id-init-fn-name-cover.js @@ -0,0 +1,73 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-cover.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static-dflt.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" functions "through" cover grammar (private static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + + +var callCount = 0; +class C { + static async * #method({ cover = (function () {}), xCover = (0, function() {}) } = {}) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-obj-ptrn-id-init-fn-name-fn.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-obj-ptrn-id-init-fn-name-fn.js new file mode 100644 index 0000000000..e3392ea16d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-obj-ptrn-id-init-fn-name-fn.js @@ -0,0 +1,73 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-fn.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (private static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + + +var callCount = 0; +class C { + static async * #method({ fn = function () {}, xFn = function x() {} } = {}) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-obj-ptrn-id-init-fn-name-gen.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-obj-ptrn-id-init-fn-name-gen.js new file mode 100644 index 0000000000..224933e9a3 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-obj-ptrn-id-init-fn-name-gen.js @@ -0,0 +1,74 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-gen.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (private static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, class, class-static-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). + +---*/ + + +var callCount = 0; +class C { + static async * #method({ gen = function* () {}, xGen = function* x() {} } = {}) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-obj-ptrn-id-init-skipped.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-obj-ptrn-id-init-skipped.js new file mode 100644 index 0000000000..c43913f345 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-obj-ptrn-id-init-skipped.js @@ -0,0 +1,76 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-skipped.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static-dflt.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (private static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + + +var callCount = 0; +class C { + static async * #method({ w = counter(), x = counter(), y = counter(), z = counter() } = { w: null, x: 0, y: false, z: '' }) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-obj-ptrn-id-trailing-comma.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-obj-ptrn-id-trailing-comma.js new file mode 100644 index 0000000000..2de5d499be --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-obj-ptrn-id-trailing-comma.js @@ -0,0 +1,66 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-trailing-comma.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static-dflt.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (private static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + + +var callCount = 0; +class C { + static async * #method({ x, } = { x: 23 }) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-obj-ptrn-prop-ary-init.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-obj-ptrn-prop-ary-init.js new file mode 100644 index 0000000000..6ad473ebd5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-obj-ptrn-prop-ary-init.js @@ -0,0 +1,75 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-init.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static-dflt.template +/*--- +description: Object binding pattern with "nested" array binding pattern using initializer (private static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 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). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + + +var callCount = 0; +class C { + static async * #method({ w: [x, y, z] = [4, 5, 6] } = {}) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-obj-ptrn-prop-ary-trailing-comma.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-obj-ptrn-prop-ary-trailing-comma.js new file mode 100644 index 0000000000..d37273c692 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-obj-ptrn-prop-ary-trailing-comma.js @@ -0,0 +1,66 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-trailing-comma.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static-dflt.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (private static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + + +var callCount = 0; +class C { + static async * #method({ x: [y], } = { x: [45] }) { + assert.sameValue(y,45); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-obj-ptrn-prop-ary.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-obj-ptrn-prop-ary.js new file mode 100644 index 0000000000..f3f8e4c585 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-obj-ptrn-prop-ary.js @@ -0,0 +1,73 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static-dflt.template +/*--- +description: Object binding pattern with "nested" array binding pattern not using initializer (private static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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. +---*/ + + +var callCount = 0; +class C { + static async * #method({ w: [x, y, z] = [4, 5, 6] } = { w: [7, undefined, ] }) { + assert.sameValue(x, 7); + assert.sameValue(y, undefined); + assert.sameValue(z, undefined); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-obj-ptrn-prop-id-init-skipped.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-obj-ptrn-prop-id-init-skipped.js new file mode 100644 index 0000000000..73805697a4 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-obj-ptrn-prop-id-init-skipped.js @@ -0,0 +1,88 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-skipped.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static-dflt.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (private static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + + +var callCount = 0; +class C { + static async * #method({ s: t = counter(), u: v = counter(), w: x = counter(), y: z = counter() } = { s: null, u: 0, w: false, y: '' }) { + assert.sameValue(t, null); + assert.sameValue(v, 0); + assert.sameValue(x, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + + assert.throws(ReferenceError, function() { + s; + }); + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-obj-ptrn-prop-id-init.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-obj-ptrn-prop-id-init.js new file mode 100644 index 0000000000..d6ddc3b435 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-obj-ptrn-prop-id-init.js @@ -0,0 +1,69 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static-dflt.template +/*--- +description: Binding as specified via property name, identifier, and initializer (private static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +class C { + static async * #method({ x: y = 33 } = { }) { + assert.sameValue(y, 33); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-obj-ptrn-prop-id-trailing-comma.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-obj-ptrn-prop-id-trailing-comma.js new file mode 100644 index 0000000000..f503d2b36b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-obj-ptrn-prop-id-trailing-comma.js @@ -0,0 +1,70 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-trailing-comma.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static-dflt.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (private static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + + +var callCount = 0; +class C { + static async * #method({ x: y, } = { x: 23 }) { + assert.sameValue(y, 23); + + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-obj-ptrn-prop-id.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-obj-ptrn-prop-id.js new file mode 100644 index 0000000000..cfdbe14355 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-obj-ptrn-prop-id.js @@ -0,0 +1,69 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static-dflt.template +/*--- +description: Binding as specified via property name and identifier (private static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +class C { + static async * #method({ x: y } = { x: 23 }) { + assert.sameValue(y, 23); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-obj-ptrn-prop-obj-init.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-obj-ptrn-prop-obj-init.js new file mode 100644 index 0000000000..a3e3b63c78 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-obj-ptrn-prop-obj-init.js @@ -0,0 +1,75 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-init.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern using initializer (private static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 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). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + + +var callCount = 0; +class C { + static async * #method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } } = { w: undefined }) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-obj-ptrn-prop-obj.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-obj-ptrn-prop-obj.js new file mode 100644 index 0000000000..a02754ce1e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-obj-ptrn-prop-obj.js @@ -0,0 +1,73 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern not using initializer (private static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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. +---*/ + + +var callCount = 0; +class C { + static async * #method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } } = { w: { x: undefined, z: 7 } }) { + assert.sameValue(x, undefined); + assert.sameValue(y, undefined); + assert.sameValue(z, 7); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-obj-ptrn-rest-getter.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-obj-ptrn-rest-getter.js new file mode 100644 index 0000000000..329ab3412a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-obj-ptrn-rest-getter.js @@ -0,0 +1,68 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-getter.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static-dflt.template +/*--- +description: Getter is called when obj is being deconstructed to a rest Object (private static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [object-rest, class, class-static-methods-private, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + +---*/ +var count = 0; + + +var callCount = 0; +class C { + static async * #method({...x} = { get v() { count++; return 2; } }) { + assert.sameValue(count, 1); + + verifyProperty(x, "v", { + enumerable: true, + writable: true, + configurable: true, + value: 2 + }); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-obj-ptrn-rest-skip-non-enumerable.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-obj-ptrn-rest-skip-non-enumerable.js new file mode 100644 index 0000000000..2e16bc72fa --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-obj-ptrn-rest-skip-non-enumerable.js @@ -0,0 +1,76 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-skip-non-enumerable.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static-dflt.template +/*--- +description: Rest object doesn't contain non-enumerable properties (private static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [object-rest, class, class-static-methods-private, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + +---*/ +var o = {a: 3, b: 4}; +Object.defineProperty(o, "x", { value: 4, enumerable: false }); + + +var callCount = 0; +class C { + static async * #method({...rest} = o) { + assert.sameValue(rest.x, undefined); + + verifyProperty(rest, "a", { + enumerable: true, + writable: true, + configurable: true, + value: 3 + }); + + verifyProperty(rest, "b", { + enumerable: true, + writable: true, + configurable: true, + value: 4 + }); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-obj-ptrn-rest-val-obj.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-obj-ptrn-rest-val-obj.js new file mode 100644 index 0000000000..6b4fa0c5a9 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-dflt-obj-ptrn-rest-val-obj.js @@ -0,0 +1,75 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-val-obj.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static-dflt.template +/*--- +description: Rest object contains just unextracted data (private static class expression async generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [object-rest, class, class-static-methods-private, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + +---*/ + + +var callCount = 0; +class C { + static async * #method({a, b, ...rest} = {x: 1, y: 2, a: 5, b: 3}) { + assert.sameValue(rest.a, undefined); + assert.sameValue(rest.b, undefined); + + verifyProperty(rest, "x", { + enumerable: true, + writable: true, + configurable: true, + value: 1 + }); + + verifyProperty(rest, "y", { + enumerable: true, + writable: true, + configurable: true, + value: 2 + }); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-obj-ptrn-empty.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-obj-ptrn-empty.js new file mode 100644 index 0000000000..9da9ee901e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-obj-ptrn-empty.js @@ -0,0 +1,71 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-empty.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static.template +/*--- +description: No property access occurs for an "empty" object binding pattern (private static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ +var accessCount = 0; +var obj = Object.defineProperty({}, 'attr', { + get: function() { + accessCount += 1; + } +}); + + +var callCount = 0; +class C { + static async * #method({}) { + assert.sameValue(accessCount, 0); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method(obj).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-obj-ptrn-id-init-fn-name-arrow.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-obj-ptrn-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..91af8421c3 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-obj-ptrn-id-init-fn-name-arrow.js @@ -0,0 +1,72 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-arrow.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static.template +/*--- +description: SingleNameBinding assigns `name` to arrow functions (private static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + + +var callCount = 0; +class C { + static async * #method({ arrow = () => {} }) { + assert.sameValue(arrow.name, 'arrow'); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method({}).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-obj-ptrn-id-init-fn-name-class.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-obj-ptrn-id-init-fn-name-class.js new file mode 100644 index 0000000000..c29cb50aba --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-obj-ptrn-id-init-fn-name-class.js @@ -0,0 +1,74 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-class.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (private static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + + +var callCount = 0; +class C { + static async * #method({ cls = class {}, xCls = class X {}, xCls2 = class { static name() {} } }) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + assert.notSameValue(xCls2.name, 'xCls2'); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method({}).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-obj-ptrn-id-init-fn-name-cover.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-obj-ptrn-id-init-fn-name-cover.js new file mode 100644 index 0000000000..c3548fc2f8 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-obj-ptrn-id-init-fn-name-cover.js @@ -0,0 +1,73 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-cover.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" functions "through" cover grammar (private static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + + +var callCount = 0; +class C { + static async * #method({ cover = (function () {}), xCover = (0, function() {}) }) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method({}).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-obj-ptrn-id-init-fn-name-fn.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-obj-ptrn-id-init-fn-name-fn.js new file mode 100644 index 0000000000..c872338099 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-obj-ptrn-id-init-fn-name-fn.js @@ -0,0 +1,73 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-fn.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (private static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + + +var callCount = 0; +class C { + static async * #method({ fn = function () {}, xFn = function x() {} }) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method({}).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-obj-ptrn-id-init-fn-name-gen.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-obj-ptrn-id-init-fn-name-gen.js new file mode 100644 index 0000000000..29c6cb6d02 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-obj-ptrn-id-init-fn-name-gen.js @@ -0,0 +1,74 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-gen.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (private static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, class, class-static-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). + +---*/ + + +var callCount = 0; +class C { + static async * #method({ gen = function* () {}, xGen = function* x() {} }) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method({}).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-obj-ptrn-id-init-skipped.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-obj-ptrn-id-init-skipped.js new file mode 100644 index 0000000000..57c11c9ec8 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-obj-ptrn-id-init-skipped.js @@ -0,0 +1,76 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-skipped.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (private static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + + +var callCount = 0; +class C { + static async * #method({ w = counter(), x = counter(), y = counter(), z = counter() }) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method({ w: null, x: 0, y: false, z: '' }).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-obj-ptrn-id-trailing-comma.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-obj-ptrn-id-trailing-comma.js new file mode 100644 index 0000000000..2e804c4278 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-obj-ptrn-id-trailing-comma.js @@ -0,0 +1,66 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-trailing-comma.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (private static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + + +var callCount = 0; +class C { + static async * #method({ x, }) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method({ x: 23 }).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-obj-ptrn-prop-ary-init.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-obj-ptrn-prop-ary-init.js new file mode 100644 index 0000000000..7de01e3581 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-obj-ptrn-prop-ary-init.js @@ -0,0 +1,75 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-init.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static.template +/*--- +description: Object binding pattern with "nested" array binding pattern using initializer (private static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 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). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + + +var callCount = 0; +class C { + static async * #method({ w: [x, y, z] = [4, 5, 6] }) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method({}).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-obj-ptrn-prop-ary-trailing-comma.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-obj-ptrn-prop-ary-trailing-comma.js new file mode 100644 index 0000000000..69df272711 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-obj-ptrn-prop-ary-trailing-comma.js @@ -0,0 +1,66 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-trailing-comma.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (private static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + + +var callCount = 0; +class C { + static async * #method({ x: [y], }) { + assert.sameValue(y,45); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method({ x: [45] }).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-obj-ptrn-prop-ary.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-obj-ptrn-prop-ary.js new file mode 100644 index 0000000000..d4641d51cc --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-obj-ptrn-prop-ary.js @@ -0,0 +1,73 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static.template +/*--- +description: Object binding pattern with "nested" array binding pattern not using initializer (private static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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. +---*/ + + +var callCount = 0; +class C { + static async * #method({ w: [x, y, z] = [4, 5, 6] }) { + assert.sameValue(x, 7); + assert.sameValue(y, undefined); + assert.sameValue(z, undefined); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method({ w: [7, undefined, ] }).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-obj-ptrn-prop-id-init-skipped.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-obj-ptrn-prop-id-init-skipped.js new file mode 100644 index 0000000000..84cdb306de --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-obj-ptrn-prop-id-init-skipped.js @@ -0,0 +1,88 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-skipped.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (private static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + + +var callCount = 0; +class C { + static async * #method({ s: t = counter(), u: v = counter(), w: x = counter(), y: z = counter() }) { + assert.sameValue(t, null); + assert.sameValue(v, 0); + assert.sameValue(x, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + + assert.throws(ReferenceError, function() { + s; + }); + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method({ s: null, u: 0, w: false, y: '' }).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-obj-ptrn-prop-id-init.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-obj-ptrn-prop-id-init.js new file mode 100644 index 0000000000..9adc2a6838 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-obj-ptrn-prop-id-init.js @@ -0,0 +1,69 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static.template +/*--- +description: Binding as specified via property name, identifier, and initializer (private static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +class C { + static async * #method({ x: y = 33 }) { + assert.sameValue(y, 33); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method({ }).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-obj-ptrn-prop-id-trailing-comma.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-obj-ptrn-prop-id-trailing-comma.js new file mode 100644 index 0000000000..8bcc12a4e7 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-obj-ptrn-prop-id-trailing-comma.js @@ -0,0 +1,70 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-trailing-comma.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (private static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + + +var callCount = 0; +class C { + static async * #method({ x: y, }) { + assert.sameValue(y, 23); + + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method({ x: 23 }).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-obj-ptrn-prop-id.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-obj-ptrn-prop-id.js new file mode 100644 index 0000000000..af2601e576 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-obj-ptrn-prop-id.js @@ -0,0 +1,69 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static.template +/*--- +description: Binding as specified via property name and identifier (private static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + + +var callCount = 0; +class C { + static async * #method({ x: y }) { + assert.sameValue(y, 23); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method({ x: 23 }).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-obj-ptrn-prop-obj-init.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-obj-ptrn-prop-obj-init.js new file mode 100644 index 0000000000..2686a72d90 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-obj-ptrn-prop-obj-init.js @@ -0,0 +1,75 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-init.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static.template +/*--- +description: Object binding pattern with "nested" object binding pattern using initializer (private static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 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). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + + +var callCount = 0; +class C { + static async * #method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } }) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method({ w: undefined }).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-obj-ptrn-prop-obj.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-obj-ptrn-prop-obj.js new file mode 100644 index 0000000000..f0a49a842f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-obj-ptrn-prop-obj.js @@ -0,0 +1,73 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static.template +/*--- +description: Object binding pattern with "nested" object binding pattern not using initializer (private static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, async-iteration] +flags: [generated, async] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + + + 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. +---*/ + + +var callCount = 0; +class C { + static async * #method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } }) { + assert.sameValue(x, undefined); + assert.sameValue(y, undefined); + assert.sameValue(z, 7); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method({ w: { x: undefined, z: 7 } }).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-obj-ptrn-rest-getter.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-obj-ptrn-rest-getter.js new file mode 100644 index 0000000000..0590d88ed6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-obj-ptrn-rest-getter.js @@ -0,0 +1,68 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-getter.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static.template +/*--- +description: Getter is called when obj is being deconstructed to a rest Object (private static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [object-rest, class, class-static-methods-private, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + +---*/ +var count = 0; + + +var callCount = 0; +class C { + static async * #method({...x}) { + assert.sameValue(count, 1); + + verifyProperty(x, "v", { + enumerable: true, + writable: true, + configurable: true, + value: 2 + }); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method({ get v() { count++; return 2; } }).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-obj-ptrn-rest-skip-non-enumerable.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-obj-ptrn-rest-skip-non-enumerable.js new file mode 100644 index 0000000000..913b83b81a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-obj-ptrn-rest-skip-non-enumerable.js @@ -0,0 +1,76 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-skip-non-enumerable.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static.template +/*--- +description: Rest object doesn't contain non-enumerable properties (private static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [object-rest, class, class-static-methods-private, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + +---*/ +var o = {a: 3, b: 4}; +Object.defineProperty(o, "x", { value: 4, enumerable: false }); + + +var callCount = 0; +class C { + static async * #method({...rest}) { + assert.sameValue(rest.x, undefined); + + verifyProperty(rest, "a", { + enumerable: true, + writable: true, + configurable: true, + value: 3 + }); + + verifyProperty(rest, "b", { + enumerable: true, + writable: true, + configurable: true, + value: 4 + }); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method(o).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-obj-ptrn-rest-val-obj.js b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-obj-ptrn-rest-val-obj.js new file mode 100644 index 0000000000..d88e0414db --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/async-private-gen-meth-static-obj-ptrn-rest-val-obj.js @@ -0,0 +1,75 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-val-obj.case +// - src/dstr-binding/default/cls-decl-async-private-gen-meth-static.template +/*--- +description: Rest object contains just unextracted data (private static class expression async generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [object-rest, class, class-static-methods-private, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) + { AsyncGeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true. + Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters, + AsyncGeneratorBody, scope, strict). + [...] + +---*/ + + +var callCount = 0; +class C { + static async * #method({a, b, ...rest}) { + assert.sameValue(rest.a, undefined); + assert.sameValue(rest.b, undefined); + + verifyProperty(rest, "x", { + enumerable: true, + writable: true, + configurable: true, + value: 1 + }); + + verifyProperty(rest, "y", { + enumerable: true, + writable: true, + configurable: true, + value: 2 + }); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method({x: 1, y: 2, a: 5, b: 3}).next().then(() => { + assert.sameValue(callCount, 1, 'invoked exactly once'); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/dstr/browser.js b/js/src/tests/test262/language/statements/class/dstr/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-init-iter-close.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-init-iter-close.js new file mode 100644 index 0000000000..60f8762b99 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-init-iter-close.js @@ -0,0 +1,96 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-close.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: Iterator is closed when not exhausted by pattern evaluation (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [Symbol.iterator, generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: false }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var callCount = 0; +class C { + *method([x]) { + assert.sameValue(doneCallCount, 1); + callCount = callCount + 1; + } +}; + +new C().method(iter).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-init-iter-get-err-array-prototype.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-init-iter-get-err-array-prototype.js new file mode 100644 index 0000000000..6d109041dd --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-init-iter-get-err-array-prototype.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-get-err-array-prototype.case +// - src/dstr-binding/error/cls-decl-gen-meth.template +/*--- +description: Abrupt completion returned by GetIterator (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [Symbol.iterator, generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iteratorRecord be ? GetIterator(value). + + GetIterator ( obj [ , hint [ , method ] ] ) + + [...] + 4. Let iterator be ? Call(method, obj). + + Call ( F, V [ , argumentsList ] ) + + [...] + 2. If IsCallable(F) is false, throw a TypeError exception. + +---*/ +delete Array.prototype[Symbol.iterator]; + +class C { + *method([x, y, z]) {} +}; +var c = new C(); + +assert.throws(TypeError, function() { + c.method([1, 2, 3]); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-init-iter-get-err.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-init-iter-get-err.js new file mode 100644 index 0000000000..7a49a318e7 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-init-iter-get-err.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-get-err.case +// - src/dstr-binding/error/cls-decl-gen-meth.template +/*--- +description: Abrupt completion returned by GetIterator (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [Symbol.iterator, generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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(); +}; + +class C { + *method([x]) {} +}; +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(iter); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-init-iter-no-close.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-init-iter-no-close.js new file mode 100644 index 0000000000..f8168190de --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-init-iter-no-close.js @@ -0,0 +1,96 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-no-close.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: Iterator is not closed when exhausted by pattern evaluation (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [Symbol.iterator, generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: true }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var callCount = 0; +class C { + *method([x]) { + assert.sameValue(doneCallCount, 0); + callCount = callCount + 1; + } +}; + +new C().method(iter).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-name-iter-val.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-name-iter-val.js new file mode 100644 index 0000000000..6e007890ef --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-name-iter-val.js @@ -0,0 +1,95 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-name-iter-val.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: SingleNameBinding with normal value iteration (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + *method([x, y, z]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; + } +}; + +new C().method([1, 2, 3]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-ary-elem-init.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-ary-elem-init.js new file mode 100644 index 0000000000..e900afa05e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-ary-elem-init.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-init.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: BindingElement with array binding pattern and initializer is used (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + *method([[x, y, z] = [4, 5, 6]]) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + callCount = callCount + 1; + } +}; + +new C().method([]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-ary-elem-iter.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-ary-elem-iter.js new file mode 100644 index 0000000000..ebb9072276 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-ary-elem-iter.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-iter.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + *method([[x, y, z] = [4, 5, 6]]) { + assert.sameValue(x, 7); + assert.sameValue(y, 8); + assert.sameValue(z, 9); + callCount = callCount + 1; + } +}; + +new C().method([[7, 8, 9]]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-ary-elision-init.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-ary-elision-init.js new file mode 100644 index 0000000000..e7a6728f0a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-ary-elision-init.js @@ -0,0 +1,94 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-init.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: BindingElement with array binding pattern and initializer is used (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +class C { + *method([[,] = g()]) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; + } +}; + +new C().method([]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-ary-elision-iter.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-ary-elision-iter.js new file mode 100644 index 0000000000..38e712609c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-ary-elision-iter.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-iter.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var callCount = 0; +function* g() { + callCount += 1; +}; + +var callCount = 0; +class C { + *method([[,] = g()]) { + assert.sameValue(callCount, 0); + callCount = callCount + 1; + } +}; + +new C().method([[]]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-ary-empty-init.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-ary-empty-init.js new file mode 100644 index 0000000000..d8fb02b065 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-ary-empty-init.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-init.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: BindingElement with array binding pattern and initializer is used (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var initCount = 0; +var iterCount = 0; +var iter = function*() { iterCount += 1; }(); + +var callCount = 0; +class C { + *method([[] = function() { initCount += 1; return iter; }()]) { + assert.sameValue(initCount, 1); + assert.sameValue(iterCount, 0); + callCount = callCount + 1; + } +}; + +new C().method([]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-ary-empty-iter.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-ary-empty-iter.js new file mode 100644 index 0000000000..7da1531868 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-ary-empty-iter.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-iter.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var initCount = 0; + +var callCount = 0; +class C { + *method([[] = function() { initCount += 1; }()]) { + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +new C().method([[23]]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-ary-rest-init.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-ary-rest-init.js new file mode 100644 index 0000000000..89e570be58 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-ary-rest-init.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-init.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: BindingElement with array binding pattern and initializer is used (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; + +var callCount = 0; +class C { + *method([[...x] = values]) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + callCount = callCount + 1; + } +}; + +new C().method([]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-ary-rest-iter.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-ary-rest-iter.js new file mode 100644 index 0000000000..7358b4b9a7 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-ary-rest-iter.js @@ -0,0 +1,94 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-iter.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; +var initCount = 0; + +var callCount = 0; +class C { + *method([[...x] = function() { initCount += 1; }()]) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +new C().method([values]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-ary-val-null.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-ary-val-null.js new file mode 100644 index 0000000000..45d18bbfdb --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-ary-val-null.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-val-null.case +// - src/dstr-binding/error/cls-decl-gen-meth.template +/*--- +description: Nested array destructuring with a null value (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). +---*/ + +class C { + *method([[x]]) {} +}; +var c = new C(); + +assert.throws(TypeError, function() { + c.method([null]); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-id-init-exhausted.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-id-init-exhausted.js new file mode 100644 index 0000000000..e925049d88 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-id-init-exhausted.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-exhausted.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: Destructuring initializer with an exhausted iterator (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + *method([x = 23]) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } +}; + +new C().method([]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-id-init-fn-name-arrow.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..a968f65793 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-id-init-fn-name-arrow.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-arrow.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: SingleNameBinding does assign name to arrow functions (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + *method([arrow = () => {}]) { + assert.sameValue(arrow.name, 'arrow'); + callCount = callCount + 1; + } +}; + +new C().method([]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-id-init-fn-name-class.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-id-init-fn-name-class.js new file mode 100644 index 0000000000..3325408c54 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-id-init-fn-name-class.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-class.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + *method([cls = class {}, xCls = class X {}, xCls2 = class { static name() {} }]) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + assert.notSameValue(xCls2.name, 'xCls2'); + callCount = callCount + 1; + } +}; + +new C().method([]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-id-init-fn-name-cover.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-id-init-fn-name-cover.js new file mode 100644 index 0000000000..2210300270 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-id-init-fn-name-cover.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-cover.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: SingleNameBinding does assign name to "anonymous" functions "through" cover grammar (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + *method([cover = (function () {}), xCover = (0, function() {})]) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + callCount = callCount + 1; + } +}; + +new C().method([]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-id-init-fn-name-fn.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-id-init-fn-name-fn.js new file mode 100644 index 0000000000..620b3f4c83 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-id-init-fn-name-fn.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-fn.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + *method([fn = function () {}, xFn = function x() {}]) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + callCount = callCount + 1; + } +}; + +new C().method([]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-id-init-fn-name-gen.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-id-init-fn-name-gen.js new file mode 100644 index 0000000000..5437fef254 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-id-init-fn-name-gen.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-gen.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). + +---*/ + +var callCount = 0; +class C { + *method([gen = function* () {}, xGen = function* x() {}]) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + callCount = callCount + 1; + } +}; + +new C().method([]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-id-init-hole.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-id-init-hole.js new file mode 100644 index 0000000000..905c2fddeb --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-id-init-hole.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-hole.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: Destructuring initializer with a "hole" (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + [...] + 7. If environment is undefined, return PutValue(lhs, v). 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + *method([x = 23]) { + assert.sameValue(x, 23); + // another statement + callCount = callCount + 1; + } +}; + +new C().method([,]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-id-init-skipped.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-id-init-skipped.js new file mode 100644 index 0000000000..2874fe472b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-id-init-skipped.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-skipped.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +class C { + *method([w = counter(), x = counter(), y = counter(), z = counter()]) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +new C().method([null, 0, false, '']).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-id-init-throws.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-id-init-throws.js new file mode 100644 index 0000000000..e5b20512dd --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-id-init-throws.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-throws.case +// - src/dstr-binding/error/cls-decl-gen-meth.template +/*--- +description: Destructuring initializer returns an abrupt completion (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). +---*/ + +class C { + *method([x = (function() { throw new Test262Error(); })()]) {} +}; +var c = new C(); + +assert.throws(Test262Error, function() { + c.method([undefined]); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-id-init-undef.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-id-init-undef.js new file mode 100644 index 0000000000..bd91406569 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-id-init-undef.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-undef.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: Destructuring initializer with an undefined value (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + *method([x = 23]) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } +}; + +new C().method([undefined]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-id-init-unresolvable.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-id-init-unresolvable.js new file mode 100644 index 0000000000..d07e7e0581 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-id-init-unresolvable.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-unresolvable.case +// - src/dstr-binding/error/cls-decl-gen-meth.template +/*--- +description: Destructuring initializer is an unresolvable reference (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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. +---*/ + +class C { + *method([ x = unresolvableReference ]) {} +}; +var c = new C(); + +assert.throws(ReferenceError, function() { + c.method([]); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-id-iter-complete.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-id-iter-complete.js new file mode 100644 index 0000000000..36d8c27df3 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-id-iter-complete.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-complete.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: SingleNameBinding when value iteration completes (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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, + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + *method([x]) { + assert.sameValue(x, undefined); + callCount = callCount + 1; + } +}; + +new C().method([]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-id-iter-done.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-id-iter-done.js new file mode 100644 index 0000000000..56f7eacfd4 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-id-iter-done.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-done.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: SingleNameBinding when value iteration was completed previously (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + *method([_, x]) { + assert.sameValue(x, undefined); + callCount = callCount + 1; + } +}; + +new C().method([]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-id-iter-step-err.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-id-iter-step-err.js new file mode 100644 index 0000000000..e8d9e954bc --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-id-iter-step-err.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-step-err.case +// - src/dstr-binding/error/cls-decl-gen-meth.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [Symbol.iterator, generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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(); + } + }; +}; + +class C { + *method([x]) {} +}; +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(g); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-id-iter-val-array-prototype.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-id-iter-val-array-prototype.js new file mode 100644 index 0000000000..92185b6425 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-id-iter-val-array-prototype.js @@ -0,0 +1,105 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val-array-prototype.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: Array destructuring uses overriden Array.prototype[Symbol.iterator] (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [Symbol.iterator, generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializer_opt + + 1. Let bindingId be StringValue of BindingIdentifier. + 2. Let lhs be ? ResolveBinding(bindingId, environment). + 3. If iteratorRecord.[[Done]] is false, then + a. Let next be IteratorStep(iteratorRecord). + 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). + [...] + 7. Return InitializeReferencedBinding(lhs, v). + +---*/ +Array.prototype[Symbol.iterator] = function* () { + if (this.length > 0) { + yield this[0]; + } + if (this.length > 1) { + yield this[1]; + } + if (this.length > 2) { + yield 42; + } +}; + +var callCount = 0; +class C { + *method([x, y, z]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 42); + callCount = callCount + 1; + } +}; + +new C().method([1, 2, 3]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-id-iter-val-err.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-id-iter-val-err.js new file mode 100644 index 0000000000..77431f912f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-id-iter-val-err.js @@ -0,0 +1,101 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val-err.case +// - src/dstr-binding/error/cls-decl-gen-meth.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [Symbol.iterator, generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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; + } + }; +}; + +class C { + *method([x]) {} +}; +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(g); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-id-iter-val.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-id-iter-val.js new file mode 100644 index 0000000000..392cc78b3a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-id-iter-val.js @@ -0,0 +1,95 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: SingleNameBinding when value iteration was completed previously (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + *method([x, y, z]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; + } +}; + +new C().method([1, 2, 3]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-obj-id-init.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-obj-id-init.js new file mode 100644 index 0000000000..f120020eca --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-obj-id-init.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id-init.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: BindingElement with object binding pattern and initializer is used (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + *method([{ x, y, z } = { x: 44, y: 55, z: 66 }]) { + assert.sameValue(x, 44); + assert.sameValue(y, 55); + assert.sameValue(z, 66); + callCount = callCount + 1; + } +}; + +new C().method([]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-obj-id.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-obj-id.js new file mode 100644 index 0000000000..2551614b44 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-obj-id.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + *method([{ x, y, z } = { x: 44, y: 55, z: 66 }]) { + assert.sameValue(x, 11); + assert.sameValue(y, 22); + assert.sameValue(z, 33); + callCount = callCount + 1; + } +}; + +new C().method([{ x: 11, y: 22, z: 33 }]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-obj-prop-id-init.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-obj-prop-id-init.js new file mode 100644 index 0000000000..eb07682d7f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-obj-prop-id-init.js @@ -0,0 +1,97 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id-init.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: BindingElement with object binding pattern and initializer is used (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + *method([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }]) { + assert.sameValue(v, 444); + assert.sameValue(x, 555); + assert.sameValue(z, 666); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } +}; + +new C().method([]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-obj-prop-id.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-obj-prop-id.js new file mode 100644 index 0000000000..765472dadd --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-obj-prop-id.js @@ -0,0 +1,97 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + *method([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }]) { + assert.sameValue(v, 777); + assert.sameValue(x, 888); + assert.sameValue(z, 999); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } +}; + +new C().method([{ u: 777, w: 888, y: 999 }]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-obj-val-null.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-obj-val-null.js new file mode 100644 index 0000000000..caf17f56d6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-obj-val-null.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-null.case +// - src/dstr-binding/error/cls-decl-gen-meth.template +/*--- +description: Nested object destructuring with a null value (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). +---*/ + +class C { + *method([{ x }]) {} +}; +var c = new C(); + +assert.throws(TypeError, function() { + c.method([null]); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-obj-val-undef.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-obj-val-undef.js new file mode 100644 index 0000000000..9ecce046aa --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elem-obj-val-undef.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-undef.case +// - src/dstr-binding/error/cls-decl-gen-meth.template +/*--- +description: Nested object destructuring with a value of `undefined` (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). +---*/ + +class C { + *method([{ x }]) {} +}; +var c = new C(); + +assert.throws(TypeError, function() { + c.method([]); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elision-exhausted.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elision-exhausted.js new file mode 100644 index 0000000000..8bd26ce047 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elision-exhausted.js @@ -0,0 +1,92 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-exhausted.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: Elision accepts exhausted iterator (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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 + [...] + 2. Return NormalCompletion(empty). + +---*/ +var iter = function*() {}(); +iter.next(); + +var callCount = 0; +class C { + *method([,]) { + + callCount = callCount + 1; + } +}; + +new C().method(iter).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elision-step-err.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elision-step-err.js new file mode 100644 index 0000000000..bc284194bd --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elision-step-err.js @@ -0,0 +1,97 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-step-err.case +// - src/dstr-binding/error/cls-decl-gen-meth.template +/*--- +description: Elision advances iterator and forwards abrupt completions (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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; +}(); + +class C { + *method([,]) {} +}; +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(iter); +}); + +iter.next(); +assert.sameValue(following, 0, 'Iterator was properly closed.'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elision.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elision.js new file mode 100644 index 0000000000..8a12b5b037 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-elision.js @@ -0,0 +1,101 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: Elision advances iterator (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +class C { + *method([,]) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; + } +}; + +new C().method(g()).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-empty.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-empty.js new file mode 100644 index 0000000000..f3527a3f1c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-empty.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-empty.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: No iteration occurs for an "empty" array binding pattern (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var callCount = 0; +class C { + *method([]) { + assert.sameValue(iterations, 0); + callCount = callCount + 1; + } +}; + +new C().method(iter).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-rest-ary-elem.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-rest-ary-elem.js new file mode 100644 index 0000000000..5b866bb28b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-rest-ary-elem.js @@ -0,0 +1,108 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elem.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: Rest element containing an array BindingElementList pattern (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the 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). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + *method([...[x, y, z]]) { + assert.sameValue(x, 3); + assert.sameValue(y, 4); + assert.sameValue(z, 5); + callCount = callCount + 1; + } +}; + +new C().method([3, 4, 5]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-rest-ary-elision.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-rest-ary-elision.js new file mode 100644 index 0000000000..bdee78b8b4 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-rest-ary-elision.js @@ -0,0 +1,114 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elision.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: Rest element containing an elision (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the 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). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +class C { + *method([...[,]]) { + assert.sameValue(first, 1); + assert.sameValue(second, 1); + callCount = callCount + 1; + } +}; + +new C().method(g()).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-rest-ary-empty.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-rest-ary-empty.js new file mode 100644 index 0000000000..6c3f3e5c5f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-rest-ary-empty.js @@ -0,0 +1,97 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-empty.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: Rest element containing an "empty" array pattern (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var callCount = 0; +class C { + *method([...[]]) { + assert.sameValue(iterations, 1); + callCount = callCount + 1; + } +}; + +new C().method(iter).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-rest-ary-rest.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-rest-ary-rest.js new file mode 100644 index 0000000000..233928fd22 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-rest-ary-rest.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-rest.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: Rest element containing a rest element (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ +var values = [1, 2, 3]; + +var callCount = 0; +class C { + *method([...[...x]]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + + callCount = callCount + 1; + } +}; + +new C().method(values).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-rest-id-direct.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-rest-id-direct.js new file mode 100644 index 0000000000..a3b2f44b6d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-rest-id-direct.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-direct.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: Lone rest element (direct binding) (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding] +flags: [generated] +includes: [compareArray.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingIdentifier + + [...] + 2. Let A be ! ArrayCreate(0). + 3. Let n be 0. + 4. Repeat, + [...] + f. Perform ! CreateDataPropertyOrThrow(A, ! ToString(n), nextValue). + g. Set n to n + 1. + +---*/ + +var callCount = 0; +class C { + *method([...x]) { + assert(Array.isArray(x)); + assert.compareArray(x, [1]); + callCount = callCount + 1; + } +}; + +new C().method([1]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-rest-id-elision-next-err.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-rest-id-elision-next-err.js new file mode 100644 index 0000000000..85b69a2327 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-rest-id-elision-next-err.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision-next-err.case +// - src/dstr-binding/error/cls-decl-gen-meth.template +/*--- +description: Rest element following elision elements (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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(); })(); + +class C { + *method([, ...x]) {} +}; +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(iter); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-rest-id-elision.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-rest-id-elision.js new file mode 100644 index 0000000000..9f130353aa --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-rest-id-elision.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: Rest element following elision elements (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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 values = [1, 2, 3, 4, 5]; + +var callCount = 0; +class C { + *method([ , , ...x]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 3); + assert.sameValue(x[1], 4); + assert.sameValue(x[2], 5); + assert.notSameValue(x, values); + callCount = callCount + 1; + } +}; + +new C().method(values).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-rest-id-exhausted.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-rest-id-exhausted.js new file mode 100644 index 0000000000..3cd99f1515 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-rest-id-exhausted.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-exhausted.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: RestElement applied to an exhausted iterator (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [Symbol.iterator, generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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, + [...] + b. If iteratorRecord.[[done]] is true, then + i. If environment is undefined, return PutValue(lhs, A). + ii. Return InitializeReferencedBinding(lhs, A). + +---*/ + +var callCount = 0; +class C { + *method([, , ...x]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 0); + callCount = callCount + 1; + } +}; + +new C().method([1, 2]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-rest-id-iter-step-err.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-rest-id-iter-step-err.js new file mode 100644 index 0000000000..07ea6817ed --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-rest-id-iter-step-err.js @@ -0,0 +1,94 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-step-err.case +// - src/dstr-binding/error/cls-decl-gen-meth.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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; +}(); + +class C { + *method([...x]) {} +}; +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(iter); +}); + +iter.next(); +assert.sameValue(first, 1); +assert.sameValue(second, 0, 'Iterator is closed following abrupt completion.'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-rest-id-iter-val-err.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-rest-id-iter-val-err.js new file mode 100644 index 0000000000..c472664e6f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-rest-id-iter-val-err.js @@ -0,0 +1,96 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-val-err.case +// - src/dstr-binding/error/cls-decl-gen-meth.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [Symbol.iterator, generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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; + } + }; +}; + +class C { + *method([...x]) {} +}; +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(iter); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-rest-id.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-rest-id.js new file mode 100644 index 0000000000..7ad33056b6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-rest-id.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: Lone rest element (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + [...] 3. Let A be ArrayCreate(0). [...] 5. Repeat + [...] + f. Let status be CreateDataProperty(A, ToString (n), nextValue). + [...] +---*/ +var values = [1, 2, 3]; + +var callCount = 0; +class C { + *method([...x]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + callCount = callCount + 1; + } +}; + +new C().method(values).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-rest-init-ary.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-rest-init-ary.js new file mode 100644 index 0000000000..cbb298e900 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-rest-init-ary.js @@ -0,0 +1,82 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-ary.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: Rest element (nested array pattern) does not support initializer (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var callCount = 0; +class C { + *method([...[ x ] = []]) { + + callCount = callCount + 1; + } +}; + +new C().method([]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-rest-init-id.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-rest-init-id.js new file mode 100644 index 0000000000..49bb698e7f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-rest-init-id.js @@ -0,0 +1,82 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-id.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: Rest element (identifier) does not support initializer (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var callCount = 0; +class C { + *method([...x = []]) { + + callCount = callCount + 1; + } +}; + +new C().method([]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-rest-init-obj.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-rest-init-obj.js new file mode 100644 index 0000000000..1fa29db40a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-rest-init-obj.js @@ -0,0 +1,82 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-obj.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: Rest element (nested object pattern) does not support initializer (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var callCount = 0; +class C { + *method([...{ x } = []]) { + + callCount = callCount + 1; + } +}; + +new C().method([]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-rest-not-final-ary.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-rest-not-final-ary.js new file mode 100644 index 0000000000..a9774c5ae3 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-rest-not-final-ary.js @@ -0,0 +1,82 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-ary.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: Rest element (array binding pattern) may not be followed by any element (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var callCount = 0; +class C { + *method([...[x], y]) { + + callCount = callCount + 1; + } +}; + +new C().method([1, 2, 3]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-rest-not-final-id.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-rest-not-final-id.js new file mode 100644 index 0000000000..a7e5be6e6e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-rest-not-final-id.js @@ -0,0 +1,82 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-id.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: Rest element (identifier) may not be followed by any element (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var callCount = 0; +class C { + *method([...x, y]) { + + callCount = callCount + 1; + } +}; + +new C().method([1, 2, 3]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-rest-not-final-obj.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-rest-not-final-obj.js new file mode 100644 index 0000000000..33c6f5c0f4 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-rest-not-final-obj.js @@ -0,0 +1,82 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-obj.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: Rest element (object binding pattern) may not be followed by any element (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var callCount = 0; +class C { + *method([...{ x }, y]) { + + callCount = callCount + 1; + } +}; + +new C().method([1, 2, 3]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-rest-obj-id.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-rest-obj-id.js new file mode 100644 index 0000000000..5479300a4f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-rest-obj-id.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-id.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: Rest element containing an object binding pattern (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ + +var callCount = 0; +class C { + *method([...{ length }]) { + assert.sameValue(length, 3); + callCount = callCount + 1; + } +}; + +new C().method([1, 2, 3]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-rest-obj-prop-id.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-rest-obj-prop-id.js new file mode 100644 index 0000000000..64ebfbc9fe --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-ary-ptrn-rest-obj-prop-id.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-prop-id.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: Rest element containing an object binding pattern (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ +let length = "outer"; + +var callCount = 0; +class C { + *method([...{ 0: v, 1: w, 2: x, 3: y, length: z }]) { + assert.sameValue(v, 7); + assert.sameValue(w, 8); + assert.sameValue(x, 9); + assert.sameValue(y, undefined); + assert.sameValue(z, 3); + + assert.sameValue(length, "outer", "the length prop is not set as a binding name"); + callCount = callCount + 1; + } +}; + +new C().method([7, 8, 9]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-init-iter-close.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-init-iter-close.js new file mode 100644 index 0000000000..cfcbe4ea69 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-init-iter-close.js @@ -0,0 +1,96 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-close.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: Iterator is closed when not exhausted by pattern evaluation (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [Symbol.iterator, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: false }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var callCount = 0; +class C { + *method([x] = iter) { + assert.sameValue(doneCallCount, 1); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-init-iter-get-err-array-prototype.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-init-iter-get-err-array-prototype.js new file mode 100644 index 0000000000..f348b2fc00 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-init-iter-get-err-array-prototype.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-get-err-array-prototype.case +// - src/dstr-binding/error/cls-decl-gen-meth-dflt.template +/*--- +description: Abrupt completion returned by GetIterator (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [Symbol.iterator, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iteratorRecord be ? GetIterator(value). + + GetIterator ( obj [ , hint [ , method ] ] ) + + [...] + 4. Let iterator be ? Call(method, obj). + + Call ( F, V [ , argumentsList ] ) + + [...] + 2. If IsCallable(F) is false, throw a TypeError exception. + +---*/ +delete Array.prototype[Symbol.iterator]; + +class C { + *method([x, y, z] = [1, 2, 3]) {} +}; +var c = new C(); + +assert.throws(TypeError, function() { + c.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-init-iter-get-err.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-init-iter-get-err.js new file mode 100644 index 0000000000..ee72353d3b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-init-iter-get-err.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-get-err.case +// - src/dstr-binding/error/cls-decl-gen-meth-dflt.template +/*--- +description: Abrupt completion returned by GetIterator (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [Symbol.iterator, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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(); +}; + +class C { + *method([x] = iter) {} +}; +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-init-iter-no-close.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-init-iter-no-close.js new file mode 100644 index 0000000000..9b23534760 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-init-iter-no-close.js @@ -0,0 +1,96 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-no-close.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: Iterator is not closed when exhausted by pattern evaluation (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [Symbol.iterator, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: true }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var callCount = 0; +class C { + *method([x] = iter) { + assert.sameValue(doneCallCount, 0); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-name-iter-val.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-name-iter-val.js new file mode 100644 index 0000000000..88958102ec --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-name-iter-val.js @@ -0,0 +1,95 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-name-iter-val.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: SingleNameBinding with normal value iteration (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + *method([x, y, z] = [1, 2, 3]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-ary-elem-init.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-ary-elem-init.js new file mode 100644 index 0000000000..9eacb9ef6e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-ary-elem-init.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-init.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + *method([[x, y, z] = [4, 5, 6]] = []) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-ary-elem-iter.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-ary-elem-iter.js new file mode 100644 index 0000000000..48e49cf3a9 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-ary-elem-iter.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-iter.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + *method([[x, y, z] = [4, 5, 6]] = [[7, 8, 9]]) { + assert.sameValue(x, 7); + assert.sameValue(y, 8); + assert.sameValue(z, 9); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-ary-elision-init.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-ary-elision-init.js new file mode 100644 index 0000000000..4d043eb182 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-ary-elision-init.js @@ -0,0 +1,94 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-init.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +class C { + *method([[,] = g()] = []) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-ary-elision-iter.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-ary-elision-iter.js new file mode 100644 index 0000000000..886051a0d9 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-ary-elision-iter.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-iter.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var callCount = 0; +function* g() { + callCount += 1; +}; + +var callCount = 0; +class C { + *method([[,] = g()] = [[]]) { + assert.sameValue(callCount, 0); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-ary-empty-init.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-ary-empty-init.js new file mode 100644 index 0000000000..b092e8a660 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-ary-empty-init.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-init.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var initCount = 0; +var iterCount = 0; +var iter = function*() { iterCount += 1; }(); + +var callCount = 0; +class C { + *method([[] = function() { initCount += 1; return iter; }()] = []) { + assert.sameValue(initCount, 1); + assert.sameValue(iterCount, 0); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-ary-empty-iter.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-ary-empty-iter.js new file mode 100644 index 0000000000..9c9cc980fd --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-ary-empty-iter.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-iter.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var initCount = 0; + +var callCount = 0; +class C { + *method([[] = function() { initCount += 1; }()] = [[23]]) { + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-ary-rest-init.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-ary-rest-init.js new file mode 100644 index 0000000000..053f3d1efd --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-ary-rest-init.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-init.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; + +var callCount = 0; +class C { + *method([[...x] = values] = []) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-ary-rest-iter.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-ary-rest-iter.js new file mode 100644 index 0000000000..58283e5804 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-ary-rest-iter.js @@ -0,0 +1,94 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-iter.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; +var initCount = 0; + +var callCount = 0; +class C { + *method([[...x] = function() { initCount += 1; }()] = [values]) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-ary-val-null.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-ary-val-null.js new file mode 100644 index 0000000000..03bc2d230c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-ary-val-null.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-val-null.case +// - src/dstr-binding/error/cls-decl-gen-meth-dflt.template +/*--- +description: Nested array destructuring with a null value (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). +---*/ + +class C { + *method([[x]] = [null]) {} +}; +var c = new C(); + +assert.throws(TypeError, function() { + c.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-id-init-exhausted.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-id-init-exhausted.js new file mode 100644 index 0000000000..b2098fed17 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-id-init-exhausted.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-exhausted.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: Destructuring initializer with an exhausted iterator (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + *method([x = 23] = []) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..7d23bbdcba --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-arrow.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: SingleNameBinding does assign name to arrow functions (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + *method([arrow = () => {}] = []) { + assert.sameValue(arrow.name, 'arrow'); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-class.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-class.js new file mode 100644 index 0000000000..5471431d8a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-class.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-class.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + *method([cls = class {}, xCls = class X {}, xCls2 = class { static name() {} }] = []) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + assert.notSameValue(xCls2.name, 'xCls2'); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-cover.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-cover.js new file mode 100644 index 0000000000..1828e71634 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-cover.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-cover.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: SingleNameBinding does assign name to "anonymous" functions "through" cover grammar (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + *method([cover = (function () {}), xCover = (0, function() {})] = []) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-fn.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-fn.js new file mode 100644 index 0000000000..6f1642b4fa --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-fn.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-fn.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + *method([fn = function () {}, xFn = function x() {}] = []) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-gen.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-gen.js new file mode 100644 index 0000000000..0931a63e13 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-gen.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-gen.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). + +---*/ + +var callCount = 0; +class C { + *method([gen = function* () {}, xGen = function* x() {}] = []) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-id-init-hole.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-id-init-hole.js new file mode 100644 index 0000000000..e82a3df6cc --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-id-init-hole.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-hole.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: Destructuring initializer with a "hole" (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + [...] + 7. If environment is undefined, return PutValue(lhs, v). 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + *method([x = 23] = [,]) { + assert.sameValue(x, 23); + // another statement + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-id-init-skipped.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-id-init-skipped.js new file mode 100644 index 0000000000..56e457f2e3 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-id-init-skipped.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-skipped.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +class C { + *method([w = counter(), x = counter(), y = counter(), z = counter()] = [null, 0, false, '']) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-id-init-throws.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-id-init-throws.js new file mode 100644 index 0000000000..7bbc85e5fe --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-id-init-throws.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-throws.case +// - src/dstr-binding/error/cls-decl-gen-meth-dflt.template +/*--- +description: Destructuring initializer returns an abrupt completion (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). +---*/ + +class C { + *method([x = (function() { throw new Test262Error(); })()] = [undefined]) {} +}; +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-id-init-undef.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-id-init-undef.js new file mode 100644 index 0000000000..eecfbf8d14 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-id-init-undef.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-undef.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: Destructuring initializer with an undefined value (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + *method([x = 23] = [undefined]) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-id-init-unresolvable.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-id-init-unresolvable.js new file mode 100644 index 0000000000..6e7a339f33 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-id-init-unresolvable.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-unresolvable.case +// - src/dstr-binding/error/cls-decl-gen-meth-dflt.template +/*--- +description: Destructuring initializer is an unresolvable reference (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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. +---*/ + +class C { + *method([ x = unresolvableReference ] = []) {} +}; +var c = new C(); + +assert.throws(ReferenceError, function() { + c.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-id-iter-complete.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-id-iter-complete.js new file mode 100644 index 0000000000..68b2a5290a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-id-iter-complete.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-complete.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: SingleNameBinding when value iteration completes (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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, + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + *method([x] = []) { + assert.sameValue(x, undefined); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-id-iter-done.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-id-iter-done.js new file mode 100644 index 0000000000..02d0772a78 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-id-iter-done.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-done.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: SingleNameBinding when value iteration was completed previously (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + *method([_, x] = []) { + assert.sameValue(x, undefined); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-id-iter-step-err.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-id-iter-step-err.js new file mode 100644 index 0000000000..c617460958 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-id-iter-step-err.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-step-err.case +// - src/dstr-binding/error/cls-decl-gen-meth-dflt.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [Symbol.iterator, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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(); + } + }; +}; + +class C { + *method([x] = g) {} +}; +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-id-iter-val-array-prototype.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-id-iter-val-array-prototype.js new file mode 100644 index 0000000000..f22588a401 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-id-iter-val-array-prototype.js @@ -0,0 +1,105 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val-array-prototype.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: Array destructuring uses overriden Array.prototype[Symbol.iterator] (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [Symbol.iterator, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializer_opt + + 1. Let bindingId be StringValue of BindingIdentifier. + 2. Let lhs be ? ResolveBinding(bindingId, environment). + 3. If iteratorRecord.[[Done]] is false, then + a. Let next be IteratorStep(iteratorRecord). + 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). + [...] + 7. Return InitializeReferencedBinding(lhs, v). + +---*/ +Array.prototype[Symbol.iterator] = function* () { + if (this.length > 0) { + yield this[0]; + } + if (this.length > 1) { + yield this[1]; + } + if (this.length > 2) { + yield 42; + } +}; + +var callCount = 0; +class C { + *method([x, y, z] = [1, 2, 3]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 42); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-id-iter-val-err.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-id-iter-val-err.js new file mode 100644 index 0000000000..aaad4685c1 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-id-iter-val-err.js @@ -0,0 +1,101 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val-err.case +// - src/dstr-binding/error/cls-decl-gen-meth-dflt.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [Symbol.iterator, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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; + } + }; +}; + +class C { + *method([x] = g) {} +}; +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-id-iter-val.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-id-iter-val.js new file mode 100644 index 0000000000..2d7bf80199 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-id-iter-val.js @@ -0,0 +1,95 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: SingleNameBinding when value iteration was completed previously (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + *method([x, y, z] = [1, 2, 3]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-obj-id-init.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-obj-id-init.js new file mode 100644 index 0000000000..2b462e3380 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-obj-id-init.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id-init.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is used (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + *method([{ x, y, z } = { x: 44, y: 55, z: 66 }] = []) { + assert.sameValue(x, 44); + assert.sameValue(y, 55); + assert.sameValue(z, 66); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-obj-id.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-obj-id.js new file mode 100644 index 0000000000..4722fe8d09 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-obj-id.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + *method([{ x, y, z } = { x: 44, y: 55, z: 66 }] = [{ x: 11, y: 22, z: 33 }]) { + assert.sameValue(x, 11); + assert.sameValue(y, 22); + assert.sameValue(z, 33); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-obj-prop-id-init.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-obj-prop-id-init.js new file mode 100644 index 0000000000..16c9d00275 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-obj-prop-id-init.js @@ -0,0 +1,97 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id-init.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is used (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + *method([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] = []) { + assert.sameValue(v, 444); + assert.sameValue(x, 555); + assert.sameValue(z, 666); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-obj-prop-id.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-obj-prop-id.js new file mode 100644 index 0000000000..78c5ca1cfb --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-obj-prop-id.js @@ -0,0 +1,97 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + *method([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] = [{ u: 777, w: 888, y: 999 }]) { + assert.sameValue(v, 777); + assert.sameValue(x, 888); + assert.sameValue(z, 999); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-obj-val-null.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-obj-val-null.js new file mode 100644 index 0000000000..0917834752 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-obj-val-null.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-null.case +// - src/dstr-binding/error/cls-decl-gen-meth-dflt.template +/*--- +description: Nested object destructuring with a null value (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). +---*/ + +class C { + *method([{ x }] = [null]) {} +}; +var c = new C(); + +assert.throws(TypeError, function() { + c.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-obj-val-undef.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-obj-val-undef.js new file mode 100644 index 0000000000..fb34d8d82a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elem-obj-val-undef.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-undef.case +// - src/dstr-binding/error/cls-decl-gen-meth-dflt.template +/*--- +description: Nested object destructuring with a value of `undefined` (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). +---*/ + +class C { + *method([{ x }] = []) {} +}; +var c = new C(); + +assert.throws(TypeError, function() { + c.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elision-exhausted.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elision-exhausted.js new file mode 100644 index 0000000000..f5413c7c7f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elision-exhausted.js @@ -0,0 +1,92 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-exhausted.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: Elision accepts exhausted iterator (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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 + [...] + 2. Return NormalCompletion(empty). + +---*/ +var iter = function*() {}(); +iter.next(); + +var callCount = 0; +class C { + *method([,] = iter) { + + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elision-step-err.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elision-step-err.js new file mode 100644 index 0000000000..bb7338d6d6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elision-step-err.js @@ -0,0 +1,97 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-step-err.case +// - src/dstr-binding/error/cls-decl-gen-meth-dflt.template +/*--- +description: Elision advances iterator and forwards abrupt completions (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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; +}(); + +class C { + *method([,] = iter) {} +}; +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(); +}); + +iter.next(); +assert.sameValue(following, 0, 'Iterator was properly closed.'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elision.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elision.js new file mode 100644 index 0000000000..d167145dd6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-elision.js @@ -0,0 +1,101 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: Elision advances iterator (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +class C { + *method([,] = g()) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-empty.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-empty.js new file mode 100644 index 0000000000..37f8dc6aec --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-empty.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-empty.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: No iteration occurs for an "empty" array binding pattern (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var callCount = 0; +class C { + *method([] = iter) { + assert.sameValue(iterations, 0); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-rest-ary-elem.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-rest-ary-elem.js new file mode 100644 index 0000000000..4fea96c065 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-rest-ary-elem.js @@ -0,0 +1,108 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elem.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: Rest element containing an array BindingElementList pattern (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the 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). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + *method([...[x, y, z]] = [3, 4, 5]) { + assert.sameValue(x, 3); + assert.sameValue(y, 4); + assert.sameValue(z, 5); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-rest-ary-elision.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-rest-ary-elision.js new file mode 100644 index 0000000000..48e9025589 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-rest-ary-elision.js @@ -0,0 +1,114 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elision.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: Rest element containing an elision (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the 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). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +class C { + *method([...[,]] = g()) { + assert.sameValue(first, 1); + assert.sameValue(second, 1); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-rest-ary-empty.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-rest-ary-empty.js new file mode 100644 index 0000000000..dba39b1949 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-rest-ary-empty.js @@ -0,0 +1,97 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-empty.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: Rest element containing an "empty" array pattern (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var callCount = 0; +class C { + *method([...[]] = iter) { + assert.sameValue(iterations, 1); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-rest-ary-rest.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-rest-ary-rest.js new file mode 100644 index 0000000000..fa021d284b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-rest-ary-rest.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-rest.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: Rest element containing a rest element (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ +var values = [1, 2, 3]; + +var callCount = 0; +class C { + *method([...[...x]] = values) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-rest-id-direct.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-rest-id-direct.js new file mode 100644 index 0000000000..6925899c92 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-rest-id-direct.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-direct.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: Lone rest element (direct binding) (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +includes: [compareArray.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingIdentifier + + [...] + 2. Let A be ! ArrayCreate(0). + 3. Let n be 0. + 4. Repeat, + [...] + f. Perform ! CreateDataPropertyOrThrow(A, ! ToString(n), nextValue). + g. Set n to n + 1. + +---*/ + +var callCount = 0; +class C { + *method([...x] = [1]) { + assert(Array.isArray(x)); + assert.compareArray(x, [1]); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-rest-id-elision-next-err.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-rest-id-elision-next-err.js new file mode 100644 index 0000000000..05387d8438 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-rest-id-elision-next-err.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision-next-err.case +// - src/dstr-binding/error/cls-decl-gen-meth-dflt.template +/*--- +description: Rest element following elision elements (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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(); })(); + +class C { + *method([, ...x] = iter) {} +}; +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-rest-id-elision.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-rest-id-elision.js new file mode 100644 index 0000000000..2f1298217e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-rest-id-elision.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: Rest element following elision elements (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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 values = [1, 2, 3, 4, 5]; + +var callCount = 0; +class C { + *method([ , , ...x] = values) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 3); + assert.sameValue(x[1], 4); + assert.sameValue(x[2], 5); + assert.notSameValue(x, values); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-rest-id-exhausted.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-rest-id-exhausted.js new file mode 100644 index 0000000000..e99a2b7b0f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-rest-id-exhausted.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-exhausted.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: RestElement applied to an exhausted iterator (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [Symbol.iterator, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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, + [...] + b. If iteratorRecord.[[done]] is true, then + i. If environment is undefined, return PutValue(lhs, A). + ii. Return InitializeReferencedBinding(lhs, A). + +---*/ + +var callCount = 0; +class C { + *method([, , ...x] = [1, 2]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 0); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-rest-id-iter-step-err.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-rest-id-iter-step-err.js new file mode 100644 index 0000000000..665fe77298 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-rest-id-iter-step-err.js @@ -0,0 +1,94 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-step-err.case +// - src/dstr-binding/error/cls-decl-gen-meth-dflt.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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; +}(); + +class C { + *method([...x] = iter) {} +}; +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(); +}); + +iter.next(); +assert.sameValue(first, 1); +assert.sameValue(second, 0, 'Iterator is closed following abrupt completion.'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-rest-id-iter-val-err.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-rest-id-iter-val-err.js new file mode 100644 index 0000000000..c94e0f6659 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-rest-id-iter-val-err.js @@ -0,0 +1,96 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-val-err.case +// - src/dstr-binding/error/cls-decl-gen-meth-dflt.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [Symbol.iterator, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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; + } + }; +}; + +class C { + *method([...x] = iter) {} +}; +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-rest-id.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-rest-id.js new file mode 100644 index 0000000000..728e7a642e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-rest-id.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: Lone rest element (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + [...] 3. Let A be ArrayCreate(0). [...] 5. Repeat + [...] + f. Let status be CreateDataProperty(A, ToString (n), nextValue). + [...] +---*/ +var values = [1, 2, 3]; + +var callCount = 0; +class C { + *method([...x] = values) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-rest-init-ary.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-rest-init-ary.js new file mode 100644 index 0000000000..08ea4666b2 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-rest-init-ary.js @@ -0,0 +1,82 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-ary.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: Rest element (nested array pattern) does not support initializer (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var callCount = 0; +class C { + *method([...[ x ] = []] = []) { + + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-rest-init-id.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-rest-init-id.js new file mode 100644 index 0000000000..409d798503 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-rest-init-id.js @@ -0,0 +1,82 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-id.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: Rest element (identifier) does not support initializer (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var callCount = 0; +class C { + *method([...x = []] = []) { + + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-rest-init-obj.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-rest-init-obj.js new file mode 100644 index 0000000000..3741aa88d3 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-rest-init-obj.js @@ -0,0 +1,82 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-obj.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: Rest element (nested object pattern) does not support initializer (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var callCount = 0; +class C { + *method([...{ x } = []] = []) { + + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-rest-not-final-ary.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-rest-not-final-ary.js new file mode 100644 index 0000000000..8283c7463b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-rest-not-final-ary.js @@ -0,0 +1,82 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-ary.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: Rest element (array binding pattern) may not be followed by any element (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var callCount = 0; +class C { + *method([...[x], y] = [1, 2, 3]) { + + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-rest-not-final-id.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-rest-not-final-id.js new file mode 100644 index 0000000000..e22718babc --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-rest-not-final-id.js @@ -0,0 +1,82 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-id.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: Rest element (identifier) may not be followed by any element (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var callCount = 0; +class C { + *method([...x, y] = [1, 2, 3]) { + + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-rest-not-final-obj.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-rest-not-final-obj.js new file mode 100644 index 0000000000..312d328db3 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-rest-not-final-obj.js @@ -0,0 +1,82 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-obj.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: Rest element (object binding pattern) may not be followed by any element (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var callCount = 0; +class C { + *method([...{ x }, y] = [1, 2, 3]) { + + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-rest-obj-id.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-rest-obj-id.js new file mode 100644 index 0000000000..25f0cb92f5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-rest-obj-id.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-id.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: Rest element containing an object binding pattern (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ + +var callCount = 0; +class C { + *method([...{ length }] = [1, 2, 3]) { + assert.sameValue(length, 3); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-rest-obj-prop-id.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-rest-obj-prop-id.js new file mode 100644 index 0000000000..41427219bf --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-ary-ptrn-rest-obj-prop-id.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-prop-id.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: Rest element containing an object binding pattern (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ +let length = "outer"; + +var callCount = 0; +class C { + *method([...{ 0: v, 1: w, 2: x, 3: y, length: z }] = [7, 8, 9]) { + assert.sameValue(v, 7); + assert.sameValue(w, 8); + assert.sameValue(x, 9); + assert.sameValue(y, undefined); + assert.sameValue(z, 3); + + assert.sameValue(length, "outer", "the length prop is not set as a binding name"); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-init-null.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-init-null.js new file mode 100644 index 0000000000..4395e91747 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-init-null.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-null.case +// - src/dstr-binding/error/cls-decl-gen-meth-dflt.template +/*--- +description: Value specifed for object binding pattern must be object coercible (null) (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +class C { + *method({} = null) {} +}; +var c = new C(); + +assert.throws(TypeError, function() { + c.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-init-undefined.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-init-undefined.js new file mode 100644 index 0000000000..f115e339d9 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-init-undefined.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-undefined.case +// - src/dstr-binding/error/cls-decl-gen-meth-dflt.template +/*--- +description: Value specifed for object binding pattern must be object coercible (undefined) (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +class C { + *method({} = undefined) {} +}; +var c = new C(); + +assert.throws(TypeError, function() { + c.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-empty.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-empty.js new file mode 100644 index 0000000000..5c24f90ccf --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-empty.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-empty.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: No property access occurs for an "empty" object binding pattern (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ +var accessCount = 0; +var obj = Object.defineProperty({}, 'attr', { + get: function() { + accessCount += 1; + } +}); + +var callCount = 0; +class C { + *method({} = obj) { + assert.sameValue(accessCount, 0); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-id-get-value-err.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-id-get-value-err.js new file mode 100644 index 0000000000..8c41bcb23a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-id-get-value-err.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-get-value-err.case +// - src/dstr-binding/error/cls-decl-gen-meth-dflt.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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(); + } +}); + +class C { + *method({ poisoned } = poisonedProperty) {} +}; +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-id-init-fn-name-arrow.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..e99280252a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-id-init-fn-name-arrow.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-arrow.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: SingleNameBinding assigns `name` to arrow functions (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +class C { + *method({ arrow = () => {} } = {}) { + assert.sameValue(arrow.name, 'arrow'); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-id-init-fn-name-class.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-id-init-fn-name-class.js new file mode 100644 index 0000000000..bfd333f0e4 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-id-init-fn-name-class.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-class.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +class C { + *method({ cls = class {}, xCls = class X {}, xCls2 = class { static name() {} } } = {}) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + assert.notSameValue(xCls2.name, 'xCls2'); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-id-init-fn-name-cover.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-id-init-fn-name-cover.js new file mode 100644 index 0000000000..0065e7b980 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-id-init-fn-name-cover.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-cover.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" functions "through" cover grammar (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +class C { + *method({ cover = (function () {}), xCover = (0, function() {}) } = {}) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-id-init-fn-name-fn.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-id-init-fn-name-fn.js new file mode 100644 index 0000000000..177633fd22 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-id-init-fn-name-fn.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-fn.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +class C { + *method({ fn = function () {}, xFn = function x() {} } = {}) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-id-init-fn-name-gen.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-id-init-fn-name-gen.js new file mode 100644 index 0000000000..6bb67edddf --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-id-init-fn-name-gen.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-gen.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). + +---*/ + +var callCount = 0; +class C { + *method({ gen = function* () {}, xGen = function* x() {} } = {}) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-id-init-skipped.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-id-init-skipped.js new file mode 100644 index 0000000000..d4c4876ade --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-id-init-skipped.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-skipped.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +class C { + *method({ w = counter(), x = counter(), y = counter(), z = counter() } = { w: null, x: 0, y: false, z: '' }) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-id-init-throws.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-id-init-throws.js new file mode 100644 index 0000000000..b793663a73 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-id-init-throws.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-throws.case +// - src/dstr-binding/error/cls-decl-gen-meth-dflt.template +/*--- +description: Error thrown when evaluating the initializer (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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(); +} + +class C { + *method({ x = thrower() } = {}) {} +}; +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-id-init-unresolvable.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-id-init-unresolvable.js new file mode 100644 index 0000000000..00664b78a6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-id-init-unresolvable.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-unresolvable.case +// - src/dstr-binding/error/cls-decl-gen-meth-dflt.template +/*--- +description: Destructuring initializer is an unresolvable reference (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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. +---*/ + +class C { + *method({ x = unresolvableReference } = {}) {} +}; +var c = new C(); + +assert.throws(ReferenceError, function() { + c.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-id-trailing-comma.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-id-trailing-comma.js new file mode 100644 index 0000000000..dba2e28897 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-id-trailing-comma.js @@ -0,0 +1,80 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-trailing-comma.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +class C { + *method({ x, } = { x: 23 }) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-list-err.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-list-err.js new file mode 100644 index 0000000000..3725990759 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-list-err.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-list-err.case +// - src/dstr-binding/error/cls-decl-gen-meth-dflt.template +/*--- +description: Binding property list evaluation is interrupted by an abrupt completion (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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(); +} + +class C { + *method({ a, b = thrower(), c = ++initCount } = {}) {} +}; +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(); +}); + +assert.sameValue(initCount, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-prop-ary-init.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-prop-ary-init.js new file mode 100644 index 0000000000..e72f38564b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-prop-ary-init.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-init.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: Object binding pattern with "nested" array binding pattern using initializer (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 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). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +class C { + *method({ w: [x, y, z] = [4, 5, 6] } = {}) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-prop-ary-trailing-comma.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-prop-ary-trailing-comma.js new file mode 100644 index 0000000000..bf00460a7a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-prop-ary-trailing-comma.js @@ -0,0 +1,80 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-trailing-comma.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +class C { + *method({ x: [y], } = { x: [45] }) { + assert.sameValue(y,45); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-prop-ary-value-null.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-prop-ary-value-null.js new file mode 100644 index 0000000000..0cd2840e41 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-prop-ary-value-null.js @@ -0,0 +1,79 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-value-null.case +// - src/dstr-binding/error/cls-decl-gen-meth-dflt.template +/*--- +description: Object binding pattern with "nested" array binding pattern taking the `null` value (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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. +---*/ + +class C { + *method({ w: [x, y, z] = [4, 5, 6] } = { w: null }) {} +}; +var c = new C(); + +assert.throws(TypeError, function() { + c.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-prop-ary.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-prop-ary.js new file mode 100644 index 0000000000..74866111c0 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-prop-ary.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: Object binding pattern with "nested" array binding pattern not using initializer (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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. +---*/ + +var callCount = 0; +class C { + *method({ w: [x, y, z] = [4, 5, 6] } = { w: [7, undefined, ] }) { + assert.sameValue(x, 7); + assert.sameValue(y, undefined); + assert.sameValue(z, undefined); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-prop-eval-err.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-prop-eval-err.js new file mode 100644 index 0000000000..904950e1e9 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-prop-eval-err.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-eval-err.case +// - src/dstr-binding/error/cls-decl-gen-meth-dflt.template +/*--- +description: Evaluation of property name returns an abrupt completion (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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(); +} + +class C { + *method({ [thrower()]: x } = {}) {} +}; +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-prop-id-get-value-err.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-prop-id-get-value-err.js new file mode 100644 index 0000000000..c4e1c9db3c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-prop-id-get-value-err.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-get-value-err.case +// - src/dstr-binding/error/cls-decl-gen-meth-dflt.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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(); + } +}); + +class C { + *method({ poisoned: x = ++initEvalCount } = poisonedProperty) {} +}; +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(); +}); + +assert.sameValue(initEvalCount, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-prop-id-init-skipped.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-prop-id-init-skipped.js new file mode 100644 index 0000000000..ac98760dd6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-prop-id-init-skipped.js @@ -0,0 +1,102 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-skipped.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +class C { + *method({ s: t = counter(), u: v = counter(), w: x = counter(), y: z = counter() } = { s: null, u: 0, w: false, y: '' }) { + assert.sameValue(t, null); + assert.sameValue(v, 0); + assert.sameValue(x, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + + assert.throws(ReferenceError, function() { + s; + }); + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-prop-id-init-throws.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-prop-id-init-throws.js new file mode 100644 index 0000000000..7dec62ce79 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-prop-id-init-throws.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-throws.case +// - src/dstr-binding/error/cls-decl-gen-meth-dflt.template +/*--- +description: Error thrown when evaluating the initializer (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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(); +} + +class C { + *method({ x: y = thrower() } = {}) {} +}; +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-prop-id-init-unresolvable.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-prop-id-init-unresolvable.js new file mode 100644 index 0000000000..7692318e73 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-prop-id-init-unresolvable.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-unresolvable.case +// - src/dstr-binding/error/cls-decl-gen-meth-dflt.template +/*--- +description: Destructuring initializer is an unresolvable reference (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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. +---*/ + +class C { + *method({ x: y = unresolvableReference } = {}) {} +}; +var c = new C(); + +assert.throws(ReferenceError, function() { + c.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-prop-id-init.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-prop-id-init.js new file mode 100644 index 0000000000..4abf16cd7c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-prop-id-init.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: Binding as specified via property name, identifier, and initializer (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + *method({ x: y = 33 } = { }) { + assert.sameValue(y, 33); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-prop-id-trailing-comma.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-prop-id-trailing-comma.js new file mode 100644 index 0000000000..97ab5b3fe7 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-prop-id-trailing-comma.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-trailing-comma.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +class C { + *method({ x: y, } = { x: 23 }) { + assert.sameValue(y, 23); + + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-prop-id.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-prop-id.js new file mode 100644 index 0000000000..0aefdeec97 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-prop-id.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: Binding as specified via property name and identifier (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + *method({ x: y } = { x: 23 }) { + assert.sameValue(y, 23); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-prop-obj-init.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-prop-obj-init.js new file mode 100644 index 0000000000..9a92c631d8 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-prop-obj-init.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-init.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern using initializer (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 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). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +class C { + *method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } } = { w: undefined }) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-prop-obj-value-null.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-prop-obj-value-null.js new file mode 100644 index 0000000000..9f19d4f352 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-prop-obj-value-null.js @@ -0,0 +1,79 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-null.case +// - src/dstr-binding/error/cls-decl-gen-meth-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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. +---*/ + +class C { + *method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } } = { w: null }) {} +}; +var c = new C(); + +assert.throws(TypeError, function() { + c.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-prop-obj-value-undef.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-prop-obj-value-undef.js new file mode 100644 index 0000000000..4d1195bac2 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-prop-obj-value-undef.js @@ -0,0 +1,79 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-undef.case +// - src/dstr-binding/error/cls-decl-gen-meth-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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. +---*/ + +class C { + *method({ w: { x, y, z } = undefined } = { }) {} +}; +var c = new C(); + +assert.throws(TypeError, function() { + c.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-prop-obj.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-prop-obj.js new file mode 100644 index 0000000000..5ff981ed8f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-prop-obj.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern not using initializer (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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. +---*/ + +var callCount = 0; +class C { + *method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } } = { w: { x: undefined, z: 7 } }) { + assert.sameValue(x, undefined); + assert.sameValue(y, undefined); + assert.sameValue(z, 7); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-rest-getter.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-rest-getter.js new file mode 100644 index 0000000000..51409659a3 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-rest-getter.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-getter.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: Getter is called when obj is being deconstructed to a rest Object (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [object-rest, generators, destructuring-binding, default-parameters] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var count = 0; + +var callCount = 0; +class C { + *method({...x} = { get v() { count++; return 2; } }) { + assert.sameValue(count, 1); + + verifyProperty(x, "v", { + enumerable: true, + writable: true, + configurable: true, + value: 2 + }); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-rest-skip-non-enumerable.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-rest-skip-non-enumerable.js new file mode 100644 index 0000000000..ad488f077c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-rest-skip-non-enumerable.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-skip-non-enumerable.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: Rest object doesn't contain non-enumerable properties (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [object-rest, generators, destructuring-binding, default-parameters] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var o = {a: 3, b: 4}; +Object.defineProperty(o, "x", { value: 4, enumerable: false }); + +var callCount = 0; +class C { + *method({...rest} = o) { + assert.sameValue(rest.x, undefined); + + verifyProperty(rest, "a", { + enumerable: true, + writable: true, + configurable: true, + value: 3 + }); + + verifyProperty(rest, "b", { + enumerable: true, + writable: true, + configurable: true, + value: 4 + }); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-rest-val-obj.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-rest-val-obj.js new file mode 100644 index 0000000000..5d0d7432d6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-dflt-obj-ptrn-rest-val-obj.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-val-obj.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: Rest object contains just unextracted data (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [object-rest, generators, destructuring-binding, default-parameters] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +class C { + *method({a, b, ...rest} = {x: 1, y: 2, a: 5, b: 3}) { + assert.sameValue(rest.a, undefined); + assert.sameValue(rest.b, undefined); + + verifyProperty(rest, "x", { + enumerable: true, + writable: true, + configurable: true, + value: 1 + }); + + verifyProperty(rest, "y", { + enumerable: true, + writable: true, + configurable: true, + value: 2 + }); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-init-null.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-init-null.js new file mode 100644 index 0000000000..ad20c081cd --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-init-null.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-null.case +// - src/dstr-binding/error/cls-decl-gen-meth.template +/*--- +description: Value specifed for object binding pattern must be object coercible (null) (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +class C { + *method({}) {} +}; +var c = new C(); + +assert.throws(TypeError, function() { + c.method(null); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-init-undefined.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-init-undefined.js new file mode 100644 index 0000000000..569d3cc1f7 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-init-undefined.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-undefined.case +// - src/dstr-binding/error/cls-decl-gen-meth.template +/*--- +description: Value specifed for object binding pattern must be object coercible (undefined) (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +class C { + *method({}) {} +}; +var c = new C(); + +assert.throws(TypeError, function() { + c.method(undefined); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-empty.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-empty.js new file mode 100644 index 0000000000..0e9aa3d97a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-empty.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-empty.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: No property access occurs for an "empty" object binding pattern (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ +var accessCount = 0; +var obj = Object.defineProperty({}, 'attr', { + get: function() { + accessCount += 1; + } +}); + +var callCount = 0; +class C { + *method({}) { + assert.sameValue(accessCount, 0); + callCount = callCount + 1; + } +}; + +new C().method(obj).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-id-get-value-err.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-id-get-value-err.js new file mode 100644 index 0000000000..05cfd3eeeb --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-id-get-value-err.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-get-value-err.case +// - src/dstr-binding/error/cls-decl-gen-meth.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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(); + } +}); + +class C { + *method({ poisoned }) {} +}; +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(poisonedProperty); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-id-init-fn-name-arrow.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..3f6883e35e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-id-init-fn-name-arrow.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-arrow.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: SingleNameBinding assigns `name` to arrow functions (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +class C { + *method({ arrow = () => {} }) { + assert.sameValue(arrow.name, 'arrow'); + callCount = callCount + 1; + } +}; + +new C().method({}).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-id-init-fn-name-class.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-id-init-fn-name-class.js new file mode 100644 index 0000000000..4fccb76131 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-id-init-fn-name-class.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-class.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +class C { + *method({ cls = class {}, xCls = class X {}, xCls2 = class { static name() {} } }) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + assert.notSameValue(xCls2.name, 'xCls2'); + callCount = callCount + 1; + } +}; + +new C().method({}).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-id-init-fn-name-cover.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-id-init-fn-name-cover.js new file mode 100644 index 0000000000..815c048576 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-id-init-fn-name-cover.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-cover.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" functions "through" cover grammar (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +class C { + *method({ cover = (function () {}), xCover = (0, function() {}) }) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + callCount = callCount + 1; + } +}; + +new C().method({}).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-id-init-fn-name-fn.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-id-init-fn-name-fn.js new file mode 100644 index 0000000000..60773be254 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-id-init-fn-name-fn.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-fn.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +class C { + *method({ fn = function () {}, xFn = function x() {} }) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + callCount = callCount + 1; + } +}; + +new C().method({}).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-id-init-fn-name-gen.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-id-init-fn-name-gen.js new file mode 100644 index 0000000000..01dd1f669f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-id-init-fn-name-gen.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-gen.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). + +---*/ + +var callCount = 0; +class C { + *method({ gen = function* () {}, xGen = function* x() {} }) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + callCount = callCount + 1; + } +}; + +new C().method({}).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-id-init-skipped.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-id-init-skipped.js new file mode 100644 index 0000000000..16a058c0d1 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-id-init-skipped.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-skipped.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +class C { + *method({ w = counter(), x = counter(), y = counter(), z = counter() }) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +new C().method({ w: null, x: 0, y: false, z: '' }).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-id-init-throws.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-id-init-throws.js new file mode 100644 index 0000000000..9a6a7a50aa --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-id-init-throws.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-throws.case +// - src/dstr-binding/error/cls-decl-gen-meth.template +/*--- +description: Error thrown when evaluating the initializer (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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(); +} + +class C { + *method({ x = thrower() }) {} +}; +var c = new C(); + +assert.throws(Test262Error, function() { + c.method({}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-id-init-unresolvable.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-id-init-unresolvable.js new file mode 100644 index 0000000000..47b81f95bf --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-id-init-unresolvable.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-unresolvable.case +// - src/dstr-binding/error/cls-decl-gen-meth.template +/*--- +description: Destructuring initializer is an unresolvable reference (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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. +---*/ + +class C { + *method({ x = unresolvableReference }) {} +}; +var c = new C(); + +assert.throws(ReferenceError, function() { + c.method({}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-id-trailing-comma.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-id-trailing-comma.js new file mode 100644 index 0000000000..bd77979097 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-id-trailing-comma.js @@ -0,0 +1,80 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-trailing-comma.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +class C { + *method({ x, }) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } +}; + +new C().method({ x: 23 }).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-list-err.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-list-err.js new file mode 100644 index 0000000000..546a5f8472 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-list-err.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-list-err.case +// - src/dstr-binding/error/cls-decl-gen-meth.template +/*--- +description: Binding property list evaluation is interrupted by an abrupt completion (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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(); +} + +class C { + *method({ a, b = thrower(), c = ++initCount }) {} +}; +var c = new C(); + +assert.throws(Test262Error, function() { + c.method({}); +}); + +assert.sameValue(initCount, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-prop-ary-init.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-prop-ary-init.js new file mode 100644 index 0000000000..7eb51afb83 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-prop-ary-init.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-init.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: Object binding pattern with "nested" array binding pattern using initializer (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 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). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +class C { + *method({ w: [x, y, z] = [4, 5, 6] }) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } +}; + +new C().method({}).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-prop-ary-trailing-comma.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-prop-ary-trailing-comma.js new file mode 100644 index 0000000000..1628761752 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-prop-ary-trailing-comma.js @@ -0,0 +1,80 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-trailing-comma.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +class C { + *method({ x: [y], }) { + assert.sameValue(y,45); + callCount = callCount + 1; + } +}; + +new C().method({ x: [45] }).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-prop-ary-value-null.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-prop-ary-value-null.js new file mode 100644 index 0000000000..43b84378d2 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-prop-ary-value-null.js @@ -0,0 +1,79 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-value-null.case +// - src/dstr-binding/error/cls-decl-gen-meth.template +/*--- +description: Object binding pattern with "nested" array binding pattern taking the `null` value (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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. +---*/ + +class C { + *method({ w: [x, y, z] = [4, 5, 6] }) {} +}; +var c = new C(); + +assert.throws(TypeError, function() { + c.method({ w: null }); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-prop-ary.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-prop-ary.js new file mode 100644 index 0000000000..b942628839 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-prop-ary.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: Object binding pattern with "nested" array binding pattern not using initializer (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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. +---*/ + +var callCount = 0; +class C { + *method({ w: [x, y, z] = [4, 5, 6] }) { + assert.sameValue(x, 7); + assert.sameValue(y, undefined); + assert.sameValue(z, undefined); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } +}; + +new C().method({ w: [7, undefined, ] }).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-prop-eval-err.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-prop-eval-err.js new file mode 100644 index 0000000000..9b9d37c223 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-prop-eval-err.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-eval-err.case +// - src/dstr-binding/error/cls-decl-gen-meth.template +/*--- +description: Evaluation of property name returns an abrupt completion (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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(); +} + +class C { + *method({ [thrower()]: x }) {} +}; +var c = new C(); + +assert.throws(Test262Error, function() { + c.method({}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-prop-id-get-value-err.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-prop-id-get-value-err.js new file mode 100644 index 0000000000..8b81f05740 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-prop-id-get-value-err.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-get-value-err.case +// - src/dstr-binding/error/cls-decl-gen-meth.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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(); + } +}); + +class C { + *method({ poisoned: x = ++initEvalCount }) {} +}; +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(poisonedProperty); +}); + +assert.sameValue(initEvalCount, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-prop-id-init-skipped.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-prop-id-init-skipped.js new file mode 100644 index 0000000000..ba0674aa04 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-prop-id-init-skipped.js @@ -0,0 +1,102 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-skipped.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +class C { + *method({ s: t = counter(), u: v = counter(), w: x = counter(), y: z = counter() }) { + assert.sameValue(t, null); + assert.sameValue(v, 0); + assert.sameValue(x, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + + assert.throws(ReferenceError, function() { + s; + }); + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } +}; + +new C().method({ s: null, u: 0, w: false, y: '' }).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-prop-id-init-throws.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-prop-id-init-throws.js new file mode 100644 index 0000000000..8f3618919e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-prop-id-init-throws.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-throws.case +// - src/dstr-binding/error/cls-decl-gen-meth.template +/*--- +description: Error thrown when evaluating the initializer (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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(); +} + +class C { + *method({ x: y = thrower() }) {} +}; +var c = new C(); + +assert.throws(Test262Error, function() { + c.method({}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-prop-id-init-unresolvable.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-prop-id-init-unresolvable.js new file mode 100644 index 0000000000..6dd3658aee --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-prop-id-init-unresolvable.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-unresolvable.case +// - src/dstr-binding/error/cls-decl-gen-meth.template +/*--- +description: Destructuring initializer is an unresolvable reference (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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. +---*/ + +class C { + *method({ x: y = unresolvableReference }) {} +}; +var c = new C(); + +assert.throws(ReferenceError, function() { + c.method({}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-prop-id-init.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-prop-id-init.js new file mode 100644 index 0000000000..8eb689f206 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-prop-id-init.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: Binding as specified via property name, identifier, and initializer (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + *method({ x: y = 33 }) { + assert.sameValue(y, 33); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } +}; + +new C().method({ }).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-prop-id-trailing-comma.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-prop-id-trailing-comma.js new file mode 100644 index 0000000000..6147800da2 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-prop-id-trailing-comma.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-trailing-comma.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +class C { + *method({ x: y, }) { + assert.sameValue(y, 23); + + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } +}; + +new C().method({ x: 23 }).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-prop-id.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-prop-id.js new file mode 100644 index 0000000000..a0b0435795 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-prop-id.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: Binding as specified via property name and identifier (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + *method({ x: y }) { + assert.sameValue(y, 23); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } +}; + +new C().method({ x: 23 }).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-prop-obj-init.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-prop-obj-init.js new file mode 100644 index 0000000000..7adfb5287f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-prop-obj-init.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-init.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: Object binding pattern with "nested" object binding pattern using initializer (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 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). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +class C { + *method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } }) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } +}; + +new C().method({ w: undefined }).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-prop-obj-value-null.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-prop-obj-value-null.js new file mode 100644 index 0000000000..38eb7c1859 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-prop-obj-value-null.js @@ -0,0 +1,79 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-null.case +// - src/dstr-binding/error/cls-decl-gen-meth.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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. +---*/ + +class C { + *method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } }) {} +}; +var c = new C(); + +assert.throws(TypeError, function() { + c.method({ w: null }); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-prop-obj-value-undef.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-prop-obj-value-undef.js new file mode 100644 index 0000000000..d64dc82e19 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-prop-obj-value-undef.js @@ -0,0 +1,79 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-undef.case +// - src/dstr-binding/error/cls-decl-gen-meth.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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. +---*/ + +class C { + *method({ w: { x, y, z } = undefined }) {} +}; +var c = new C(); + +assert.throws(TypeError, function() { + c.method({ }); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-prop-obj.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-prop-obj.js new file mode 100644 index 0000000000..3eb571e88b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-prop-obj.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: Object binding pattern with "nested" object binding pattern not using initializer (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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. +---*/ + +var callCount = 0; +class C { + *method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } }) { + assert.sameValue(x, undefined); + assert.sameValue(y, undefined); + assert.sameValue(z, 7); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } +}; + +new C().method({ w: { x: undefined, z: 7 } }).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-rest-getter.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-rest-getter.js new file mode 100644 index 0000000000..32c9e80a9a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-rest-getter.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-getter.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: Getter is called when obj is being deconstructed to a rest Object (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [object-rest, generators, destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var count = 0; + +var callCount = 0; +class C { + *method({...x}) { + assert.sameValue(count, 1); + + verifyProperty(x, "v", { + enumerable: true, + writable: true, + configurable: true, + value: 2 + }); + callCount = callCount + 1; + } +}; + +new C().method({ get v() { count++; return 2; } }).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-rest-skip-non-enumerable.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-rest-skip-non-enumerable.js new file mode 100644 index 0000000000..20d9f89818 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-rest-skip-non-enumerable.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-skip-non-enumerable.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: Rest object doesn't contain non-enumerable properties (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [object-rest, generators, destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var o = {a: 3, b: 4}; +Object.defineProperty(o, "x", { value: 4, enumerable: false }); + +var callCount = 0; +class C { + *method({...rest}) { + assert.sameValue(rest.x, undefined); + + verifyProperty(rest, "a", { + enumerable: true, + writable: true, + configurable: true, + value: 3 + }); + + verifyProperty(rest, "b", { + enumerable: true, + writable: true, + configurable: true, + value: 4 + }); + callCount = callCount + 1; + } +}; + +new C().method(o).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-rest-val-obj.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-rest-val-obj.js new file mode 100644 index 0000000000..8d272c8273 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-obj-ptrn-rest-val-obj.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-val-obj.case +// - src/dstr-binding/default/cls-decl-gen-meth.template +/*--- +description: Rest object contains just unextracted data (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [object-rest, generators, destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +class C { + *method({a, b, ...rest}) { + assert.sameValue(rest.a, undefined); + assert.sameValue(rest.b, undefined); + + verifyProperty(rest, "x", { + enumerable: true, + writable: true, + configurable: true, + value: 1 + }); + + verifyProperty(rest, "y", { + enumerable: true, + writable: true, + configurable: true, + value: 2 + }); + callCount = callCount + 1; + } +}; + +new C().method({x: 1, y: 2, a: 5, b: 3}).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-init-iter-close.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-init-iter-close.js new file mode 100644 index 0000000000..3a3d91d039 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-init-iter-close.js @@ -0,0 +1,96 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-close.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: Iterator is closed when not exhausted by pattern evaluation (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [Symbol.iterator, generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: false }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var callCount = 0; +class C { + static *method([x]) { + assert.sameValue(doneCallCount, 1); + callCount = callCount + 1; + } +}; + +C.method(iter).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-init-iter-get-err-array-prototype.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-init-iter-get-err-array-prototype.js new file mode 100644 index 0000000000..a488358c5b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-init-iter-get-err-array-prototype.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-get-err-array-prototype.case +// - src/dstr-binding/error/cls-decl-gen-meth-static.template +/*--- +description: Abrupt completion returned by GetIterator (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [Symbol.iterator, generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iteratorRecord be ? GetIterator(value). + + GetIterator ( obj [ , hint [ , method ] ] ) + + [...] + 4. Let iterator be ? Call(method, obj). + + Call ( F, V [ , argumentsList ] ) + + [...] + 2. If IsCallable(F) is false, throw a TypeError exception. + +---*/ +delete Array.prototype[Symbol.iterator]; + +class C { + static *method([x, y, z]) {} +}; + +assert.throws(TypeError, function() { + C.method([1, 2, 3]); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-init-iter-get-err.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-init-iter-get-err.js new file mode 100644 index 0000000000..ec7bc1288e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-init-iter-get-err.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-get-err.case +// - src/dstr-binding/error/cls-decl-gen-meth-static.template +/*--- +description: Abrupt completion returned by GetIterator (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [Symbol.iterator, generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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(); +}; + +class C { + static *method([x]) {} +}; + +assert.throws(Test262Error, function() { + C.method(iter); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-init-iter-no-close.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-init-iter-no-close.js new file mode 100644 index 0000000000..f4e91c513d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-init-iter-no-close.js @@ -0,0 +1,96 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-no-close.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: Iterator is not closed when exhausted by pattern evaluation (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [Symbol.iterator, generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: true }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var callCount = 0; +class C { + static *method([x]) { + assert.sameValue(doneCallCount, 0); + callCount = callCount + 1; + } +}; + +C.method(iter).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-name-iter-val.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-name-iter-val.js new file mode 100644 index 0000000000..45b68377c5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-name-iter-val.js @@ -0,0 +1,95 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-name-iter-val.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: SingleNameBinding with normal value iteration (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static *method([x, y, z]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; + } +}; + +C.method([1, 2, 3]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-ary-elem-init.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-ary-elem-init.js new file mode 100644 index 0000000000..7ad4563944 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-ary-elem-init.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-init.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: BindingElement with array binding pattern and initializer is used (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + static *method([[x, y, z] = [4, 5, 6]]) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + callCount = callCount + 1; + } +}; + +C.method([]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-ary-elem-iter.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-ary-elem-iter.js new file mode 100644 index 0000000000..132ea0c923 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-ary-elem-iter.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-iter.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + static *method([[x, y, z] = [4, 5, 6]]) { + assert.sameValue(x, 7); + assert.sameValue(y, 8); + assert.sameValue(z, 9); + callCount = callCount + 1; + } +}; + +C.method([[7, 8, 9]]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-ary-elision-init.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-ary-elision-init.js new file mode 100644 index 0000000000..9f72547316 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-ary-elision-init.js @@ -0,0 +1,94 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-init.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: BindingElement with array binding pattern and initializer is used (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +class C { + static *method([[,] = g()]) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; + } +}; + +C.method([]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-ary-elision-iter.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-ary-elision-iter.js new file mode 100644 index 0000000000..40fcc2f144 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-ary-elision-iter.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-iter.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var callCount = 0; +function* g() { + callCount += 1; +}; + +var callCount = 0; +class C { + static *method([[,] = g()]) { + assert.sameValue(callCount, 0); + callCount = callCount + 1; + } +}; + +C.method([[]]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-ary-empty-init.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-ary-empty-init.js new file mode 100644 index 0000000000..64903ad17b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-ary-empty-init.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-init.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: BindingElement with array binding pattern and initializer is used (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var initCount = 0; +var iterCount = 0; +var iter = function*() { iterCount += 1; }(); + +var callCount = 0; +class C { + static *method([[] = function() { initCount += 1; return iter; }()]) { + assert.sameValue(initCount, 1); + assert.sameValue(iterCount, 0); + callCount = callCount + 1; + } +}; + +C.method([]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-ary-empty-iter.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-ary-empty-iter.js new file mode 100644 index 0000000000..c357654f9a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-ary-empty-iter.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-iter.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var initCount = 0; + +var callCount = 0; +class C { + static *method([[] = function() { initCount += 1; }()]) { + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +C.method([[23]]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-ary-rest-init.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-ary-rest-init.js new file mode 100644 index 0000000000..073749c71e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-ary-rest-init.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-init.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: BindingElement with array binding pattern and initializer is used (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; + +var callCount = 0; +class C { + static *method([[...x] = values]) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + callCount = callCount + 1; + } +}; + +C.method([]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-ary-rest-iter.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-ary-rest-iter.js new file mode 100644 index 0000000000..08326bb80e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-ary-rest-iter.js @@ -0,0 +1,94 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-iter.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; +var initCount = 0; + +var callCount = 0; +class C { + static *method([[...x] = function() { initCount += 1; }()]) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +C.method([values]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-ary-val-null.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-ary-val-null.js new file mode 100644 index 0000000000..0a3c9fad87 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-ary-val-null.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-val-null.case +// - src/dstr-binding/error/cls-decl-gen-meth-static.template +/*--- +description: Nested array destructuring with a null value (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). +---*/ + +class C { + static *method([[x]]) {} +}; + +assert.throws(TypeError, function() { + C.method([null]); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-id-init-exhausted.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-id-init-exhausted.js new file mode 100644 index 0000000000..c8321ead6c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-id-init-exhausted.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-exhausted.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: Destructuring initializer with an exhausted iterator (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static *method([x = 23]) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } +}; + +C.method([]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-id-init-fn-name-arrow.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..d2a9930873 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-id-init-fn-name-arrow.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-arrow.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: SingleNameBinding does assign name to arrow functions (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static *method([arrow = () => {}]) { + assert.sameValue(arrow.name, 'arrow'); + callCount = callCount + 1; + } +}; + +C.method([]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-id-init-fn-name-class.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-id-init-fn-name-class.js new file mode 100644 index 0000000000..c5ad7cdad5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-id-init-fn-name-class.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-class.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static *method([cls = class {}, xCls = class X {}, xCls2 = class { static name() {} }]) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + assert.notSameValue(xCls2.name, 'xCls2'); + callCount = callCount + 1; + } +}; + +C.method([]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-id-init-fn-name-cover.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-id-init-fn-name-cover.js new file mode 100644 index 0000000000..64adf969ac --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-id-init-fn-name-cover.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-cover.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: SingleNameBinding does assign name to "anonymous" functions "through" cover grammar (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static *method([cover = (function () {}), xCover = (0, function() {})]) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + callCount = callCount + 1; + } +}; + +C.method([]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-id-init-fn-name-fn.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-id-init-fn-name-fn.js new file mode 100644 index 0000000000..f23d95c569 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-id-init-fn-name-fn.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-fn.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static *method([fn = function () {}, xFn = function x() {}]) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + callCount = callCount + 1; + } +}; + +C.method([]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-id-init-fn-name-gen.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-id-init-fn-name-gen.js new file mode 100644 index 0000000000..63abad2c3b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-id-init-fn-name-gen.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-gen.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). + +---*/ + +var callCount = 0; +class C { + static *method([gen = function* () {}, xGen = function* x() {}]) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + callCount = callCount + 1; + } +}; + +C.method([]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-id-init-hole.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-id-init-hole.js new file mode 100644 index 0000000000..345ca0e8f1 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-id-init-hole.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-hole.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: Destructuring initializer with a "hole" (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + [...] + 7. If environment is undefined, return PutValue(lhs, v). 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static *method([x = 23]) { + assert.sameValue(x, 23); + // another statement + callCount = callCount + 1; + } +}; + +C.method([,]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-id-init-skipped.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-id-init-skipped.js new file mode 100644 index 0000000000..98eac43502 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-id-init-skipped.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-skipped.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +class C { + static *method([w = counter(), x = counter(), y = counter(), z = counter()]) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +C.method([null, 0, false, '']).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-id-init-throws.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-id-init-throws.js new file mode 100644 index 0000000000..7feef62677 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-id-init-throws.js @@ -0,0 +1,80 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-throws.case +// - src/dstr-binding/error/cls-decl-gen-meth-static.template +/*--- +description: Destructuring initializer returns an abrupt completion (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). +---*/ + +class C { + static *method([x = (function() { throw new Test262Error(); })()]) {} +}; + +assert.throws(Test262Error, function() { + C.method([undefined]); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-id-init-undef.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-id-init-undef.js new file mode 100644 index 0000000000..efccb8a3cf --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-id-init-undef.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-undef.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: Destructuring initializer with an undefined value (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static *method([x = 23]) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } +}; + +C.method([undefined]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-id-init-unresolvable.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-id-init-unresolvable.js new file mode 100644 index 0000000000..004d863005 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-id-init-unresolvable.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-unresolvable.case +// - src/dstr-binding/error/cls-decl-gen-meth-static.template +/*--- +description: Destructuring initializer is an unresolvable reference (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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. +---*/ + +class C { + static *method([ x = unresolvableReference ]) {} +}; + +assert.throws(ReferenceError, function() { + C.method([]); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-id-iter-complete.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-id-iter-complete.js new file mode 100644 index 0000000000..f36b552cfb --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-id-iter-complete.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-complete.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: SingleNameBinding when value iteration completes (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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, + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static *method([x]) { + assert.sameValue(x, undefined); + callCount = callCount + 1; + } +}; + +C.method([]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-id-iter-done.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-id-iter-done.js new file mode 100644 index 0000000000..0216f63489 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-id-iter-done.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-done.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: SingleNameBinding when value iteration was completed previously (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static *method([_, x]) { + assert.sameValue(x, undefined); + callCount = callCount + 1; + } +}; + +C.method([]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-id-iter-step-err.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-id-iter-step-err.js new file mode 100644 index 0000000000..a509bba319 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-id-iter-step-err.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-step-err.case +// - src/dstr-binding/error/cls-decl-gen-meth-static.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [Symbol.iterator, generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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(); + } + }; +}; + +class C { + static *method([x]) {} +}; + +assert.throws(Test262Error, function() { + C.method(g); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-id-iter-val-array-prototype.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-id-iter-val-array-prototype.js new file mode 100644 index 0000000000..68860f3f69 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-id-iter-val-array-prototype.js @@ -0,0 +1,105 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val-array-prototype.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: Array destructuring uses overriden Array.prototype[Symbol.iterator] (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [Symbol.iterator, generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializer_opt + + 1. Let bindingId be StringValue of BindingIdentifier. + 2. Let lhs be ? ResolveBinding(bindingId, environment). + 3. If iteratorRecord.[[Done]] is false, then + a. Let next be IteratorStep(iteratorRecord). + 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). + [...] + 7. Return InitializeReferencedBinding(lhs, v). + +---*/ +Array.prototype[Symbol.iterator] = function* () { + if (this.length > 0) { + yield this[0]; + } + if (this.length > 1) { + yield this[1]; + } + if (this.length > 2) { + yield 42; + } +}; + +var callCount = 0; +class C { + static *method([x, y, z]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 42); + callCount = callCount + 1; + } +}; + +C.method([1, 2, 3]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-id-iter-val-err.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-id-iter-val-err.js new file mode 100644 index 0000000000..705a3a03f8 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-id-iter-val-err.js @@ -0,0 +1,100 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val-err.case +// - src/dstr-binding/error/cls-decl-gen-meth-static.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [Symbol.iterator, generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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; + } + }; +}; + +class C { + static *method([x]) {} +}; + +assert.throws(Test262Error, function() { + C.method(g); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-id-iter-val.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-id-iter-val.js new file mode 100644 index 0000000000..4f011e0701 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-id-iter-val.js @@ -0,0 +1,95 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: SingleNameBinding when value iteration was completed previously (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static *method([x, y, z]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; + } +}; + +C.method([1, 2, 3]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-obj-id-init.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-obj-id-init.js new file mode 100644 index 0000000000..1517c7038a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-obj-id-init.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id-init.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: BindingElement with object binding pattern and initializer is used (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + static *method([{ x, y, z } = { x: 44, y: 55, z: 66 }]) { + assert.sameValue(x, 44); + assert.sameValue(y, 55); + assert.sameValue(z, 66); + callCount = callCount + 1; + } +}; + +C.method([]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-obj-id.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-obj-id.js new file mode 100644 index 0000000000..1fb34c42e5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-obj-id.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + static *method([{ x, y, z } = { x: 44, y: 55, z: 66 }]) { + assert.sameValue(x, 11); + assert.sameValue(y, 22); + assert.sameValue(z, 33); + callCount = callCount + 1; + } +}; + +C.method([{ x: 11, y: 22, z: 33 }]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-obj-prop-id-init.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-obj-prop-id-init.js new file mode 100644 index 0000000000..fcd72cd0b7 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-obj-prop-id-init.js @@ -0,0 +1,97 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id-init.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: BindingElement with object binding pattern and initializer is used (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + static *method([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }]) { + assert.sameValue(v, 444); + assert.sameValue(x, 555); + assert.sameValue(z, 666); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } +}; + +C.method([]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-obj-prop-id.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-obj-prop-id.js new file mode 100644 index 0000000000..a5e71946c1 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-obj-prop-id.js @@ -0,0 +1,97 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + static *method([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }]) { + assert.sameValue(v, 777); + assert.sameValue(x, 888); + assert.sameValue(z, 999); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } +}; + +C.method([{ u: 777, w: 888, y: 999 }]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-obj-val-null.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-obj-val-null.js new file mode 100644 index 0000000000..924beb7a1d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-obj-val-null.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-null.case +// - src/dstr-binding/error/cls-decl-gen-meth-static.template +/*--- +description: Nested object destructuring with a null value (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). +---*/ + +class C { + static *method([{ x }]) {} +}; + +assert.throws(TypeError, function() { + C.method([null]); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-obj-val-undef.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-obj-val-undef.js new file mode 100644 index 0000000000..60fc8fa75b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elem-obj-val-undef.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-undef.case +// - src/dstr-binding/error/cls-decl-gen-meth-static.template +/*--- +description: Nested object destructuring with a value of `undefined` (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). +---*/ + +class C { + static *method([{ x }]) {} +}; + +assert.throws(TypeError, function() { + C.method([]); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elision-exhausted.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elision-exhausted.js new file mode 100644 index 0000000000..dfd2b53f64 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elision-exhausted.js @@ -0,0 +1,92 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-exhausted.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: Elision accepts exhausted iterator (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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 + [...] + 2. Return NormalCompletion(empty). + +---*/ +var iter = function*() {}(); +iter.next(); + +var callCount = 0; +class C { + static *method([,]) { + + callCount = callCount + 1; + } +}; + +C.method(iter).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elision-step-err.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elision-step-err.js new file mode 100644 index 0000000000..62ddc8cbfc --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elision-step-err.js @@ -0,0 +1,96 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-step-err.case +// - src/dstr-binding/error/cls-decl-gen-meth-static.template +/*--- +description: Elision advances iterator and forwards abrupt completions (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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; +}(); + +class C { + static *method([,]) {} +}; + +assert.throws(Test262Error, function() { + C.method(iter); +}); + +iter.next(); +assert.sameValue(following, 0, 'Iterator was properly closed.'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elision.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elision.js new file mode 100644 index 0000000000..c7250ca05c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-elision.js @@ -0,0 +1,101 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: Elision advances iterator (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +class C { + static *method([,]) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; + } +}; + +C.method(g()).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-empty.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-empty.js new file mode 100644 index 0000000000..f68b91f4b7 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-empty.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-empty.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: No iteration occurs for an "empty" array binding pattern (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var callCount = 0; +class C { + static *method([]) { + assert.sameValue(iterations, 0); + callCount = callCount + 1; + } +}; + +C.method(iter).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-rest-ary-elem.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-rest-ary-elem.js new file mode 100644 index 0000000000..166f67d6fa --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-rest-ary-elem.js @@ -0,0 +1,108 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elem.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: Rest element containing an array BindingElementList pattern (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the 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). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static *method([...[x, y, z]]) { + assert.sameValue(x, 3); + assert.sameValue(y, 4); + assert.sameValue(z, 5); + callCount = callCount + 1; + } +}; + +C.method([3, 4, 5]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-rest-ary-elision.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-rest-ary-elision.js new file mode 100644 index 0000000000..7cf8377d43 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-rest-ary-elision.js @@ -0,0 +1,114 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elision.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: Rest element containing an elision (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the 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). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +class C { + static *method([...[,]]) { + assert.sameValue(first, 1); + assert.sameValue(second, 1); + callCount = callCount + 1; + } +}; + +C.method(g()).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-rest-ary-empty.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-rest-ary-empty.js new file mode 100644 index 0000000000..6e73d5c0fd --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-rest-ary-empty.js @@ -0,0 +1,97 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-empty.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: Rest element containing an "empty" array pattern (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var callCount = 0; +class C { + static *method([...[]]) { + assert.sameValue(iterations, 1); + callCount = callCount + 1; + } +}; + +C.method(iter).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-rest-ary-rest.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-rest-ary-rest.js new file mode 100644 index 0000000000..4a6a2e7c35 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-rest-ary-rest.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-rest.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: Rest element containing a rest element (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ +var values = [1, 2, 3]; + +var callCount = 0; +class C { + static *method([...[...x]]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + + callCount = callCount + 1; + } +}; + +C.method(values).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-rest-id-direct.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-rest-id-direct.js new file mode 100644 index 0000000000..8a107ed1c2 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-rest-id-direct.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-direct.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: Lone rest element (direct binding) (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding] +flags: [generated] +includes: [compareArray.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingIdentifier + + [...] + 2. Let A be ! ArrayCreate(0). + 3. Let n be 0. + 4. Repeat, + [...] + f. Perform ! CreateDataPropertyOrThrow(A, ! ToString(n), nextValue). + g. Set n to n + 1. + +---*/ + +var callCount = 0; +class C { + static *method([...x]) { + assert(Array.isArray(x)); + assert.compareArray(x, [1]); + callCount = callCount + 1; + } +}; + +C.method([1]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-rest-id-elision-next-err.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-rest-id-elision-next-err.js new file mode 100644 index 0000000000..c5a89eb956 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-rest-id-elision-next-err.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision-next-err.case +// - src/dstr-binding/error/cls-decl-gen-meth-static.template +/*--- +description: Rest element following elision elements (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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(); })(); + +class C { + static *method([, ...x]) {} +}; + +assert.throws(Test262Error, function() { + C.method(iter); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-rest-id-elision.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-rest-id-elision.js new file mode 100644 index 0000000000..719b55c61a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-rest-id-elision.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: Rest element following elision elements (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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 values = [1, 2, 3, 4, 5]; + +var callCount = 0; +class C { + static *method([ , , ...x]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 3); + assert.sameValue(x[1], 4); + assert.sameValue(x[2], 5); + assert.notSameValue(x, values); + callCount = callCount + 1; + } +}; + +C.method(values).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-rest-id-exhausted.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-rest-id-exhausted.js new file mode 100644 index 0000000000..6426ecf207 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-rest-id-exhausted.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-exhausted.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: RestElement applied to an exhausted iterator (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [Symbol.iterator, generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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, + [...] + b. If iteratorRecord.[[done]] is true, then + i. If environment is undefined, return PutValue(lhs, A). + ii. Return InitializeReferencedBinding(lhs, A). + +---*/ + +var callCount = 0; +class C { + static *method([, , ...x]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 0); + callCount = callCount + 1; + } +}; + +C.method([1, 2]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-rest-id-iter-step-err.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-rest-id-iter-step-err.js new file mode 100644 index 0000000000..0990a7bafc --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-rest-id-iter-step-err.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-step-err.case +// - src/dstr-binding/error/cls-decl-gen-meth-static.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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; +}(); + +class C { + static *method([...x]) {} +}; + +assert.throws(Test262Error, function() { + C.method(iter); +}); + +iter.next(); +assert.sameValue(first, 1); +assert.sameValue(second, 0, 'Iterator is closed following abrupt completion.'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-rest-id-iter-val-err.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-rest-id-iter-val-err.js new file mode 100644 index 0000000000..faab033428 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-rest-id-iter-val-err.js @@ -0,0 +1,95 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-val-err.case +// - src/dstr-binding/error/cls-decl-gen-meth-static.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [Symbol.iterator, generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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; + } + }; +}; + +class C { + static *method([...x]) {} +}; + +assert.throws(Test262Error, function() { + C.method(iter); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-rest-id.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-rest-id.js new file mode 100644 index 0000000000..8e7fdd3e98 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-rest-id.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: Lone rest element (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + [...] 3. Let A be ArrayCreate(0). [...] 5. Repeat + [...] + f. Let status be CreateDataProperty(A, ToString (n), nextValue). + [...] +---*/ +var values = [1, 2, 3]; + +var callCount = 0; +class C { + static *method([...x]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + callCount = callCount + 1; + } +}; + +C.method(values).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-rest-init-ary.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-rest-init-ary.js new file mode 100644 index 0000000000..473e6eaa98 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-rest-init-ary.js @@ -0,0 +1,82 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-ary.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: Rest element (nested array pattern) does not support initializer (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var callCount = 0; +class C { + static *method([...[ x ] = []]) { + + callCount = callCount + 1; + } +}; + +C.method([]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-rest-init-id.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-rest-init-id.js new file mode 100644 index 0000000000..bebffcfdbe --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-rest-init-id.js @@ -0,0 +1,82 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-id.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: Rest element (identifier) does not support initializer (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var callCount = 0; +class C { + static *method([...x = []]) { + + callCount = callCount + 1; + } +}; + +C.method([]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-rest-init-obj.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-rest-init-obj.js new file mode 100644 index 0000000000..74137c3696 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-rest-init-obj.js @@ -0,0 +1,82 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-obj.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: Rest element (nested object pattern) does not support initializer (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var callCount = 0; +class C { + static *method([...{ x } = []]) { + + callCount = callCount + 1; + } +}; + +C.method([]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-rest-not-final-ary.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-rest-not-final-ary.js new file mode 100644 index 0000000000..7820542366 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-rest-not-final-ary.js @@ -0,0 +1,82 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-ary.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: Rest element (array binding pattern) may not be followed by any element (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var callCount = 0; +class C { + static *method([...[x], y]) { + + callCount = callCount + 1; + } +}; + +C.method([1, 2, 3]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-rest-not-final-id.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-rest-not-final-id.js new file mode 100644 index 0000000000..71fc80a8ec --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-rest-not-final-id.js @@ -0,0 +1,82 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-id.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: Rest element (identifier) may not be followed by any element (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var callCount = 0; +class C { + static *method([...x, y]) { + + callCount = callCount + 1; + } +}; + +C.method([1, 2, 3]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-rest-not-final-obj.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-rest-not-final-obj.js new file mode 100644 index 0000000000..b3bd8c84a2 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-rest-not-final-obj.js @@ -0,0 +1,82 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-obj.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: Rest element (object binding pattern) may not be followed by any element (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var callCount = 0; +class C { + static *method([...{ x }, y]) { + + callCount = callCount + 1; + } +}; + +C.method([1, 2, 3]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-rest-obj-id.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-rest-obj-id.js new file mode 100644 index 0000000000..0e17d0f97b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-rest-obj-id.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-id.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: Rest element containing an object binding pattern (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ + +var callCount = 0; +class C { + static *method([...{ length }]) { + assert.sameValue(length, 3); + callCount = callCount + 1; + } +}; + +C.method([1, 2, 3]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-rest-obj-prop-id.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-rest-obj-prop-id.js new file mode 100644 index 0000000000..81820ac50b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-ary-ptrn-rest-obj-prop-id.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-prop-id.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: Rest element containing an object binding pattern (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ +let length = "outer"; + +var callCount = 0; +class C { + static *method([...{ 0: v, 1: w, 2: x, 3: y, length: z }]) { + assert.sameValue(v, 7); + assert.sameValue(w, 8); + assert.sameValue(x, 9); + assert.sameValue(y, undefined); + assert.sameValue(z, 3); + + assert.sameValue(length, "outer", "the length prop is not set as a binding name"); + callCount = callCount + 1; + } +}; + +C.method([7, 8, 9]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-init-iter-close.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-init-iter-close.js new file mode 100644 index 0000000000..c215d6656b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-init-iter-close.js @@ -0,0 +1,96 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-close.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: Iterator is closed when not exhausted by pattern evaluation (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [Symbol.iterator, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: false }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var callCount = 0; +class C { + static *method([x] = iter) { + assert.sameValue(doneCallCount, 1); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-init-iter-get-err-array-prototype.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-init-iter-get-err-array-prototype.js new file mode 100644 index 0000000000..911ef43eb0 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-init-iter-get-err-array-prototype.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-get-err-array-prototype.case +// - src/dstr-binding/error/cls-decl-gen-meth-static-dflt.template +/*--- +description: Abrupt completion returned by GetIterator (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [Symbol.iterator, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iteratorRecord be ? GetIterator(value). + + GetIterator ( obj [ , hint [ , method ] ] ) + + [...] + 4. Let iterator be ? Call(method, obj). + + Call ( F, V [ , argumentsList ] ) + + [...] + 2. If IsCallable(F) is false, throw a TypeError exception. + +---*/ +delete Array.prototype[Symbol.iterator]; + +class C { + static *method([x, y, z] = [1, 2, 3]) {} +}; + +assert.throws(TypeError, function() { + C.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-init-iter-get-err.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-init-iter-get-err.js new file mode 100644 index 0000000000..1b7496d07c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-init-iter-get-err.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-get-err.case +// - src/dstr-binding/error/cls-decl-gen-meth-static-dflt.template +/*--- +description: Abrupt completion returned by GetIterator (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [Symbol.iterator, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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(); +}; + +class C { + static *method([x] = iter) {} +}; + +assert.throws(Test262Error, function() { + C.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-init-iter-no-close.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-init-iter-no-close.js new file mode 100644 index 0000000000..51fdd14c5d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-init-iter-no-close.js @@ -0,0 +1,96 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-no-close.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: Iterator is not closed when exhausted by pattern evaluation (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [Symbol.iterator, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: true }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var callCount = 0; +class C { + static *method([x] = iter) { + assert.sameValue(doneCallCount, 0); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-name-iter-val.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-name-iter-val.js new file mode 100644 index 0000000000..2469ff5c6f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-name-iter-val.js @@ -0,0 +1,95 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-name-iter-val.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: SingleNameBinding with normal value iteration (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static *method([x, y, z] = [1, 2, 3]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-ary-elem-init.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-ary-elem-init.js new file mode 100644 index 0000000000..da84e745df --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-ary-elem-init.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-init.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + static *method([[x, y, z] = [4, 5, 6]] = []) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-ary-elem-iter.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-ary-elem-iter.js new file mode 100644 index 0000000000..2c06f60599 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-ary-elem-iter.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-iter.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + static *method([[x, y, z] = [4, 5, 6]] = [[7, 8, 9]]) { + assert.sameValue(x, 7); + assert.sameValue(y, 8); + assert.sameValue(z, 9); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-ary-elision-init.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-ary-elision-init.js new file mode 100644 index 0000000000..3e317c4701 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-ary-elision-init.js @@ -0,0 +1,94 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-init.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +class C { + static *method([[,] = g()] = []) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-ary-elision-iter.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-ary-elision-iter.js new file mode 100644 index 0000000000..fc374e0f44 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-ary-elision-iter.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-iter.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var callCount = 0; +function* g() { + callCount += 1; +}; + +var callCount = 0; +class C { + static *method([[,] = g()] = [[]]) { + assert.sameValue(callCount, 0); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-ary-empty-init.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-ary-empty-init.js new file mode 100644 index 0000000000..a28746a7ae --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-ary-empty-init.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-init.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var initCount = 0; +var iterCount = 0; +var iter = function*() { iterCount += 1; }(); + +var callCount = 0; +class C { + static *method([[] = function() { initCount += 1; return iter; }()] = []) { + assert.sameValue(initCount, 1); + assert.sameValue(iterCount, 0); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-ary-empty-iter.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-ary-empty-iter.js new file mode 100644 index 0000000000..70f13b13f0 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-ary-empty-iter.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-iter.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var initCount = 0; + +var callCount = 0; +class C { + static *method([[] = function() { initCount += 1; }()] = [[23]]) { + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-ary-rest-init.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-ary-rest-init.js new file mode 100644 index 0000000000..8c758022e6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-ary-rest-init.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-init.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; + +var callCount = 0; +class C { + static *method([[...x] = values] = []) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-ary-rest-iter.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-ary-rest-iter.js new file mode 100644 index 0000000000..bea4026d96 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-ary-rest-iter.js @@ -0,0 +1,94 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-iter.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; +var initCount = 0; + +var callCount = 0; +class C { + static *method([[...x] = function() { initCount += 1; }()] = [values]) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-ary-val-null.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-ary-val-null.js new file mode 100644 index 0000000000..d844c24475 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-ary-val-null.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-val-null.case +// - src/dstr-binding/error/cls-decl-gen-meth-static-dflt.template +/*--- +description: Nested array destructuring with a null value (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). +---*/ + +class C { + static *method([[x]] = [null]) {} +}; + +assert.throws(TypeError, function() { + C.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-id-init-exhausted.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-id-init-exhausted.js new file mode 100644 index 0000000000..be61a9d8f4 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-id-init-exhausted.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-exhausted.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: Destructuring initializer with an exhausted iterator (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static *method([x = 23] = []) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..383abd12c0 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-arrow.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: SingleNameBinding does assign name to arrow functions (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static *method([arrow = () => {}] = []) { + assert.sameValue(arrow.name, 'arrow'); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-class.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-class.js new file mode 100644 index 0000000000..1ee19dc8e7 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-class.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-class.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static *method([cls = class {}, xCls = class X {}, xCls2 = class { static name() {} }] = []) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + assert.notSameValue(xCls2.name, 'xCls2'); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-cover.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-cover.js new file mode 100644 index 0000000000..9b593d072b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-cover.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-cover.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: SingleNameBinding does assign name to "anonymous" functions "through" cover grammar (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static *method([cover = (function () {}), xCover = (0, function() {})] = []) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-fn.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-fn.js new file mode 100644 index 0000000000..6d6b0a714f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-fn.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-fn.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static *method([fn = function () {}, xFn = function x() {}] = []) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-gen.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-gen.js new file mode 100644 index 0000000000..3d3cc773fb --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-gen.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-gen.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). + +---*/ + +var callCount = 0; +class C { + static *method([gen = function* () {}, xGen = function* x() {}] = []) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-id-init-hole.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-id-init-hole.js new file mode 100644 index 0000000000..908345bb13 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-id-init-hole.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-hole.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: Destructuring initializer with a "hole" (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + [...] + 7. If environment is undefined, return PutValue(lhs, v). 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static *method([x = 23] = [,]) { + assert.sameValue(x, 23); + // another statement + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-id-init-skipped.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-id-init-skipped.js new file mode 100644 index 0000000000..4db81f201a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-id-init-skipped.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-skipped.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +class C { + static *method([w = counter(), x = counter(), y = counter(), z = counter()] = [null, 0, false, '']) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-id-init-throws.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-id-init-throws.js new file mode 100644 index 0000000000..2fc460b448 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-id-init-throws.js @@ -0,0 +1,80 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-throws.case +// - src/dstr-binding/error/cls-decl-gen-meth-static-dflt.template +/*--- +description: Destructuring initializer returns an abrupt completion (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). +---*/ + +class C { + static *method([x = (function() { throw new Test262Error(); })()] = [undefined]) {} +}; + +assert.throws(Test262Error, function() { + C.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-id-init-undef.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-id-init-undef.js new file mode 100644 index 0000000000..047af41234 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-id-init-undef.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-undef.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: Destructuring initializer with an undefined value (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static *method([x = 23] = [undefined]) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-id-init-unresolvable.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-id-init-unresolvable.js new file mode 100644 index 0000000000..c5f816ba20 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-id-init-unresolvable.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-unresolvable.case +// - src/dstr-binding/error/cls-decl-gen-meth-static-dflt.template +/*--- +description: Destructuring initializer is an unresolvable reference (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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. +---*/ + +class C { + static *method([ x = unresolvableReference ] = []) {} +}; + +assert.throws(ReferenceError, function() { + C.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-id-iter-complete.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-id-iter-complete.js new file mode 100644 index 0000000000..6160d0b401 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-id-iter-complete.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-complete.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: SingleNameBinding when value iteration completes (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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, + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static *method([x] = []) { + assert.sameValue(x, undefined); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-id-iter-done.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-id-iter-done.js new file mode 100644 index 0000000000..44e4238e1f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-id-iter-done.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-done.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: SingleNameBinding when value iteration was completed previously (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static *method([_, x] = []) { + assert.sameValue(x, undefined); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-id-iter-step-err.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-id-iter-step-err.js new file mode 100644 index 0000000000..1293c8a74c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-id-iter-step-err.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-step-err.case +// - src/dstr-binding/error/cls-decl-gen-meth-static-dflt.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [Symbol.iterator, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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(); + } + }; +}; + +class C { + static *method([x] = g) {} +}; + +assert.throws(Test262Error, function() { + C.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-id-iter-val-array-prototype.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-id-iter-val-array-prototype.js new file mode 100644 index 0000000000..522e14dd85 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-id-iter-val-array-prototype.js @@ -0,0 +1,105 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val-array-prototype.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: Array destructuring uses overriden Array.prototype[Symbol.iterator] (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [Symbol.iterator, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializer_opt + + 1. Let bindingId be StringValue of BindingIdentifier. + 2. Let lhs be ? ResolveBinding(bindingId, environment). + 3. If iteratorRecord.[[Done]] is false, then + a. Let next be IteratorStep(iteratorRecord). + 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). + [...] + 7. Return InitializeReferencedBinding(lhs, v). + +---*/ +Array.prototype[Symbol.iterator] = function* () { + if (this.length > 0) { + yield this[0]; + } + if (this.length > 1) { + yield this[1]; + } + if (this.length > 2) { + yield 42; + } +}; + +var callCount = 0; +class C { + static *method([x, y, z] = [1, 2, 3]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 42); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-id-iter-val-err.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-id-iter-val-err.js new file mode 100644 index 0000000000..709208fd61 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-id-iter-val-err.js @@ -0,0 +1,100 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val-err.case +// - src/dstr-binding/error/cls-decl-gen-meth-static-dflt.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [Symbol.iterator, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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; + } + }; +}; + +class C { + static *method([x] = g) {} +}; + +assert.throws(Test262Error, function() { + C.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-id-iter-val.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-id-iter-val.js new file mode 100644 index 0000000000..7618e04432 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-id-iter-val.js @@ -0,0 +1,95 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: SingleNameBinding when value iteration was completed previously (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static *method([x, y, z] = [1, 2, 3]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-obj-id-init.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-obj-id-init.js new file mode 100644 index 0000000000..991e3c9bdc --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-obj-id-init.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id-init.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is used (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + static *method([{ x, y, z } = { x: 44, y: 55, z: 66 }] = []) { + assert.sameValue(x, 44); + assert.sameValue(y, 55); + assert.sameValue(z, 66); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-obj-id.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-obj-id.js new file mode 100644 index 0000000000..2867b76609 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-obj-id.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + static *method([{ x, y, z } = { x: 44, y: 55, z: 66 }] = [{ x: 11, y: 22, z: 33 }]) { + assert.sameValue(x, 11); + assert.sameValue(y, 22); + assert.sameValue(z, 33); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-obj-prop-id-init.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-obj-prop-id-init.js new file mode 100644 index 0000000000..02ce6b0c0f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-obj-prop-id-init.js @@ -0,0 +1,97 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id-init.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is used (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + static *method([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] = []) { + assert.sameValue(v, 444); + assert.sameValue(x, 555); + assert.sameValue(z, 666); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-obj-prop-id.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-obj-prop-id.js new file mode 100644 index 0000000000..1a8b30b593 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-obj-prop-id.js @@ -0,0 +1,97 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + static *method([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] = [{ u: 777, w: 888, y: 999 }]) { + assert.sameValue(v, 777); + assert.sameValue(x, 888); + assert.sameValue(z, 999); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-obj-val-null.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-obj-val-null.js new file mode 100644 index 0000000000..f051c6b331 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-obj-val-null.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-null.case +// - src/dstr-binding/error/cls-decl-gen-meth-static-dflt.template +/*--- +description: Nested object destructuring with a null value (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). +---*/ + +class C { + static *method([{ x }] = [null]) {} +}; + +assert.throws(TypeError, function() { + C.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-obj-val-undef.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-obj-val-undef.js new file mode 100644 index 0000000000..a804b5eb17 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elem-obj-val-undef.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-undef.case +// - src/dstr-binding/error/cls-decl-gen-meth-static-dflt.template +/*--- +description: Nested object destructuring with a value of `undefined` (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). +---*/ + +class C { + static *method([{ x }] = []) {} +}; + +assert.throws(TypeError, function() { + C.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elision-exhausted.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elision-exhausted.js new file mode 100644 index 0000000000..eaf3c5f4dc --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elision-exhausted.js @@ -0,0 +1,92 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-exhausted.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: Elision accepts exhausted iterator (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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 + [...] + 2. Return NormalCompletion(empty). + +---*/ +var iter = function*() {}(); +iter.next(); + +var callCount = 0; +class C { + static *method([,] = iter) { + + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elision-step-err.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elision-step-err.js new file mode 100644 index 0000000000..1d318233ab --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elision-step-err.js @@ -0,0 +1,96 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-step-err.case +// - src/dstr-binding/error/cls-decl-gen-meth-static-dflt.template +/*--- +description: Elision advances iterator and forwards abrupt completions (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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; +}(); + +class C { + static *method([,] = iter) {} +}; + +assert.throws(Test262Error, function() { + C.method(); +}); + +iter.next(); +assert.sameValue(following, 0, 'Iterator was properly closed.'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elision.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elision.js new file mode 100644 index 0000000000..41fa6cca35 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-elision.js @@ -0,0 +1,101 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: Elision advances iterator (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +class C { + static *method([,] = g()) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-empty.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-empty.js new file mode 100644 index 0000000000..5a545c2c2b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-empty.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-empty.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: No iteration occurs for an "empty" array binding pattern (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var callCount = 0; +class C { + static *method([] = iter) { + assert.sameValue(iterations, 0); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-rest-ary-elem.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-rest-ary-elem.js new file mode 100644 index 0000000000..709bf8f2d7 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-rest-ary-elem.js @@ -0,0 +1,108 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elem.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: Rest element containing an array BindingElementList pattern (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the 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). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static *method([...[x, y, z]] = [3, 4, 5]) { + assert.sameValue(x, 3); + assert.sameValue(y, 4); + assert.sameValue(z, 5); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-rest-ary-elision.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-rest-ary-elision.js new file mode 100644 index 0000000000..266b6e8faf --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-rest-ary-elision.js @@ -0,0 +1,114 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elision.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: Rest element containing an elision (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the 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). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +class C { + static *method([...[,]] = g()) { + assert.sameValue(first, 1); + assert.sameValue(second, 1); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-rest-ary-empty.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-rest-ary-empty.js new file mode 100644 index 0000000000..56b39ef77e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-rest-ary-empty.js @@ -0,0 +1,97 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-empty.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: Rest element containing an "empty" array pattern (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var callCount = 0; +class C { + static *method([...[]] = iter) { + assert.sameValue(iterations, 1); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-rest-ary-rest.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-rest-ary-rest.js new file mode 100644 index 0000000000..3d3c3f923b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-rest-ary-rest.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-rest.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: Rest element containing a rest element (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ +var values = [1, 2, 3]; + +var callCount = 0; +class C { + static *method([...[...x]] = values) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-rest-id-direct.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-rest-id-direct.js new file mode 100644 index 0000000000..b6f3327a44 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-rest-id-direct.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-direct.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: Lone rest element (direct binding) (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +includes: [compareArray.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingIdentifier + + [...] + 2. Let A be ! ArrayCreate(0). + 3. Let n be 0. + 4. Repeat, + [...] + f. Perform ! CreateDataPropertyOrThrow(A, ! ToString(n), nextValue). + g. Set n to n + 1. + +---*/ + +var callCount = 0; +class C { + static *method([...x] = [1]) { + assert(Array.isArray(x)); + assert.compareArray(x, [1]); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-rest-id-elision-next-err.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-rest-id-elision-next-err.js new file mode 100644 index 0000000000..bfa213cecf --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-rest-id-elision-next-err.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision-next-err.case +// - src/dstr-binding/error/cls-decl-gen-meth-static-dflt.template +/*--- +description: Rest element following elision elements (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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(); })(); + +class C { + static *method([, ...x] = iter) {} +}; + +assert.throws(Test262Error, function() { + C.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-rest-id-elision.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-rest-id-elision.js new file mode 100644 index 0000000000..d43cc7a748 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-rest-id-elision.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: Rest element following elision elements (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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 values = [1, 2, 3, 4, 5]; + +var callCount = 0; +class C { + static *method([ , , ...x] = values) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 3); + assert.sameValue(x[1], 4); + assert.sameValue(x[2], 5); + assert.notSameValue(x, values); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-rest-id-exhausted.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-rest-id-exhausted.js new file mode 100644 index 0000000000..4fac33c15f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-rest-id-exhausted.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-exhausted.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: RestElement applied to an exhausted iterator (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [Symbol.iterator, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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, + [...] + b. If iteratorRecord.[[done]] is true, then + i. If environment is undefined, return PutValue(lhs, A). + ii. Return InitializeReferencedBinding(lhs, A). + +---*/ + +var callCount = 0; +class C { + static *method([, , ...x] = [1, 2]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 0); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-rest-id-iter-step-err.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-rest-id-iter-step-err.js new file mode 100644 index 0000000000..18d925e236 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-rest-id-iter-step-err.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-step-err.case +// - src/dstr-binding/error/cls-decl-gen-meth-static-dflt.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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; +}(); + +class C { + static *method([...x] = iter) {} +}; + +assert.throws(Test262Error, function() { + C.method(); +}); + +iter.next(); +assert.sameValue(first, 1); +assert.sameValue(second, 0, 'Iterator is closed following abrupt completion.'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-rest-id-iter-val-err.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-rest-id-iter-val-err.js new file mode 100644 index 0000000000..0239380bc3 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-rest-id-iter-val-err.js @@ -0,0 +1,95 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-val-err.case +// - src/dstr-binding/error/cls-decl-gen-meth-static-dflt.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [Symbol.iterator, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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; + } + }; +}; + +class C { + static *method([...x] = iter) {} +}; + +assert.throws(Test262Error, function() { + C.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-rest-id.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-rest-id.js new file mode 100644 index 0000000000..12dde164e4 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-rest-id.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: Lone rest element (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + [...] 3. Let A be ArrayCreate(0). [...] 5. Repeat + [...] + f. Let status be CreateDataProperty(A, ToString (n), nextValue). + [...] +---*/ +var values = [1, 2, 3]; + +var callCount = 0; +class C { + static *method([...x] = values) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-rest-init-ary.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-rest-init-ary.js new file mode 100644 index 0000000000..89fd8a30e4 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-rest-init-ary.js @@ -0,0 +1,82 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-ary.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: Rest element (nested array pattern) does not support initializer (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var callCount = 0; +class C { + static *method([...[ x ] = []] = []) { + + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-rest-init-id.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-rest-init-id.js new file mode 100644 index 0000000000..40bb240d07 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-rest-init-id.js @@ -0,0 +1,82 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-id.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: Rest element (identifier) does not support initializer (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var callCount = 0; +class C { + static *method([...x = []] = []) { + + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-rest-init-obj.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-rest-init-obj.js new file mode 100644 index 0000000000..b24b90b955 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-rest-init-obj.js @@ -0,0 +1,82 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-obj.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: Rest element (nested object pattern) does not support initializer (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var callCount = 0; +class C { + static *method([...{ x } = []] = []) { + + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-rest-not-final-ary.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-rest-not-final-ary.js new file mode 100644 index 0000000000..4851b08cfb --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-rest-not-final-ary.js @@ -0,0 +1,82 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-ary.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: Rest element (array binding pattern) may not be followed by any element (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var callCount = 0; +class C { + static *method([...[x], y] = [1, 2, 3]) { + + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-rest-not-final-id.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-rest-not-final-id.js new file mode 100644 index 0000000000..40f1add548 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-rest-not-final-id.js @@ -0,0 +1,82 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-id.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: Rest element (identifier) may not be followed by any element (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var callCount = 0; +class C { + static *method([...x, y] = [1, 2, 3]) { + + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-rest-not-final-obj.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-rest-not-final-obj.js new file mode 100644 index 0000000000..e325248831 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-rest-not-final-obj.js @@ -0,0 +1,82 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-obj.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: Rest element (object binding pattern) may not be followed by any element (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var callCount = 0; +class C { + static *method([...{ x }, y] = [1, 2, 3]) { + + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-rest-obj-id.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-rest-obj-id.js new file mode 100644 index 0000000000..76b85b23a7 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-rest-obj-id.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-id.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: Rest element containing an object binding pattern (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ + +var callCount = 0; +class C { + static *method([...{ length }] = [1, 2, 3]) { + assert.sameValue(length, 3); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-rest-obj-prop-id.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-rest-obj-prop-id.js new file mode 100644 index 0000000000..b1a0dfae26 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-ary-ptrn-rest-obj-prop-id.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-prop-id.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: Rest element containing an object binding pattern (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ +let length = "outer"; + +var callCount = 0; +class C { + static *method([...{ 0: v, 1: w, 2: x, 3: y, length: z }] = [7, 8, 9]) { + assert.sameValue(v, 7); + assert.sameValue(w, 8); + assert.sameValue(x, 9); + assert.sameValue(y, undefined); + assert.sameValue(z, 3); + + assert.sameValue(length, "outer", "the length prop is not set as a binding name"); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-init-null.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-init-null.js new file mode 100644 index 0000000000..35e88231ca --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-init-null.js @@ -0,0 +1,76 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-null.case +// - src/dstr-binding/error/cls-decl-gen-meth-static-dflt.template +/*--- +description: Value specifed for object binding pattern must be object coercible (null) (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +class C { + static *method({} = null) {} +}; + +assert.throws(TypeError, function() { + C.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-init-undefined.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-init-undefined.js new file mode 100644 index 0000000000..42a9e2a75e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-init-undefined.js @@ -0,0 +1,76 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-undefined.case +// - src/dstr-binding/error/cls-decl-gen-meth-static-dflt.template +/*--- +description: Value specifed for object binding pattern must be object coercible (undefined) (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +class C { + static *method({} = undefined) {} +}; + +assert.throws(TypeError, function() { + C.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-empty.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-empty.js new file mode 100644 index 0000000000..ad1960b0b0 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-empty.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-empty.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: No property access occurs for an "empty" object binding pattern (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ +var accessCount = 0; +var obj = Object.defineProperty({}, 'attr', { + get: function() { + accessCount += 1; + } +}); + +var callCount = 0; +class C { + static *method({} = obj) { + assert.sameValue(accessCount, 0); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-id-get-value-err.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-id-get-value-err.js new file mode 100644 index 0000000000..43a917c57c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-id-get-value-err.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-get-value-err.case +// - src/dstr-binding/error/cls-decl-gen-meth-static-dflt.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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(); + } +}); + +class C { + static *method({ poisoned } = poisonedProperty) {} +}; + +assert.throws(Test262Error, function() { + C.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-id-init-fn-name-arrow.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..48944fc65b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-id-init-fn-name-arrow.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-arrow.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: SingleNameBinding assigns `name` to arrow functions (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +class C { + static *method({ arrow = () => {} } = {}) { + assert.sameValue(arrow.name, 'arrow'); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-id-init-fn-name-class.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-id-init-fn-name-class.js new file mode 100644 index 0000000000..025bd7d90d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-id-init-fn-name-class.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-class.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +class C { + static *method({ cls = class {}, xCls = class X {}, xCls2 = class { static name() {} } } = {}) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + assert.notSameValue(xCls2.name, 'xCls2'); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-id-init-fn-name-cover.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-id-init-fn-name-cover.js new file mode 100644 index 0000000000..662fb849d6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-id-init-fn-name-cover.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-cover.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" functions "through" cover grammar (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +class C { + static *method({ cover = (function () {}), xCover = (0, function() {}) } = {}) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-id-init-fn-name-fn.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-id-init-fn-name-fn.js new file mode 100644 index 0000000000..c636fd2d4e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-id-init-fn-name-fn.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-fn.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +class C { + static *method({ fn = function () {}, xFn = function x() {} } = {}) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-id-init-fn-name-gen.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-id-init-fn-name-gen.js new file mode 100644 index 0000000000..9bbb3b06d2 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-id-init-fn-name-gen.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-gen.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). + +---*/ + +var callCount = 0; +class C { + static *method({ gen = function* () {}, xGen = function* x() {} } = {}) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-id-init-skipped.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-id-init-skipped.js new file mode 100644 index 0000000000..b4b2787963 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-id-init-skipped.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-skipped.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +class C { + static *method({ w = counter(), x = counter(), y = counter(), z = counter() } = { w: null, x: 0, y: false, z: '' }) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-id-init-throws.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-id-init-throws.js new file mode 100644 index 0000000000..9739de71c8 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-id-init-throws.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-throws.case +// - src/dstr-binding/error/cls-decl-gen-meth-static-dflt.template +/*--- +description: Error thrown when evaluating the initializer (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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(); +} + +class C { + static *method({ x = thrower() } = {}) {} +}; + +assert.throws(Test262Error, function() { + C.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-id-init-unresolvable.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-id-init-unresolvable.js new file mode 100644 index 0000000000..e25fb1b496 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-id-init-unresolvable.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-unresolvable.case +// - src/dstr-binding/error/cls-decl-gen-meth-static-dflt.template +/*--- +description: Destructuring initializer is an unresolvable reference (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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. +---*/ + +class C { + static *method({ x = unresolvableReference } = {}) {} +}; + +assert.throws(ReferenceError, function() { + C.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-id-trailing-comma.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-id-trailing-comma.js new file mode 100644 index 0000000000..c7f99ae884 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-id-trailing-comma.js @@ -0,0 +1,80 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-trailing-comma.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +class C { + static *method({ x, } = { x: 23 }) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-list-err.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-list-err.js new file mode 100644 index 0000000000..2bbdb4261d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-list-err.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-list-err.case +// - src/dstr-binding/error/cls-decl-gen-meth-static-dflt.template +/*--- +description: Binding property list evaluation is interrupted by an abrupt completion (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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(); +} + +class C { + static *method({ a, b = thrower(), c = ++initCount } = {}) {} +}; + +assert.throws(Test262Error, function() { + C.method(); +}); + +assert.sameValue(initCount, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-prop-ary-init.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-prop-ary-init.js new file mode 100644 index 0000000000..26742762cf --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-prop-ary-init.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-init.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: Object binding pattern with "nested" array binding pattern using initializer (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 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). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +class C { + static *method({ w: [x, y, z] = [4, 5, 6] } = {}) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-prop-ary-trailing-comma.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-prop-ary-trailing-comma.js new file mode 100644 index 0000000000..bfa832e1d0 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-prop-ary-trailing-comma.js @@ -0,0 +1,80 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-trailing-comma.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +class C { + static *method({ x: [y], } = { x: [45] }) { + assert.sameValue(y,45); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-prop-ary-value-null.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-prop-ary-value-null.js new file mode 100644 index 0000000000..724095625c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-prop-ary-value-null.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-value-null.case +// - src/dstr-binding/error/cls-decl-gen-meth-static-dflt.template +/*--- +description: Object binding pattern with "nested" array binding pattern taking the `null` value (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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. +---*/ + +class C { + static *method({ w: [x, y, z] = [4, 5, 6] } = { w: null }) {} +}; + +assert.throws(TypeError, function() { + C.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-prop-ary.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-prop-ary.js new file mode 100644 index 0000000000..4277491363 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-prop-ary.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: Object binding pattern with "nested" array binding pattern not using initializer (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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. +---*/ + +var callCount = 0; +class C { + static *method({ w: [x, y, z] = [4, 5, 6] } = { w: [7, undefined, ] }) { + assert.sameValue(x, 7); + assert.sameValue(y, undefined); + assert.sameValue(z, undefined); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-prop-eval-err.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-prop-eval-err.js new file mode 100644 index 0000000000..873dc625c7 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-prop-eval-err.js @@ -0,0 +1,80 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-eval-err.case +// - src/dstr-binding/error/cls-decl-gen-meth-static-dflt.template +/*--- +description: Evaluation of property name returns an abrupt completion (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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(); +} + +class C { + static *method({ [thrower()]: x } = {}) {} +}; + +assert.throws(Test262Error, function() { + C.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-prop-id-get-value-err.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-prop-id-get-value-err.js new file mode 100644 index 0000000000..55a6fea28c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-prop-id-get-value-err.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-get-value-err.case +// - src/dstr-binding/error/cls-decl-gen-meth-static-dflt.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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(); + } +}); + +class C { + static *method({ poisoned: x = ++initEvalCount } = poisonedProperty) {} +}; + +assert.throws(Test262Error, function() { + C.method(); +}); + +assert.sameValue(initEvalCount, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-prop-id-init-skipped.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-prop-id-init-skipped.js new file mode 100644 index 0000000000..668c518f36 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-prop-id-init-skipped.js @@ -0,0 +1,102 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-skipped.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +class C { + static *method({ s: t = counter(), u: v = counter(), w: x = counter(), y: z = counter() } = { s: null, u: 0, w: false, y: '' }) { + assert.sameValue(t, null); + assert.sameValue(v, 0); + assert.sameValue(x, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + + assert.throws(ReferenceError, function() { + s; + }); + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-prop-id-init-throws.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-prop-id-init-throws.js new file mode 100644 index 0000000000..4036ce4dd1 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-prop-id-init-throws.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-throws.case +// - src/dstr-binding/error/cls-decl-gen-meth-static-dflt.template +/*--- +description: Error thrown when evaluating the initializer (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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(); +} + +class C { + static *method({ x: y = thrower() } = {}) {} +}; + +assert.throws(Test262Error, function() { + C.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-prop-id-init-unresolvable.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-prop-id-init-unresolvable.js new file mode 100644 index 0000000000..272edfbc99 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-prop-id-init-unresolvable.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-unresolvable.case +// - src/dstr-binding/error/cls-decl-gen-meth-static-dflt.template +/*--- +description: Destructuring initializer is an unresolvable reference (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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. +---*/ + +class C { + static *method({ x: y = unresolvableReference } = {}) {} +}; + +assert.throws(ReferenceError, function() { + C.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-prop-id-init.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-prop-id-init.js new file mode 100644 index 0000000000..4a4b492bca --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-prop-id-init.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: Binding as specified via property name, identifier, and initializer (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static *method({ x: y = 33 } = { }) { + assert.sameValue(y, 33); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-prop-id-trailing-comma.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-prop-id-trailing-comma.js new file mode 100644 index 0000000000..346669cbd0 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-prop-id-trailing-comma.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-trailing-comma.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +class C { + static *method({ x: y, } = { x: 23 }) { + assert.sameValue(y, 23); + + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-prop-id.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-prop-id.js new file mode 100644 index 0000000000..b157c71677 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-prop-id.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: Binding as specified via property name and identifier (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static *method({ x: y } = { x: 23 }) { + assert.sameValue(y, 23); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-prop-obj-init.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-prop-obj-init.js new file mode 100644 index 0000000000..4b929c3ca3 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-prop-obj-init.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-init.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern using initializer (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 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). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +class C { + static *method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } } = { w: undefined }) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-prop-obj-value-null.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-prop-obj-value-null.js new file mode 100644 index 0000000000..a2b51e2f45 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-prop-obj-value-null.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-null.case +// - src/dstr-binding/error/cls-decl-gen-meth-static-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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. +---*/ + +class C { + static *method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } } = { w: null }) {} +}; + +assert.throws(TypeError, function() { + C.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-prop-obj-value-undef.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-prop-obj-value-undef.js new file mode 100644 index 0000000000..62b845667a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-prop-obj-value-undef.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-undef.case +// - src/dstr-binding/error/cls-decl-gen-meth-static-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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. +---*/ + +class C { + static *method({ w: { x, y, z } = undefined } = { }) {} +}; + +assert.throws(TypeError, function() { + C.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-prop-obj.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-prop-obj.js new file mode 100644 index 0000000000..aaf80b4764 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-prop-obj.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern not using initializer (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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. +---*/ + +var callCount = 0; +class C { + static *method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } } = { w: { x: undefined, z: 7 } }) { + assert.sameValue(x, undefined); + assert.sameValue(y, undefined); + assert.sameValue(z, 7); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-rest-getter.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-rest-getter.js new file mode 100644 index 0000000000..f73c062841 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-rest-getter.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-getter.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: Getter is called when obj is being deconstructed to a rest Object (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [object-rest, generators, destructuring-binding, default-parameters] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var count = 0; + +var callCount = 0; +class C { + static *method({...x} = { get v() { count++; return 2; } }) { + assert.sameValue(count, 1); + + verifyProperty(x, "v", { + enumerable: true, + writable: true, + configurable: true, + value: 2 + }); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-rest-skip-non-enumerable.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-rest-skip-non-enumerable.js new file mode 100644 index 0000000000..07bc5f9764 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-rest-skip-non-enumerable.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-skip-non-enumerable.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: Rest object doesn't contain non-enumerable properties (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [object-rest, generators, destructuring-binding, default-parameters] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var o = {a: 3, b: 4}; +Object.defineProperty(o, "x", { value: 4, enumerable: false }); + +var callCount = 0; +class C { + static *method({...rest} = o) { + assert.sameValue(rest.x, undefined); + + verifyProperty(rest, "a", { + enumerable: true, + writable: true, + configurable: true, + value: 3 + }); + + verifyProperty(rest, "b", { + enumerable: true, + writable: true, + configurable: true, + value: 4 + }); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-rest-val-obj.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-rest-val-obj.js new file mode 100644 index 0000000000..f4f3d799c5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-dflt-obj-ptrn-rest-val-obj.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-val-obj.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: Rest object contains just unextracted data (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [object-rest, generators, destructuring-binding, default-parameters] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +class C { + static *method({a, b, ...rest} = {x: 1, y: 2, a: 5, b: 3}) { + assert.sameValue(rest.a, undefined); + assert.sameValue(rest.b, undefined); + + verifyProperty(rest, "x", { + enumerable: true, + writable: true, + configurable: true, + value: 1 + }); + + verifyProperty(rest, "y", { + enumerable: true, + writable: true, + configurable: true, + value: 2 + }); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-init-null.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-init-null.js new file mode 100644 index 0000000000..2ef714fd6a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-init-null.js @@ -0,0 +1,76 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-null.case +// - src/dstr-binding/error/cls-decl-gen-meth-static.template +/*--- +description: Value specifed for object binding pattern must be object coercible (null) (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +class C { + static *method({}) {} +}; + +assert.throws(TypeError, function() { + C.method(null); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-init-undefined.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-init-undefined.js new file mode 100644 index 0000000000..9e983ee2cf --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-init-undefined.js @@ -0,0 +1,76 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-undefined.case +// - src/dstr-binding/error/cls-decl-gen-meth-static.template +/*--- +description: Value specifed for object binding pattern must be object coercible (undefined) (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +class C { + static *method({}) {} +}; + +assert.throws(TypeError, function() { + C.method(undefined); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-empty.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-empty.js new file mode 100644 index 0000000000..0cb56067ea --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-empty.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-empty.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: No property access occurs for an "empty" object binding pattern (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ +var accessCount = 0; +var obj = Object.defineProperty({}, 'attr', { + get: function() { + accessCount += 1; + } +}); + +var callCount = 0; +class C { + static *method({}) { + assert.sameValue(accessCount, 0); + callCount = callCount + 1; + } +}; + +C.method(obj).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-id-get-value-err.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-id-get-value-err.js new file mode 100644 index 0000000000..e9185fa545 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-id-get-value-err.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-get-value-err.case +// - src/dstr-binding/error/cls-decl-gen-meth-static.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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(); + } +}); + +class C { + static *method({ poisoned }) {} +}; + +assert.throws(Test262Error, function() { + C.method(poisonedProperty); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-id-init-fn-name-arrow.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..87997fca05 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-id-init-fn-name-arrow.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-arrow.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: SingleNameBinding assigns `name` to arrow functions (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +class C { + static *method({ arrow = () => {} }) { + assert.sameValue(arrow.name, 'arrow'); + callCount = callCount + 1; + } +}; + +C.method({}).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-id-init-fn-name-class.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-id-init-fn-name-class.js new file mode 100644 index 0000000000..7e6d35bc59 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-id-init-fn-name-class.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-class.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +class C { + static *method({ cls = class {}, xCls = class X {}, xCls2 = class { static name() {} } }) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + assert.notSameValue(xCls2.name, 'xCls2'); + callCount = callCount + 1; + } +}; + +C.method({}).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-id-init-fn-name-cover.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-id-init-fn-name-cover.js new file mode 100644 index 0000000000..21965c66b7 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-id-init-fn-name-cover.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-cover.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" functions "through" cover grammar (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +class C { + static *method({ cover = (function () {}), xCover = (0, function() {}) }) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + callCount = callCount + 1; + } +}; + +C.method({}).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-id-init-fn-name-fn.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-id-init-fn-name-fn.js new file mode 100644 index 0000000000..d7b1d4d2c7 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-id-init-fn-name-fn.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-fn.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +class C { + static *method({ fn = function () {}, xFn = function x() {} }) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + callCount = callCount + 1; + } +}; + +C.method({}).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-id-init-fn-name-gen.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-id-init-fn-name-gen.js new file mode 100644 index 0000000000..44a81b541f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-id-init-fn-name-gen.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-gen.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). + +---*/ + +var callCount = 0; +class C { + static *method({ gen = function* () {}, xGen = function* x() {} }) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + callCount = callCount + 1; + } +}; + +C.method({}).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-id-init-skipped.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-id-init-skipped.js new file mode 100644 index 0000000000..83ff468f2c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-id-init-skipped.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-skipped.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +class C { + static *method({ w = counter(), x = counter(), y = counter(), z = counter() }) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +C.method({ w: null, x: 0, y: false, z: '' }).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-id-init-throws.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-id-init-throws.js new file mode 100644 index 0000000000..d6e7e9e883 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-id-init-throws.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-throws.case +// - src/dstr-binding/error/cls-decl-gen-meth-static.template +/*--- +description: Error thrown when evaluating the initializer (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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(); +} + +class C { + static *method({ x = thrower() }) {} +}; + +assert.throws(Test262Error, function() { + C.method({}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-id-init-unresolvable.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-id-init-unresolvable.js new file mode 100644 index 0000000000..0e27e7c683 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-id-init-unresolvable.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-unresolvable.case +// - src/dstr-binding/error/cls-decl-gen-meth-static.template +/*--- +description: Destructuring initializer is an unresolvable reference (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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. +---*/ + +class C { + static *method({ x = unresolvableReference }) {} +}; + +assert.throws(ReferenceError, function() { + C.method({}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-id-trailing-comma.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-id-trailing-comma.js new file mode 100644 index 0000000000..3b09a587ce --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-id-trailing-comma.js @@ -0,0 +1,80 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-trailing-comma.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +class C { + static *method({ x, }) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } +}; + +C.method({ x: 23 }).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-list-err.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-list-err.js new file mode 100644 index 0000000000..248afa936c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-list-err.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-list-err.case +// - src/dstr-binding/error/cls-decl-gen-meth-static.template +/*--- +description: Binding property list evaluation is interrupted by an abrupt completion (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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(); +} + +class C { + static *method({ a, b = thrower(), c = ++initCount }) {} +}; + +assert.throws(Test262Error, function() { + C.method({}); +}); + +assert.sameValue(initCount, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-prop-ary-init.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-prop-ary-init.js new file mode 100644 index 0000000000..1d8e2f1b5c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-prop-ary-init.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-init.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: Object binding pattern with "nested" array binding pattern using initializer (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 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). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +class C { + static *method({ w: [x, y, z] = [4, 5, 6] }) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } +}; + +C.method({}).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-prop-ary-trailing-comma.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-prop-ary-trailing-comma.js new file mode 100644 index 0000000000..fdf2ab2476 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-prop-ary-trailing-comma.js @@ -0,0 +1,80 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-trailing-comma.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +class C { + static *method({ x: [y], }) { + assert.sameValue(y,45); + callCount = callCount + 1; + } +}; + +C.method({ x: [45] }).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-prop-ary-value-null.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-prop-ary-value-null.js new file mode 100644 index 0000000000..3ea5b90bc6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-prop-ary-value-null.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-value-null.case +// - src/dstr-binding/error/cls-decl-gen-meth-static.template +/*--- +description: Object binding pattern with "nested" array binding pattern taking the `null` value (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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. +---*/ + +class C { + static *method({ w: [x, y, z] = [4, 5, 6] }) {} +}; + +assert.throws(TypeError, function() { + C.method({ w: null }); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-prop-ary.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-prop-ary.js new file mode 100644 index 0000000000..88b59b373a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-prop-ary.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: Object binding pattern with "nested" array binding pattern not using initializer (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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. +---*/ + +var callCount = 0; +class C { + static *method({ w: [x, y, z] = [4, 5, 6] }) { + assert.sameValue(x, 7); + assert.sameValue(y, undefined); + assert.sameValue(z, undefined); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } +}; + +C.method({ w: [7, undefined, ] }).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-prop-eval-err.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-prop-eval-err.js new file mode 100644 index 0000000000..bfb43c4555 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-prop-eval-err.js @@ -0,0 +1,80 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-eval-err.case +// - src/dstr-binding/error/cls-decl-gen-meth-static.template +/*--- +description: Evaluation of property name returns an abrupt completion (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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(); +} + +class C { + static *method({ [thrower()]: x }) {} +}; + +assert.throws(Test262Error, function() { + C.method({}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-prop-id-get-value-err.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-prop-id-get-value-err.js new file mode 100644 index 0000000000..6f70fc507a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-prop-id-get-value-err.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-get-value-err.case +// - src/dstr-binding/error/cls-decl-gen-meth-static.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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(); + } +}); + +class C { + static *method({ poisoned: x = ++initEvalCount }) {} +}; + +assert.throws(Test262Error, function() { + C.method(poisonedProperty); +}); + +assert.sameValue(initEvalCount, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-prop-id-init-skipped.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-prop-id-init-skipped.js new file mode 100644 index 0000000000..1d7a5f67f5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-prop-id-init-skipped.js @@ -0,0 +1,102 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-skipped.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +class C { + static *method({ s: t = counter(), u: v = counter(), w: x = counter(), y: z = counter() }) { + assert.sameValue(t, null); + assert.sameValue(v, 0); + assert.sameValue(x, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + + assert.throws(ReferenceError, function() { + s; + }); + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } +}; + +C.method({ s: null, u: 0, w: false, y: '' }).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-prop-id-init-throws.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-prop-id-init-throws.js new file mode 100644 index 0000000000..c9be76292d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-prop-id-init-throws.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-throws.case +// - src/dstr-binding/error/cls-decl-gen-meth-static.template +/*--- +description: Error thrown when evaluating the initializer (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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(); +} + +class C { + static *method({ x: y = thrower() }) {} +}; + +assert.throws(Test262Error, function() { + C.method({}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-prop-id-init-unresolvable.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-prop-id-init-unresolvable.js new file mode 100644 index 0000000000..3920ec1b93 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-prop-id-init-unresolvable.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-unresolvable.case +// - src/dstr-binding/error/cls-decl-gen-meth-static.template +/*--- +description: Destructuring initializer is an unresolvable reference (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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. +---*/ + +class C { + static *method({ x: y = unresolvableReference }) {} +}; + +assert.throws(ReferenceError, function() { + C.method({}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-prop-id-init.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-prop-id-init.js new file mode 100644 index 0000000000..648afc2365 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-prop-id-init.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: Binding as specified via property name, identifier, and initializer (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static *method({ x: y = 33 }) { + assert.sameValue(y, 33); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } +}; + +C.method({ }).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-prop-id-trailing-comma.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-prop-id-trailing-comma.js new file mode 100644 index 0000000000..e049b373cc --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-prop-id-trailing-comma.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-trailing-comma.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +class C { + static *method({ x: y, }) { + assert.sameValue(y, 23); + + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } +}; + +C.method({ x: 23 }).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-prop-id.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-prop-id.js new file mode 100644 index 0000000000..a444b24983 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-prop-id.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: Binding as specified via property name and identifier (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static *method({ x: y }) { + assert.sameValue(y, 23); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } +}; + +C.method({ x: 23 }).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-prop-obj-init.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-prop-obj-init.js new file mode 100644 index 0000000000..6dc29d04c4 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-prop-obj-init.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-init.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: Object binding pattern with "nested" object binding pattern using initializer (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 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). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +class C { + static *method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } }) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } +}; + +C.method({ w: undefined }).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-prop-obj-value-null.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-prop-obj-value-null.js new file mode 100644 index 0000000000..6d5453ea3e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-prop-obj-value-null.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-null.case +// - src/dstr-binding/error/cls-decl-gen-meth-static.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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. +---*/ + +class C { + static *method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } }) {} +}; + +assert.throws(TypeError, function() { + C.method({ w: null }); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-prop-obj-value-undef.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-prop-obj-value-undef.js new file mode 100644 index 0000000000..4af1f1ec0b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-prop-obj-value-undef.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-undef.case +// - src/dstr-binding/error/cls-decl-gen-meth-static.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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. +---*/ + +class C { + static *method({ w: { x, y, z } = undefined }) {} +}; + +assert.throws(TypeError, function() { + C.method({ }); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-prop-obj.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-prop-obj.js new file mode 100644 index 0000000000..50eb623cb3 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-prop-obj.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: Object binding pattern with "nested" object binding pattern not using initializer (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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. +---*/ + +var callCount = 0; +class C { + static *method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } }) { + assert.sameValue(x, undefined); + assert.sameValue(y, undefined); + assert.sameValue(z, 7); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } +}; + +C.method({ w: { x: undefined, z: 7 } }).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-rest-getter.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-rest-getter.js new file mode 100644 index 0000000000..3d02788c95 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-rest-getter.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-getter.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: Getter is called when obj is being deconstructed to a rest Object (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [object-rest, generators, destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var count = 0; + +var callCount = 0; +class C { + static *method({...x}) { + assert.sameValue(count, 1); + + verifyProperty(x, "v", { + enumerable: true, + writable: true, + configurable: true, + value: 2 + }); + callCount = callCount + 1; + } +}; + +C.method({ get v() { count++; return 2; } }).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-rest-skip-non-enumerable.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-rest-skip-non-enumerable.js new file mode 100644 index 0000000000..ceed609fce --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-rest-skip-non-enumerable.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-skip-non-enumerable.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: Rest object doesn't contain non-enumerable properties (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [object-rest, generators, destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var o = {a: 3, b: 4}; +Object.defineProperty(o, "x", { value: 4, enumerable: false }); + +var callCount = 0; +class C { + static *method({...rest}) { + assert.sameValue(rest.x, undefined); + + verifyProperty(rest, "a", { + enumerable: true, + writable: true, + configurable: true, + value: 3 + }); + + verifyProperty(rest, "b", { + enumerable: true, + writable: true, + configurable: true, + value: 4 + }); + callCount = callCount + 1; + } +}; + +C.method(o).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-rest-val-obj.js b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-rest-val-obj.js new file mode 100644 index 0000000000..a7bba684b3 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/gen-meth-static-obj-ptrn-rest-val-obj.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-val-obj.case +// - src/dstr-binding/default/cls-decl-gen-meth-static.template +/*--- +description: Rest object contains just unextracted data (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [object-rest, generators, destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +class C { + static *method({a, b, ...rest}) { + assert.sameValue(rest.a, undefined); + assert.sameValue(rest.b, undefined); + + verifyProperty(rest, "x", { + enumerable: true, + writable: true, + configurable: true, + value: 1 + }); + + verifyProperty(rest, "y", { + enumerable: true, + writable: true, + configurable: true, + value: 2 + }); + callCount = callCount + 1; + } +}; + +C.method({x: 1, y: 2, a: 5, b: 3}).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-ary-init-iter-close.js b/js/src/tests/test262/language/statements/class/dstr/meth-ary-init-iter-close.js new file mode 100644 index 0000000000..005ab4212b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-ary-init-iter-close.js @@ -0,0 +1,94 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-close.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: Iterator is closed when not exhausted by pattern evaluation (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [Symbol.iterator, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: false }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var callCount = 0; +class C { + method([x]) { + assert.sameValue(doneCallCount, 1); + callCount = callCount + 1; + } +}; + +new C().method(iter); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-ary-init-iter-get-err-array-prototype.js b/js/src/tests/test262/language/statements/class/dstr/meth-ary-init-iter-get-err-array-prototype.js new file mode 100644 index 0000000000..3ea10b1bba --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-ary-init-iter-get-err-array-prototype.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-get-err-array-prototype.case +// - src/dstr-binding/error/cls-decl-meth.template +/*--- +description: Abrupt completion returned by GetIterator (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [Symbol.iterator, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iteratorRecord be ? GetIterator(value). + + GetIterator ( obj [ , hint [ , method ] ] ) + + [...] + 4. Let iterator be ? Call(method, obj). + + Call ( F, V [ , argumentsList ] ) + + [...] + 2. If IsCallable(F) is false, throw a TypeError exception. + +---*/ +delete Array.prototype[Symbol.iterator]; + +class C { + method([x, y, z]) {} +}; + +var c = new C(); + +assert.throws(TypeError, function() { + c.method([1, 2, 3]); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-ary-init-iter-get-err.js b/js/src/tests/test262/language/statements/class/dstr/meth-ary-init-iter-get-err.js new file mode 100644 index 0000000000..f35ae02a6b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-ary-init-iter-get-err.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-get-err.case +// - src/dstr-binding/error/cls-decl-meth.template +/*--- +description: Abrupt completion returned by GetIterator (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [Symbol.iterator, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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(); +}; + +class C { + method([x]) {} +}; + +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(iter); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-ary-init-iter-no-close.js b/js/src/tests/test262/language/statements/class/dstr/meth-ary-init-iter-no-close.js new file mode 100644 index 0000000000..ef34711a63 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-ary-init-iter-no-close.js @@ -0,0 +1,94 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-no-close.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: Iterator is not closed when exhausted by pattern evaluation (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [Symbol.iterator, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: true }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var callCount = 0; +class C { + method([x]) { + assert.sameValue(doneCallCount, 0); + callCount = callCount + 1; + } +}; + +new C().method(iter); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-ary-name-iter-val.js b/js/src/tests/test262/language/statements/class/dstr/meth-ary-name-iter-val.js new file mode 100644 index 0000000000..de708238d2 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-ary-name-iter-val.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-name-iter-val.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: SingleNameBinding with normal value iteration (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + method([x, y, z]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; + } +}; + +new C().method([1, 2, 3]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-ary-elem-init.js b/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-ary-elem-init.js new file mode 100644 index 0000000000..0ab7d31f63 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-ary-elem-init.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-init.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: BindingElement with array binding pattern and initializer is used (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + method([[x, y, z] = [4, 5, 6]]) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + callCount = callCount + 1; + } +}; + +new C().method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-ary-elem-iter.js b/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-ary-elem-iter.js new file mode 100644 index 0000000000..bff42e9ed6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-ary-elem-iter.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-iter.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + method([[x, y, z] = [4, 5, 6]]) { + assert.sameValue(x, 7); + assert.sameValue(y, 8); + assert.sameValue(z, 9); + callCount = callCount + 1; + } +}; + +new C().method([[7, 8, 9]]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-ary-elision-init.js b/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-ary-elision-init.js new file mode 100644 index 0000000000..6664c608dc --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-ary-elision-init.js @@ -0,0 +1,92 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-init.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: BindingElement with array binding pattern and initializer is used (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +class C { + method([[,] = g()]) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; + } +}; + +new C().method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-ary-elision-iter.js b/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-ary-elision-iter.js new file mode 100644 index 0000000000..d039d4a783 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-ary-elision-iter.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-iter.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var callCount = 0; +function* g() { + callCount += 1; +}; + +var callCount = 0; +class C { + method([[,] = g()]) { + assert.sameValue(callCount, 0); + callCount = callCount + 1; + } +}; + +new C().method([[]]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-ary-empty-init.js b/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-ary-empty-init.js new file mode 100644 index 0000000000..ea075f405c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-ary-empty-init.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-init.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: BindingElement with array binding pattern and initializer is used (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var initCount = 0; +var iterCount = 0; +var iter = function*() { iterCount += 1; }(); + +var callCount = 0; +class C { + method([[] = function() { initCount += 1; return iter; }()]) { + assert.sameValue(initCount, 1); + assert.sameValue(iterCount, 0); + callCount = callCount + 1; + } +}; + +new C().method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-ary-empty-iter.js b/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-ary-empty-iter.js new file mode 100644 index 0000000000..afaa677dfa --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-ary-empty-iter.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-iter.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var initCount = 0; + +var callCount = 0; +class C { + method([[] = function() { initCount += 1; }()]) { + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +new C().method([[23]]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-ary-rest-init.js b/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-ary-rest-init.js new file mode 100644 index 0000000000..0d70ed2f3a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-ary-rest-init.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-init.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: BindingElement with array binding pattern and initializer is used (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; + +var callCount = 0; +class C { + method([[...x] = values]) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + callCount = callCount + 1; + } +}; + +new C().method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-ary-rest-iter.js b/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-ary-rest-iter.js new file mode 100644 index 0000000000..973529fd11 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-ary-rest-iter.js @@ -0,0 +1,92 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-iter.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; +var initCount = 0; + +var callCount = 0; +class C { + method([[...x] = function() { initCount += 1; }()]) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +new C().method([values]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-ary-val-null.js b/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-ary-val-null.js new file mode 100644 index 0000000000..17ecd68f3a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-ary-val-null.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-val-null.case +// - src/dstr-binding/error/cls-decl-meth.template +/*--- +description: Nested array destructuring with a null value (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). +---*/ + +class C { + method([[x]]) {} +}; + +var c = new C(); + +assert.throws(TypeError, function() { + c.method([null]); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-id-init-exhausted.js b/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-id-init-exhausted.js new file mode 100644 index 0000000000..f646aeeb91 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-id-init-exhausted.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-exhausted.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: Destructuring initializer with an exhausted iterator (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + method([x = 23]) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } +}; + +new C().method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-id-init-fn-name-arrow.js b/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..386cf5f99a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-id-init-fn-name-arrow.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-arrow.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: SingleNameBinding does assign name to arrow functions (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + method([arrow = () => {}]) { + assert.sameValue(arrow.name, 'arrow'); + callCount = callCount + 1; + } +}; + +new C().method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-id-init-fn-name-class.js b/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-id-init-fn-name-class.js new file mode 100644 index 0000000000..cbb022ae7f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-id-init-fn-name-class.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-class.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + method([cls = class {}, xCls = class X {}, xCls2 = class { static name() {} }]) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + assert.notSameValue(xCls2.name, 'xCls2'); + callCount = callCount + 1; + } +}; + +new C().method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-id-init-fn-name-cover.js b/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-id-init-fn-name-cover.js new file mode 100644 index 0000000000..3ff3b6d099 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-id-init-fn-name-cover.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-cover.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: SingleNameBinding does assign name to "anonymous" functions "through" cover grammar (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + method([cover = (function () {}), xCover = (0, function() {})]) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + callCount = callCount + 1; + } +}; + +new C().method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-id-init-fn-name-fn.js b/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-id-init-fn-name-fn.js new file mode 100644 index 0000000000..cf77ae9bb8 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-id-init-fn-name-fn.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-fn.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + method([fn = function () {}, xFn = function x() {}]) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + callCount = callCount + 1; + } +}; + +new C().method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-id-init-fn-name-gen.js b/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-id-init-fn-name-gen.js new file mode 100644 index 0000000000..d5d602bcac --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-id-init-fn-name-gen.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-gen.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). + +---*/ + +var callCount = 0; +class C { + method([gen = function* () {}, xGen = function* x() {}]) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + callCount = callCount + 1; + } +}; + +new C().method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-id-init-hole.js b/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-id-init-hole.js new file mode 100644 index 0000000000..ffc7ee9150 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-id-init-hole.js @@ -0,0 +1,80 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-hole.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: Destructuring initializer with a "hole" (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + [...] + 7. If environment is undefined, return PutValue(lhs, v). 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + method([x = 23]) { + assert.sameValue(x, 23); + // another statement + callCount = callCount + 1; + } +}; + +new C().method([,]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-id-init-skipped.js b/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-id-init-skipped.js new file mode 100644 index 0000000000..e42b431c4f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-id-init-skipped.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-skipped.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +class C { + method([w = counter(), x = counter(), y = counter(), z = counter()]) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +new C().method([null, 0, false, '']); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-id-init-throws.js b/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-id-init-throws.js new file mode 100644 index 0000000000..5d64c1244c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-id-init-throws.js @@ -0,0 +1,80 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-throws.case +// - src/dstr-binding/error/cls-decl-meth.template +/*--- +description: Destructuring initializer returns an abrupt completion (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). +---*/ + +class C { + method([x = (function() { throw new Test262Error(); })()]) {} +}; + +var c = new C(); + +assert.throws(Test262Error, function() { + c.method([undefined]); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-id-init-undef.js b/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-id-init-undef.js new file mode 100644 index 0000000000..d637e61223 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-id-init-undef.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-undef.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: Destructuring initializer with an undefined value (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + method([x = 23]) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } +}; + +new C().method([undefined]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-id-init-unresolvable.js b/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-id-init-unresolvable.js new file mode 100644 index 0000000000..4e2298f444 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-id-init-unresolvable.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-unresolvable.case +// - src/dstr-binding/error/cls-decl-meth.template +/*--- +description: Destructuring initializer is an unresolvable reference (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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. +---*/ + +class C { + method([ x = unresolvableReference ]) {} +}; + +var c = new C(); + +assert.throws(ReferenceError, function() { + c.method([]); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-id-iter-complete.js b/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-id-iter-complete.js new file mode 100644 index 0000000000..ad42383ae3 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-id-iter-complete.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-complete.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: SingleNameBinding when value iteration completes (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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, + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + method([x]) { + assert.sameValue(x, undefined); + callCount = callCount + 1; + } +}; + +new C().method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-id-iter-done.js b/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-id-iter-done.js new file mode 100644 index 0000000000..5104806e25 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-id-iter-done.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-done.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: SingleNameBinding when value iteration was completed previously (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + method([_, x]) { + assert.sameValue(x, undefined); + callCount = callCount + 1; + } +}; + +new C().method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-id-iter-step-err.js b/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-id-iter-step-err.js new file mode 100644 index 0000000000..cf3dfa6ef2 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-id-iter-step-err.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-step-err.case +// - src/dstr-binding/error/cls-decl-meth.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [Symbol.iterator, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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(); + } + }; +}; + +class C { + method([x]) {} +}; + +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(g); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-id-iter-val-array-prototype.js b/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-id-iter-val-array-prototype.js new file mode 100644 index 0000000000..14d0ad72ea --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-id-iter-val-array-prototype.js @@ -0,0 +1,103 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val-array-prototype.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: Array destructuring uses overriden Array.prototype[Symbol.iterator] (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [Symbol.iterator, generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializer_opt + + 1. Let bindingId be StringValue of BindingIdentifier. + 2. Let lhs be ? ResolveBinding(bindingId, environment). + 3. If iteratorRecord.[[Done]] is false, then + a. Let next be IteratorStep(iteratorRecord). + 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). + [...] + 7. Return InitializeReferencedBinding(lhs, v). + +---*/ +Array.prototype[Symbol.iterator] = function* () { + if (this.length > 0) { + yield this[0]; + } + if (this.length > 1) { + yield this[1]; + } + if (this.length > 2) { + yield 42; + } +}; + +var callCount = 0; +class C { + method([x, y, z]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 42); + callCount = callCount + 1; + } +}; + +new C().method([1, 2, 3]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-id-iter-val-err.js b/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-id-iter-val-err.js new file mode 100644 index 0000000000..96b3148560 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-id-iter-val-err.js @@ -0,0 +1,100 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val-err.case +// - src/dstr-binding/error/cls-decl-meth.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [Symbol.iterator, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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; + } + }; +}; + +class C { + method([x]) {} +}; + +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(g); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-id-iter-val.js b/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-id-iter-val.js new file mode 100644 index 0000000000..68833d503e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-id-iter-val.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: SingleNameBinding when value iteration was completed previously (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + method([x, y, z]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; + } +}; + +new C().method([1, 2, 3]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-obj-id-init.js b/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-obj-id-init.js new file mode 100644 index 0000000000..6cbe47422c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-obj-id-init.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id-init.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: BindingElement with object binding pattern and initializer is used (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + method([{ x, y, z } = { x: 44, y: 55, z: 66 }]) { + assert.sameValue(x, 44); + assert.sameValue(y, 55); + assert.sameValue(z, 66); + callCount = callCount + 1; + } +}; + +new C().method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-obj-id.js b/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-obj-id.js new file mode 100644 index 0000000000..95650ac497 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-obj-id.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + method([{ x, y, z } = { x: 44, y: 55, z: 66 }]) { + assert.sameValue(x, 11); + assert.sameValue(y, 22); + assert.sameValue(z, 33); + callCount = callCount + 1; + } +}; + +new C().method([{ x: 11, y: 22, z: 33 }]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-obj-prop-id-init.js b/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-obj-prop-id-init.js new file mode 100644 index 0000000000..db9badd5e6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-obj-prop-id-init.js @@ -0,0 +1,95 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id-init.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: BindingElement with object binding pattern and initializer is used (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + method([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }]) { + assert.sameValue(v, 444); + assert.sameValue(x, 555); + assert.sameValue(z, 666); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } +}; + +new C().method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-obj-prop-id.js b/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-obj-prop-id.js new file mode 100644 index 0000000000..8304975b93 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-obj-prop-id.js @@ -0,0 +1,95 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + method([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }]) { + assert.sameValue(v, 777); + assert.sameValue(x, 888); + assert.sameValue(z, 999); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } +}; + +new C().method([{ u: 777, w: 888, y: 999 }]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-obj-val-null.js b/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-obj-val-null.js new file mode 100644 index 0000000000..7657d0414d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-obj-val-null.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-null.case +// - src/dstr-binding/error/cls-decl-meth.template +/*--- +description: Nested object destructuring with a null value (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). +---*/ + +class C { + method([{ x }]) {} +}; + +var c = new C(); + +assert.throws(TypeError, function() { + c.method([null]); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-obj-val-undef.js b/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-obj-val-undef.js new file mode 100644 index 0000000000..df76a7f537 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elem-obj-val-undef.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-undef.case +// - src/dstr-binding/error/cls-decl-meth.template +/*--- +description: Nested object destructuring with a value of `undefined` (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). +---*/ + +class C { + method([{ x }]) {} +}; + +var c = new C(); + +assert.throws(TypeError, function() { + c.method([]); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elision-exhausted.js b/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elision-exhausted.js new file mode 100644 index 0000000000..46ac9945fc --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elision-exhausted.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-exhausted.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: Elision accepts exhausted iterator (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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 + [...] + 2. Return NormalCompletion(empty). + +---*/ +var iter = function*() {}(); +iter.next(); + +var callCount = 0; +class C { + method([,]) { + + callCount = callCount + 1; + } +}; + +new C().method(iter); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elision-step-err.js b/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elision-step-err.js new file mode 100644 index 0000000000..ea26c3aaf7 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elision-step-err.js @@ -0,0 +1,96 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-step-err.case +// - src/dstr-binding/error/cls-decl-meth.template +/*--- +description: Elision advances iterator and forwards abrupt completions (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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; +}(); + +class C { + method([,]) {} +}; + +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(iter); +}); + +iter.next(); +assert.sameValue(following, 0, 'Iterator was properly closed.'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elision.js b/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elision.js new file mode 100644 index 0000000000..94695ff321 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-elision.js @@ -0,0 +1,99 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: Elision advances iterator (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +class C { + method([,]) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; + } +}; + +new C().method(g()); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-empty.js b/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-empty.js new file mode 100644 index 0000000000..fef6b48e0c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-empty.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-empty.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: No iteration occurs for an "empty" array binding pattern (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var callCount = 0; +class C { + method([]) { + assert.sameValue(iterations, 0); + callCount = callCount + 1; + } +}; + +new C().method(iter); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-rest-ary-elem.js b/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-rest-ary-elem.js new file mode 100644 index 0000000000..21cd0216f7 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-rest-ary-elem.js @@ -0,0 +1,106 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elem.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: Rest element containing an array BindingElementList pattern (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the 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). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + method([...[x, y, z]]) { + assert.sameValue(x, 3); + assert.sameValue(y, 4); + assert.sameValue(z, 5); + callCount = callCount + 1; + } +}; + +new C().method([3, 4, 5]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-rest-ary-elision.js b/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-rest-ary-elision.js new file mode 100644 index 0000000000..7522fe40c6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-rest-ary-elision.js @@ -0,0 +1,112 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elision.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: Rest element containing an elision (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the 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). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +class C { + method([...[,]]) { + assert.sameValue(first, 1); + assert.sameValue(second, 1); + callCount = callCount + 1; + } +}; + +new C().method(g()); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-rest-ary-empty.js b/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-rest-ary-empty.js new file mode 100644 index 0000000000..155abede58 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-rest-ary-empty.js @@ -0,0 +1,95 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-empty.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: Rest element containing an "empty" array pattern (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var callCount = 0; +class C { + method([...[]]) { + assert.sameValue(iterations, 1); + callCount = callCount + 1; + } +}; + +new C().method(iter); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-rest-ary-rest.js b/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-rest-ary-rest.js new file mode 100644 index 0000000000..4bd1b7640c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-rest-ary-rest.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-rest.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: Rest element containing a rest element (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ +var values = [1, 2, 3]; + +var callCount = 0; +class C { + method([...[...x]]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + + callCount = callCount + 1; + } +}; + +new C().method(values); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-rest-id-direct.js b/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-rest-id-direct.js new file mode 100644 index 0000000000..88b8749969 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-rest-id-direct.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-direct.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: Lone rest element (direct binding) (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +includes: [compareArray.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingIdentifier + + [...] + 2. Let A be ! ArrayCreate(0). + 3. Let n be 0. + 4. Repeat, + [...] + f. Perform ! CreateDataPropertyOrThrow(A, ! ToString(n), nextValue). + g. Set n to n + 1. + +---*/ + +var callCount = 0; +class C { + method([...x]) { + assert(Array.isArray(x)); + assert.compareArray(x, [1]); + callCount = callCount + 1; + } +}; + +new C().method([1]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-rest-id-elision-next-err.js b/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-rest-id-elision-next-err.js new file mode 100644 index 0000000000..aae9152dc8 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-rest-id-elision-next-err.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision-next-err.case +// - src/dstr-binding/error/cls-decl-meth.template +/*--- +description: Rest element following elision elements (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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(); })(); + +class C { + method([, ...x]) {} +}; + +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(iter); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-rest-id-elision.js b/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-rest-id-elision.js new file mode 100644 index 0000000000..c8e14a5038 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-rest-id-elision.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: Rest element following elision elements (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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 values = [1, 2, 3, 4, 5]; + +var callCount = 0; +class C { + method([ , , ...x]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 3); + assert.sameValue(x[1], 4); + assert.sameValue(x[2], 5); + assert.notSameValue(x, values); + callCount = callCount + 1; + } +}; + +new C().method(values); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-rest-id-exhausted.js b/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-rest-id-exhausted.js new file mode 100644 index 0000000000..36b68b678e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-rest-id-exhausted.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-exhausted.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: RestElement applied to an exhausted iterator (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [Symbol.iterator, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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, + [...] + b. If iteratorRecord.[[done]] is true, then + i. If environment is undefined, return PutValue(lhs, A). + ii. Return InitializeReferencedBinding(lhs, A). + +---*/ + +var callCount = 0; +class C { + method([, , ...x]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 0); + callCount = callCount + 1; + } +}; + +new C().method([1, 2]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-rest-id-iter-step-err.js b/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-rest-id-iter-step-err.js new file mode 100644 index 0000000000..4e8dbe5587 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-rest-id-iter-step-err.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-step-err.case +// - src/dstr-binding/error/cls-decl-meth.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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; +}(); + +class C { + method([...x]) {} +}; + +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(iter); +}); + +iter.next(); +assert.sameValue(first, 1); +assert.sameValue(second, 0, 'Iterator is closed following abrupt completion.'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-rest-id-iter-val-err.js b/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-rest-id-iter-val-err.js new file mode 100644 index 0000000000..017032252e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-rest-id-iter-val-err.js @@ -0,0 +1,95 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-val-err.case +// - src/dstr-binding/error/cls-decl-meth.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [Symbol.iterator, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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; + } + }; +}; + +class C { + method([...x]) {} +}; + +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(iter); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-rest-id.js b/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-rest-id.js new file mode 100644 index 0000000000..2dd80d774b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-rest-id.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: Lone rest element (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + [...] 3. Let A be ArrayCreate(0). [...] 5. Repeat + [...] + f. Let status be CreateDataProperty(A, ToString (n), nextValue). + [...] +---*/ +var values = [1, 2, 3]; + +var callCount = 0; +class C { + method([...x]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + callCount = callCount + 1; + } +}; + +new C().method(values); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-rest-init-ary.js b/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-rest-init-ary.js new file mode 100644 index 0000000000..d2bc0a9903 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-rest-init-ary.js @@ -0,0 +1,80 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-ary.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: Rest element (nested array pattern) does not support initializer (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var callCount = 0; +class C { + method([...[ x ] = []]) { + + callCount = callCount + 1; + } +}; + +new C().method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-rest-init-id.js b/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-rest-init-id.js new file mode 100644 index 0000000000..996eec5e90 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-rest-init-id.js @@ -0,0 +1,80 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-id.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: Rest element (identifier) does not support initializer (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var callCount = 0; +class C { + method([...x = []]) { + + callCount = callCount + 1; + } +}; + +new C().method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-rest-init-obj.js b/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-rest-init-obj.js new file mode 100644 index 0000000000..388e6f26b5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-rest-init-obj.js @@ -0,0 +1,80 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-obj.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: Rest element (nested object pattern) does not support initializer (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var callCount = 0; +class C { + method([...{ x } = []]) { + + callCount = callCount + 1; + } +}; + +new C().method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-rest-not-final-ary.js b/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-rest-not-final-ary.js new file mode 100644 index 0000000000..2a6de08dfa --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-rest-not-final-ary.js @@ -0,0 +1,80 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-ary.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: Rest element (array binding pattern) may not be followed by any element (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var callCount = 0; +class C { + method([...[x], y]) { + + callCount = callCount + 1; + } +}; + +new C().method([1, 2, 3]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-rest-not-final-id.js b/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-rest-not-final-id.js new file mode 100644 index 0000000000..0ee09dfa59 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-rest-not-final-id.js @@ -0,0 +1,80 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-id.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: Rest element (identifier) may not be followed by any element (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var callCount = 0; +class C { + method([...x, y]) { + + callCount = callCount + 1; + } +}; + +new C().method([1, 2, 3]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-rest-not-final-obj.js b/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-rest-not-final-obj.js new file mode 100644 index 0000000000..140b929319 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-rest-not-final-obj.js @@ -0,0 +1,80 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-obj.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: Rest element (object binding pattern) may not be followed by any element (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var callCount = 0; +class C { + method([...{ x }, y]) { + + callCount = callCount + 1; + } +}; + +new C().method([1, 2, 3]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-rest-obj-id.js b/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-rest-obj-id.js new file mode 100644 index 0000000000..a9a9252c74 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-rest-obj-id.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-id.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: Rest element containing an object binding pattern (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ + +var callCount = 0; +class C { + method([...{ length }]) { + assert.sameValue(length, 3); + callCount = callCount + 1; + } +}; + +new C().method([1, 2, 3]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-rest-obj-prop-id.js b/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-rest-obj-prop-id.js new file mode 100644 index 0000000000..a9d8735976 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-ary-ptrn-rest-obj-prop-id.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-prop-id.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: Rest element containing an object binding pattern (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ +let length = "outer"; + +var callCount = 0; +class C { + method([...{ 0: v, 1: w, 2: x, 3: y, length: z }]) { + assert.sameValue(v, 7); + assert.sameValue(w, 8); + assert.sameValue(x, 9); + assert.sameValue(y, undefined); + assert.sameValue(z, 3); + + assert.sameValue(length, "outer", "the length prop is not set as a binding name"); + callCount = callCount + 1; + } +}; + +new C().method([7, 8, 9]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-init-iter-close.js b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-init-iter-close.js new file mode 100644 index 0000000000..d5fd2fde69 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-init-iter-close.js @@ -0,0 +1,94 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-close.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: Iterator is closed when not exhausted by pattern evaluation (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [Symbol.iterator, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: false }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var callCount = 0; +class C { + method([x] = iter) { + assert.sameValue(doneCallCount, 1); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-init-iter-get-err-array-prototype.js b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-init-iter-get-err-array-prototype.js new file mode 100644 index 0000000000..7447e35f81 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-init-iter-get-err-array-prototype.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-get-err-array-prototype.case +// - src/dstr-binding/error/cls-decl-meth-dflt.template +/*--- +description: Abrupt completion returned by GetIterator (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [Symbol.iterator, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iteratorRecord be ? GetIterator(value). + + GetIterator ( obj [ , hint [ , method ] ] ) + + [...] + 4. Let iterator be ? Call(method, obj). + + Call ( F, V [ , argumentsList ] ) + + [...] + 2. If IsCallable(F) is false, throw a TypeError exception. + +---*/ +delete Array.prototype[Symbol.iterator]; + +class C { + method([x, y, z] = [1, 2, 3]) {} +}; + +var c = new C(); + +assert.throws(TypeError, function() { + c.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-init-iter-get-err.js b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-init-iter-get-err.js new file mode 100644 index 0000000000..3e33190ed1 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-init-iter-get-err.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-get-err.case +// - src/dstr-binding/error/cls-decl-meth-dflt.template +/*--- +description: Abrupt completion returned by GetIterator (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [Symbol.iterator, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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(); +}; + +class C { + method([x] = iter) {} +}; + +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-init-iter-no-close.js b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-init-iter-no-close.js new file mode 100644 index 0000000000..4d2b4afbe3 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-init-iter-no-close.js @@ -0,0 +1,94 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-no-close.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: Iterator is not closed when exhausted by pattern evaluation (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [Symbol.iterator, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: true }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var callCount = 0; +class C { + method([x] = iter) { + assert.sameValue(doneCallCount, 0); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-name-iter-val.js b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-name-iter-val.js new file mode 100644 index 0000000000..a750f1a5f9 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-name-iter-val.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-name-iter-val.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: SingleNameBinding with normal value iteration (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + method([x, y, z] = [1, 2, 3]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-ary-elem-init.js b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-ary-elem-init.js new file mode 100644 index 0000000000..b9a8aaa625 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-ary-elem-init.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-init.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + method([[x, y, z] = [4, 5, 6]] = []) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-ary-elem-iter.js b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-ary-elem-iter.js new file mode 100644 index 0000000000..ed81931b07 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-ary-elem-iter.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-iter.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + method([[x, y, z] = [4, 5, 6]] = [[7, 8, 9]]) { + assert.sameValue(x, 7); + assert.sameValue(y, 8); + assert.sameValue(z, 9); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-ary-elision-init.js b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-ary-elision-init.js new file mode 100644 index 0000000000..18a060e4b5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-ary-elision-init.js @@ -0,0 +1,92 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-init.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +class C { + method([[,] = g()] = []) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-ary-elision-iter.js b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-ary-elision-iter.js new file mode 100644 index 0000000000..ca7a23457d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-ary-elision-iter.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-iter.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var callCount = 0; +function* g() { + callCount += 1; +}; + +var callCount = 0; +class C { + method([[,] = g()] = [[]]) { + assert.sameValue(callCount, 0); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-ary-empty-init.js b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-ary-empty-init.js new file mode 100644 index 0000000000..7557d56e0a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-ary-empty-init.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-init.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var initCount = 0; +var iterCount = 0; +var iter = function*() { iterCount += 1; }(); + +var callCount = 0; +class C { + method([[] = function() { initCount += 1; return iter; }()] = []) { + assert.sameValue(initCount, 1); + assert.sameValue(iterCount, 0); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-ary-empty-iter.js b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-ary-empty-iter.js new file mode 100644 index 0000000000..5a2e1e20f9 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-ary-empty-iter.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-iter.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var initCount = 0; + +var callCount = 0; +class C { + method([[] = function() { initCount += 1; }()] = [[23]]) { + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-ary-rest-init.js b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-ary-rest-init.js new file mode 100644 index 0000000000..8106d4e1c4 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-ary-rest-init.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-init.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; + +var callCount = 0; +class C { + method([[...x] = values] = []) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-ary-rest-iter.js b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-ary-rest-iter.js new file mode 100644 index 0000000000..d9739b0256 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-ary-rest-iter.js @@ -0,0 +1,92 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-iter.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; +var initCount = 0; + +var callCount = 0; +class C { + method([[...x] = function() { initCount += 1; }()] = [values]) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-ary-val-null.js b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-ary-val-null.js new file mode 100644 index 0000000000..f52f2de2cc --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-ary-val-null.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-val-null.case +// - src/dstr-binding/error/cls-decl-meth-dflt.template +/*--- +description: Nested array destructuring with a null value (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). +---*/ + +class C { + method([[x]] = [null]) {} +}; + +var c = new C(); + +assert.throws(TypeError, function() { + c.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-id-init-exhausted.js b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-id-init-exhausted.js new file mode 100644 index 0000000000..401917ddc4 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-id-init-exhausted.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-exhausted.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: Destructuring initializer with an exhausted iterator (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + method([x = 23] = []) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..2880a9e9a4 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-arrow.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: SingleNameBinding does assign name to arrow functions (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + method([arrow = () => {}] = []) { + assert.sameValue(arrow.name, 'arrow'); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-id-init-fn-name-class.js b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-id-init-fn-name-class.js new file mode 100644 index 0000000000..127d3c4cc2 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-id-init-fn-name-class.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-class.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + method([cls = class {}, xCls = class X {}, xCls2 = class { static name() {} }] = []) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + assert.notSameValue(xCls2.name, 'xCls2'); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-id-init-fn-name-cover.js b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-id-init-fn-name-cover.js new file mode 100644 index 0000000000..9879ac042c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-id-init-fn-name-cover.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-cover.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: SingleNameBinding does assign name to "anonymous" functions "through" cover grammar (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + method([cover = (function () {}), xCover = (0, function() {})] = []) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-id-init-fn-name-fn.js b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-id-init-fn-name-fn.js new file mode 100644 index 0000000000..8981ce4a2a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-id-init-fn-name-fn.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-fn.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + method([fn = function () {}, xFn = function x() {}] = []) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-id-init-fn-name-gen.js b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-id-init-fn-name-gen.js new file mode 100644 index 0000000000..756deb15da --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-id-init-fn-name-gen.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-gen.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). + +---*/ + +var callCount = 0; +class C { + method([gen = function* () {}, xGen = function* x() {}] = []) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-id-init-hole.js b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-id-init-hole.js new file mode 100644 index 0000000000..9e2d008c33 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-id-init-hole.js @@ -0,0 +1,80 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-hole.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: Destructuring initializer with a "hole" (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + [...] + 7. If environment is undefined, return PutValue(lhs, v). 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + method([x = 23] = [,]) { + assert.sameValue(x, 23); + // another statement + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-id-init-skipped.js b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-id-init-skipped.js new file mode 100644 index 0000000000..364f518c22 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-id-init-skipped.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-skipped.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +class C { + method([w = counter(), x = counter(), y = counter(), z = counter()] = [null, 0, false, '']) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-id-init-throws.js b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-id-init-throws.js new file mode 100644 index 0000000000..636e8b17c8 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-id-init-throws.js @@ -0,0 +1,80 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-throws.case +// - src/dstr-binding/error/cls-decl-meth-dflt.template +/*--- +description: Destructuring initializer returns an abrupt completion (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). +---*/ + +class C { + method([x = (function() { throw new Test262Error(); })()] = [undefined]) {} +}; + +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-id-init-undef.js b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-id-init-undef.js new file mode 100644 index 0000000000..0aa4f7af54 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-id-init-undef.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-undef.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: Destructuring initializer with an undefined value (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + method([x = 23] = [undefined]) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-id-init-unresolvable.js b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-id-init-unresolvable.js new file mode 100644 index 0000000000..5f3153fb69 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-id-init-unresolvable.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-unresolvable.case +// - src/dstr-binding/error/cls-decl-meth-dflt.template +/*--- +description: Destructuring initializer is an unresolvable reference (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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. +---*/ + +class C { + method([ x = unresolvableReference ] = []) {} +}; + +var c = new C(); + +assert.throws(ReferenceError, function() { + c.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-id-iter-complete.js b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-id-iter-complete.js new file mode 100644 index 0000000000..4c9d487bd8 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-id-iter-complete.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-complete.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: SingleNameBinding when value iteration completes (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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, + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + method([x] = []) { + assert.sameValue(x, undefined); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-id-iter-done.js b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-id-iter-done.js new file mode 100644 index 0000000000..9e3930e1c3 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-id-iter-done.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-done.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: SingleNameBinding when value iteration was completed previously (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + method([_, x] = []) { + assert.sameValue(x, undefined); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-id-iter-step-err.js b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-id-iter-step-err.js new file mode 100644 index 0000000000..32dd893be0 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-id-iter-step-err.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-step-err.case +// - src/dstr-binding/error/cls-decl-meth-dflt.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [Symbol.iterator, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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(); + } + }; +}; + +class C { + method([x] = g) {} +}; + +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-id-iter-val-array-prototype.js b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-id-iter-val-array-prototype.js new file mode 100644 index 0000000000..2b19156b41 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-id-iter-val-array-prototype.js @@ -0,0 +1,103 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val-array-prototype.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: Array destructuring uses overriden Array.prototype[Symbol.iterator] (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [Symbol.iterator, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializer_opt + + 1. Let bindingId be StringValue of BindingIdentifier. + 2. Let lhs be ? ResolveBinding(bindingId, environment). + 3. If iteratorRecord.[[Done]] is false, then + a. Let next be IteratorStep(iteratorRecord). + 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). + [...] + 7. Return InitializeReferencedBinding(lhs, v). + +---*/ +Array.prototype[Symbol.iterator] = function* () { + if (this.length > 0) { + yield this[0]; + } + if (this.length > 1) { + yield this[1]; + } + if (this.length > 2) { + yield 42; + } +}; + +var callCount = 0; +class C { + method([x, y, z] = [1, 2, 3]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 42); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-id-iter-val-err.js b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-id-iter-val-err.js new file mode 100644 index 0000000000..75827ac733 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-id-iter-val-err.js @@ -0,0 +1,100 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val-err.case +// - src/dstr-binding/error/cls-decl-meth-dflt.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [Symbol.iterator, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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; + } + }; +}; + +class C { + method([x] = g) {} +}; + +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-id-iter-val.js b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-id-iter-val.js new file mode 100644 index 0000000000..e605a40034 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-id-iter-val.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: SingleNameBinding when value iteration was completed previously (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + method([x, y, z] = [1, 2, 3]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-obj-id-init.js b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-obj-id-init.js new file mode 100644 index 0000000000..ed59a156b4 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-obj-id-init.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id-init.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is used (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + method([{ x, y, z } = { x: 44, y: 55, z: 66 }] = []) { + assert.sameValue(x, 44); + assert.sameValue(y, 55); + assert.sameValue(z, 66); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-obj-id.js b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-obj-id.js new file mode 100644 index 0000000000..89f8f2a890 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-obj-id.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + method([{ x, y, z } = { x: 44, y: 55, z: 66 }] = [{ x: 11, y: 22, z: 33 }]) { + assert.sameValue(x, 11); + assert.sameValue(y, 22); + assert.sameValue(z, 33); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-obj-prop-id-init.js b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-obj-prop-id-init.js new file mode 100644 index 0000000000..2916687ce2 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-obj-prop-id-init.js @@ -0,0 +1,95 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id-init.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is used (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + method([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] = []) { + assert.sameValue(v, 444); + assert.sameValue(x, 555); + assert.sameValue(z, 666); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-obj-prop-id.js b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-obj-prop-id.js new file mode 100644 index 0000000000..162a807165 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-obj-prop-id.js @@ -0,0 +1,95 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + method([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] = [{ u: 777, w: 888, y: 999 }]) { + assert.sameValue(v, 777); + assert.sameValue(x, 888); + assert.sameValue(z, 999); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-obj-val-null.js b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-obj-val-null.js new file mode 100644 index 0000000000..4fca071ff6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-obj-val-null.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-null.case +// - src/dstr-binding/error/cls-decl-meth-dflt.template +/*--- +description: Nested object destructuring with a null value (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). +---*/ + +class C { + method([{ x }] = [null]) {} +}; + +var c = new C(); + +assert.throws(TypeError, function() { + c.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-obj-val-undef.js b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-obj-val-undef.js new file mode 100644 index 0000000000..cd17eac0cb --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elem-obj-val-undef.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-undef.case +// - src/dstr-binding/error/cls-decl-meth-dflt.template +/*--- +description: Nested object destructuring with a value of `undefined` (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). +---*/ + +class C { + method([{ x }] = []) {} +}; + +var c = new C(); + +assert.throws(TypeError, function() { + c.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elision-exhausted.js b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elision-exhausted.js new file mode 100644 index 0000000000..86f9bbf5b9 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elision-exhausted.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-exhausted.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: Elision accepts exhausted iterator (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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 + [...] + 2. Return NormalCompletion(empty). + +---*/ +var iter = function*() {}(); +iter.next(); + +var callCount = 0; +class C { + method([,] = iter) { + + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elision-step-err.js b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elision-step-err.js new file mode 100644 index 0000000000..e7be6aac4e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elision-step-err.js @@ -0,0 +1,96 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-step-err.case +// - src/dstr-binding/error/cls-decl-meth-dflt.template +/*--- +description: Elision advances iterator and forwards abrupt completions (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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; +}(); + +class C { + method([,] = iter) {} +}; + +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(); +}); + +iter.next(); +assert.sameValue(following, 0, 'Iterator was properly closed.'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elision.js b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elision.js new file mode 100644 index 0000000000..4b19df93bf --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-elision.js @@ -0,0 +1,99 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: Elision advances iterator (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +class C { + method([,] = g()) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-empty.js b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-empty.js new file mode 100644 index 0000000000..7a98296dd6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-empty.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-empty.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: No iteration occurs for an "empty" array binding pattern (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var callCount = 0; +class C { + method([] = iter) { + assert.sameValue(iterations, 0); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-rest-ary-elem.js b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-rest-ary-elem.js new file mode 100644 index 0000000000..af0957121c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-rest-ary-elem.js @@ -0,0 +1,106 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elem.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: Rest element containing an array BindingElementList pattern (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the 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). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + method([...[x, y, z]] = [3, 4, 5]) { + assert.sameValue(x, 3); + assert.sameValue(y, 4); + assert.sameValue(z, 5); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-rest-ary-elision.js b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-rest-ary-elision.js new file mode 100644 index 0000000000..4b92ccdcb6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-rest-ary-elision.js @@ -0,0 +1,112 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elision.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: Rest element containing an elision (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the 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). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +class C { + method([...[,]] = g()) { + assert.sameValue(first, 1); + assert.sameValue(second, 1); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-rest-ary-empty.js b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-rest-ary-empty.js new file mode 100644 index 0000000000..17fc39a214 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-rest-ary-empty.js @@ -0,0 +1,95 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-empty.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: Rest element containing an "empty" array pattern (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var callCount = 0; +class C { + method([...[]] = iter) { + assert.sameValue(iterations, 1); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-rest-ary-rest.js b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-rest-ary-rest.js new file mode 100644 index 0000000000..bc541b73f5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-rest-ary-rest.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-rest.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: Rest element containing a rest element (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ +var values = [1, 2, 3]; + +var callCount = 0; +class C { + method([...[...x]] = values) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-rest-id-direct.js b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-rest-id-direct.js new file mode 100644 index 0000000000..129fb000db --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-rest-id-direct.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-direct.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: Lone rest element (direct binding) (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +includes: [compareArray.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingIdentifier + + [...] + 2. Let A be ! ArrayCreate(0). + 3. Let n be 0. + 4. Repeat, + [...] + f. Perform ! CreateDataPropertyOrThrow(A, ! ToString(n), nextValue). + g. Set n to n + 1. + +---*/ + +var callCount = 0; +class C { + method([...x] = [1]) { + assert(Array.isArray(x)); + assert.compareArray(x, [1]); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-rest-id-elision-next-err.js b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-rest-id-elision-next-err.js new file mode 100644 index 0000000000..987bec94f4 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-rest-id-elision-next-err.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision-next-err.case +// - src/dstr-binding/error/cls-decl-meth-dflt.template +/*--- +description: Rest element following elision elements (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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(); })(); + +class C { + method([, ...x] = iter) {} +}; + +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-rest-id-elision.js b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-rest-id-elision.js new file mode 100644 index 0000000000..6f27b0b9cd --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-rest-id-elision.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: Rest element following elision elements (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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 values = [1, 2, 3, 4, 5]; + +var callCount = 0; +class C { + method([ , , ...x] = values) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 3); + assert.sameValue(x[1], 4); + assert.sameValue(x[2], 5); + assert.notSameValue(x, values); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-rest-id-exhausted.js b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-rest-id-exhausted.js new file mode 100644 index 0000000000..9d7adc641f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-rest-id-exhausted.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-exhausted.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: RestElement applied to an exhausted iterator (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [Symbol.iterator, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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, + [...] + b. If iteratorRecord.[[done]] is true, then + i. If environment is undefined, return PutValue(lhs, A). + ii. Return InitializeReferencedBinding(lhs, A). + +---*/ + +var callCount = 0; +class C { + method([, , ...x] = [1, 2]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 0); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-rest-id-iter-step-err.js b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-rest-id-iter-step-err.js new file mode 100644 index 0000000000..aef6bb4a49 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-rest-id-iter-step-err.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-step-err.case +// - src/dstr-binding/error/cls-decl-meth-dflt.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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; +}(); + +class C { + method([...x] = iter) {} +}; + +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(); +}); + +iter.next(); +assert.sameValue(first, 1); +assert.sameValue(second, 0, 'Iterator is closed following abrupt completion.'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-rest-id-iter-val-err.js b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-rest-id-iter-val-err.js new file mode 100644 index 0000000000..2e505bfba1 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-rest-id-iter-val-err.js @@ -0,0 +1,95 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-val-err.case +// - src/dstr-binding/error/cls-decl-meth-dflt.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [Symbol.iterator, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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; + } + }; +}; + +class C { + method([...x] = iter) {} +}; + +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-rest-id.js b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-rest-id.js new file mode 100644 index 0000000000..d4e5e0f892 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-rest-id.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: Lone rest element (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + [...] 3. Let A be ArrayCreate(0). [...] 5. Repeat + [...] + f. Let status be CreateDataProperty(A, ToString (n), nextValue). + [...] +---*/ +var values = [1, 2, 3]; + +var callCount = 0; +class C { + method([...x] = values) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-rest-init-ary.js b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-rest-init-ary.js new file mode 100644 index 0000000000..1d009b3318 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-rest-init-ary.js @@ -0,0 +1,80 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-ary.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: Rest element (nested array pattern) does not support initializer (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var callCount = 0; +class C { + method([...[ x ] = []] = []) { + + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-rest-init-id.js b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-rest-init-id.js new file mode 100644 index 0000000000..d494273cbc --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-rest-init-id.js @@ -0,0 +1,80 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-id.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: Rest element (identifier) does not support initializer (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var callCount = 0; +class C { + method([...x = []] = []) { + + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-rest-init-obj.js b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-rest-init-obj.js new file mode 100644 index 0000000000..590b6cc240 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-rest-init-obj.js @@ -0,0 +1,80 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-obj.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: Rest element (nested object pattern) does not support initializer (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var callCount = 0; +class C { + method([...{ x } = []] = []) { + + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-rest-not-final-ary.js b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-rest-not-final-ary.js new file mode 100644 index 0000000000..cec717b63f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-rest-not-final-ary.js @@ -0,0 +1,80 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-ary.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: Rest element (array binding pattern) may not be followed by any element (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var callCount = 0; +class C { + method([...[x], y] = [1, 2, 3]) { + + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-rest-not-final-id.js b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-rest-not-final-id.js new file mode 100644 index 0000000000..937a57aaf4 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-rest-not-final-id.js @@ -0,0 +1,80 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-id.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: Rest element (identifier) may not be followed by any element (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var callCount = 0; +class C { + method([...x, y] = [1, 2, 3]) { + + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-rest-not-final-obj.js b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-rest-not-final-obj.js new file mode 100644 index 0000000000..9a75b35c3d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-rest-not-final-obj.js @@ -0,0 +1,80 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-obj.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: Rest element (object binding pattern) may not be followed by any element (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var callCount = 0; +class C { + method([...{ x }, y] = [1, 2, 3]) { + + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-rest-obj-id.js b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-rest-obj-id.js new file mode 100644 index 0000000000..a5ff0b91eb --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-rest-obj-id.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-id.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: Rest element containing an object binding pattern (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ + +var callCount = 0; +class C { + method([...{ length }] = [1, 2, 3]) { + assert.sameValue(length, 3); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-rest-obj-prop-id.js b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-rest-obj-prop-id.js new file mode 100644 index 0000000000..40a7166178 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-ary-ptrn-rest-obj-prop-id.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-prop-id.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: Rest element containing an object binding pattern (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ +let length = "outer"; + +var callCount = 0; +class C { + method([...{ 0: v, 1: w, 2: x, 3: y, length: z }] = [7, 8, 9]) { + assert.sameValue(v, 7); + assert.sameValue(w, 8); + assert.sameValue(x, 9); + assert.sameValue(y, undefined); + assert.sameValue(z, 3); + + assert.sameValue(length, "outer", "the length prop is not set as a binding name"); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-init-null.js b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-init-null.js new file mode 100644 index 0000000000..b999133400 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-init-null.js @@ -0,0 +1,76 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-null.case +// - src/dstr-binding/error/cls-decl-meth-dflt.template +/*--- +description: Value specifed for object binding pattern must be object coercible (null) (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +class C { + method({} = null) {} +}; + +var c = new C(); + +assert.throws(TypeError, function() { + c.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-init-undefined.js b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-init-undefined.js new file mode 100644 index 0000000000..11234a1875 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-init-undefined.js @@ -0,0 +1,76 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-undefined.case +// - src/dstr-binding/error/cls-decl-meth-dflt.template +/*--- +description: Value specifed for object binding pattern must be object coercible (undefined) (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +class C { + method({} = undefined) {} +}; + +var c = new C(); + +assert.throws(TypeError, function() { + c.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-empty.js b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-empty.js new file mode 100644 index 0000000000..01594d5443 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-empty.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-empty.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: No property access occurs for an "empty" object binding pattern (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ +var accessCount = 0; +var obj = Object.defineProperty({}, 'attr', { + get: function() { + accessCount += 1; + } +}); + +var callCount = 0; +class C { + method({} = obj) { + assert.sameValue(accessCount, 0); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-id-get-value-err.js b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-id-get-value-err.js new file mode 100644 index 0000000000..6f39d99969 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-id-get-value-err.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-get-value-err.case +// - src/dstr-binding/error/cls-decl-meth-dflt.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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(); + } +}); + +class C { + method({ poisoned } = poisonedProperty) {} +}; + +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-id-init-fn-name-arrow.js b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..6cfefaf62f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-id-init-fn-name-arrow.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-arrow.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: SingleNameBinding assigns `name` to arrow functions (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +class C { + method({ arrow = () => {} } = {}) { + assert.sameValue(arrow.name, 'arrow'); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-id-init-fn-name-class.js b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-id-init-fn-name-class.js new file mode 100644 index 0000000000..aba947c3e4 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-id-init-fn-name-class.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-class.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +class C { + method({ cls = class {}, xCls = class X {}, xCls2 = class { static name() {} } } = {}) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + assert.notSameValue(xCls2.name, 'xCls2'); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-id-init-fn-name-cover.js b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-id-init-fn-name-cover.js new file mode 100644 index 0000000000..5a31c9cf3e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-id-init-fn-name-cover.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-cover.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" functions "through" cover grammar (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +class C { + method({ cover = (function () {}), xCover = (0, function() {}) } = {}) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-id-init-fn-name-fn.js b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-id-init-fn-name-fn.js new file mode 100644 index 0000000000..7593b3c947 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-id-init-fn-name-fn.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-fn.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +class C { + method({ fn = function () {}, xFn = function x() {} } = {}) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-id-init-fn-name-gen.js b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-id-init-fn-name-gen.js new file mode 100644 index 0000000000..80974cc4ef --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-id-init-fn-name-gen.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-gen.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). + +---*/ + +var callCount = 0; +class C { + method({ gen = function* () {}, xGen = function* x() {} } = {}) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-id-init-skipped.js b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-id-init-skipped.js new file mode 100644 index 0000000000..a2754f9944 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-id-init-skipped.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-skipped.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +class C { + method({ w = counter(), x = counter(), y = counter(), z = counter() } = { w: null, x: 0, y: false, z: '' }) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-id-init-throws.js b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-id-init-throws.js new file mode 100644 index 0000000000..02dde5b5a9 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-id-init-throws.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-throws.case +// - src/dstr-binding/error/cls-decl-meth-dflt.template +/*--- +description: Error thrown when evaluating the initializer (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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(); +} + +class C { + method({ x = thrower() } = {}) {} +}; + +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-id-init-unresolvable.js b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-id-init-unresolvable.js new file mode 100644 index 0000000000..376a67c7e6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-id-init-unresolvable.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-unresolvable.case +// - src/dstr-binding/error/cls-decl-meth-dflt.template +/*--- +description: Destructuring initializer is an unresolvable reference (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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. +---*/ + +class C { + method({ x = unresolvableReference } = {}) {} +}; + +var c = new C(); + +assert.throws(ReferenceError, function() { + c.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-id-trailing-comma.js b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-id-trailing-comma.js new file mode 100644 index 0000000000..38236ebb18 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-id-trailing-comma.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-trailing-comma.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +class C { + method({ x, } = { x: 23 }) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-list-err.js b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-list-err.js new file mode 100644 index 0000000000..fadaa36c49 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-list-err.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-list-err.case +// - src/dstr-binding/error/cls-decl-meth-dflt.template +/*--- +description: Binding property list evaluation is interrupted by an abrupt completion (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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(); +} + +class C { + method({ a, b = thrower(), c = ++initCount } = {}) {} +}; + +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(); +}); + +assert.sameValue(initCount, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-prop-ary-init.js b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-prop-ary-init.js new file mode 100644 index 0000000000..264340a818 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-prop-ary-init.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-init.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: Object binding pattern with "nested" array binding pattern using initializer (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 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). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +class C { + method({ w: [x, y, z] = [4, 5, 6] } = {}) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-prop-ary-trailing-comma.js b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-prop-ary-trailing-comma.js new file mode 100644 index 0000000000..776d3bf0b7 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-prop-ary-trailing-comma.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-trailing-comma.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +class C { + method({ x: [y], } = { x: [45] }) { + assert.sameValue(y,45); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-prop-ary-value-null.js b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-prop-ary-value-null.js new file mode 100644 index 0000000000..d93c5454c1 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-prop-ary-value-null.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-value-null.case +// - src/dstr-binding/error/cls-decl-meth-dflt.template +/*--- +description: Object binding pattern with "nested" array binding pattern taking the `null` value (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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. +---*/ + +class C { + method({ w: [x, y, z] = [4, 5, 6] } = { w: null }) {} +}; + +var c = new C(); + +assert.throws(TypeError, function() { + c.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-prop-ary.js b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-prop-ary.js new file mode 100644 index 0000000000..53a57ce4ae --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-prop-ary.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: Object binding pattern with "nested" array binding pattern not using initializer (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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. +---*/ + +var callCount = 0; +class C { + method({ w: [x, y, z] = [4, 5, 6] } = { w: [7, undefined, ] }) { + assert.sameValue(x, 7); + assert.sameValue(y, undefined); + assert.sameValue(z, undefined); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-prop-eval-err.js b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-prop-eval-err.js new file mode 100644 index 0000000000..b9eb618795 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-prop-eval-err.js @@ -0,0 +1,80 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-eval-err.case +// - src/dstr-binding/error/cls-decl-meth-dflt.template +/*--- +description: Evaluation of property name returns an abrupt completion (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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(); +} + +class C { + method({ [thrower()]: x } = {}) {} +}; + +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-prop-id-get-value-err.js b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-prop-id-get-value-err.js new file mode 100644 index 0000000000..970e57ae02 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-prop-id-get-value-err.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-get-value-err.case +// - src/dstr-binding/error/cls-decl-meth-dflt.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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(); + } +}); + +class C { + method({ poisoned: x = ++initEvalCount } = poisonedProperty) {} +}; + +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(); +}); + +assert.sameValue(initEvalCount, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-prop-id-init-skipped.js b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-prop-id-init-skipped.js new file mode 100644 index 0000000000..273e568703 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-prop-id-init-skipped.js @@ -0,0 +1,100 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-skipped.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +class C { + method({ s: t = counter(), u: v = counter(), w: x = counter(), y: z = counter() } = { s: null, u: 0, w: false, y: '' }) { + assert.sameValue(t, null); + assert.sameValue(v, 0); + assert.sameValue(x, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + + assert.throws(ReferenceError, function() { + s; + }); + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-prop-id-init-throws.js b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-prop-id-init-throws.js new file mode 100644 index 0000000000..f0a0b526b4 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-prop-id-init-throws.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-throws.case +// - src/dstr-binding/error/cls-decl-meth-dflt.template +/*--- +description: Error thrown when evaluating the initializer (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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(); +} + +class C { + method({ x: y = thrower() } = {}) {} +}; + +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-prop-id-init-unresolvable.js b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-prop-id-init-unresolvable.js new file mode 100644 index 0000000000..5e6109f2a8 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-prop-id-init-unresolvable.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-unresolvable.case +// - src/dstr-binding/error/cls-decl-meth-dflt.template +/*--- +description: Destructuring initializer is an unresolvable reference (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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. +---*/ + +class C { + method({ x: y = unresolvableReference } = {}) {} +}; + +var c = new C(); + +assert.throws(ReferenceError, function() { + c.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-prop-id-init.js b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-prop-id-init.js new file mode 100644 index 0000000000..508b41ffaf --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-prop-id-init.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: Binding as specified via property name, identifier, and initializer (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + method({ x: y = 33 } = { }) { + assert.sameValue(y, 33); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-prop-id-trailing-comma.js b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-prop-id-trailing-comma.js new file mode 100644 index 0000000000..360ec7e092 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-prop-id-trailing-comma.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-trailing-comma.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +class C { + method({ x: y, } = { x: 23 }) { + assert.sameValue(y, 23); + + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-prop-id.js b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-prop-id.js new file mode 100644 index 0000000000..417188f461 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-prop-id.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: Binding as specified via property name and identifier (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + method({ x: y } = { x: 23 }) { + assert.sameValue(y, 23); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-prop-obj-init.js b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-prop-obj-init.js new file mode 100644 index 0000000000..68bf8916e1 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-prop-obj-init.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-init.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern using initializer (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 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). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +class C { + method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } } = { w: undefined }) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-prop-obj-value-null.js b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-prop-obj-value-null.js new file mode 100644 index 0000000000..2c78d5ca19 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-prop-obj-value-null.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-null.case +// - src/dstr-binding/error/cls-decl-meth-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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. +---*/ + +class C { + method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } } = { w: null }) {} +}; + +var c = new C(); + +assert.throws(TypeError, function() { + c.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-prop-obj-value-undef.js b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-prop-obj-value-undef.js new file mode 100644 index 0000000000..d182ca7445 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-prop-obj-value-undef.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-undef.case +// - src/dstr-binding/error/cls-decl-meth-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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. +---*/ + +class C { + method({ w: { x, y, z } = undefined } = { }) {} +}; + +var c = new C(); + +assert.throws(TypeError, function() { + c.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-prop-obj.js b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-prop-obj.js new file mode 100644 index 0000000000..9a01630eab --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-prop-obj.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern not using initializer (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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. +---*/ + +var callCount = 0; +class C { + method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } } = { w: { x: undefined, z: 7 } }) { + assert.sameValue(x, undefined); + assert.sameValue(y, undefined); + assert.sameValue(z, 7); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-rest-getter.js b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-rest-getter.js new file mode 100644 index 0000000000..89b6da687f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-rest-getter.js @@ -0,0 +1,80 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-getter.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: Getter is called when obj is being deconstructed to a rest Object (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [object-rest, destructuring-binding, default-parameters] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var count = 0; + +var callCount = 0; +class C { + method({...x} = { get v() { count++; return 2; } }) { + assert.sameValue(count, 1); + + verifyProperty(x, "v", { + enumerable: true, + writable: true, + configurable: true, + value: 2 + }); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-rest-skip-non-enumerable.js b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-rest-skip-non-enumerable.js new file mode 100644 index 0000000000..3952729118 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-rest-skip-non-enumerable.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-skip-non-enumerable.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: Rest object doesn't contain non-enumerable properties (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [object-rest, destructuring-binding, default-parameters] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var o = {a: 3, b: 4}; +Object.defineProperty(o, "x", { value: 4, enumerable: false }); + +var callCount = 0; +class C { + method({...rest} = o) { + assert.sameValue(rest.x, undefined); + + verifyProperty(rest, "a", { + enumerable: true, + writable: true, + configurable: true, + value: 3 + }); + + verifyProperty(rest, "b", { + enumerable: true, + writable: true, + configurable: true, + value: 4 + }); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-rest-val-obj.js b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-rest-val-obj.js new file mode 100644 index 0000000000..18908855db --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-dflt-obj-ptrn-rest-val-obj.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-val-obj.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: Rest object contains just unextracted data (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [object-rest, destructuring-binding, default-parameters] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +class C { + method({a, b, ...rest} = {x: 1, y: 2, a: 5, b: 3}) { + assert.sameValue(rest.a, undefined); + assert.sameValue(rest.b, undefined); + + verifyProperty(rest, "x", { + enumerable: true, + writable: true, + configurable: true, + value: 1 + }); + + verifyProperty(rest, "y", { + enumerable: true, + writable: true, + configurable: true, + value: 2 + }); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-obj-init-null.js b/js/src/tests/test262/language/statements/class/dstr/meth-obj-init-null.js new file mode 100644 index 0000000000..d6f298a8f7 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-obj-init-null.js @@ -0,0 +1,76 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-null.case +// - src/dstr-binding/error/cls-decl-meth.template +/*--- +description: Value specifed for object binding pattern must be object coercible (null) (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +class C { + method({}) {} +}; + +var c = new C(); + +assert.throws(TypeError, function() { + c.method(null); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-obj-init-undefined.js b/js/src/tests/test262/language/statements/class/dstr/meth-obj-init-undefined.js new file mode 100644 index 0000000000..a06de3fe97 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-obj-init-undefined.js @@ -0,0 +1,76 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-undefined.case +// - src/dstr-binding/error/cls-decl-meth.template +/*--- +description: Value specifed for object binding pattern must be object coercible (undefined) (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +class C { + method({}) {} +}; + +var c = new C(); + +assert.throws(TypeError, function() { + c.method(undefined); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-empty.js b/js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-empty.js new file mode 100644 index 0000000000..dc950e43ae --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-empty.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-empty.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: No property access occurs for an "empty" object binding pattern (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ +var accessCount = 0; +var obj = Object.defineProperty({}, 'attr', { + get: function() { + accessCount += 1; + } +}); + +var callCount = 0; +class C { + method({}) { + assert.sameValue(accessCount, 0); + callCount = callCount + 1; + } +}; + +new C().method(obj); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-id-get-value-err.js b/js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-id-get-value-err.js new file mode 100644 index 0000000000..1a1937db61 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-id-get-value-err.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-get-value-err.case +// - src/dstr-binding/error/cls-decl-meth.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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(); + } +}); + +class C { + method({ poisoned }) {} +}; + +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(poisonedProperty); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-id-init-fn-name-arrow.js b/js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..2d22819e73 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-id-init-fn-name-arrow.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-arrow.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: SingleNameBinding assigns `name` to arrow functions (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +class C { + method({ arrow = () => {} }) { + assert.sameValue(arrow.name, 'arrow'); + callCount = callCount + 1; + } +}; + +new C().method({}); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-id-init-fn-name-class.js b/js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-id-init-fn-name-class.js new file mode 100644 index 0000000000..464465222b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-id-init-fn-name-class.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-class.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +class C { + method({ cls = class {}, xCls = class X {}, xCls2 = class { static name() {} } }) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + assert.notSameValue(xCls2.name, 'xCls2'); + callCount = callCount + 1; + } +}; + +new C().method({}); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-id-init-fn-name-cover.js b/js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-id-init-fn-name-cover.js new file mode 100644 index 0000000000..2f5349cdf6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-id-init-fn-name-cover.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-cover.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" functions "through" cover grammar (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +class C { + method({ cover = (function () {}), xCover = (0, function() {}) }) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + callCount = callCount + 1; + } +}; + +new C().method({}); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-id-init-fn-name-fn.js b/js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-id-init-fn-name-fn.js new file mode 100644 index 0000000000..6b3c83bc9d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-id-init-fn-name-fn.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-fn.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +class C { + method({ fn = function () {}, xFn = function x() {} }) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + callCount = callCount + 1; + } +}; + +new C().method({}); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-id-init-fn-name-gen.js b/js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-id-init-fn-name-gen.js new file mode 100644 index 0000000000..5c33c28105 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-id-init-fn-name-gen.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-gen.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). + +---*/ + +var callCount = 0; +class C { + method({ gen = function* () {}, xGen = function* x() {} }) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + callCount = callCount + 1; + } +}; + +new C().method({}); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-id-init-skipped.js b/js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-id-init-skipped.js new file mode 100644 index 0000000000..c4d4b79c48 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-id-init-skipped.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-skipped.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +class C { + method({ w = counter(), x = counter(), y = counter(), z = counter() }) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +new C().method({ w: null, x: 0, y: false, z: '' }); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-id-init-throws.js b/js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-id-init-throws.js new file mode 100644 index 0000000000..dd55f4bce6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-id-init-throws.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-throws.case +// - src/dstr-binding/error/cls-decl-meth.template +/*--- +description: Error thrown when evaluating the initializer (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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(); +} + +class C { + method({ x = thrower() }) {} +}; + +var c = new C(); + +assert.throws(Test262Error, function() { + c.method({}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-id-init-unresolvable.js b/js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-id-init-unresolvable.js new file mode 100644 index 0000000000..c8cbe8551a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-id-init-unresolvable.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-unresolvable.case +// - src/dstr-binding/error/cls-decl-meth.template +/*--- +description: Destructuring initializer is an unresolvable reference (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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. +---*/ + +class C { + method({ x = unresolvableReference }) {} +}; + +var c = new C(); + +assert.throws(ReferenceError, function() { + c.method({}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-id-trailing-comma.js b/js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-id-trailing-comma.js new file mode 100644 index 0000000000..bd34550744 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-id-trailing-comma.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-trailing-comma.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +class C { + method({ x, }) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } +}; + +new C().method({ x: 23 }); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-list-err.js b/js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-list-err.js new file mode 100644 index 0000000000..d95d4e82b2 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-list-err.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-list-err.case +// - src/dstr-binding/error/cls-decl-meth.template +/*--- +description: Binding property list evaluation is interrupted by an abrupt completion (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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(); +} + +class C { + method({ a, b = thrower(), c = ++initCount }) {} +}; + +var c = new C(); + +assert.throws(Test262Error, function() { + c.method({}); +}); + +assert.sameValue(initCount, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-prop-ary-init.js b/js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-prop-ary-init.js new file mode 100644 index 0000000000..b15189fcf4 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-prop-ary-init.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-init.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: Object binding pattern with "nested" array binding pattern using initializer (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 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). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +class C { + method({ w: [x, y, z] = [4, 5, 6] }) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } +}; + +new C().method({}); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-prop-ary-trailing-comma.js b/js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-prop-ary-trailing-comma.js new file mode 100644 index 0000000000..881d22c338 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-prop-ary-trailing-comma.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-trailing-comma.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +class C { + method({ x: [y], }) { + assert.sameValue(y,45); + callCount = callCount + 1; + } +}; + +new C().method({ x: [45] }); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-prop-ary-value-null.js b/js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-prop-ary-value-null.js new file mode 100644 index 0000000000..d63a34a3cc --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-prop-ary-value-null.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-value-null.case +// - src/dstr-binding/error/cls-decl-meth.template +/*--- +description: Object binding pattern with "nested" array binding pattern taking the `null` value (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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. +---*/ + +class C { + method({ w: [x, y, z] = [4, 5, 6] }) {} +}; + +var c = new C(); + +assert.throws(TypeError, function() { + c.method({ w: null }); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-prop-ary.js b/js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-prop-ary.js new file mode 100644 index 0000000000..d34fdd1dda --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-prop-ary.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: Object binding pattern with "nested" array binding pattern not using initializer (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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. +---*/ + +var callCount = 0; +class C { + method({ w: [x, y, z] = [4, 5, 6] }) { + assert.sameValue(x, 7); + assert.sameValue(y, undefined); + assert.sameValue(z, undefined); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } +}; + +new C().method({ w: [7, undefined, ] }); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-prop-eval-err.js b/js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-prop-eval-err.js new file mode 100644 index 0000000000..5c3fa0712e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-prop-eval-err.js @@ -0,0 +1,80 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-eval-err.case +// - src/dstr-binding/error/cls-decl-meth.template +/*--- +description: Evaluation of property name returns an abrupt completion (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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(); +} + +class C { + method({ [thrower()]: x }) {} +}; + +var c = new C(); + +assert.throws(Test262Error, function() { + c.method({}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-prop-id-get-value-err.js b/js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-prop-id-get-value-err.js new file mode 100644 index 0000000000..673cfab5d9 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-prop-id-get-value-err.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-get-value-err.case +// - src/dstr-binding/error/cls-decl-meth.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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(); + } +}); + +class C { + method({ poisoned: x = ++initEvalCount }) {} +}; + +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(poisonedProperty); +}); + +assert.sameValue(initEvalCount, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-prop-id-init-skipped.js b/js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-prop-id-init-skipped.js new file mode 100644 index 0000000000..46cbd78ea0 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-prop-id-init-skipped.js @@ -0,0 +1,100 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-skipped.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +class C { + method({ s: t = counter(), u: v = counter(), w: x = counter(), y: z = counter() }) { + assert.sameValue(t, null); + assert.sameValue(v, 0); + assert.sameValue(x, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + + assert.throws(ReferenceError, function() { + s; + }); + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } +}; + +new C().method({ s: null, u: 0, w: false, y: '' }); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-prop-id-init-throws.js b/js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-prop-id-init-throws.js new file mode 100644 index 0000000000..085d3a2db1 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-prop-id-init-throws.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-throws.case +// - src/dstr-binding/error/cls-decl-meth.template +/*--- +description: Error thrown when evaluating the initializer (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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(); +} + +class C { + method({ x: y = thrower() }) {} +}; + +var c = new C(); + +assert.throws(Test262Error, function() { + c.method({}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-prop-id-init-unresolvable.js b/js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-prop-id-init-unresolvable.js new file mode 100644 index 0000000000..ce537ad84c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-prop-id-init-unresolvable.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-unresolvable.case +// - src/dstr-binding/error/cls-decl-meth.template +/*--- +description: Destructuring initializer is an unresolvable reference (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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. +---*/ + +class C { + method({ x: y = unresolvableReference }) {} +}; + +var c = new C(); + +assert.throws(ReferenceError, function() { + c.method({}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-prop-id-init.js b/js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-prop-id-init.js new file mode 100644 index 0000000000..3fb9ca6909 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-prop-id-init.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: Binding as specified via property name, identifier, and initializer (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + method({ x: y = 33 }) { + assert.sameValue(y, 33); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } +}; + +new C().method({ }); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-prop-id-trailing-comma.js b/js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-prop-id-trailing-comma.js new file mode 100644 index 0000000000..77d1feff57 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-prop-id-trailing-comma.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-trailing-comma.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +class C { + method({ x: y, }) { + assert.sameValue(y, 23); + + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } +}; + +new C().method({ x: 23 }); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-prop-id.js b/js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-prop-id.js new file mode 100644 index 0000000000..4183736d42 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-prop-id.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: Binding as specified via property name and identifier (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + method({ x: y }) { + assert.sameValue(y, 23); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } +}; + +new C().method({ x: 23 }); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-prop-obj-init.js b/js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-prop-obj-init.js new file mode 100644 index 0000000000..adf11a5ed1 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-prop-obj-init.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-init.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: Object binding pattern with "nested" object binding pattern using initializer (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 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). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +class C { + method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } }) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } +}; + +new C().method({ w: undefined }); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-prop-obj-value-null.js b/js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-prop-obj-value-null.js new file mode 100644 index 0000000000..0055aeac99 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-prop-obj-value-null.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-null.case +// - src/dstr-binding/error/cls-decl-meth.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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. +---*/ + +class C { + method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } }) {} +}; + +var c = new C(); + +assert.throws(TypeError, function() { + c.method({ w: null }); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-prop-obj-value-undef.js b/js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-prop-obj-value-undef.js new file mode 100644 index 0000000000..fee809c44d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-prop-obj-value-undef.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-undef.case +// - src/dstr-binding/error/cls-decl-meth.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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. +---*/ + +class C { + method({ w: { x, y, z } = undefined }) {} +}; + +var c = new C(); + +assert.throws(TypeError, function() { + c.method({ }); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-prop-obj.js b/js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-prop-obj.js new file mode 100644 index 0000000000..40121ab0d5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-prop-obj.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: Object binding pattern with "nested" object binding pattern not using initializer (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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. +---*/ + +var callCount = 0; +class C { + method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } }) { + assert.sameValue(x, undefined); + assert.sameValue(y, undefined); + assert.sameValue(z, 7); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } +}; + +new C().method({ w: { x: undefined, z: 7 } }); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-rest-getter.js b/js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-rest-getter.js new file mode 100644 index 0000000000..9bd46cfd6e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-rest-getter.js @@ -0,0 +1,80 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-getter.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: Getter is called when obj is being deconstructed to a rest Object (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [object-rest, destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var count = 0; + +var callCount = 0; +class C { + method({...x}) { + assert.sameValue(count, 1); + + verifyProperty(x, "v", { + enumerable: true, + writable: true, + configurable: true, + value: 2 + }); + callCount = callCount + 1; + } +}; + +new C().method({ get v() { count++; return 2; } }); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-rest-skip-non-enumerable.js b/js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-rest-skip-non-enumerable.js new file mode 100644 index 0000000000..0507093351 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-rest-skip-non-enumerable.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-skip-non-enumerable.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: Rest object doesn't contain non-enumerable properties (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [object-rest, destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var o = {a: 3, b: 4}; +Object.defineProperty(o, "x", { value: 4, enumerable: false }); + +var callCount = 0; +class C { + method({...rest}) { + assert.sameValue(rest.x, undefined); + + verifyProperty(rest, "a", { + enumerable: true, + writable: true, + configurable: true, + value: 3 + }); + + verifyProperty(rest, "b", { + enumerable: true, + writable: true, + configurable: true, + value: 4 + }); + callCount = callCount + 1; + } +}; + +new C().method(o); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-rest-val-obj.js b/js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-rest-val-obj.js new file mode 100644 index 0000000000..256e56ef0c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-obj-ptrn-rest-val-obj.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-val-obj.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: Rest object contains just unextracted data (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [object-rest, destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +class C { + method({a, b, ...rest}) { + assert.sameValue(rest.a, undefined); + assert.sameValue(rest.b, undefined); + + verifyProperty(rest, "x", { + enumerable: true, + writable: true, + configurable: true, + value: 1 + }); + + verifyProperty(rest, "y", { + enumerable: true, + writable: true, + configurable: true, + value: 2 + }); + callCount = callCount + 1; + } +}; + +new C().method({x: 1, y: 2, a: 5, b: 3}); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-init-iter-close.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-init-iter-close.js new file mode 100644 index 0000000000..500e8143c7 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-init-iter-close.js @@ -0,0 +1,94 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-close.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: Iterator is closed when not exhausted by pattern evaluation (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [Symbol.iterator, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: false }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var callCount = 0; +class C { + static method([x]) { + assert.sameValue(doneCallCount, 1); + callCount = callCount + 1; + } +}; + +C.method(iter); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-init-iter-get-err-array-prototype.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-init-iter-get-err-array-prototype.js new file mode 100644 index 0000000000..a0e1a411bb --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-init-iter-get-err-array-prototype.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-get-err-array-prototype.case +// - src/dstr-binding/error/cls-decl-meth-static.template +/*--- +description: Abrupt completion returned by GetIterator (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [Symbol.iterator, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iteratorRecord be ? GetIterator(value). + + GetIterator ( obj [ , hint [ , method ] ] ) + + [...] + 4. Let iterator be ? Call(method, obj). + + Call ( F, V [ , argumentsList ] ) + + [...] + 2. If IsCallable(F) is false, throw a TypeError exception. + +---*/ +delete Array.prototype[Symbol.iterator]; + +class C { + static method([x, y, z]) {} +}; + +assert.throws(TypeError, function() { + C.method([1, 2, 3]); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-init-iter-get-err.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-init-iter-get-err.js new file mode 100644 index 0000000000..aabe99798b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-init-iter-get-err.js @@ -0,0 +1,80 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-get-err.case +// - src/dstr-binding/error/cls-decl-meth-static.template +/*--- +description: Abrupt completion returned by GetIterator (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [Symbol.iterator, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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(); +}; + +class C { + static method([x]) {} +}; + +assert.throws(Test262Error, function() { + C.method(iter); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-init-iter-no-close.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-init-iter-no-close.js new file mode 100644 index 0000000000..f0e2c20b70 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-init-iter-no-close.js @@ -0,0 +1,94 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-no-close.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: Iterator is not closed when exhausted by pattern evaluation (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [Symbol.iterator, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: true }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var callCount = 0; +class C { + static method([x]) { + assert.sameValue(doneCallCount, 0); + callCount = callCount + 1; + } +}; + +C.method(iter); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-name-iter-val.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-name-iter-val.js new file mode 100644 index 0000000000..2dae5048f0 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-name-iter-val.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-name-iter-val.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: SingleNameBinding with normal value iteration (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static method([x, y, z]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; + } +}; + +C.method([1, 2, 3]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-ary-elem-init.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-ary-elem-init.js new file mode 100644 index 0000000000..c2d94c04f9 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-ary-elem-init.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-init.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: BindingElement with array binding pattern and initializer is used (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + static method([[x, y, z] = [4, 5, 6]]) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + callCount = callCount + 1; + } +}; + +C.method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-ary-elem-iter.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-ary-elem-iter.js new file mode 100644 index 0000000000..701808e01d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-ary-elem-iter.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-iter.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + static method([[x, y, z] = [4, 5, 6]]) { + assert.sameValue(x, 7); + assert.sameValue(y, 8); + assert.sameValue(z, 9); + callCount = callCount + 1; + } +}; + +C.method([[7, 8, 9]]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-ary-elision-init.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-ary-elision-init.js new file mode 100644 index 0000000000..151ced0c89 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-ary-elision-init.js @@ -0,0 +1,92 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-init.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: BindingElement with array binding pattern and initializer is used (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +class C { + static method([[,] = g()]) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; + } +}; + +C.method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-ary-elision-iter.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-ary-elision-iter.js new file mode 100644 index 0000000000..60f4dc10d3 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-ary-elision-iter.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-iter.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var callCount = 0; +function* g() { + callCount += 1; +}; + +var callCount = 0; +class C { + static method([[,] = g()]) { + assert.sameValue(callCount, 0); + callCount = callCount + 1; + } +}; + +C.method([[]]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-ary-empty-init.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-ary-empty-init.js new file mode 100644 index 0000000000..e5baeeb181 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-ary-empty-init.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-init.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: BindingElement with array binding pattern and initializer is used (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var initCount = 0; +var iterCount = 0; +var iter = function*() { iterCount += 1; }(); + +var callCount = 0; +class C { + static method([[] = function() { initCount += 1; return iter; }()]) { + assert.sameValue(initCount, 1); + assert.sameValue(iterCount, 0); + callCount = callCount + 1; + } +}; + +C.method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-ary-empty-iter.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-ary-empty-iter.js new file mode 100644 index 0000000000..96fe933c77 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-ary-empty-iter.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-iter.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var initCount = 0; + +var callCount = 0; +class C { + static method([[] = function() { initCount += 1; }()]) { + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +C.method([[23]]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-ary-rest-init.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-ary-rest-init.js new file mode 100644 index 0000000000..2dc3a0a2fa --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-ary-rest-init.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-init.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: BindingElement with array binding pattern and initializer is used (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; + +var callCount = 0; +class C { + static method([[...x] = values]) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + callCount = callCount + 1; + } +}; + +C.method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-ary-rest-iter.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-ary-rest-iter.js new file mode 100644 index 0000000000..3cb5844ac6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-ary-rest-iter.js @@ -0,0 +1,92 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-iter.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; +var initCount = 0; + +var callCount = 0; +class C { + static method([[...x] = function() { initCount += 1; }()]) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +C.method([values]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-ary-val-null.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-ary-val-null.js new file mode 100644 index 0000000000..26d4a15eab --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-ary-val-null.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-val-null.case +// - src/dstr-binding/error/cls-decl-meth-static.template +/*--- +description: Nested array destructuring with a null value (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). +---*/ + +class C { + static method([[x]]) {} +}; + +assert.throws(TypeError, function() { + C.method([null]); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-id-init-exhausted.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-id-init-exhausted.js new file mode 100644 index 0000000000..1a855e64e6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-id-init-exhausted.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-exhausted.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: Destructuring initializer with an exhausted iterator (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static method([x = 23]) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } +}; + +C.method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-id-init-fn-name-arrow.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..41822de003 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-id-init-fn-name-arrow.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-arrow.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: SingleNameBinding does assign name to arrow functions (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static method([arrow = () => {}]) { + assert.sameValue(arrow.name, 'arrow'); + callCount = callCount + 1; + } +}; + +C.method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-id-init-fn-name-class.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-id-init-fn-name-class.js new file mode 100644 index 0000000000..1c3a215c7c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-id-init-fn-name-class.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-class.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static method([cls = class {}, xCls = class X {}, xCls2 = class { static name() {} }]) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + assert.notSameValue(xCls2.name, 'xCls2'); + callCount = callCount + 1; + } +}; + +C.method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-id-init-fn-name-cover.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-id-init-fn-name-cover.js new file mode 100644 index 0000000000..87555c71ce --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-id-init-fn-name-cover.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-cover.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: SingleNameBinding does assign name to "anonymous" functions "through" cover grammar (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static method([cover = (function () {}), xCover = (0, function() {})]) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + callCount = callCount + 1; + } +}; + +C.method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-id-init-fn-name-fn.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-id-init-fn-name-fn.js new file mode 100644 index 0000000000..cb90504051 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-id-init-fn-name-fn.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-fn.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static method([fn = function () {}, xFn = function x() {}]) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + callCount = callCount + 1; + } +}; + +C.method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-id-init-fn-name-gen.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-id-init-fn-name-gen.js new file mode 100644 index 0000000000..123fee6fa6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-id-init-fn-name-gen.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-gen.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). + +---*/ + +var callCount = 0; +class C { + static method([gen = function* () {}, xGen = function* x() {}]) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + callCount = callCount + 1; + } +}; + +C.method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-id-init-hole.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-id-init-hole.js new file mode 100644 index 0000000000..008697629e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-id-init-hole.js @@ -0,0 +1,80 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-hole.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: Destructuring initializer with a "hole" (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + [...] + 7. If environment is undefined, return PutValue(lhs, v). 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static method([x = 23]) { + assert.sameValue(x, 23); + // another statement + callCount = callCount + 1; + } +}; + +C.method([,]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-id-init-skipped.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-id-init-skipped.js new file mode 100644 index 0000000000..61072d87c3 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-id-init-skipped.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-skipped.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +class C { + static method([w = counter(), x = counter(), y = counter(), z = counter()]) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +C.method([null, 0, false, '']); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-id-init-throws.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-id-init-throws.js new file mode 100644 index 0000000000..bf484b0875 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-id-init-throws.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-throws.case +// - src/dstr-binding/error/cls-decl-meth-static.template +/*--- +description: Destructuring initializer returns an abrupt completion (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). +---*/ + +class C { + static method([x = (function() { throw new Test262Error(); })()]) {} +}; + +assert.throws(Test262Error, function() { + C.method([undefined]); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-id-init-undef.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-id-init-undef.js new file mode 100644 index 0000000000..8581e1c790 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-id-init-undef.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-undef.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: Destructuring initializer with an undefined value (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static method([x = 23]) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } +}; + +C.method([undefined]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-id-init-unresolvable.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-id-init-unresolvable.js new file mode 100644 index 0000000000..d547915dd4 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-id-init-unresolvable.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-unresolvable.case +// - src/dstr-binding/error/cls-decl-meth-static.template +/*--- +description: Destructuring initializer is an unresolvable reference (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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. +---*/ + +class C { + static method([ x = unresolvableReference ]) {} +}; + +assert.throws(ReferenceError, function() { + C.method([]); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-id-iter-complete.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-id-iter-complete.js new file mode 100644 index 0000000000..406883eba1 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-id-iter-complete.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-complete.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: SingleNameBinding when value iteration completes (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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, + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static method([x]) { + assert.sameValue(x, undefined); + callCount = callCount + 1; + } +}; + +C.method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-id-iter-done.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-id-iter-done.js new file mode 100644 index 0000000000..366e8bbb4d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-id-iter-done.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-done.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: SingleNameBinding when value iteration was completed previously (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static method([_, x]) { + assert.sameValue(x, undefined); + callCount = callCount + 1; + } +}; + +C.method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-id-iter-step-err.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-id-iter-step-err.js new file mode 100644 index 0000000000..bc5e9491c6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-id-iter-step-err.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-step-err.case +// - src/dstr-binding/error/cls-decl-meth-static.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [Symbol.iterator, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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(); + } + }; +}; + +class C { + static method([x]) {} +}; + +assert.throws(Test262Error, function() { + C.method(g); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-id-iter-val-array-prototype.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-id-iter-val-array-prototype.js new file mode 100644 index 0000000000..6c1e06ecc5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-id-iter-val-array-prototype.js @@ -0,0 +1,103 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val-array-prototype.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: Array destructuring uses overriden Array.prototype[Symbol.iterator] (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [Symbol.iterator, generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializer_opt + + 1. Let bindingId be StringValue of BindingIdentifier. + 2. Let lhs be ? ResolveBinding(bindingId, environment). + 3. If iteratorRecord.[[Done]] is false, then + a. Let next be IteratorStep(iteratorRecord). + 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). + [...] + 7. Return InitializeReferencedBinding(lhs, v). + +---*/ +Array.prototype[Symbol.iterator] = function* () { + if (this.length > 0) { + yield this[0]; + } + if (this.length > 1) { + yield this[1]; + } + if (this.length > 2) { + yield 42; + } +}; + +var callCount = 0; +class C { + static method([x, y, z]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 42); + callCount = callCount + 1; + } +}; + +C.method([1, 2, 3]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-id-iter-val-err.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-id-iter-val-err.js new file mode 100644 index 0000000000..545132ea44 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-id-iter-val-err.js @@ -0,0 +1,98 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val-err.case +// - src/dstr-binding/error/cls-decl-meth-static.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [Symbol.iterator, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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; + } + }; +}; + +class C { + static method([x]) {} +}; + +assert.throws(Test262Error, function() { + C.method(g); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-id-iter-val.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-id-iter-val.js new file mode 100644 index 0000000000..23fbd2b225 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-id-iter-val.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: SingleNameBinding when value iteration was completed previously (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static method([x, y, z]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; + } +}; + +C.method([1, 2, 3]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-obj-id-init.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-obj-id-init.js new file mode 100644 index 0000000000..d0c7653682 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-obj-id-init.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id-init.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: BindingElement with object binding pattern and initializer is used (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + static method([{ x, y, z } = { x: 44, y: 55, z: 66 }]) { + assert.sameValue(x, 44); + assert.sameValue(y, 55); + assert.sameValue(z, 66); + callCount = callCount + 1; + } +}; + +C.method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-obj-id.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-obj-id.js new file mode 100644 index 0000000000..8bd1848300 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-obj-id.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + static method([{ x, y, z } = { x: 44, y: 55, z: 66 }]) { + assert.sameValue(x, 11); + assert.sameValue(y, 22); + assert.sameValue(z, 33); + callCount = callCount + 1; + } +}; + +C.method([{ x: 11, y: 22, z: 33 }]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-obj-prop-id-init.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-obj-prop-id-init.js new file mode 100644 index 0000000000..cae912d565 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-obj-prop-id-init.js @@ -0,0 +1,95 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id-init.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: BindingElement with object binding pattern and initializer is used (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + static method([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }]) { + assert.sameValue(v, 444); + assert.sameValue(x, 555); + assert.sameValue(z, 666); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } +}; + +C.method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-obj-prop-id.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-obj-prop-id.js new file mode 100644 index 0000000000..f734f70da7 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-obj-prop-id.js @@ -0,0 +1,95 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + static method([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }]) { + assert.sameValue(v, 777); + assert.sameValue(x, 888); + assert.sameValue(z, 999); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } +}; + +C.method([{ u: 777, w: 888, y: 999 }]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-obj-val-null.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-obj-val-null.js new file mode 100644 index 0000000000..c634ba1566 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-obj-val-null.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-null.case +// - src/dstr-binding/error/cls-decl-meth-static.template +/*--- +description: Nested object destructuring with a null value (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). +---*/ + +class C { + static method([{ x }]) {} +}; + +assert.throws(TypeError, function() { + C.method([null]); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-obj-val-undef.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-obj-val-undef.js new file mode 100644 index 0000000000..f79592341c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elem-obj-val-undef.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-undef.case +// - src/dstr-binding/error/cls-decl-meth-static.template +/*--- +description: Nested object destructuring with a value of `undefined` (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). +---*/ + +class C { + static method([{ x }]) {} +}; + +assert.throws(TypeError, function() { + C.method([]); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elision-exhausted.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elision-exhausted.js new file mode 100644 index 0000000000..809296796d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elision-exhausted.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-exhausted.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: Elision accepts exhausted iterator (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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 + [...] + 2. Return NormalCompletion(empty). + +---*/ +var iter = function*() {}(); +iter.next(); + +var callCount = 0; +class C { + static method([,]) { + + callCount = callCount + 1; + } +}; + +C.method(iter); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elision-step-err.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elision-step-err.js new file mode 100644 index 0000000000..6dec356bd6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elision-step-err.js @@ -0,0 +1,94 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-step-err.case +// - src/dstr-binding/error/cls-decl-meth-static.template +/*--- +description: Elision advances iterator and forwards abrupt completions (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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; +}(); + +class C { + static method([,]) {} +}; + +assert.throws(Test262Error, function() { + C.method(iter); +}); + +iter.next(); +assert.sameValue(following, 0, 'Iterator was properly closed.'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elision.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elision.js new file mode 100644 index 0000000000..fb75ef7921 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-elision.js @@ -0,0 +1,99 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: Elision advances iterator (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +class C { + static method([,]) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; + } +}; + +C.method(g()); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-empty.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-empty.js new file mode 100644 index 0000000000..bfd4073a97 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-empty.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-empty.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: No iteration occurs for an "empty" array binding pattern (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var callCount = 0; +class C { + static method([]) { + assert.sameValue(iterations, 0); + callCount = callCount + 1; + } +}; + +C.method(iter); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-rest-ary-elem.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-rest-ary-elem.js new file mode 100644 index 0000000000..e53d40f16e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-rest-ary-elem.js @@ -0,0 +1,106 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elem.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: Rest element containing an array BindingElementList pattern (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the 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). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static method([...[x, y, z]]) { + assert.sameValue(x, 3); + assert.sameValue(y, 4); + assert.sameValue(z, 5); + callCount = callCount + 1; + } +}; + +C.method([3, 4, 5]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-rest-ary-elision.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-rest-ary-elision.js new file mode 100644 index 0000000000..9ec22d241c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-rest-ary-elision.js @@ -0,0 +1,112 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elision.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: Rest element containing an elision (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the 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). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +class C { + static method([...[,]]) { + assert.sameValue(first, 1); + assert.sameValue(second, 1); + callCount = callCount + 1; + } +}; + +C.method(g()); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-rest-ary-empty.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-rest-ary-empty.js new file mode 100644 index 0000000000..7f82bd1ad8 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-rest-ary-empty.js @@ -0,0 +1,95 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-empty.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: Rest element containing an "empty" array pattern (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var callCount = 0; +class C { + static method([...[]]) { + assert.sameValue(iterations, 1); + callCount = callCount + 1; + } +}; + +C.method(iter); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-rest-ary-rest.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-rest-ary-rest.js new file mode 100644 index 0000000000..6e2f19c1fc --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-rest-ary-rest.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-rest.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: Rest element containing a rest element (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ +var values = [1, 2, 3]; + +var callCount = 0; +class C { + static method([...[...x]]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + + callCount = callCount + 1; + } +}; + +C.method(values); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-rest-id-direct.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-rest-id-direct.js new file mode 100644 index 0000000000..53b80e77e5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-rest-id-direct.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-direct.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: Lone rest element (direct binding) (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +includes: [compareArray.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingIdentifier + + [...] + 2. Let A be ! ArrayCreate(0). + 3. Let n be 0. + 4. Repeat, + [...] + f. Perform ! CreateDataPropertyOrThrow(A, ! ToString(n), nextValue). + g. Set n to n + 1. + +---*/ + +var callCount = 0; +class C { + static method([...x]) { + assert(Array.isArray(x)); + assert.compareArray(x, [1]); + callCount = callCount + 1; + } +}; + +C.method([1]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-rest-id-elision-next-err.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-rest-id-elision-next-err.js new file mode 100644 index 0000000000..b272895f4f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-rest-id-elision-next-err.js @@ -0,0 +1,80 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision-next-err.case +// - src/dstr-binding/error/cls-decl-meth-static.template +/*--- +description: Rest element following elision elements (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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(); })(); + +class C { + static method([, ...x]) {} +}; + +assert.throws(Test262Error, function() { + C.method(iter); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-rest-id-elision.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-rest-id-elision.js new file mode 100644 index 0000000000..bfb6ddb88e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-rest-id-elision.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: Rest element following elision elements (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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 values = [1, 2, 3, 4, 5]; + +var callCount = 0; +class C { + static method([ , , ...x]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 3); + assert.sameValue(x[1], 4); + assert.sameValue(x[2], 5); + assert.notSameValue(x, values); + callCount = callCount + 1; + } +}; + +C.method(values); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-rest-id-exhausted.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-rest-id-exhausted.js new file mode 100644 index 0000000000..36dcf31e01 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-rest-id-exhausted.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-exhausted.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: RestElement applied to an exhausted iterator (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [Symbol.iterator, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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, + [...] + b. If iteratorRecord.[[done]] is true, then + i. If environment is undefined, return PutValue(lhs, A). + ii. Return InitializeReferencedBinding(lhs, A). + +---*/ + +var callCount = 0; +class C { + static method([, , ...x]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 0); + callCount = callCount + 1; + } +}; + +C.method([1, 2]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-rest-id-iter-step-err.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-rest-id-iter-step-err.js new file mode 100644 index 0000000000..f15808f0fd --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-rest-id-iter-step-err.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-step-err.case +// - src/dstr-binding/error/cls-decl-meth-static.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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; +}(); + +class C { + static method([...x]) {} +}; + +assert.throws(Test262Error, function() { + C.method(iter); +}); + +iter.next(); +assert.sameValue(first, 1); +assert.sameValue(second, 0, 'Iterator is closed following abrupt completion.'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-rest-id-iter-val-err.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-rest-id-iter-val-err.js new file mode 100644 index 0000000000..b030b5c809 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-rest-id-iter-val-err.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-val-err.case +// - src/dstr-binding/error/cls-decl-meth-static.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [Symbol.iterator, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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; + } + }; +}; + +class C { + static method([...x]) {} +}; + +assert.throws(Test262Error, function() { + C.method(iter); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-rest-id.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-rest-id.js new file mode 100644 index 0000000000..801bd582fd --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-rest-id.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: Lone rest element (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + [...] 3. Let A be ArrayCreate(0). [...] 5. Repeat + [...] + f. Let status be CreateDataProperty(A, ToString (n), nextValue). + [...] +---*/ +var values = [1, 2, 3]; + +var callCount = 0; +class C { + static method([...x]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + callCount = callCount + 1; + } +}; + +C.method(values); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-rest-init-ary.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-rest-init-ary.js new file mode 100644 index 0000000000..da6176dbf7 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-rest-init-ary.js @@ -0,0 +1,80 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-ary.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: Rest element (nested array pattern) does not support initializer (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var callCount = 0; +class C { + static method([...[ x ] = []]) { + + callCount = callCount + 1; + } +}; + +C.method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-rest-init-id.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-rest-init-id.js new file mode 100644 index 0000000000..e056fd74a8 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-rest-init-id.js @@ -0,0 +1,80 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-id.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: Rest element (identifier) does not support initializer (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var callCount = 0; +class C { + static method([...x = []]) { + + callCount = callCount + 1; + } +}; + +C.method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-rest-init-obj.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-rest-init-obj.js new file mode 100644 index 0000000000..bcc72d51bd --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-rest-init-obj.js @@ -0,0 +1,80 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-obj.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: Rest element (nested object pattern) does not support initializer (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var callCount = 0; +class C { + static method([...{ x } = []]) { + + callCount = callCount + 1; + } +}; + +C.method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-rest-not-final-ary.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-rest-not-final-ary.js new file mode 100644 index 0000000000..fbead3414b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-rest-not-final-ary.js @@ -0,0 +1,80 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-ary.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: Rest element (array binding pattern) may not be followed by any element (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var callCount = 0; +class C { + static method([...[x], y]) { + + callCount = callCount + 1; + } +}; + +C.method([1, 2, 3]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-rest-not-final-id.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-rest-not-final-id.js new file mode 100644 index 0000000000..0c56098718 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-rest-not-final-id.js @@ -0,0 +1,80 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-id.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: Rest element (identifier) may not be followed by any element (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var callCount = 0; +class C { + static method([...x, y]) { + + callCount = callCount + 1; + } +}; + +C.method([1, 2, 3]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-rest-not-final-obj.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-rest-not-final-obj.js new file mode 100644 index 0000000000..04dccb553b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-rest-not-final-obj.js @@ -0,0 +1,80 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-obj.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: Rest element (object binding pattern) may not be followed by any element (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var callCount = 0; +class C { + static method([...{ x }, y]) { + + callCount = callCount + 1; + } +}; + +C.method([1, 2, 3]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-rest-obj-id.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-rest-obj-id.js new file mode 100644 index 0000000000..3eaf12affe --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-rest-obj-id.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-id.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: Rest element containing an object binding pattern (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ + +var callCount = 0; +class C { + static method([...{ length }]) { + assert.sameValue(length, 3); + callCount = callCount + 1; + } +}; + +C.method([1, 2, 3]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-rest-obj-prop-id.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-rest-obj-prop-id.js new file mode 100644 index 0000000000..580e6e2474 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-ary-ptrn-rest-obj-prop-id.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-prop-id.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: Rest element containing an object binding pattern (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ +let length = "outer"; + +var callCount = 0; +class C { + static method([...{ 0: v, 1: w, 2: x, 3: y, length: z }]) { + assert.sameValue(v, 7); + assert.sameValue(w, 8); + assert.sameValue(x, 9); + assert.sameValue(y, undefined); + assert.sameValue(z, 3); + + assert.sameValue(length, "outer", "the length prop is not set as a binding name"); + callCount = callCount + 1; + } +}; + +C.method([7, 8, 9]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-init-iter-close.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-init-iter-close.js new file mode 100644 index 0000000000..a2d21847dd --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-init-iter-close.js @@ -0,0 +1,94 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-close.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: Iterator is closed when not exhausted by pattern evaluation (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [Symbol.iterator, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: false }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var callCount = 0; +class C { + static method([x] = iter) { + assert.sameValue(doneCallCount, 1); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-init-iter-get-err-array-prototype.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-init-iter-get-err-array-prototype.js new file mode 100644 index 0000000000..62bd70103c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-init-iter-get-err-array-prototype.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-get-err-array-prototype.case +// - src/dstr-binding/error/cls-decl-meth-static-dflt.template +/*--- +description: Abrupt completion returned by GetIterator (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [Symbol.iterator, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + 1. Let iteratorRecord be ? GetIterator(value). + + GetIterator ( obj [ , hint [ , method ] ] ) + + [...] + 4. Let iterator be ? Call(method, obj). + + Call ( F, V [ , argumentsList ] ) + + [...] + 2. If IsCallable(F) is false, throw a TypeError exception. + +---*/ +delete Array.prototype[Symbol.iterator]; + +class C { + static method([x, y, z] = [1, 2, 3]) {} +}; + +assert.throws(TypeError, function() { + C.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-init-iter-get-err.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-init-iter-get-err.js new file mode 100644 index 0000000000..008df29b09 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-init-iter-get-err.js @@ -0,0 +1,80 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-get-err.case +// - src/dstr-binding/error/cls-decl-meth-static-dflt.template +/*--- +description: Abrupt completion returned by GetIterator (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [Symbol.iterator, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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(); +}; + +class C { + static method([x] = iter) {} +}; + +assert.throws(Test262Error, function() { + C.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-init-iter-no-close.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-init-iter-no-close.js new file mode 100644 index 0000000000..c06666e67b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-init-iter-no-close.js @@ -0,0 +1,94 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-no-close.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: Iterator is not closed when exhausted by pattern evaluation (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [Symbol.iterator, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: true }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var callCount = 0; +class C { + static method([x] = iter) { + assert.sameValue(doneCallCount, 0); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-name-iter-val.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-name-iter-val.js new file mode 100644 index 0000000000..87e353dca5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-name-iter-val.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-name-iter-val.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: SingleNameBinding with normal value iteration (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static method([x, y, z] = [1, 2, 3]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-ary-elem-init.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-ary-elem-init.js new file mode 100644 index 0000000000..151b7b08ff --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-ary-elem-init.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-init.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + static method([[x, y, z] = [4, 5, 6]] = []) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-ary-elem-iter.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-ary-elem-iter.js new file mode 100644 index 0000000000..444eb1131f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-ary-elem-iter.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-iter.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + static method([[x, y, z] = [4, 5, 6]] = [[7, 8, 9]]) { + assert.sameValue(x, 7); + assert.sameValue(y, 8); + assert.sameValue(z, 9); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-ary-elision-init.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-ary-elision-init.js new file mode 100644 index 0000000000..21a1ece746 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-ary-elision-init.js @@ -0,0 +1,92 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-init.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +class C { + static method([[,] = g()] = []) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-ary-elision-iter.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-ary-elision-iter.js new file mode 100644 index 0000000000..b2bbd718b6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-ary-elision-iter.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-iter.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var callCount = 0; +function* g() { + callCount += 1; +}; + +var callCount = 0; +class C { + static method([[,] = g()] = [[]]) { + assert.sameValue(callCount, 0); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-ary-empty-init.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-ary-empty-init.js new file mode 100644 index 0000000000..fbf6db5f0c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-ary-empty-init.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-init.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var initCount = 0; +var iterCount = 0; +var iter = function*() { iterCount += 1; }(); + +var callCount = 0; +class C { + static method([[] = function() { initCount += 1; return iter; }()] = []) { + assert.sameValue(initCount, 1); + assert.sameValue(iterCount, 0); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-ary-empty-iter.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-ary-empty-iter.js new file mode 100644 index 0000000000..deed39c61d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-ary-empty-iter.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-iter.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var initCount = 0; + +var callCount = 0; +class C { + static method([[] = function() { initCount += 1; }()] = [[23]]) { + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-ary-rest-init.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-ary-rest-init.js new file mode 100644 index 0000000000..ee024c106e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-ary-rest-init.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-init.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; + +var callCount = 0; +class C { + static method([[...x] = values] = []) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-ary-rest-iter.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-ary-rest-iter.js new file mode 100644 index 0000000000..46d39662c1 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-ary-rest-iter.js @@ -0,0 +1,92 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-iter.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; +var initCount = 0; + +var callCount = 0; +class C { + static method([[...x] = function() { initCount += 1; }()] = [values]) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-ary-val-null.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-ary-val-null.js new file mode 100644 index 0000000000..6f2266bc2c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-ary-val-null.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-val-null.case +// - src/dstr-binding/error/cls-decl-meth-static-dflt.template +/*--- +description: Nested array destructuring with a null value (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). +---*/ + +class C { + static method([[x]] = [null]) {} +}; + +assert.throws(TypeError, function() { + C.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-id-init-exhausted.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-id-init-exhausted.js new file mode 100644 index 0000000000..93d288f4be --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-id-init-exhausted.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-exhausted.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: Destructuring initializer with an exhausted iterator (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static method([x = 23] = []) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..41c1c034a4 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-arrow.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: SingleNameBinding does assign name to arrow functions (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static method([arrow = () => {}] = []) { + assert.sameValue(arrow.name, 'arrow'); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-id-init-fn-name-class.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-id-init-fn-name-class.js new file mode 100644 index 0000000000..64fe77970d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-id-init-fn-name-class.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-class.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static method([cls = class {}, xCls = class X {}, xCls2 = class { static name() {} }] = []) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + assert.notSameValue(xCls2.name, 'xCls2'); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-id-init-fn-name-cover.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-id-init-fn-name-cover.js new file mode 100644 index 0000000000..3ca7b8fa46 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-id-init-fn-name-cover.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-cover.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: SingleNameBinding does assign name to "anonymous" functions "through" cover grammar (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static method([cover = (function () {}), xCover = (0, function() {})] = []) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-id-init-fn-name-fn.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-id-init-fn-name-fn.js new file mode 100644 index 0000000000..ce09d93690 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-id-init-fn-name-fn.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-fn.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static method([fn = function () {}, xFn = function x() {}] = []) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-id-init-fn-name-gen.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-id-init-fn-name-gen.js new file mode 100644 index 0000000000..7d3bd26dea --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-id-init-fn-name-gen.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-gen.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). + +---*/ + +var callCount = 0; +class C { + static method([gen = function* () {}, xGen = function* x() {}] = []) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-id-init-hole.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-id-init-hole.js new file mode 100644 index 0000000000..b54ce90f2d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-id-init-hole.js @@ -0,0 +1,80 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-hole.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: Destructuring initializer with a "hole" (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + [...] + 7. If environment is undefined, return PutValue(lhs, v). 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static method([x = 23] = [,]) { + assert.sameValue(x, 23); + // another statement + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-id-init-skipped.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-id-init-skipped.js new file mode 100644 index 0000000000..6e132d3fa6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-id-init-skipped.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-skipped.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +class C { + static method([w = counter(), x = counter(), y = counter(), z = counter()] = [null, 0, false, '']) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-id-init-throws.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-id-init-throws.js new file mode 100644 index 0000000000..8d7c82bd21 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-id-init-throws.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-throws.case +// - src/dstr-binding/error/cls-decl-meth-static-dflt.template +/*--- +description: Destructuring initializer returns an abrupt completion (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). +---*/ + +class C { + static method([x = (function() { throw new Test262Error(); })()] = [undefined]) {} +}; + +assert.throws(Test262Error, function() { + C.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-id-init-undef.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-id-init-undef.js new file mode 100644 index 0000000000..98be07a5d7 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-id-init-undef.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-undef.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: Destructuring initializer with an undefined value (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static method([x = 23] = [undefined]) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-id-init-unresolvable.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-id-init-unresolvable.js new file mode 100644 index 0000000000..11660bc235 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-id-init-unresolvable.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-unresolvable.case +// - src/dstr-binding/error/cls-decl-meth-static-dflt.template +/*--- +description: Destructuring initializer is an unresolvable reference (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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. +---*/ + +class C { + static method([ x = unresolvableReference ] = []) {} +}; + +assert.throws(ReferenceError, function() { + C.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-id-iter-complete.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-id-iter-complete.js new file mode 100644 index 0000000000..0c185833ed --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-id-iter-complete.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-complete.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: SingleNameBinding when value iteration completes (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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, + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static method([x] = []) { + assert.sameValue(x, undefined); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-id-iter-done.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-id-iter-done.js new file mode 100644 index 0000000000..1a7875583c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-id-iter-done.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-done.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: SingleNameBinding when value iteration was completed previously (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static method([_, x] = []) { + assert.sameValue(x, undefined); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-id-iter-step-err.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-id-iter-step-err.js new file mode 100644 index 0000000000..413d2db6ce --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-id-iter-step-err.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-step-err.case +// - src/dstr-binding/error/cls-decl-meth-static-dflt.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [Symbol.iterator, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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(); + } + }; +}; + +class C { + static method([x] = g) {} +}; + +assert.throws(Test262Error, function() { + C.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-id-iter-val-array-prototype.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-id-iter-val-array-prototype.js new file mode 100644 index 0000000000..1dbf119c2c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-id-iter-val-array-prototype.js @@ -0,0 +1,103 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val-array-prototype.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: Array destructuring uses overriden Array.prototype[Symbol.iterator] (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [Symbol.iterator, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializer_opt + + 1. Let bindingId be StringValue of BindingIdentifier. + 2. Let lhs be ? ResolveBinding(bindingId, environment). + 3. If iteratorRecord.[[Done]] is false, then + a. Let next be IteratorStep(iteratorRecord). + 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). + [...] + 7. Return InitializeReferencedBinding(lhs, v). + +---*/ +Array.prototype[Symbol.iterator] = function* () { + if (this.length > 0) { + yield this[0]; + } + if (this.length > 1) { + yield this[1]; + } + if (this.length > 2) { + yield 42; + } +}; + +var callCount = 0; +class C { + static method([x, y, z] = [1, 2, 3]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 42); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-id-iter-val-err.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-id-iter-val-err.js new file mode 100644 index 0000000000..78d689ed44 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-id-iter-val-err.js @@ -0,0 +1,98 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val-err.case +// - src/dstr-binding/error/cls-decl-meth-static-dflt.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [Symbol.iterator, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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; + } + }; +}; + +class C { + static method([x] = g) {} +}; + +assert.throws(Test262Error, function() { + C.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-id-iter-val.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-id-iter-val.js new file mode 100644 index 0000000000..b687c1d24a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-id-iter-val.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: SingleNameBinding when value iteration was completed previously (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static method([x, y, z] = [1, 2, 3]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-obj-id-init.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-obj-id-init.js new file mode 100644 index 0000000000..8bee682ca7 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-obj-id-init.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id-init.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is used (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + static method([{ x, y, z } = { x: 44, y: 55, z: 66 }] = []) { + assert.sameValue(x, 44); + assert.sameValue(y, 55); + assert.sameValue(z, 66); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-obj-id.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-obj-id.js new file mode 100644 index 0000000000..078ed2493c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-obj-id.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + static method([{ x, y, z } = { x: 44, y: 55, z: 66 }] = [{ x: 11, y: 22, z: 33 }]) { + assert.sameValue(x, 11); + assert.sameValue(y, 22); + assert.sameValue(z, 33); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-obj-prop-id-init.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-obj-prop-id-init.js new file mode 100644 index 0000000000..7c1e5eeba7 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-obj-prop-id-init.js @@ -0,0 +1,95 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id-init.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is used (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + static method([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] = []) { + assert.sameValue(v, 444); + assert.sameValue(x, 555); + assert.sameValue(z, 666); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-obj-prop-id.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-obj-prop-id.js new file mode 100644 index 0000000000..8b0ea301c8 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-obj-prop-id.js @@ -0,0 +1,95 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + static method([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] = [{ u: 777, w: 888, y: 999 }]) { + assert.sameValue(v, 777); + assert.sameValue(x, 888); + assert.sameValue(z, 999); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-obj-val-null.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-obj-val-null.js new file mode 100644 index 0000000000..824f63ef6b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-obj-val-null.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-null.case +// - src/dstr-binding/error/cls-decl-meth-static-dflt.template +/*--- +description: Nested object destructuring with a null value (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). +---*/ + +class C { + static method([{ x }] = [null]) {} +}; + +assert.throws(TypeError, function() { + C.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-obj-val-undef.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-obj-val-undef.js new file mode 100644 index 0000000000..a52286646a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elem-obj-val-undef.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-undef.case +// - src/dstr-binding/error/cls-decl-meth-static-dflt.template +/*--- +description: Nested object destructuring with a value of `undefined` (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). +---*/ + +class C { + static method([{ x }] = []) {} +}; + +assert.throws(TypeError, function() { + C.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elision-exhausted.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elision-exhausted.js new file mode 100644 index 0000000000..8d536d8bf9 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elision-exhausted.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-exhausted.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: Elision accepts exhausted iterator (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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 + [...] + 2. Return NormalCompletion(empty). + +---*/ +var iter = function*() {}(); +iter.next(); + +var callCount = 0; +class C { + static method([,] = iter) { + + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elision-step-err.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elision-step-err.js new file mode 100644 index 0000000000..478c54ebc6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elision-step-err.js @@ -0,0 +1,94 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-step-err.case +// - src/dstr-binding/error/cls-decl-meth-static-dflt.template +/*--- +description: Elision advances iterator and forwards abrupt completions (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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; +}(); + +class C { + static method([,] = iter) {} +}; + +assert.throws(Test262Error, function() { + C.method(); +}); + +iter.next(); +assert.sameValue(following, 0, 'Iterator was properly closed.'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elision.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elision.js new file mode 100644 index 0000000000..974efa1e98 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-elision.js @@ -0,0 +1,99 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: Elision advances iterator (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +class C { + static method([,] = g()) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-empty.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-empty.js new file mode 100644 index 0000000000..2abad8546c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-empty.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-empty.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: No iteration occurs for an "empty" array binding pattern (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var callCount = 0; +class C { + static method([] = iter) { + assert.sameValue(iterations, 0); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-rest-ary-elem.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-rest-ary-elem.js new file mode 100644 index 0000000000..9d05ce26f7 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-rest-ary-elem.js @@ -0,0 +1,106 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elem.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: Rest element containing an array BindingElementList pattern (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the 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). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static method([...[x, y, z]] = [3, 4, 5]) { + assert.sameValue(x, 3); + assert.sameValue(y, 4); + assert.sameValue(z, 5); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-rest-ary-elision.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-rest-ary-elision.js new file mode 100644 index 0000000000..7985bce454 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-rest-ary-elision.js @@ -0,0 +1,112 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elision.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: Rest element containing an elision (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the 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). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +class C { + static method([...[,]] = g()) { + assert.sameValue(first, 1); + assert.sameValue(second, 1); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-rest-ary-empty.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-rest-ary-empty.js new file mode 100644 index 0000000000..82489d494b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-rest-ary-empty.js @@ -0,0 +1,95 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-empty.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: Rest element containing an "empty" array pattern (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var callCount = 0; +class C { + static method([...[]] = iter) { + assert.sameValue(iterations, 1); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-rest-ary-rest.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-rest-ary-rest.js new file mode 100644 index 0000000000..5532e679b0 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-rest-ary-rest.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-rest.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: Rest element containing a rest element (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ +var values = [1, 2, 3]; + +var callCount = 0; +class C { + static method([...[...x]] = values) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-rest-id-direct.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-rest-id-direct.js new file mode 100644 index 0000000000..23e357765e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-rest-id-direct.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-direct.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: Lone rest element (direct binding) (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +includes: [compareArray.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingIdentifier + + [...] + 2. Let A be ! ArrayCreate(0). + 3. Let n be 0. + 4. Repeat, + [...] + f. Perform ! CreateDataPropertyOrThrow(A, ! ToString(n), nextValue). + g. Set n to n + 1. + +---*/ + +var callCount = 0; +class C { + static method([...x] = [1]) { + assert(Array.isArray(x)); + assert.compareArray(x, [1]); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-rest-id-elision-next-err.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-rest-id-elision-next-err.js new file mode 100644 index 0000000000..1fda23354a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-rest-id-elision-next-err.js @@ -0,0 +1,80 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision-next-err.case +// - src/dstr-binding/error/cls-decl-meth-static-dflt.template +/*--- +description: Rest element following elision elements (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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(); })(); + +class C { + static method([, ...x] = iter) {} +}; + +assert.throws(Test262Error, function() { + C.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-rest-id-elision.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-rest-id-elision.js new file mode 100644 index 0000000000..bd1bd72375 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-rest-id-elision.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: Rest element following elision elements (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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 values = [1, 2, 3, 4, 5]; + +var callCount = 0; +class C { + static method([ , , ...x] = values) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 3); + assert.sameValue(x[1], 4); + assert.sameValue(x[2], 5); + assert.notSameValue(x, values); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-rest-id-exhausted.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-rest-id-exhausted.js new file mode 100644 index 0000000000..4dac070b95 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-rest-id-exhausted.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-exhausted.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: RestElement applied to an exhausted iterator (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [Symbol.iterator, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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, + [...] + b. If iteratorRecord.[[done]] is true, then + i. If environment is undefined, return PutValue(lhs, A). + ii. Return InitializeReferencedBinding(lhs, A). + +---*/ + +var callCount = 0; +class C { + static method([, , ...x] = [1, 2]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 0); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-rest-id-iter-step-err.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-rest-id-iter-step-err.js new file mode 100644 index 0000000000..789cce3fcc --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-rest-id-iter-step-err.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-step-err.case +// - src/dstr-binding/error/cls-decl-meth-static-dflt.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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; +}(); + +class C { + static method([...x] = iter) {} +}; + +assert.throws(Test262Error, function() { + C.method(); +}); + +iter.next(); +assert.sameValue(first, 1); +assert.sameValue(second, 0, 'Iterator is closed following abrupt completion.'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-rest-id-iter-val-err.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-rest-id-iter-val-err.js new file mode 100644 index 0000000000..3f8c537878 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-rest-id-iter-val-err.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-val-err.case +// - src/dstr-binding/error/cls-decl-meth-static-dflt.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [Symbol.iterator, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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; + } + }; +}; + +class C { + static method([...x] = iter) {} +}; + +assert.throws(Test262Error, function() { + C.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-rest-id.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-rest-id.js new file mode 100644 index 0000000000..9196483b26 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-rest-id.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: Lone rest element (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + [...] 3. Let A be ArrayCreate(0). [...] 5. Repeat + [...] + f. Let status be CreateDataProperty(A, ToString (n), nextValue). + [...] +---*/ +var values = [1, 2, 3]; + +var callCount = 0; +class C { + static method([...x] = values) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-rest-init-ary.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-rest-init-ary.js new file mode 100644 index 0000000000..becf98ed27 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-rest-init-ary.js @@ -0,0 +1,80 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-ary.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: Rest element (nested array pattern) does not support initializer (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var callCount = 0; +class C { + static method([...[ x ] = []] = []) { + + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-rest-init-id.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-rest-init-id.js new file mode 100644 index 0000000000..cb38592a52 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-rest-init-id.js @@ -0,0 +1,80 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-id.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: Rest element (identifier) does not support initializer (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var callCount = 0; +class C { + static method([...x = []] = []) { + + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-rest-init-obj.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-rest-init-obj.js new file mode 100644 index 0000000000..8df5adb4b2 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-rest-init-obj.js @@ -0,0 +1,80 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-obj.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: Rest element (nested object pattern) does not support initializer (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var callCount = 0; +class C { + static method([...{ x } = []] = []) { + + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-rest-not-final-ary.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-rest-not-final-ary.js new file mode 100644 index 0000000000..47c21d6b6e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-rest-not-final-ary.js @@ -0,0 +1,80 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-ary.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: Rest element (array binding pattern) may not be followed by any element (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var callCount = 0; +class C { + static method([...[x], y] = [1, 2, 3]) { + + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-rest-not-final-id.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-rest-not-final-id.js new file mode 100644 index 0000000000..aa6f0654d5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-rest-not-final-id.js @@ -0,0 +1,80 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-id.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: Rest element (identifier) may not be followed by any element (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var callCount = 0; +class C { + static method([...x, y] = [1, 2, 3]) { + + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-rest-not-final-obj.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-rest-not-final-obj.js new file mode 100644 index 0000000000..c936e7d16a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-rest-not-final-obj.js @@ -0,0 +1,80 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-obj.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: Rest element (object binding pattern) may not be followed by any element (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var callCount = 0; +class C { + static method([...{ x }, y] = [1, 2, 3]) { + + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-rest-obj-id.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-rest-obj-id.js new file mode 100644 index 0000000000..bfe824cd54 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-rest-obj-id.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-id.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: Rest element containing an object binding pattern (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ + +var callCount = 0; +class C { + static method([...{ length }] = [1, 2, 3]) { + assert.sameValue(length, 3); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-rest-obj-prop-id.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-rest-obj-prop-id.js new file mode 100644 index 0000000000..8616c2eaf9 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-ary-ptrn-rest-obj-prop-id.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-prop-id.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: Rest element containing an object binding pattern (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ +let length = "outer"; + +var callCount = 0; +class C { + static method([...{ 0: v, 1: w, 2: x, 3: y, length: z }] = [7, 8, 9]) { + assert.sameValue(v, 7); + assert.sameValue(w, 8); + assert.sameValue(x, 9); + assert.sameValue(y, undefined); + assert.sameValue(z, 3); + + assert.sameValue(length, "outer", "the length prop is not set as a binding name"); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-init-null.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-init-null.js new file mode 100644 index 0000000000..0df12743b0 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-init-null.js @@ -0,0 +1,74 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-null.case +// - src/dstr-binding/error/cls-decl-meth-static-dflt.template +/*--- +description: Value specifed for object binding pattern must be object coercible (null) (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +class C { + static method({} = null) {} +}; + +assert.throws(TypeError, function() { + C.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-init-undefined.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-init-undefined.js new file mode 100644 index 0000000000..5482a527df --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-init-undefined.js @@ -0,0 +1,74 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-undefined.case +// - src/dstr-binding/error/cls-decl-meth-static-dflt.template +/*--- +description: Value specifed for object binding pattern must be object coercible (undefined) (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +class C { + static method({} = undefined) {} +}; + +assert.throws(TypeError, function() { + C.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-empty.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-empty.js new file mode 100644 index 0000000000..1dcb78a2f8 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-empty.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-empty.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: No property access occurs for an "empty" object binding pattern (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ +var accessCount = 0; +var obj = Object.defineProperty({}, 'attr', { + get: function() { + accessCount += 1; + } +}); + +var callCount = 0; +class C { + static method({} = obj) { + assert.sameValue(accessCount, 0); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-id-get-value-err.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-id-get-value-err.js new file mode 100644 index 0000000000..0c8e610e1f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-id-get-value-err.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-get-value-err.case +// - src/dstr-binding/error/cls-decl-meth-static-dflt.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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(); + } +}); + +class C { + static method({ poisoned } = poisonedProperty) {} +}; + +assert.throws(Test262Error, function() { + C.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-id-init-fn-name-arrow.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..db5d64d7c3 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-id-init-fn-name-arrow.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-arrow.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: SingleNameBinding assigns `name` to arrow functions (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +class C { + static method({ arrow = () => {} } = {}) { + assert.sameValue(arrow.name, 'arrow'); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-id-init-fn-name-class.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-id-init-fn-name-class.js new file mode 100644 index 0000000000..8a6acdd653 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-id-init-fn-name-class.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-class.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +class C { + static method({ cls = class {}, xCls = class X {}, xCls2 = class { static name() {} } } = {}) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + assert.notSameValue(xCls2.name, 'xCls2'); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-id-init-fn-name-cover.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-id-init-fn-name-cover.js new file mode 100644 index 0000000000..4c92b603ee --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-id-init-fn-name-cover.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-cover.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" functions "through" cover grammar (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +class C { + static method({ cover = (function () {}), xCover = (0, function() {}) } = {}) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-id-init-fn-name-fn.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-id-init-fn-name-fn.js new file mode 100644 index 0000000000..33fe20608e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-id-init-fn-name-fn.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-fn.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +class C { + static method({ fn = function () {}, xFn = function x() {} } = {}) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-id-init-fn-name-gen.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-id-init-fn-name-gen.js new file mode 100644 index 0000000000..254a45fb30 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-id-init-fn-name-gen.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-gen.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). + +---*/ + +var callCount = 0; +class C { + static method({ gen = function* () {}, xGen = function* x() {} } = {}) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-id-init-skipped.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-id-init-skipped.js new file mode 100644 index 0000000000..16d7f045a0 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-id-init-skipped.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-skipped.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +class C { + static method({ w = counter(), x = counter(), y = counter(), z = counter() } = { w: null, x: 0, y: false, z: '' }) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-id-init-throws.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-id-init-throws.js new file mode 100644 index 0000000000..7f26af06e0 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-id-init-throws.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-throws.case +// - src/dstr-binding/error/cls-decl-meth-static-dflt.template +/*--- +description: Error thrown when evaluating the initializer (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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(); +} + +class C { + static method({ x = thrower() } = {}) {} +}; + +assert.throws(Test262Error, function() { + C.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-id-init-unresolvable.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-id-init-unresolvable.js new file mode 100644 index 0000000000..3f296a8bbc --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-id-init-unresolvable.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-unresolvable.case +// - src/dstr-binding/error/cls-decl-meth-static-dflt.template +/*--- +description: Destructuring initializer is an unresolvable reference (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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. +---*/ + +class C { + static method({ x = unresolvableReference } = {}) {} +}; + +assert.throws(ReferenceError, function() { + C.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-id-trailing-comma.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-id-trailing-comma.js new file mode 100644 index 0000000000..09fc7b81f4 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-id-trailing-comma.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-trailing-comma.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +class C { + static method({ x, } = { x: 23 }) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-list-err.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-list-err.js new file mode 100644 index 0000000000..100b54214c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-list-err.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-list-err.case +// - src/dstr-binding/error/cls-decl-meth-static-dflt.template +/*--- +description: Binding property list evaluation is interrupted by an abrupt completion (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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(); +} + +class C { + static method({ a, b = thrower(), c = ++initCount } = {}) {} +}; + +assert.throws(Test262Error, function() { + C.method(); +}); + +assert.sameValue(initCount, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-prop-ary-init.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-prop-ary-init.js new file mode 100644 index 0000000000..ef6b6e1a85 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-prop-ary-init.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-init.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: Object binding pattern with "nested" array binding pattern using initializer (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 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). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +class C { + static method({ w: [x, y, z] = [4, 5, 6] } = {}) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-prop-ary-trailing-comma.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-prop-ary-trailing-comma.js new file mode 100644 index 0000000000..32afec6816 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-prop-ary-trailing-comma.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-trailing-comma.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +class C { + static method({ x: [y], } = { x: [45] }) { + assert.sameValue(y,45); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-prop-ary-value-null.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-prop-ary-value-null.js new file mode 100644 index 0000000000..b9fec2f199 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-prop-ary-value-null.js @@ -0,0 +1,76 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-value-null.case +// - src/dstr-binding/error/cls-decl-meth-static-dflt.template +/*--- +description: Object binding pattern with "nested" array binding pattern taking the `null` value (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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. +---*/ + +class C { + static method({ w: [x, y, z] = [4, 5, 6] } = { w: null }) {} +}; + +assert.throws(TypeError, function() { + C.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-prop-ary.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-prop-ary.js new file mode 100644 index 0000000000..d40c513688 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-prop-ary.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: Object binding pattern with "nested" array binding pattern not using initializer (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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. +---*/ + +var callCount = 0; +class C { + static method({ w: [x, y, z] = [4, 5, 6] } = { w: [7, undefined, ] }) { + assert.sameValue(x, 7); + assert.sameValue(y, undefined); + assert.sameValue(z, undefined); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-prop-eval-err.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-prop-eval-err.js new file mode 100644 index 0000000000..1f4fd2c000 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-prop-eval-err.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-eval-err.case +// - src/dstr-binding/error/cls-decl-meth-static-dflt.template +/*--- +description: Evaluation of property name returns an abrupt completion (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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(); +} + +class C { + static method({ [thrower()]: x } = {}) {} +}; + +assert.throws(Test262Error, function() { + C.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-prop-id-get-value-err.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-prop-id-get-value-err.js new file mode 100644 index 0000000000..6d011ce820 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-prop-id-get-value-err.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-get-value-err.case +// - src/dstr-binding/error/cls-decl-meth-static-dflt.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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(); + } +}); + +class C { + static method({ poisoned: x = ++initEvalCount } = poisonedProperty) {} +}; + +assert.throws(Test262Error, function() { + C.method(); +}); + +assert.sameValue(initEvalCount, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-prop-id-init-skipped.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-prop-id-init-skipped.js new file mode 100644 index 0000000000..533e81f45e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-prop-id-init-skipped.js @@ -0,0 +1,100 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-skipped.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +class C { + static method({ s: t = counter(), u: v = counter(), w: x = counter(), y: z = counter() } = { s: null, u: 0, w: false, y: '' }) { + assert.sameValue(t, null); + assert.sameValue(v, 0); + assert.sameValue(x, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + + assert.throws(ReferenceError, function() { + s; + }); + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-prop-id-init-throws.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-prop-id-init-throws.js new file mode 100644 index 0000000000..331ef4acfd --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-prop-id-init-throws.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-throws.case +// - src/dstr-binding/error/cls-decl-meth-static-dflt.template +/*--- +description: Error thrown when evaluating the initializer (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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(); +} + +class C { + static method({ x: y = thrower() } = {}) {} +}; + +assert.throws(Test262Error, function() { + C.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-prop-id-init-unresolvable.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-prop-id-init-unresolvable.js new file mode 100644 index 0000000000..34e0fe5d3f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-prop-id-init-unresolvable.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-unresolvable.case +// - src/dstr-binding/error/cls-decl-meth-static-dflt.template +/*--- +description: Destructuring initializer is an unresolvable reference (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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. +---*/ + +class C { + static method({ x: y = unresolvableReference } = {}) {} +}; + +assert.throws(ReferenceError, function() { + C.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-prop-id-init.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-prop-id-init.js new file mode 100644 index 0000000000..c6cf8b08a7 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-prop-id-init.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: Binding as specified via property name, identifier, and initializer (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static method({ x: y = 33 } = { }) { + assert.sameValue(y, 33); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-prop-id-trailing-comma.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-prop-id-trailing-comma.js new file mode 100644 index 0000000000..6571168670 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-prop-id-trailing-comma.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-trailing-comma.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +class C { + static method({ x: y, } = { x: 23 }) { + assert.sameValue(y, 23); + + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-prop-id.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-prop-id.js new file mode 100644 index 0000000000..4fe6779887 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-prop-id.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: Binding as specified via property name and identifier (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static method({ x: y } = { x: 23 }) { + assert.sameValue(y, 23); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-prop-obj-init.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-prop-obj-init.js new file mode 100644 index 0000000000..9012ab99f9 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-prop-obj-init.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-init.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern using initializer (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 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). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +class C { + static method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } } = { w: undefined }) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-prop-obj-value-null.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-prop-obj-value-null.js new file mode 100644 index 0000000000..2511427ef0 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-prop-obj-value-null.js @@ -0,0 +1,76 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-null.case +// - src/dstr-binding/error/cls-decl-meth-static-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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. +---*/ + +class C { + static method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } } = { w: null }) {} +}; + +assert.throws(TypeError, function() { + C.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-prop-obj-value-undef.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-prop-obj-value-undef.js new file mode 100644 index 0000000000..e44cb5afa4 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-prop-obj-value-undef.js @@ -0,0 +1,76 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-undef.case +// - src/dstr-binding/error/cls-decl-meth-static-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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. +---*/ + +class C { + static method({ w: { x, y, z } = undefined } = { }) {} +}; + +assert.throws(TypeError, function() { + C.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-prop-obj.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-prop-obj.js new file mode 100644 index 0000000000..fc5fe12ffb --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-prop-obj.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern not using initializer (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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. +---*/ + +var callCount = 0; +class C { + static method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } } = { w: { x: undefined, z: 7 } }) { + assert.sameValue(x, undefined); + assert.sameValue(y, undefined); + assert.sameValue(z, 7); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-rest-getter.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-rest-getter.js new file mode 100644 index 0000000000..6c44ed25f6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-rest-getter.js @@ -0,0 +1,80 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-getter.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: Getter is called when obj is being deconstructed to a rest Object (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [object-rest, destructuring-binding, default-parameters] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var count = 0; + +var callCount = 0; +class C { + static method({...x} = { get v() { count++; return 2; } }) { + assert.sameValue(count, 1); + + verifyProperty(x, "v", { + enumerable: true, + writable: true, + configurable: true, + value: 2 + }); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-rest-skip-non-enumerable.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-rest-skip-non-enumerable.js new file mode 100644 index 0000000000..421c74c656 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-rest-skip-non-enumerable.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-skip-non-enumerable.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: Rest object doesn't contain non-enumerable properties (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [object-rest, destructuring-binding, default-parameters] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var o = {a: 3, b: 4}; +Object.defineProperty(o, "x", { value: 4, enumerable: false }); + +var callCount = 0; +class C { + static method({...rest} = o) { + assert.sameValue(rest.x, undefined); + + verifyProperty(rest, "a", { + enumerable: true, + writable: true, + configurable: true, + value: 3 + }); + + verifyProperty(rest, "b", { + enumerable: true, + writable: true, + configurable: true, + value: 4 + }); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-rest-val-obj.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-rest-val-obj.js new file mode 100644 index 0000000000..920a42ae46 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-dflt-obj-ptrn-rest-val-obj.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-val-obj.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: Rest object contains just unextracted data (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [object-rest, destructuring-binding, default-parameters] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +class C { + static method({a, b, ...rest} = {x: 1, y: 2, a: 5, b: 3}) { + assert.sameValue(rest.a, undefined); + assert.sameValue(rest.b, undefined); + + verifyProperty(rest, "x", { + enumerable: true, + writable: true, + configurable: true, + value: 1 + }); + + verifyProperty(rest, "y", { + enumerable: true, + writable: true, + configurable: true, + value: 2 + }); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-obj-init-null.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-obj-init-null.js new file mode 100644 index 0000000000..1dcebc3119 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-obj-init-null.js @@ -0,0 +1,74 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-null.case +// - src/dstr-binding/error/cls-decl-meth-static.template +/*--- +description: Value specifed for object binding pattern must be object coercible (null) (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +class C { + static method({}) {} +}; + +assert.throws(TypeError, function() { + C.method(null); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-obj-init-undefined.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-obj-init-undefined.js new file mode 100644 index 0000000000..0d40623806 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-obj-init-undefined.js @@ -0,0 +1,74 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-undefined.case +// - src/dstr-binding/error/cls-decl-meth-static.template +/*--- +description: Value specifed for object binding pattern must be object coercible (undefined) (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +class C { + static method({}) {} +}; + +assert.throws(TypeError, function() { + C.method(undefined); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-empty.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-empty.js new file mode 100644 index 0000000000..430b92a748 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-empty.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-empty.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: No property access occurs for an "empty" object binding pattern (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ +var accessCount = 0; +var obj = Object.defineProperty({}, 'attr', { + get: function() { + accessCount += 1; + } +}); + +var callCount = 0; +class C { + static method({}) { + assert.sameValue(accessCount, 0); + callCount = callCount + 1; + } +}; + +C.method(obj); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-id-get-value-err.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-id-get-value-err.js new file mode 100644 index 0000000000..8a0bbac390 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-id-get-value-err.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-get-value-err.case +// - src/dstr-binding/error/cls-decl-meth-static.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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(); + } +}); + +class C { + static method({ poisoned }) {} +}; + +assert.throws(Test262Error, function() { + C.method(poisonedProperty); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-id-init-fn-name-arrow.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..23866529ed --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-id-init-fn-name-arrow.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-arrow.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: SingleNameBinding assigns `name` to arrow functions (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +class C { + static method({ arrow = () => {} }) { + assert.sameValue(arrow.name, 'arrow'); + callCount = callCount + 1; + } +}; + +C.method({}); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-id-init-fn-name-class.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-id-init-fn-name-class.js new file mode 100644 index 0000000000..38873156c9 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-id-init-fn-name-class.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-class.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +class C { + static method({ cls = class {}, xCls = class X {}, xCls2 = class { static name() {} } }) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + assert.notSameValue(xCls2.name, 'xCls2'); + callCount = callCount + 1; + } +}; + +C.method({}); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-id-init-fn-name-cover.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-id-init-fn-name-cover.js new file mode 100644 index 0000000000..2a32fa47d0 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-id-init-fn-name-cover.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-cover.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" functions "through" cover grammar (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +class C { + static method({ cover = (function () {}), xCover = (0, function() {}) }) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + callCount = callCount + 1; + } +}; + +C.method({}); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-id-init-fn-name-fn.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-id-init-fn-name-fn.js new file mode 100644 index 0000000000..0eb3c8a31d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-id-init-fn-name-fn.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-fn.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +class C { + static method({ fn = function () {}, xFn = function x() {} }) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + callCount = callCount + 1; + } +}; + +C.method({}); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-id-init-fn-name-gen.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-id-init-fn-name-gen.js new file mode 100644 index 0000000000..0c91023450 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-id-init-fn-name-gen.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-gen.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). + +---*/ + +var callCount = 0; +class C { + static method({ gen = function* () {}, xGen = function* x() {} }) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + callCount = callCount + 1; + } +}; + +C.method({}); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-id-init-skipped.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-id-init-skipped.js new file mode 100644 index 0000000000..e1bd4dd951 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-id-init-skipped.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-skipped.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +class C { + static method({ w = counter(), x = counter(), y = counter(), z = counter() }) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +C.method({ w: null, x: 0, y: false, z: '' }); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-id-init-throws.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-id-init-throws.js new file mode 100644 index 0000000000..8527fddbf5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-id-init-throws.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-throws.case +// - src/dstr-binding/error/cls-decl-meth-static.template +/*--- +description: Error thrown when evaluating the initializer (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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(); +} + +class C { + static method({ x = thrower() }) {} +}; + +assert.throws(Test262Error, function() { + C.method({}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-id-init-unresolvable.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-id-init-unresolvable.js new file mode 100644 index 0000000000..02566d98d9 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-id-init-unresolvable.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-unresolvable.case +// - src/dstr-binding/error/cls-decl-meth-static.template +/*--- +description: Destructuring initializer is an unresolvable reference (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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. +---*/ + +class C { + static method({ x = unresolvableReference }) {} +}; + +assert.throws(ReferenceError, function() { + C.method({}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-id-trailing-comma.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-id-trailing-comma.js new file mode 100644 index 0000000000..293689da4c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-id-trailing-comma.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-trailing-comma.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +class C { + static method({ x, }) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } +}; + +C.method({ x: 23 }); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-list-err.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-list-err.js new file mode 100644 index 0000000000..99f50db21a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-list-err.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-list-err.case +// - src/dstr-binding/error/cls-decl-meth-static.template +/*--- +description: Binding property list evaluation is interrupted by an abrupt completion (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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(); +} + +class C { + static method({ a, b = thrower(), c = ++initCount }) {} +}; + +assert.throws(Test262Error, function() { + C.method({}); +}); + +assert.sameValue(initCount, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-prop-ary-init.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-prop-ary-init.js new file mode 100644 index 0000000000..ab3d9d65c7 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-prop-ary-init.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-init.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: Object binding pattern with "nested" array binding pattern using initializer (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 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). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +class C { + static method({ w: [x, y, z] = [4, 5, 6] }) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } +}; + +C.method({}); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-prop-ary-trailing-comma.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-prop-ary-trailing-comma.js new file mode 100644 index 0000000000..958a69030d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-prop-ary-trailing-comma.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-trailing-comma.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +class C { + static method({ x: [y], }) { + assert.sameValue(y,45); + callCount = callCount + 1; + } +}; + +C.method({ x: [45] }); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-prop-ary-value-null.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-prop-ary-value-null.js new file mode 100644 index 0000000000..ab18550b2a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-prop-ary-value-null.js @@ -0,0 +1,76 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-value-null.case +// - src/dstr-binding/error/cls-decl-meth-static.template +/*--- +description: Object binding pattern with "nested" array binding pattern taking the `null` value (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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. +---*/ + +class C { + static method({ w: [x, y, z] = [4, 5, 6] }) {} +}; + +assert.throws(TypeError, function() { + C.method({ w: null }); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-prop-ary.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-prop-ary.js new file mode 100644 index 0000000000..c650a387f9 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-prop-ary.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: Object binding pattern with "nested" array binding pattern not using initializer (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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. +---*/ + +var callCount = 0; +class C { + static method({ w: [x, y, z] = [4, 5, 6] }) { + assert.sameValue(x, 7); + assert.sameValue(y, undefined); + assert.sameValue(z, undefined); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } +}; + +C.method({ w: [7, undefined, ] }); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-prop-eval-err.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-prop-eval-err.js new file mode 100644 index 0000000000..65afb213f1 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-prop-eval-err.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-eval-err.case +// - src/dstr-binding/error/cls-decl-meth-static.template +/*--- +description: Evaluation of property name returns an abrupt completion (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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(); +} + +class C { + static method({ [thrower()]: x }) {} +}; + +assert.throws(Test262Error, function() { + C.method({}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-prop-id-get-value-err.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-prop-id-get-value-err.js new file mode 100644 index 0000000000..77c09b30e6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-prop-id-get-value-err.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-get-value-err.case +// - src/dstr-binding/error/cls-decl-meth-static.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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(); + } +}); + +class C { + static method({ poisoned: x = ++initEvalCount }) {} +}; + +assert.throws(Test262Error, function() { + C.method(poisonedProperty); +}); + +assert.sameValue(initEvalCount, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-prop-id-init-skipped.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-prop-id-init-skipped.js new file mode 100644 index 0000000000..e98bd1afb5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-prop-id-init-skipped.js @@ -0,0 +1,100 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-skipped.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +class C { + static method({ s: t = counter(), u: v = counter(), w: x = counter(), y: z = counter() }) { + assert.sameValue(t, null); + assert.sameValue(v, 0); + assert.sameValue(x, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + + assert.throws(ReferenceError, function() { + s; + }); + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } +}; + +C.method({ s: null, u: 0, w: false, y: '' }); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-prop-id-init-throws.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-prop-id-init-throws.js new file mode 100644 index 0000000000..bf83fa005b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-prop-id-init-throws.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-throws.case +// - src/dstr-binding/error/cls-decl-meth-static.template +/*--- +description: Error thrown when evaluating the initializer (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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(); +} + +class C { + static method({ x: y = thrower() }) {} +}; + +assert.throws(Test262Error, function() { + C.method({}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-prop-id-init-unresolvable.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-prop-id-init-unresolvable.js new file mode 100644 index 0000000000..2ee5ed2af0 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-prop-id-init-unresolvable.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-unresolvable.case +// - src/dstr-binding/error/cls-decl-meth-static.template +/*--- +description: Destructuring initializer is an unresolvable reference (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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. +---*/ + +class C { + static method({ x: y = unresolvableReference }) {} +}; + +assert.throws(ReferenceError, function() { + C.method({}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-prop-id-init.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-prop-id-init.js new file mode 100644 index 0000000000..3cd7d23406 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-prop-id-init.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: Binding as specified via property name, identifier, and initializer (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static method({ x: y = 33 }) { + assert.sameValue(y, 33); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } +}; + +C.method({ }); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-prop-id-trailing-comma.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-prop-id-trailing-comma.js new file mode 100644 index 0000000000..b1c8a4d136 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-prop-id-trailing-comma.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-trailing-comma.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +class C { + static method({ x: y, }) { + assert.sameValue(y, 23); + + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } +}; + +C.method({ x: 23 }); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-prop-id.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-prop-id.js new file mode 100644 index 0000000000..3ee0df407f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-prop-id.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: Binding as specified via property name and identifier (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static method({ x: y }) { + assert.sameValue(y, 23); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } +}; + +C.method({ x: 23 }); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-prop-obj-init.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-prop-obj-init.js new file mode 100644 index 0000000000..49f17c6bbc --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-prop-obj-init.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-init.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: Object binding pattern with "nested" object binding pattern using initializer (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 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). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +class C { + static method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } }) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } +}; + +C.method({ w: undefined }); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-prop-obj-value-null.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-prop-obj-value-null.js new file mode 100644 index 0000000000..ae37b91542 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-prop-obj-value-null.js @@ -0,0 +1,76 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-null.case +// - src/dstr-binding/error/cls-decl-meth-static.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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. +---*/ + +class C { + static method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } }) {} +}; + +assert.throws(TypeError, function() { + C.method({ w: null }); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-prop-obj-value-undef.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-prop-obj-value-undef.js new file mode 100644 index 0000000000..da1f927804 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-prop-obj-value-undef.js @@ -0,0 +1,76 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-undef.case +// - src/dstr-binding/error/cls-decl-meth-static.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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. +---*/ + +class C { + static method({ w: { x, y, z } = undefined }) {} +}; + +assert.throws(TypeError, function() { + C.method({ }); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-prop-obj.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-prop-obj.js new file mode 100644 index 0000000000..fea57dfe98 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-prop-obj.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: Object binding pattern with "nested" object binding pattern not using initializer (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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. +---*/ + +var callCount = 0; +class C { + static method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } }) { + assert.sameValue(x, undefined); + assert.sameValue(y, undefined); + assert.sameValue(z, 7); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } +}; + +C.method({ w: { x: undefined, z: 7 } }); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-rest-getter.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-rest-getter.js new file mode 100644 index 0000000000..a770ea90a5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-rest-getter.js @@ -0,0 +1,80 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-getter.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: Getter is called when obj is being deconstructed to a rest Object (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [object-rest, destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var count = 0; + +var callCount = 0; +class C { + static method({...x}) { + assert.sameValue(count, 1); + + verifyProperty(x, "v", { + enumerable: true, + writable: true, + configurable: true, + value: 2 + }); + callCount = callCount + 1; + } +}; + +C.method({ get v() { count++; return 2; } }); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-rest-skip-non-enumerable.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-rest-skip-non-enumerable.js new file mode 100644 index 0000000000..8072fe7119 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-rest-skip-non-enumerable.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-skip-non-enumerable.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: Rest object doesn't contain non-enumerable properties (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [object-rest, destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var o = {a: 3, b: 4}; +Object.defineProperty(o, "x", { value: 4, enumerable: false }); + +var callCount = 0; +class C { + static method({...rest}) { + assert.sameValue(rest.x, undefined); + + verifyProperty(rest, "a", { + enumerable: true, + writable: true, + configurable: true, + value: 3 + }); + + verifyProperty(rest, "b", { + enumerable: true, + writable: true, + configurable: true, + value: 4 + }); + callCount = callCount + 1; + } +}; + +C.method(o); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-rest-val-obj.js b/js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-rest-val-obj.js new file mode 100644 index 0000000000..32f93bfb90 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/meth-static-obj-ptrn-rest-val-obj.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-val-obj.case +// - src/dstr-binding/default/cls-decl-meth-static.template +/*--- +description: Rest object contains just unextracted data (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [object-rest, destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +class C { + static method({a, b, ...rest}) { + assert.sameValue(rest.a, undefined); + assert.sameValue(rest.b, undefined); + + verifyProperty(rest, "x", { + enumerable: true, + writable: true, + configurable: true, + value: 1 + }); + + verifyProperty(rest, "y", { + enumerable: true, + writable: true, + configurable: true, + value: 2 + }); + callCount = callCount + 1; + } +}; + +C.method({x: 1, y: 2, a: 5, b: 3}); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-init-iter-close.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-init-iter-close.js new file mode 100644 index 0000000000..5c392dcaa9 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-init-iter-close.js @@ -0,0 +1,100 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-close.case +// - src/dstr-binding/default/cls-decl-private-gen-meth.template +/*--- +description: Iterator is closed when not exhausted by pattern evaluation (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [Symbol.iterator, class, class-methods-private, generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: false }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var callCount = 0; +class C { + * #method([x]) { + assert.sameValue(doneCallCount, 1); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method(iter).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-init-iter-no-close.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-init-iter-no-close.js new file mode 100644 index 0000000000..c7afd65354 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-init-iter-no-close.js @@ -0,0 +1,100 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-no-close.case +// - src/dstr-binding/default/cls-decl-private-gen-meth.template +/*--- +description: Iterator is not closed when exhausted by pattern evaluation (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [Symbol.iterator, class, class-methods-private, generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: true }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var callCount = 0; +class C { + * #method([x]) { + assert.sameValue(doneCallCount, 0); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method(iter).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-name-iter-val.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-name-iter-val.js new file mode 100644 index 0000000000..b6c8621b1a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-name-iter-val.js @@ -0,0 +1,99 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-name-iter-val.case +// - src/dstr-binding/default/cls-decl-private-gen-meth.template +/*--- +description: SingleNameBinding with normal value iteration (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + * #method([x, y, z]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method([1, 2, 3]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-elem-ary-elem-init.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-elem-ary-elem-init.js new file mode 100644 index 0000000000..b766f51794 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-elem-ary-elem-init.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-init.case +// - src/dstr-binding/default/cls-decl-private-gen-meth.template +/*--- +description: BindingElement with array binding pattern and initializer is used (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + * #method([[x, y, z] = [4, 5, 6]]) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method([]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-elem-ary-elem-iter.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-elem-ary-elem-iter.js new file mode 100644 index 0000000000..79277a3f43 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-elem-ary-elem-iter.js @@ -0,0 +1,92 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-iter.case +// - src/dstr-binding/default/cls-decl-private-gen-meth.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + * #method([[x, y, z] = [4, 5, 6]]) { + assert.sameValue(x, 7); + assert.sameValue(y, 8); + assert.sameValue(z, 9); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method([[7, 8, 9]]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-elem-ary-elision-init.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-elem-ary-elision-init.js new file mode 100644 index 0000000000..6cf6800fa6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-elem-ary-elision-init.js @@ -0,0 +1,98 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-init.case +// - src/dstr-binding/default/cls-decl-private-gen-meth.template +/*--- +description: BindingElement with array binding pattern and initializer is used (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, class, class-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +class C { + * #method([[,] = g()]) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method([]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-elem-ary-elision-iter.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-elem-ary-elision-iter.js new file mode 100644 index 0000000000..7ce755b4bb --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-elem-ary-elision-iter.js @@ -0,0 +1,95 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-iter.case +// - src/dstr-binding/default/cls-decl-private-gen-meth.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, class, class-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var callCount = 0; +function* g() { + callCount += 1; +}; + +var callCount = 0; +class C { + * #method([[,] = g()]) { + assert.sameValue(callCount, 0); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method([[]]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-elem-ary-empty-init.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-elem-ary-empty-init.js new file mode 100644 index 0000000000..4c0acc17f8 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-elem-ary-empty-init.js @@ -0,0 +1,94 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-init.case +// - src/dstr-binding/default/cls-decl-private-gen-meth.template +/*--- +description: BindingElement with array binding pattern and initializer is used (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, class, class-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var initCount = 0; +var iterCount = 0; +var iter = function*() { iterCount += 1; }(); + +var callCount = 0; +class C { + * #method([[] = function() { initCount += 1; return iter; }()]) { + assert.sameValue(initCount, 1); + assert.sameValue(iterCount, 0); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method([]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-elem-ary-empty-iter.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-elem-ary-empty-iter.js new file mode 100644 index 0000000000..ee466b2981 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-elem-ary-empty-iter.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-iter.case +// - src/dstr-binding/default/cls-decl-private-gen-meth.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var initCount = 0; + +var callCount = 0; +class C { + * #method([[] = function() { initCount += 1; }()]) { + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method([[23]]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-elem-ary-rest-init.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-elem-ary-rest-init.js new file mode 100644 index 0000000000..ade7fd21b9 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-elem-ary-rest-init.js @@ -0,0 +1,95 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-init.case +// - src/dstr-binding/default/cls-decl-private-gen-meth.template +/*--- +description: BindingElement with array binding pattern and initializer is used (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; + +var callCount = 0; +class C { + * #method([[...x] = values]) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method([]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-elem-ary-rest-iter.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-elem-ary-rest-iter.js new file mode 100644 index 0000000000..c74564f74e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-elem-ary-rest-iter.js @@ -0,0 +1,98 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-iter.case +// - src/dstr-binding/default/cls-decl-private-gen-meth.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; +var initCount = 0; + +var callCount = 0; +class C { + * #method([[...x] = function() { initCount += 1; }()]) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method([values]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-elem-id-init-exhausted.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-elem-id-init-exhausted.js new file mode 100644 index 0000000000..022cfb465a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-elem-id-init-exhausted.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-exhausted.case +// - src/dstr-binding/default/cls-decl-private-gen-meth.template +/*--- +description: Destructuring initializer with an exhausted iterator (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + * #method([x = 23]) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method([]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-elem-id-init-fn-name-arrow.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-elem-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..4a73424ab5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-elem-id-init-fn-name-arrow.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-arrow.case +// - src/dstr-binding/default/cls-decl-private-gen-meth.template +/*--- +description: SingleNameBinding does assign name to arrow functions (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + * #method([arrow = () => {}]) { + assert.sameValue(arrow.name, 'arrow'); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method([]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-elem-id-init-fn-name-class.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-elem-id-init-fn-name-class.js new file mode 100644 index 0000000000..abba0898ec --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-elem-id-init-fn-name-class.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-class.case +// - src/dstr-binding/default/cls-decl-private-gen-meth.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + * #method([cls = class {}, xCls = class X {}, xCls2 = class { static name() {} }]) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + assert.notSameValue(xCls2.name, 'xCls2'); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method([]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-elem-id-init-fn-name-cover.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-elem-id-init-fn-name-cover.js new file mode 100644 index 0000000000..2ac4a448a9 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-elem-id-init-fn-name-cover.js @@ -0,0 +1,92 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-cover.case +// - src/dstr-binding/default/cls-decl-private-gen-meth.template +/*--- +description: SingleNameBinding does assign name to "anonymous" functions "through" cover grammar (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + * #method([cover = (function () {}), xCover = (0, function() {})]) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method([]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-elem-id-init-fn-name-fn.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-elem-id-init-fn-name-fn.js new file mode 100644 index 0000000000..33ea96854c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-elem-id-init-fn-name-fn.js @@ -0,0 +1,92 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-fn.case +// - src/dstr-binding/default/cls-decl-private-gen-meth.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + * #method([fn = function () {}, xFn = function x() {}]) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method([]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-elem-id-init-fn-name-gen.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-elem-id-init-fn-name-gen.js new file mode 100644 index 0000000000..f9305418c3 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-elem-id-init-fn-name-gen.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-gen.case +// - src/dstr-binding/default/cls-decl-private-gen-meth.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, class, class-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). + +---*/ + +var callCount = 0; +class C { + * #method([gen = function* () {}, xGen = function* x() {}]) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method([]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-elem-id-init-hole.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-elem-id-init-hole.js new file mode 100644 index 0000000000..5ead11567a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-elem-id-init-hole.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-hole.case +// - src/dstr-binding/default/cls-decl-private-gen-meth.template +/*--- +description: Destructuring initializer with a "hole" (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + [...] + 7. If environment is undefined, return PutValue(lhs, v). 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + * #method([x = 23]) { + assert.sameValue(x, 23); + // another statement + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method([,]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-elem-id-init-skipped.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-elem-id-init-skipped.js new file mode 100644 index 0000000000..4db37e6b11 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-elem-id-init-skipped.js @@ -0,0 +1,95 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-skipped.case +// - src/dstr-binding/default/cls-decl-private-gen-meth.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +class C { + * #method([w = counter(), x = counter(), y = counter(), z = counter()]) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method([null, 0, false, '']).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-elem-id-init-undef.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-elem-id-init-undef.js new file mode 100644 index 0000000000..b4f31dcd6c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-elem-id-init-undef.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-undef.case +// - src/dstr-binding/default/cls-decl-private-gen-meth.template +/*--- +description: Destructuring initializer with an undefined value (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + * #method([x = 23]) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method([undefined]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-elem-id-iter-complete.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-elem-id-iter-complete.js new file mode 100644 index 0000000000..079828c06a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-elem-id-iter-complete.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-complete.case +// - src/dstr-binding/default/cls-decl-private-gen-meth.template +/*--- +description: SingleNameBinding when value iteration completes (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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, + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + * #method([x]) { + assert.sameValue(x, undefined); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method([]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-elem-id-iter-done.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-elem-id-iter-done.js new file mode 100644 index 0000000000..d58b13b9e3 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-elem-id-iter-done.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-done.case +// - src/dstr-binding/default/cls-decl-private-gen-meth.template +/*--- +description: SingleNameBinding when value iteration was completed previously (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + * #method([_, x]) { + assert.sameValue(x, undefined); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method([]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-elem-id-iter-val-array-prototype.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-elem-id-iter-val-array-prototype.js new file mode 100644 index 0000000000..d2234a84dd --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-elem-id-iter-val-array-prototype.js @@ -0,0 +1,109 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val-array-prototype.case +// - src/dstr-binding/default/cls-decl-private-gen-meth.template +/*--- +description: Array destructuring uses overriden Array.prototype[Symbol.iterator] (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [Symbol.iterator, generators, class, class-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializer_opt + + 1. Let bindingId be StringValue of BindingIdentifier. + 2. Let lhs be ? ResolveBinding(bindingId, environment). + 3. If iteratorRecord.[[Done]] is false, then + a. Let next be IteratorStep(iteratorRecord). + 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). + [...] + 7. Return InitializeReferencedBinding(lhs, v). + +---*/ +Array.prototype[Symbol.iterator] = function* () { + if (this.length > 0) { + yield this[0]; + } + if (this.length > 1) { + yield this[1]; + } + if (this.length > 2) { + yield 42; + } +}; + +var callCount = 0; +class C { + * #method([x, y, z]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 42); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method([1, 2, 3]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-elem-id-iter-val.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-elem-id-iter-val.js new file mode 100644 index 0000000000..b67ef13002 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-elem-id-iter-val.js @@ -0,0 +1,99 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val.case +// - src/dstr-binding/default/cls-decl-private-gen-meth.template +/*--- +description: SingleNameBinding when value iteration was completed previously (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + * #method([x, y, z]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method([1, 2, 3]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-elem-obj-id-init.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-elem-obj-id-init.js new file mode 100644 index 0000000000..4ebaa3fa2a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-elem-obj-id-init.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id-init.case +// - src/dstr-binding/default/cls-decl-private-gen-meth.template +/*--- +description: BindingElement with object binding pattern and initializer is used (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + * #method([{ x, y, z } = { x: 44, y: 55, z: 66 }]) { + assert.sameValue(x, 44); + assert.sameValue(y, 55); + assert.sameValue(z, 66); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method([]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-elem-obj-id.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-elem-obj-id.js new file mode 100644 index 0000000000..91a9a0a157 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-elem-obj-id.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id.case +// - src/dstr-binding/default/cls-decl-private-gen-meth.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + * #method([{ x, y, z } = { x: 44, y: 55, z: 66 }]) { + assert.sameValue(x, 11); + assert.sameValue(y, 22); + assert.sameValue(z, 33); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method([{ x: 11, y: 22, z: 33 }]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-elem-obj-prop-id-init.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-elem-obj-prop-id-init.js new file mode 100644 index 0000000000..c80fbbeae0 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-elem-obj-prop-id-init.js @@ -0,0 +1,101 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id-init.case +// - src/dstr-binding/default/cls-decl-private-gen-meth.template +/*--- +description: BindingElement with object binding pattern and initializer is used (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + * #method([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }]) { + assert.sameValue(v, 444); + assert.sameValue(x, 555); + assert.sameValue(z, 666); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method([]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-elem-obj-prop-id.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-elem-obj-prop-id.js new file mode 100644 index 0000000000..8df54c1df5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-elem-obj-prop-id.js @@ -0,0 +1,101 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id.case +// - src/dstr-binding/default/cls-decl-private-gen-meth.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + * #method([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }]) { + assert.sameValue(v, 777); + assert.sameValue(x, 888); + assert.sameValue(z, 999); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method([{ u: 777, w: 888, y: 999 }]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-elision-exhausted.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-elision-exhausted.js new file mode 100644 index 0000000000..744d5fc2c8 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-elision-exhausted.js @@ -0,0 +1,96 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-exhausted.case +// - src/dstr-binding/default/cls-decl-private-gen-meth.template +/*--- +description: Elision accepts exhausted iterator (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, class, class-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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 + [...] + 2. Return NormalCompletion(empty). + +---*/ +var iter = function*() {}(); +iter.next(); + +var callCount = 0; +class C { + * #method([,]) { + + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method(iter).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-elision.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-elision.js new file mode 100644 index 0000000000..5c9a25c370 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-elision.js @@ -0,0 +1,105 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision.case +// - src/dstr-binding/default/cls-decl-private-gen-meth.template +/*--- +description: Elision advances iterator (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, class, class-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +class C { + * #method([,]) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method(g()).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-empty.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-empty.js new file mode 100644 index 0000000000..73d1f05312 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-empty.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-empty.case +// - src/dstr-binding/default/cls-decl-private-gen-meth.template +/*--- +description: No iteration occurs for an "empty" array binding pattern (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, class, class-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var callCount = 0; +class C { + * #method([]) { + assert.sameValue(iterations, 0); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method(iter).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-rest-ary-elem.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-rest-ary-elem.js new file mode 100644 index 0000000000..e75150ffba --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-rest-ary-elem.js @@ -0,0 +1,112 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elem.case +// - src/dstr-binding/default/cls-decl-private-gen-meth.template +/*--- +description: Rest element containing an array BindingElementList pattern (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the 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). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + * #method([...[x, y, z]]) { + assert.sameValue(x, 3); + assert.sameValue(y, 4); + assert.sameValue(z, 5); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method([3, 4, 5]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-rest-ary-elision.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-rest-ary-elision.js new file mode 100644 index 0000000000..fdc9602258 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-rest-ary-elision.js @@ -0,0 +1,118 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elision.case +// - src/dstr-binding/default/cls-decl-private-gen-meth.template +/*--- +description: Rest element containing an elision (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, class, class-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the 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). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +class C { + * #method([...[,]]) { + assert.sameValue(first, 1); + assert.sameValue(second, 1); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method(g()).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-rest-ary-empty.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-rest-ary-empty.js new file mode 100644 index 0000000000..df1a672ec3 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-rest-ary-empty.js @@ -0,0 +1,101 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-empty.case +// - src/dstr-binding/default/cls-decl-private-gen-meth.template +/*--- +description: Rest element containing an "empty" array pattern (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, class, class-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var callCount = 0; +class C { + * #method([...[]]) { + assert.sameValue(iterations, 1); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method(iter).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-rest-ary-rest.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-rest-ary-rest.js new file mode 100644 index 0000000000..5dd8852652 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-rest-ary-rest.js @@ -0,0 +1,97 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-rest.case +// - src/dstr-binding/default/cls-decl-private-gen-meth.template +/*--- +description: Rest element containing a rest element (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ +var values = [1, 2, 3]; + +var callCount = 0; +class C { + * #method([...[...x]]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method(values).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-rest-id-direct.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-rest-id-direct.js new file mode 100644 index 0000000000..85c1ac7d59 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-rest-id-direct.js @@ -0,0 +1,92 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-direct.case +// - src/dstr-binding/default/cls-decl-private-gen-meth.template +/*--- +description: Lone rest element (direct binding) (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, generators, destructuring-binding] +flags: [generated] +includes: [compareArray.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingIdentifier + + [...] + 2. Let A be ! ArrayCreate(0). + 3. Let n be 0. + 4. Repeat, + [...] + f. Perform ! CreateDataPropertyOrThrow(A, ! ToString(n), nextValue). + g. Set n to n + 1. + +---*/ + +var callCount = 0; +class C { + * #method([...x]) { + assert(Array.isArray(x)); + assert.compareArray(x, [1]); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method([1]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-rest-id-elision.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-rest-id-elision.js new file mode 100644 index 0000000000..7dbcd84d6a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-rest-id-elision.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision.case +// - src/dstr-binding/default/cls-decl-private-gen-meth.template +/*--- +description: Rest element following elision elements (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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 values = [1, 2, 3, 4, 5]; + +var callCount = 0; +class C { + * #method([ , , ...x]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 3); + assert.sameValue(x[1], 4); + assert.sameValue(x[2], 5); + assert.notSameValue(x, values); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method(values).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-rest-id-exhausted.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-rest-id-exhausted.js new file mode 100644 index 0000000000..f2838c5b39 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-rest-id-exhausted.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-exhausted.case +// - src/dstr-binding/default/cls-decl-private-gen-meth.template +/*--- +description: RestElement applied to an exhausted iterator (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [Symbol.iterator, class, class-methods-private, generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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, + [...] + b. If iteratorRecord.[[done]] is true, then + i. If environment is undefined, return PutValue(lhs, A). + ii. Return InitializeReferencedBinding(lhs, A). + +---*/ + +var callCount = 0; +class C { + * #method([, , ...x]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 0); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method([1, 2]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-rest-id.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-rest-id.js new file mode 100644 index 0000000000..770a9a20ec --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-rest-id.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id.case +// - src/dstr-binding/default/cls-decl-private-gen-meth.template +/*--- +description: Lone rest element (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + [...] 3. Let A be ArrayCreate(0). [...] 5. Repeat + [...] + f. Let status be CreateDataProperty(A, ToString (n), nextValue). + [...] +---*/ +var values = [1, 2, 3]; + +var callCount = 0; +class C { + * #method([...x]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method(values).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-rest-init-ary.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-rest-init-ary.js new file mode 100644 index 0000000000..c2d7216d9a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-rest-init-ary.js @@ -0,0 +1,86 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-ary.case +// - src/dstr-binding/default/cls-decl-private-gen-meth.template +/*--- +description: Rest element (nested array pattern) does not support initializer (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, generators, destructuring-binding] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var callCount = 0; +class C { + * #method([...[ x ] = []]) { + + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method([]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-rest-init-id.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-rest-init-id.js new file mode 100644 index 0000000000..c7549dac21 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-rest-init-id.js @@ -0,0 +1,86 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-id.case +// - src/dstr-binding/default/cls-decl-private-gen-meth.template +/*--- +description: Rest element (identifier) does not support initializer (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, generators, destructuring-binding] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var callCount = 0; +class C { + * #method([...x = []]) { + + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method([]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-rest-init-obj.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-rest-init-obj.js new file mode 100644 index 0000000000..a10e288457 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-rest-init-obj.js @@ -0,0 +1,86 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-obj.case +// - src/dstr-binding/default/cls-decl-private-gen-meth.template +/*--- +description: Rest element (nested object pattern) does not support initializer (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, generators, destructuring-binding] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var callCount = 0; +class C { + * #method([...{ x } = []]) { + + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method([]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-rest-not-final-ary.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-rest-not-final-ary.js new file mode 100644 index 0000000000..8ef03afce7 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-rest-not-final-ary.js @@ -0,0 +1,86 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-ary.case +// - src/dstr-binding/default/cls-decl-private-gen-meth.template +/*--- +description: Rest element (array binding pattern) may not be followed by any element (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, generators, destructuring-binding] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var callCount = 0; +class C { + * #method([...[x], y]) { + + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method([1, 2, 3]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-rest-not-final-id.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-rest-not-final-id.js new file mode 100644 index 0000000000..1c358e07fe --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-rest-not-final-id.js @@ -0,0 +1,86 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-id.case +// - src/dstr-binding/default/cls-decl-private-gen-meth.template +/*--- +description: Rest element (identifier) may not be followed by any element (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, generators, destructuring-binding] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var callCount = 0; +class C { + * #method([...x, y]) { + + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method([1, 2, 3]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-rest-not-final-obj.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-rest-not-final-obj.js new file mode 100644 index 0000000000..166f55992c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-rest-not-final-obj.js @@ -0,0 +1,86 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-obj.case +// - src/dstr-binding/default/cls-decl-private-gen-meth.template +/*--- +description: Rest element (object binding pattern) may not be followed by any element (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, generators, destructuring-binding] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var callCount = 0; +class C { + * #method([...{ x }, y]) { + + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method([1, 2, 3]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-rest-obj-id.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-rest-obj-id.js new file mode 100644 index 0000000000..96b737df5d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-rest-obj-id.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-id.case +// - src/dstr-binding/default/cls-decl-private-gen-meth.template +/*--- +description: Rest element containing an object binding pattern (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ + +var callCount = 0; +class C { + * #method([...{ length }]) { + assert.sameValue(length, 3); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method([1, 2, 3]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-rest-obj-prop-id.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-rest-obj-prop-id.js new file mode 100644 index 0000000000..3924bf84cf --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-ary-ptrn-rest-obj-prop-id.js @@ -0,0 +1,97 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-prop-id.case +// - src/dstr-binding/default/cls-decl-private-gen-meth.template +/*--- +description: Rest element containing an object binding pattern (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ +let length = "outer"; + +var callCount = 0; +class C { + * #method([...{ 0: v, 1: w, 2: x, 3: y, length: z }]) { + assert.sameValue(v, 7); + assert.sameValue(w, 8); + assert.sameValue(x, 9); + assert.sameValue(y, undefined); + assert.sameValue(z, 3); + + assert.sameValue(length, "outer", "the length prop is not set as a binding name"); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method([7, 8, 9]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-init-iter-close.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-init-iter-close.js new file mode 100644 index 0000000000..14cde88b29 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-init-iter-close.js @@ -0,0 +1,100 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-close.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-dflt.template +/*--- +description: Iterator is closed when not exhausted by pattern evaluation (private class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [Symbol.iterator, class, class-methods-private, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: false }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var callCount = 0; +class C { + * #method([x] = iter) { + assert.sameValue(doneCallCount, 1); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-init-iter-no-close.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-init-iter-no-close.js new file mode 100644 index 0000000000..3d6c1e35db --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-init-iter-no-close.js @@ -0,0 +1,100 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-no-close.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-dflt.template +/*--- +description: Iterator is not closed when exhausted by pattern evaluation (private class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [Symbol.iterator, class, class-methods-private, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: true }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var callCount = 0; +class C { + * #method([x] = iter) { + assert.sameValue(doneCallCount, 0); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-name-iter-val.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-name-iter-val.js new file mode 100644 index 0000000000..54f160cf23 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-name-iter-val.js @@ -0,0 +1,99 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-name-iter-val.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-dflt.template +/*--- +description: SingleNameBinding with normal value iteration (private class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + * #method([x, y, z] = [1, 2, 3]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-elem-ary-elem-init.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-elem-ary-elem-init.js new file mode 100644 index 0000000000..3823e65211 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-elem-ary-elem-init.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-init.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (private class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + * #method([[x, y, z] = [4, 5, 6]] = []) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-elem-ary-elem-iter.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-elem-ary-elem-iter.js new file mode 100644 index 0000000000..24c7ad7b41 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-elem-ary-elem-iter.js @@ -0,0 +1,92 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-iter.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (private class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + * #method([[x, y, z] = [4, 5, 6]] = [[7, 8, 9]]) { + assert.sameValue(x, 7); + assert.sameValue(y, 8); + assert.sameValue(z, 9); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-elem-ary-elision-init.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-elem-ary-elision-init.js new file mode 100644 index 0000000000..4d53cf4f3b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-elem-ary-elision-init.js @@ -0,0 +1,98 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-init.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (private class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, class, class-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +class C { + * #method([[,] = g()] = []) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-elem-ary-elision-iter.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-elem-ary-elision-iter.js new file mode 100644 index 0000000000..f8963641df --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-elem-ary-elision-iter.js @@ -0,0 +1,95 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-iter.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (private class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, class, class-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var callCount = 0; +function* g() { + callCount += 1; +}; + +var callCount = 0; +class C { + * #method([[,] = g()] = [[]]) { + assert.sameValue(callCount, 0); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-elem-ary-empty-init.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-elem-ary-empty-init.js new file mode 100644 index 0000000000..3e6b0f7fc7 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-elem-ary-empty-init.js @@ -0,0 +1,94 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-init.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (private class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, class, class-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var initCount = 0; +var iterCount = 0; +var iter = function*() { iterCount += 1; }(); + +var callCount = 0; +class C { + * #method([[] = function() { initCount += 1; return iter; }()] = []) { + assert.sameValue(initCount, 1); + assert.sameValue(iterCount, 0); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-elem-ary-empty-iter.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-elem-ary-empty-iter.js new file mode 100644 index 0000000000..88ee6b1757 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-elem-ary-empty-iter.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-iter.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (private class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var initCount = 0; + +var callCount = 0; +class C { + * #method([[] = function() { initCount += 1; }()] = [[23]]) { + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-elem-ary-rest-init.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-elem-ary-rest-init.js new file mode 100644 index 0000000000..57e549ed5e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-elem-ary-rest-init.js @@ -0,0 +1,95 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-init.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (private class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; + +var callCount = 0; +class C { + * #method([[...x] = values] = []) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-elem-ary-rest-iter.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-elem-ary-rest-iter.js new file mode 100644 index 0000000000..ddc9a9ad8e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-elem-ary-rest-iter.js @@ -0,0 +1,98 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-iter.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (private class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; +var initCount = 0; + +var callCount = 0; +class C { + * #method([[...x] = function() { initCount += 1; }()] = [values]) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-elem-id-init-exhausted.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-elem-id-init-exhausted.js new file mode 100644 index 0000000000..8720e6173a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-elem-id-init-exhausted.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-exhausted.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-dflt.template +/*--- +description: Destructuring initializer with an exhausted iterator (private class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + * #method([x = 23] = []) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..b6a784c5f5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-arrow.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-dflt.template +/*--- +description: SingleNameBinding does assign name to arrow functions (private class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + * #method([arrow = () => {}] = []) { + assert.sameValue(arrow.name, 'arrow'); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-class.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-class.js new file mode 100644 index 0000000000..de6eba1e62 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-class.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-class.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-dflt.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (private class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + * #method([cls = class {}, xCls = class X {}, xCls2 = class { static name() {} }] = []) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + assert.notSameValue(xCls2.name, 'xCls2'); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-cover.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-cover.js new file mode 100644 index 0000000000..a73ce63344 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-cover.js @@ -0,0 +1,92 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-cover.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-dflt.template +/*--- +description: SingleNameBinding does assign name to "anonymous" functions "through" cover grammar (private class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + * #method([cover = (function () {}), xCover = (0, function() {})] = []) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-fn.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-fn.js new file mode 100644 index 0000000000..12632d7677 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-fn.js @@ -0,0 +1,92 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-fn.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (private class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + * #method([fn = function () {}, xFn = function x() {}] = []) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-gen.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-gen.js new file mode 100644 index 0000000000..ffdbd3602b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-gen.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-gen.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (private class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, class, class-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). + +---*/ + +var callCount = 0; +class C { + * #method([gen = function* () {}, xGen = function* x() {}] = []) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-elem-id-init-hole.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-elem-id-init-hole.js new file mode 100644 index 0000000000..9523fa58b6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-elem-id-init-hole.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-hole.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-dflt.template +/*--- +description: Destructuring initializer with a "hole" (private class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + [...] + 7. If environment is undefined, return PutValue(lhs, v). 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + * #method([x = 23] = [,]) { + assert.sameValue(x, 23); + // another statement + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-elem-id-init-skipped.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-elem-id-init-skipped.js new file mode 100644 index 0000000000..b55a511180 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-elem-id-init-skipped.js @@ -0,0 +1,95 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-skipped.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-dflt.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (private class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +class C { + * #method([w = counter(), x = counter(), y = counter(), z = counter()] = [null, 0, false, '']) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-elem-id-init-undef.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-elem-id-init-undef.js new file mode 100644 index 0000000000..fc619299e8 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-elem-id-init-undef.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-undef.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-dflt.template +/*--- +description: Destructuring initializer with an undefined value (private class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + * #method([x = 23] = [undefined]) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-elem-id-iter-complete.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-elem-id-iter-complete.js new file mode 100644 index 0000000000..e7d42ad280 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-elem-id-iter-complete.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-complete.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-dflt.template +/*--- +description: SingleNameBinding when value iteration completes (private class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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, + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + * #method([x] = []) { + assert.sameValue(x, undefined); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-elem-id-iter-done.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-elem-id-iter-done.js new file mode 100644 index 0000000000..7248cb7412 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-elem-id-iter-done.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-done.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-dflt.template +/*--- +description: SingleNameBinding when value iteration was completed previously (private class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + * #method([_, x] = []) { + assert.sameValue(x, undefined); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-elem-id-iter-val-array-prototype.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-elem-id-iter-val-array-prototype.js new file mode 100644 index 0000000000..2d918abaa8 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-elem-id-iter-val-array-prototype.js @@ -0,0 +1,109 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val-array-prototype.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-dflt.template +/*--- +description: Array destructuring uses overriden Array.prototype[Symbol.iterator] (private class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [Symbol.iterator, generators, class, class-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializer_opt + + 1. Let bindingId be StringValue of BindingIdentifier. + 2. Let lhs be ? ResolveBinding(bindingId, environment). + 3. If iteratorRecord.[[Done]] is false, then + a. Let next be IteratorStep(iteratorRecord). + 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). + [...] + 7. Return InitializeReferencedBinding(lhs, v). + +---*/ +Array.prototype[Symbol.iterator] = function* () { + if (this.length > 0) { + yield this[0]; + } + if (this.length > 1) { + yield this[1]; + } + if (this.length > 2) { + yield 42; + } +}; + +var callCount = 0; +class C { + * #method([x, y, z] = [1, 2, 3]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 42); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-elem-id-iter-val.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-elem-id-iter-val.js new file mode 100644 index 0000000000..de945caba9 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-elem-id-iter-val.js @@ -0,0 +1,99 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-dflt.template +/*--- +description: SingleNameBinding when value iteration was completed previously (private class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + * #method([x, y, z] = [1, 2, 3]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-elem-obj-id-init.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-elem-obj-id-init.js new file mode 100644 index 0000000000..da7b8871d6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-elem-obj-id-init.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id-init.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is used (private class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + * #method([{ x, y, z } = { x: 44, y: 55, z: 66 }] = []) { + assert.sameValue(x, 44); + assert.sameValue(y, 55); + assert.sameValue(z, 66); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-elem-obj-id.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-elem-obj-id.js new file mode 100644 index 0000000000..7769013735 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-elem-obj-id.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (private class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + * #method([{ x, y, z } = { x: 44, y: 55, z: 66 }] = [{ x: 11, y: 22, z: 33 }]) { + assert.sameValue(x, 11); + assert.sameValue(y, 22); + assert.sameValue(z, 33); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-elem-obj-prop-id-init.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-elem-obj-prop-id-init.js new file mode 100644 index 0000000000..c56193ac17 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-elem-obj-prop-id-init.js @@ -0,0 +1,101 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id-init.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is used (private class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + * #method([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] = []) { + assert.sameValue(v, 444); + assert.sameValue(x, 555); + assert.sameValue(z, 666); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-elem-obj-prop-id.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-elem-obj-prop-id.js new file mode 100644 index 0000000000..e064b7fbbd --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-elem-obj-prop-id.js @@ -0,0 +1,101 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (private class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + * #method([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] = [{ u: 777, w: 888, y: 999 }]) { + assert.sameValue(v, 777); + assert.sameValue(x, 888); + assert.sameValue(z, 999); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-elision-exhausted.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-elision-exhausted.js new file mode 100644 index 0000000000..056d49f571 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-elision-exhausted.js @@ -0,0 +1,96 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-exhausted.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-dflt.template +/*--- +description: Elision accepts exhausted iterator (private class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, class, class-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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 + [...] + 2. Return NormalCompletion(empty). + +---*/ +var iter = function*() {}(); +iter.next(); + +var callCount = 0; +class C { + * #method([,] = iter) { + + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-elision.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-elision.js new file mode 100644 index 0000000000..ff9c600fe2 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-elision.js @@ -0,0 +1,105 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-dflt.template +/*--- +description: Elision advances iterator (private class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, class, class-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +class C { + * #method([,] = g()) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-empty.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-empty.js new file mode 100644 index 0000000000..b3c3060b2d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-empty.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-empty.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-dflt.template +/*--- +description: No iteration occurs for an "empty" array binding pattern (private class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, class, class-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var callCount = 0; +class C { + * #method([] = iter) { + assert.sameValue(iterations, 0); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-rest-ary-elem.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-rest-ary-elem.js new file mode 100644 index 0000000000..5e4a7baef3 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-rest-ary-elem.js @@ -0,0 +1,112 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elem.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-dflt.template +/*--- +description: Rest element containing an array BindingElementList pattern (private class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the 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). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + * #method([...[x, y, z]] = [3, 4, 5]) { + assert.sameValue(x, 3); + assert.sameValue(y, 4); + assert.sameValue(z, 5); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-rest-ary-elision.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-rest-ary-elision.js new file mode 100644 index 0000000000..b4d4a26e9b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-rest-ary-elision.js @@ -0,0 +1,118 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elision.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-dflt.template +/*--- +description: Rest element containing an elision (private class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, class, class-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the 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). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +class C { + * #method([...[,]] = g()) { + assert.sameValue(first, 1); + assert.sameValue(second, 1); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-rest-ary-empty.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-rest-ary-empty.js new file mode 100644 index 0000000000..6db82a5215 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-rest-ary-empty.js @@ -0,0 +1,101 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-empty.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-dflt.template +/*--- +description: Rest element containing an "empty" array pattern (private class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, class, class-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var callCount = 0; +class C { + * #method([...[]] = iter) { + assert.sameValue(iterations, 1); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-rest-ary-rest.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-rest-ary-rest.js new file mode 100644 index 0000000000..af1f67bfbf --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-rest-ary-rest.js @@ -0,0 +1,97 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-rest.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-dflt.template +/*--- +description: Rest element containing a rest element (private class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ +var values = [1, 2, 3]; + +var callCount = 0; +class C { + * #method([...[...x]] = values) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-rest-id-direct.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-rest-id-direct.js new file mode 100644 index 0000000000..977b261cdc --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-rest-id-direct.js @@ -0,0 +1,92 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-direct.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-dflt.template +/*--- +description: Lone rest element (direct binding) (private class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, generators, destructuring-binding, default-parameters] +flags: [generated] +includes: [compareArray.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingIdentifier + + [...] + 2. Let A be ! ArrayCreate(0). + 3. Let n be 0. + 4. Repeat, + [...] + f. Perform ! CreateDataPropertyOrThrow(A, ! ToString(n), nextValue). + g. Set n to n + 1. + +---*/ + +var callCount = 0; +class C { + * #method([...x] = [1]) { + assert(Array.isArray(x)); + assert.compareArray(x, [1]); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-rest-id-elision.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-rest-id-elision.js new file mode 100644 index 0000000000..8a8ab60709 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-rest-id-elision.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-dflt.template +/*--- +description: Rest element following elision elements (private class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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 values = [1, 2, 3, 4, 5]; + +var callCount = 0; +class C { + * #method([ , , ...x] = values) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 3); + assert.sameValue(x[1], 4); + assert.sameValue(x[2], 5); + assert.notSameValue(x, values); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-rest-id-exhausted.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-rest-id-exhausted.js new file mode 100644 index 0000000000..2a3b4ffe36 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-rest-id-exhausted.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-exhausted.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-dflt.template +/*--- +description: RestElement applied to an exhausted iterator (private class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [Symbol.iterator, class, class-methods-private, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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, + [...] + b. If iteratorRecord.[[done]] is true, then + i. If environment is undefined, return PutValue(lhs, A). + ii. Return InitializeReferencedBinding(lhs, A). + +---*/ + +var callCount = 0; +class C { + * #method([, , ...x] = [1, 2]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 0); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-rest-id.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-rest-id.js new file mode 100644 index 0000000000..2471513fcd --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-rest-id.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-dflt.template +/*--- +description: Lone rest element (private class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + [...] 3. Let A be ArrayCreate(0). [...] 5. Repeat + [...] + f. Let status be CreateDataProperty(A, ToString (n), nextValue). + [...] +---*/ +var values = [1, 2, 3]; + +var callCount = 0; +class C { + * #method([...x] = values) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-rest-init-ary.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-rest-init-ary.js new file mode 100644 index 0000000000..a8f1dc96c4 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-rest-init-ary.js @@ -0,0 +1,86 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-ary.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-dflt.template +/*--- +description: Rest element (nested array pattern) does not support initializer (private class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, generators, destructuring-binding, default-parameters] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var callCount = 0; +class C { + * #method([...[ x ] = []] = []) { + + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-rest-init-id.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-rest-init-id.js new file mode 100644 index 0000000000..59c17b3e83 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-rest-init-id.js @@ -0,0 +1,86 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-id.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-dflt.template +/*--- +description: Rest element (identifier) does not support initializer (private class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, generators, destructuring-binding, default-parameters] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var callCount = 0; +class C { + * #method([...x = []] = []) { + + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-rest-init-obj.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-rest-init-obj.js new file mode 100644 index 0000000000..0587e01b0f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-rest-init-obj.js @@ -0,0 +1,86 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-obj.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-dflt.template +/*--- +description: Rest element (nested object pattern) does not support initializer (private class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, generators, destructuring-binding, default-parameters] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var callCount = 0; +class C { + * #method([...{ x } = []] = []) { + + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-rest-not-final-ary.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-rest-not-final-ary.js new file mode 100644 index 0000000000..ca1a6cb75c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-rest-not-final-ary.js @@ -0,0 +1,86 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-ary.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-dflt.template +/*--- +description: Rest element (array binding pattern) may not be followed by any element (private class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, generators, destructuring-binding, default-parameters] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var callCount = 0; +class C { + * #method([...[x], y] = [1, 2, 3]) { + + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-rest-not-final-id.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-rest-not-final-id.js new file mode 100644 index 0000000000..352a65595c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-rest-not-final-id.js @@ -0,0 +1,86 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-id.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-dflt.template +/*--- +description: Rest element (identifier) may not be followed by any element (private class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, generators, destructuring-binding, default-parameters] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var callCount = 0; +class C { + * #method([...x, y] = [1, 2, 3]) { + + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-rest-not-final-obj.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-rest-not-final-obj.js new file mode 100644 index 0000000000..b1c63e5154 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-rest-not-final-obj.js @@ -0,0 +1,86 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-obj.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-dflt.template +/*--- +description: Rest element (object binding pattern) may not be followed by any element (private class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, generators, destructuring-binding, default-parameters] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var callCount = 0; +class C { + * #method([...{ x }, y] = [1, 2, 3]) { + + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-rest-obj-id.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-rest-obj-id.js new file mode 100644 index 0000000000..85010b5246 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-rest-obj-id.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-id.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-dflt.template +/*--- +description: Rest element containing an object binding pattern (private class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ + +var callCount = 0; +class C { + * #method([...{ length }] = [1, 2, 3]) { + assert.sameValue(length, 3); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-rest-obj-prop-id.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-rest-obj-prop-id.js new file mode 100644 index 0000000000..e7162c2ef9 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-ary-ptrn-rest-obj-prop-id.js @@ -0,0 +1,97 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-prop-id.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-dflt.template +/*--- +description: Rest element containing an object binding pattern (private class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ +let length = "outer"; + +var callCount = 0; +class C { + * #method([...{ 0: v, 1: w, 2: x, 3: y, length: z }] = [7, 8, 9]) { + assert.sameValue(v, 7); + assert.sameValue(w, 8); + assert.sameValue(x, 9); + assert.sameValue(y, undefined); + assert.sameValue(z, 3); + + assert.sameValue(length, "outer", "the length prop is not set as a binding name"); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-obj-ptrn-empty.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-obj-ptrn-empty.js new file mode 100644 index 0000000000..965a2c6306 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-obj-ptrn-empty.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-empty.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-dflt.template +/*--- +description: No property access occurs for an "empty" object binding pattern (private class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ +var accessCount = 0; +var obj = Object.defineProperty({}, 'attr', { + get: function() { + accessCount += 1; + } +}); + +var callCount = 0; +class C { + * #method({} = obj) { + assert.sameValue(accessCount, 0); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-obj-ptrn-id-init-fn-name-arrow.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-obj-ptrn-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..c0fc68acc5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-obj-ptrn-id-init-fn-name-arrow.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-arrow.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-dflt.template +/*--- +description: SingleNameBinding assigns `name` to arrow functions (private class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +class C { + * #method({ arrow = () => {} } = {}) { + assert.sameValue(arrow.name, 'arrow'); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-obj-ptrn-id-init-fn-name-class.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-obj-ptrn-id-init-fn-name-class.js new file mode 100644 index 0000000000..c65aac3dab --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-obj-ptrn-id-init-fn-name-class.js @@ -0,0 +1,92 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-class.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-dflt.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (private class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +class C { + * #method({ cls = class {}, xCls = class X {}, xCls2 = class { static name() {} } } = {}) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + assert.notSameValue(xCls2.name, 'xCls2'); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-obj-ptrn-id-init-fn-name-cover.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-obj-ptrn-id-init-fn-name-cover.js new file mode 100644 index 0000000000..7950cae0f0 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-obj-ptrn-id-init-fn-name-cover.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-cover.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-dflt.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" functions "through" cover grammar (private class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +class C { + * #method({ cover = (function () {}), xCover = (0, function() {}) } = {}) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-obj-ptrn-id-init-fn-name-fn.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-obj-ptrn-id-init-fn-name-fn.js new file mode 100644 index 0000000000..8bdf510a84 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-obj-ptrn-id-init-fn-name-fn.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-fn.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (private class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +class C { + * #method({ fn = function () {}, xFn = function x() {} } = {}) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-obj-ptrn-id-init-fn-name-gen.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-obj-ptrn-id-init-fn-name-gen.js new file mode 100644 index 0000000000..99cc90f75c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-obj-ptrn-id-init-fn-name-gen.js @@ -0,0 +1,92 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-gen.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (private class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, class, class-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). + +---*/ + +var callCount = 0; +class C { + * #method({ gen = function* () {}, xGen = function* x() {} } = {}) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-obj-ptrn-id-init-skipped.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-obj-ptrn-id-init-skipped.js new file mode 100644 index 0000000000..9b8613fe4f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-obj-ptrn-id-init-skipped.js @@ -0,0 +1,94 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-skipped.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-dflt.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (private class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +class C { + * #method({ w = counter(), x = counter(), y = counter(), z = counter() } = { w: null, x: 0, y: false, z: '' }) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-obj-ptrn-id-trailing-comma.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-obj-ptrn-id-trailing-comma.js new file mode 100644 index 0000000000..2d41f62d11 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-obj-ptrn-id-trailing-comma.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-trailing-comma.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-dflt.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (private class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +class C { + * #method({ x, } = { x: 23 }) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-obj-ptrn-prop-ary-init.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-obj-ptrn-prop-ary-init.js new file mode 100644 index 0000000000..617fd832da --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-obj-ptrn-prop-ary-init.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-init.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-dflt.template +/*--- +description: Object binding pattern with "nested" array binding pattern using initializer (private class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 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). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +class C { + * #method({ w: [x, y, z] = [4, 5, 6] } = {}) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-obj-ptrn-prop-ary-trailing-comma.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-obj-ptrn-prop-ary-trailing-comma.js new file mode 100644 index 0000000000..1c786ab378 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-obj-ptrn-prop-ary-trailing-comma.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-trailing-comma.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-dflt.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (private class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +class C { + * #method({ x: [y], } = { x: [45] }) { + assert.sameValue(y,45); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-obj-ptrn-prop-ary.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-obj-ptrn-prop-ary.js new file mode 100644 index 0000000000..bbdcb45d6a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-obj-ptrn-prop-ary.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-dflt.template +/*--- +description: Object binding pattern with "nested" array binding pattern not using initializer (private class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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. +---*/ + +var callCount = 0; +class C { + * #method({ w: [x, y, z] = [4, 5, 6] } = { w: [7, undefined, ] }) { + assert.sameValue(x, 7); + assert.sameValue(y, undefined); + assert.sameValue(z, undefined); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-obj-ptrn-prop-id-init-skipped.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-obj-ptrn-prop-id-init-skipped.js new file mode 100644 index 0000000000..45b5316041 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-obj-ptrn-prop-id-init-skipped.js @@ -0,0 +1,106 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-skipped.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-dflt.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (private class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +class C { + * #method({ s: t = counter(), u: v = counter(), w: x = counter(), y: z = counter() } = { s: null, u: 0, w: false, y: '' }) { + assert.sameValue(t, null); + assert.sameValue(v, 0); + assert.sameValue(x, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + + assert.throws(ReferenceError, function() { + s; + }); + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-obj-ptrn-prop-id-init.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-obj-ptrn-prop-id-init.js new file mode 100644 index 0000000000..3f0adefb70 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-obj-ptrn-prop-id-init.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-dflt.template +/*--- +description: Binding as specified via property name, identifier, and initializer (private class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + * #method({ x: y = 33 } = { }) { + assert.sameValue(y, 33); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-obj-ptrn-prop-id-trailing-comma.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-obj-ptrn-prop-id-trailing-comma.js new file mode 100644 index 0000000000..0c95a50eed --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-obj-ptrn-prop-id-trailing-comma.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-trailing-comma.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-dflt.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (private class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +class C { + * #method({ x: y, } = { x: 23 }) { + assert.sameValue(y, 23); + + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-obj-ptrn-prop-id.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-obj-ptrn-prop-id.js new file mode 100644 index 0000000000..cce7a615a4 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-obj-ptrn-prop-id.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-dflt.template +/*--- +description: Binding as specified via property name and identifier (private class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + * #method({ x: y } = { x: 23 }) { + assert.sameValue(y, 23); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-obj-ptrn-prop-obj-init.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-obj-ptrn-prop-obj-init.js new file mode 100644 index 0000000000..6176c1e7fa --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-obj-ptrn-prop-obj-init.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-init.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern using initializer (private class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 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). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +class C { + * #method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } } = { w: undefined }) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-obj-ptrn-prop-obj.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-obj-ptrn-prop-obj.js new file mode 100644 index 0000000000..25a0f5b49e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-obj-ptrn-prop-obj.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern not using initializer (private class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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. +---*/ + +var callCount = 0; +class C { + * #method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } } = { w: { x: undefined, z: 7 } }) { + assert.sameValue(x, undefined); + assert.sameValue(y, undefined); + assert.sameValue(z, 7); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-obj-ptrn-rest-getter.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-obj-ptrn-rest-getter.js new file mode 100644 index 0000000000..a1e57c2956 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-obj-ptrn-rest-getter.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-getter.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-dflt.template +/*--- +description: Getter is called when obj is being deconstructed to a rest Object (private class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [object-rest, class, class-methods-private, generators, destructuring-binding, default-parameters] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var count = 0; + +var callCount = 0; +class C { + * #method({...x} = { get v() { count++; return 2; } }) { + assert.sameValue(count, 1); + + verifyProperty(x, "v", { + enumerable: true, + writable: true, + configurable: true, + value: 2 + }); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-obj-ptrn-rest-skip-non-enumerable.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-obj-ptrn-rest-skip-non-enumerable.js new file mode 100644 index 0000000000..73a2e88fe1 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-obj-ptrn-rest-skip-non-enumerable.js @@ -0,0 +1,94 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-skip-non-enumerable.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-dflt.template +/*--- +description: Rest object doesn't contain non-enumerable properties (private class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [object-rest, class, class-methods-private, generators, destructuring-binding, default-parameters] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var o = {a: 3, b: 4}; +Object.defineProperty(o, "x", { value: 4, enumerable: false }); + +var callCount = 0; +class C { + * #method({...rest} = o) { + assert.sameValue(rest.x, undefined); + + verifyProperty(rest, "a", { + enumerable: true, + writable: true, + configurable: true, + value: 3 + }); + + verifyProperty(rest, "b", { + enumerable: true, + writable: true, + configurable: true, + value: 4 + }); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-obj-ptrn-rest-val-obj.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-obj-ptrn-rest-val-obj.js new file mode 100644 index 0000000000..2420235701 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-dflt-obj-ptrn-rest-val-obj.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-val-obj.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-dflt.template +/*--- +description: Rest object contains just unextracted data (private class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [object-rest, class, class-methods-private, generators, destructuring-binding, default-parameters] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +class C { + * #method({a, b, ...rest} = {x: 1, y: 2, a: 5, b: 3}) { + assert.sameValue(rest.a, undefined); + assert.sameValue(rest.b, undefined); + + verifyProperty(rest, "x", { + enumerable: true, + writable: true, + configurable: true, + value: 1 + }); + + verifyProperty(rest, "y", { + enumerable: true, + writable: true, + configurable: true, + value: 2 + }); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-obj-ptrn-empty.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-obj-ptrn-empty.js new file mode 100644 index 0000000000..f87909cbf6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-obj-ptrn-empty.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-empty.case +// - src/dstr-binding/default/cls-decl-private-gen-meth.template +/*--- +description: No property access occurs for an "empty" object binding pattern (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ +var accessCount = 0; +var obj = Object.defineProperty({}, 'attr', { + get: function() { + accessCount += 1; + } +}); + +var callCount = 0; +class C { + * #method({}) { + assert.sameValue(accessCount, 0); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method(obj).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-obj-ptrn-id-init-fn-name-arrow.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-obj-ptrn-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..864d7c02c4 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-obj-ptrn-id-init-fn-name-arrow.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-arrow.case +// - src/dstr-binding/default/cls-decl-private-gen-meth.template +/*--- +description: SingleNameBinding assigns `name` to arrow functions (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +class C { + * #method({ arrow = () => {} }) { + assert.sameValue(arrow.name, 'arrow'); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method({}).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-obj-ptrn-id-init-fn-name-class.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-obj-ptrn-id-init-fn-name-class.js new file mode 100644 index 0000000000..ddbf88da04 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-obj-ptrn-id-init-fn-name-class.js @@ -0,0 +1,92 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-class.case +// - src/dstr-binding/default/cls-decl-private-gen-meth.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +class C { + * #method({ cls = class {}, xCls = class X {}, xCls2 = class { static name() {} } }) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + assert.notSameValue(xCls2.name, 'xCls2'); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method({}).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-obj-ptrn-id-init-fn-name-cover.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-obj-ptrn-id-init-fn-name-cover.js new file mode 100644 index 0000000000..d297311c54 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-obj-ptrn-id-init-fn-name-cover.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-cover.case +// - src/dstr-binding/default/cls-decl-private-gen-meth.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" functions "through" cover grammar (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +class C { + * #method({ cover = (function () {}), xCover = (0, function() {}) }) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method({}).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-obj-ptrn-id-init-fn-name-fn.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-obj-ptrn-id-init-fn-name-fn.js new file mode 100644 index 0000000000..afa707d2ef --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-obj-ptrn-id-init-fn-name-fn.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-fn.case +// - src/dstr-binding/default/cls-decl-private-gen-meth.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +class C { + * #method({ fn = function () {}, xFn = function x() {} }) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method({}).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-obj-ptrn-id-init-fn-name-gen.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-obj-ptrn-id-init-fn-name-gen.js new file mode 100644 index 0000000000..6b93f34787 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-obj-ptrn-id-init-fn-name-gen.js @@ -0,0 +1,92 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-gen.case +// - src/dstr-binding/default/cls-decl-private-gen-meth.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators, class, class-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). + +---*/ + +var callCount = 0; +class C { + * #method({ gen = function* () {}, xGen = function* x() {} }) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method({}).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-obj-ptrn-id-init-skipped.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-obj-ptrn-id-init-skipped.js new file mode 100644 index 0000000000..43dc08e2bc --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-obj-ptrn-id-init-skipped.js @@ -0,0 +1,94 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-skipped.case +// - src/dstr-binding/default/cls-decl-private-gen-meth.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +class C { + * #method({ w = counter(), x = counter(), y = counter(), z = counter() }) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method({ w: null, x: 0, y: false, z: '' }).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-obj-ptrn-id-trailing-comma.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-obj-ptrn-id-trailing-comma.js new file mode 100644 index 0000000000..75e9f31a63 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-obj-ptrn-id-trailing-comma.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-trailing-comma.case +// - src/dstr-binding/default/cls-decl-private-gen-meth.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +class C { + * #method({ x, }) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method({ x: 23 }).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-obj-ptrn-prop-ary-init.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-obj-ptrn-prop-ary-init.js new file mode 100644 index 0000000000..fae83b5565 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-obj-ptrn-prop-ary-init.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-init.case +// - src/dstr-binding/default/cls-decl-private-gen-meth.template +/*--- +description: Object binding pattern with "nested" array binding pattern using initializer (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 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). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +class C { + * #method({ w: [x, y, z] = [4, 5, 6] }) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method({}).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-obj-ptrn-prop-ary-trailing-comma.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-obj-ptrn-prop-ary-trailing-comma.js new file mode 100644 index 0000000000..a3391bbf10 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-obj-ptrn-prop-ary-trailing-comma.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-trailing-comma.case +// - src/dstr-binding/default/cls-decl-private-gen-meth.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +class C { + * #method({ x: [y], }) { + assert.sameValue(y,45); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method({ x: [45] }).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-obj-ptrn-prop-ary.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-obj-ptrn-prop-ary.js new file mode 100644 index 0000000000..fd4d92aecc --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-obj-ptrn-prop-ary.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary.case +// - src/dstr-binding/default/cls-decl-private-gen-meth.template +/*--- +description: Object binding pattern with "nested" array binding pattern not using initializer (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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. +---*/ + +var callCount = 0; +class C { + * #method({ w: [x, y, z] = [4, 5, 6] }) { + assert.sameValue(x, 7); + assert.sameValue(y, undefined); + assert.sameValue(z, undefined); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method({ w: [7, undefined, ] }).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-obj-ptrn-prop-id-init-skipped.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-obj-ptrn-prop-id-init-skipped.js new file mode 100644 index 0000000000..95cdaa1c78 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-obj-ptrn-prop-id-init-skipped.js @@ -0,0 +1,106 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-skipped.case +// - src/dstr-binding/default/cls-decl-private-gen-meth.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +class C { + * #method({ s: t = counter(), u: v = counter(), w: x = counter(), y: z = counter() }) { + assert.sameValue(t, null); + assert.sameValue(v, 0); + assert.sameValue(x, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + + assert.throws(ReferenceError, function() { + s; + }); + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method({ s: null, u: 0, w: false, y: '' }).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-obj-ptrn-prop-id-init.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-obj-ptrn-prop-id-init.js new file mode 100644 index 0000000000..2397f74699 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-obj-ptrn-prop-id-init.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init.case +// - src/dstr-binding/default/cls-decl-private-gen-meth.template +/*--- +description: Binding as specified via property name, identifier, and initializer (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + * #method({ x: y = 33 }) { + assert.sameValue(y, 33); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method({ }).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-obj-ptrn-prop-id-trailing-comma.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-obj-ptrn-prop-id-trailing-comma.js new file mode 100644 index 0000000000..4e8ad1b210 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-obj-ptrn-prop-id-trailing-comma.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-trailing-comma.case +// - src/dstr-binding/default/cls-decl-private-gen-meth.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +class C { + * #method({ x: y, }) { + assert.sameValue(y, 23); + + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method({ x: 23 }).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-obj-ptrn-prop-id.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-obj-ptrn-prop-id.js new file mode 100644 index 0000000000..05418aa63d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-obj-ptrn-prop-id.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id.case +// - src/dstr-binding/default/cls-decl-private-gen-meth.template +/*--- +description: Binding as specified via property name and identifier (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + * #method({ x: y }) { + assert.sameValue(y, 23); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method({ x: 23 }).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-obj-ptrn-prop-obj-init.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-obj-ptrn-prop-obj-init.js new file mode 100644 index 0000000000..84a4815aea --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-obj-ptrn-prop-obj-init.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-init.case +// - src/dstr-binding/default/cls-decl-private-gen-meth.template +/*--- +description: Object binding pattern with "nested" object binding pattern using initializer (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 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). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +class C { + * #method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } }) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method({ w: undefined }).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-obj-ptrn-prop-obj.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-obj-ptrn-prop-obj.js new file mode 100644 index 0000000000..5b68fbc521 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-obj-ptrn-prop-obj.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj.case +// - src/dstr-binding/default/cls-decl-private-gen-meth.template +/*--- +description: Object binding pattern with "nested" object binding pattern not using initializer (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, class-methods-private, generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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. +---*/ + +var callCount = 0; +class C { + * #method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } }) { + assert.sameValue(x, undefined); + assert.sameValue(y, undefined); + assert.sameValue(z, 7); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method({ w: { x: undefined, z: 7 } }).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-obj-ptrn-rest-getter.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-obj-ptrn-rest-getter.js new file mode 100644 index 0000000000..3ba88c7034 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-obj-ptrn-rest-getter.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-getter.case +// - src/dstr-binding/default/cls-decl-private-gen-meth.template +/*--- +description: Getter is called when obj is being deconstructed to a rest Object (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [object-rest, class, class-methods-private, generators, destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var count = 0; + +var callCount = 0; +class C { + * #method({...x}) { + assert.sameValue(count, 1); + + verifyProperty(x, "v", { + enumerable: true, + writable: true, + configurable: true, + value: 2 + }); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method({ get v() { count++; return 2; } }).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-obj-ptrn-rest-skip-non-enumerable.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-obj-ptrn-rest-skip-non-enumerable.js new file mode 100644 index 0000000000..debb0886f4 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-obj-ptrn-rest-skip-non-enumerable.js @@ -0,0 +1,94 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-skip-non-enumerable.case +// - src/dstr-binding/default/cls-decl-private-gen-meth.template +/*--- +description: Rest object doesn't contain non-enumerable properties (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [object-rest, class, class-methods-private, generators, destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var o = {a: 3, b: 4}; +Object.defineProperty(o, "x", { value: 4, enumerable: false }); + +var callCount = 0; +class C { + * #method({...rest}) { + assert.sameValue(rest.x, undefined); + + verifyProperty(rest, "a", { + enumerable: true, + writable: true, + configurable: true, + value: 3 + }); + + verifyProperty(rest, "b", { + enumerable: true, + writable: true, + configurable: true, + value: 4 + }); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method(o).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-obj-ptrn-rest-val-obj.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-obj-ptrn-rest-val-obj.js new file mode 100644 index 0000000000..4ca3a11464 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-obj-ptrn-rest-val-obj.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-val-obj.case +// - src/dstr-binding/default/cls-decl-private-gen-meth.template +/*--- +description: Rest object contains just unextracted data (private class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [object-rest, class, class-methods-private, generators, destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +class C { + * #method({a, b, ...rest}) { + assert.sameValue(rest.a, undefined); + assert.sameValue(rest.b, undefined); + + verifyProperty(rest, "x", { + enumerable: true, + writable: true, + configurable: true, + value: 1 + }); + + verifyProperty(rest, "y", { + enumerable: true, + writable: true, + configurable: true, + value: 2 + }); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method({x: 1, y: 2, a: 5, b: 3}).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-init-iter-close.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-init-iter-close.js new file mode 100644 index 0000000000..127435de5c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-init-iter-close.js @@ -0,0 +1,100 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-close.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static.template +/*--- +description: Iterator is closed when not exhausted by pattern evaluation (private static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [Symbol.iterator, class, class-static-methods-private, generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: false }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var callCount = 0; +class C { + static * #method([x]) { + assert.sameValue(doneCallCount, 1); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method(iter).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-init-iter-no-close.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-init-iter-no-close.js new file mode 100644 index 0000000000..7d156e7d3e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-init-iter-no-close.js @@ -0,0 +1,100 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-no-close.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static.template +/*--- +description: Iterator is not closed when exhausted by pattern evaluation (private static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [Symbol.iterator, class, class-static-methods-private, generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: true }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var callCount = 0; +class C { + static * #method([x]) { + assert.sameValue(doneCallCount, 0); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method(iter).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-name-iter-val.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-name-iter-val.js new file mode 100644 index 0000000000..b34129cd3c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-name-iter-val.js @@ -0,0 +1,99 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-name-iter-val.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static.template +/*--- +description: SingleNameBinding with normal value iteration (private static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static * #method([x, y, z]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method([1, 2, 3]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-elem-ary-elem-init.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-elem-ary-elem-init.js new file mode 100644 index 0000000000..b6c7405ead --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-elem-ary-elem-init.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-init.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static.template +/*--- +description: BindingElement with array binding pattern and initializer is used (private static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + static * #method([[x, y, z] = [4, 5, 6]]) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method([]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-elem-ary-elem-iter.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-elem-ary-elem-iter.js new file mode 100644 index 0000000000..09dcd9547f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-elem-ary-elem-iter.js @@ -0,0 +1,92 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-iter.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (private static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + static * #method([[x, y, z] = [4, 5, 6]]) { + assert.sameValue(x, 7); + assert.sameValue(y, 8); + assert.sameValue(z, 9); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method([[7, 8, 9]]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-elem-ary-elision-init.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-elem-ary-elision-init.js new file mode 100644 index 0000000000..341dd3f8c8 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-elem-ary-elision-init.js @@ -0,0 +1,98 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-init.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static.template +/*--- +description: BindingElement with array binding pattern and initializer is used (private static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, class, class-static-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +class C { + static * #method([[,] = g()]) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method([]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-elem-ary-elision-iter.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-elem-ary-elision-iter.js new file mode 100644 index 0000000000..e1c3adb7b1 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-elem-ary-elision-iter.js @@ -0,0 +1,95 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-iter.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (private static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, class, class-static-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var callCount = 0; +function* g() { + callCount += 1; +}; + +var callCount = 0; +class C { + static * #method([[,] = g()]) { + assert.sameValue(callCount, 0); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method([[]]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-elem-ary-empty-init.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-elem-ary-empty-init.js new file mode 100644 index 0000000000..e12e6df246 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-elem-ary-empty-init.js @@ -0,0 +1,94 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-init.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static.template +/*--- +description: BindingElement with array binding pattern and initializer is used (private static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, class, class-static-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var initCount = 0; +var iterCount = 0; +var iter = function*() { iterCount += 1; }(); + +var callCount = 0; +class C { + static * #method([[] = function() { initCount += 1; return iter; }()]) { + assert.sameValue(initCount, 1); + assert.sameValue(iterCount, 0); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method([]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-elem-ary-empty-iter.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-elem-ary-empty-iter.js new file mode 100644 index 0000000000..157c58a65d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-elem-ary-empty-iter.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-iter.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (private static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var initCount = 0; + +var callCount = 0; +class C { + static * #method([[] = function() { initCount += 1; }()]) { + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method([[23]]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-elem-ary-rest-init.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-elem-ary-rest-init.js new file mode 100644 index 0000000000..dbe8c7beaa --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-elem-ary-rest-init.js @@ -0,0 +1,95 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-init.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static.template +/*--- +description: BindingElement with array binding pattern and initializer is used (private static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; + +var callCount = 0; +class C { + static * #method([[...x] = values]) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method([]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-elem-ary-rest-iter.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-elem-ary-rest-iter.js new file mode 100644 index 0000000000..fbe8ef0952 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-elem-ary-rest-iter.js @@ -0,0 +1,98 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-iter.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (private static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; +var initCount = 0; + +var callCount = 0; +class C { + static * #method([[...x] = function() { initCount += 1; }()]) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method([values]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-elem-id-init-exhausted.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-elem-id-init-exhausted.js new file mode 100644 index 0000000000..5d9a566565 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-elem-id-init-exhausted.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-exhausted.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static.template +/*--- +description: Destructuring initializer with an exhausted iterator (private static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static * #method([x = 23]) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method([]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-elem-id-init-fn-name-arrow.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-elem-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..c097982786 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-elem-id-init-fn-name-arrow.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-arrow.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static.template +/*--- +description: SingleNameBinding does assign name to arrow functions (private static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static * #method([arrow = () => {}]) { + assert.sameValue(arrow.name, 'arrow'); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method([]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-elem-id-init-fn-name-class.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-elem-id-init-fn-name-class.js new file mode 100644 index 0000000000..988101c990 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-elem-id-init-fn-name-class.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-class.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (private static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static * #method([cls = class {}, xCls = class X {}, xCls2 = class { static name() {} }]) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + assert.notSameValue(xCls2.name, 'xCls2'); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method([]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-elem-id-init-fn-name-cover.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-elem-id-init-fn-name-cover.js new file mode 100644 index 0000000000..791be9102e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-elem-id-init-fn-name-cover.js @@ -0,0 +1,92 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-cover.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static.template +/*--- +description: SingleNameBinding does assign name to "anonymous" functions "through" cover grammar (private static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static * #method([cover = (function () {}), xCover = (0, function() {})]) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method([]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-elem-id-init-fn-name-fn.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-elem-id-init-fn-name-fn.js new file mode 100644 index 0000000000..3d527a6cc8 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-elem-id-init-fn-name-fn.js @@ -0,0 +1,92 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-fn.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (private static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static * #method([fn = function () {}, xFn = function x() {}]) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method([]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-elem-id-init-fn-name-gen.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-elem-id-init-fn-name-gen.js new file mode 100644 index 0000000000..479c84a633 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-elem-id-init-fn-name-gen.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-gen.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (private static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, class, class-static-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). + +---*/ + +var callCount = 0; +class C { + static * #method([gen = function* () {}, xGen = function* x() {}]) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method([]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-elem-id-init-hole.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-elem-id-init-hole.js new file mode 100644 index 0000000000..8c031ae289 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-elem-id-init-hole.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-hole.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static.template +/*--- +description: Destructuring initializer with a "hole" (private static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + [...] + 7. If environment is undefined, return PutValue(lhs, v). 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static * #method([x = 23]) { + assert.sameValue(x, 23); + // another statement + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method([,]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-elem-id-init-skipped.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-elem-id-init-skipped.js new file mode 100644 index 0000000000..0ef744bfac --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-elem-id-init-skipped.js @@ -0,0 +1,95 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-skipped.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (private static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +class C { + static * #method([w = counter(), x = counter(), y = counter(), z = counter()]) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method([null, 0, false, '']).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-elem-id-init-undef.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-elem-id-init-undef.js new file mode 100644 index 0000000000..6d17df77fd --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-elem-id-init-undef.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-undef.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static.template +/*--- +description: Destructuring initializer with an undefined value (private static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static * #method([x = 23]) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method([undefined]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-elem-id-iter-complete.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-elem-id-iter-complete.js new file mode 100644 index 0000000000..954e1e06a1 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-elem-id-iter-complete.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-complete.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static.template +/*--- +description: SingleNameBinding when value iteration completes (private static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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, + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static * #method([x]) { + assert.sameValue(x, undefined); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method([]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-elem-id-iter-done.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-elem-id-iter-done.js new file mode 100644 index 0000000000..60b7713822 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-elem-id-iter-done.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-done.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static.template +/*--- +description: SingleNameBinding when value iteration was completed previously (private static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static * #method([_, x]) { + assert.sameValue(x, undefined); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method([]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-elem-id-iter-val-array-prototype.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-elem-id-iter-val-array-prototype.js new file mode 100644 index 0000000000..ebba9fb209 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-elem-id-iter-val-array-prototype.js @@ -0,0 +1,109 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val-array-prototype.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static.template +/*--- +description: Array destructuring uses overriden Array.prototype[Symbol.iterator] (private static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [Symbol.iterator, generators, class, class-static-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializer_opt + + 1. Let bindingId be StringValue of BindingIdentifier. + 2. Let lhs be ? ResolveBinding(bindingId, environment). + 3. If iteratorRecord.[[Done]] is false, then + a. Let next be IteratorStep(iteratorRecord). + 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). + [...] + 7. Return InitializeReferencedBinding(lhs, v). + +---*/ +Array.prototype[Symbol.iterator] = function* () { + if (this.length > 0) { + yield this[0]; + } + if (this.length > 1) { + yield this[1]; + } + if (this.length > 2) { + yield 42; + } +}; + +var callCount = 0; +class C { + static * #method([x, y, z]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 42); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method([1, 2, 3]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-elem-id-iter-val.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-elem-id-iter-val.js new file mode 100644 index 0000000000..cbe2780269 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-elem-id-iter-val.js @@ -0,0 +1,99 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static.template +/*--- +description: SingleNameBinding when value iteration was completed previously (private static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static * #method([x, y, z]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method([1, 2, 3]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-elem-obj-id-init.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-elem-obj-id-init.js new file mode 100644 index 0000000000..118af221d6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-elem-obj-id-init.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id-init.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static.template +/*--- +description: BindingElement with object binding pattern and initializer is used (private static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + static * #method([{ x, y, z } = { x: 44, y: 55, z: 66 }]) { + assert.sameValue(x, 44); + assert.sameValue(y, 55); + assert.sameValue(z, 66); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method([]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-elem-obj-id.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-elem-obj-id.js new file mode 100644 index 0000000000..c7c83f5e9b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-elem-obj-id.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (private static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + static * #method([{ x, y, z } = { x: 44, y: 55, z: 66 }]) { + assert.sameValue(x, 11); + assert.sameValue(y, 22); + assert.sameValue(z, 33); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method([{ x: 11, y: 22, z: 33 }]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-elem-obj-prop-id-init.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-elem-obj-prop-id-init.js new file mode 100644 index 0000000000..9de34b02cb --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-elem-obj-prop-id-init.js @@ -0,0 +1,101 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id-init.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static.template +/*--- +description: BindingElement with object binding pattern and initializer is used (private static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + static * #method([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }]) { + assert.sameValue(v, 444); + assert.sameValue(x, 555); + assert.sameValue(z, 666); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method([]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-elem-obj-prop-id.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-elem-obj-prop-id.js new file mode 100644 index 0000000000..fe33488c09 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-elem-obj-prop-id.js @@ -0,0 +1,101 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (private static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + static * #method([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }]) { + assert.sameValue(v, 777); + assert.sameValue(x, 888); + assert.sameValue(z, 999); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method([{ u: 777, w: 888, y: 999 }]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-elision-exhausted.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-elision-exhausted.js new file mode 100644 index 0000000000..09e2dae315 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-elision-exhausted.js @@ -0,0 +1,96 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-exhausted.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static.template +/*--- +description: Elision accepts exhausted iterator (private static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, class, class-static-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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 + [...] + 2. Return NormalCompletion(empty). + +---*/ +var iter = function*() {}(); +iter.next(); + +var callCount = 0; +class C { + static * #method([,]) { + + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method(iter).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-elision.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-elision.js new file mode 100644 index 0000000000..4a183f15fa --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-elision.js @@ -0,0 +1,105 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static.template +/*--- +description: Elision advances iterator (private static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, class, class-static-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +class C { + static * #method([,]) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method(g()).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-empty.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-empty.js new file mode 100644 index 0000000000..557ddf2e3b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-empty.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-empty.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static.template +/*--- +description: No iteration occurs for an "empty" array binding pattern (private static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, class, class-static-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var callCount = 0; +class C { + static * #method([]) { + assert.sameValue(iterations, 0); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method(iter).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-rest-ary-elem.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-rest-ary-elem.js new file mode 100644 index 0000000000..6d88bd2098 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-rest-ary-elem.js @@ -0,0 +1,112 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elem.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static.template +/*--- +description: Rest element containing an array BindingElementList pattern (private static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the 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). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static * #method([...[x, y, z]]) { + assert.sameValue(x, 3); + assert.sameValue(y, 4); + assert.sameValue(z, 5); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method([3, 4, 5]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-rest-ary-elision.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-rest-ary-elision.js new file mode 100644 index 0000000000..8f04a77eb0 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-rest-ary-elision.js @@ -0,0 +1,118 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elision.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static.template +/*--- +description: Rest element containing an elision (private static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, class, class-static-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the 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). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +class C { + static * #method([...[,]]) { + assert.sameValue(first, 1); + assert.sameValue(second, 1); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method(g()).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-rest-ary-empty.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-rest-ary-empty.js new file mode 100644 index 0000000000..a64ad48fa1 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-rest-ary-empty.js @@ -0,0 +1,101 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-empty.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static.template +/*--- +description: Rest element containing an "empty" array pattern (private static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, class, class-static-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var callCount = 0; +class C { + static * #method([...[]]) { + assert.sameValue(iterations, 1); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method(iter).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-rest-ary-rest.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-rest-ary-rest.js new file mode 100644 index 0000000000..613d9db4a5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-rest-ary-rest.js @@ -0,0 +1,97 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-rest.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static.template +/*--- +description: Rest element containing a rest element (private static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ +var values = [1, 2, 3]; + +var callCount = 0; +class C { + static * #method([...[...x]]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method(values).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-rest-id-direct.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-rest-id-direct.js new file mode 100644 index 0000000000..e121847fb3 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-rest-id-direct.js @@ -0,0 +1,92 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-direct.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static.template +/*--- +description: Lone rest element (direct binding) (private static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, generators, destructuring-binding] +flags: [generated] +includes: [compareArray.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingIdentifier + + [...] + 2. Let A be ! ArrayCreate(0). + 3. Let n be 0. + 4. Repeat, + [...] + f. Perform ! CreateDataPropertyOrThrow(A, ! ToString(n), nextValue). + g. Set n to n + 1. + +---*/ + +var callCount = 0; +class C { + static * #method([...x]) { + assert(Array.isArray(x)); + assert.compareArray(x, [1]); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method([1]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-rest-id-elision.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-rest-id-elision.js new file mode 100644 index 0000000000..9921121677 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-rest-id-elision.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static.template +/*--- +description: Rest element following elision elements (private static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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 values = [1, 2, 3, 4, 5]; + +var callCount = 0; +class C { + static * #method([ , , ...x]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 3); + assert.sameValue(x[1], 4); + assert.sameValue(x[2], 5); + assert.notSameValue(x, values); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method(values).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-rest-id-exhausted.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-rest-id-exhausted.js new file mode 100644 index 0000000000..ba392de7f0 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-rest-id-exhausted.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-exhausted.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static.template +/*--- +description: RestElement applied to an exhausted iterator (private static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [Symbol.iterator, class, class-static-methods-private, generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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, + [...] + b. If iteratorRecord.[[done]] is true, then + i. If environment is undefined, return PutValue(lhs, A). + ii. Return InitializeReferencedBinding(lhs, A). + +---*/ + +var callCount = 0; +class C { + static * #method([, , ...x]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 0); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method([1, 2]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-rest-id.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-rest-id.js new file mode 100644 index 0000000000..04111f98aa --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-rest-id.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static.template +/*--- +description: Lone rest element (private static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + [...] 3. Let A be ArrayCreate(0). [...] 5. Repeat + [...] + f. Let status be CreateDataProperty(A, ToString (n), nextValue). + [...] +---*/ +var values = [1, 2, 3]; + +var callCount = 0; +class C { + static * #method([...x]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method(values).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-rest-init-ary.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-rest-init-ary.js new file mode 100644 index 0000000000..0c1e144905 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-rest-init-ary.js @@ -0,0 +1,86 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-ary.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static.template +/*--- +description: Rest element (nested array pattern) does not support initializer (private static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, generators, destructuring-binding] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var callCount = 0; +class C { + static * #method([...[ x ] = []]) { + + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method([]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-rest-init-id.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-rest-init-id.js new file mode 100644 index 0000000000..04f38775a9 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-rest-init-id.js @@ -0,0 +1,86 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-id.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static.template +/*--- +description: Rest element (identifier) does not support initializer (private static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, generators, destructuring-binding] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var callCount = 0; +class C { + static * #method([...x = []]) { + + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method([]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-rest-init-obj.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-rest-init-obj.js new file mode 100644 index 0000000000..412e2a26d3 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-rest-init-obj.js @@ -0,0 +1,86 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-obj.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static.template +/*--- +description: Rest element (nested object pattern) does not support initializer (private static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, generators, destructuring-binding] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var callCount = 0; +class C { + static * #method([...{ x } = []]) { + + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method([]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-rest-not-final-ary.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-rest-not-final-ary.js new file mode 100644 index 0000000000..cc39d9eba6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-rest-not-final-ary.js @@ -0,0 +1,86 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-ary.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static.template +/*--- +description: Rest element (array binding pattern) may not be followed by any element (private static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, generators, destructuring-binding] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var callCount = 0; +class C { + static * #method([...[x], y]) { + + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method([1, 2, 3]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-rest-not-final-id.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-rest-not-final-id.js new file mode 100644 index 0000000000..4b048c5779 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-rest-not-final-id.js @@ -0,0 +1,86 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-id.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static.template +/*--- +description: Rest element (identifier) may not be followed by any element (private static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, generators, destructuring-binding] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var callCount = 0; +class C { + static * #method([...x, y]) { + + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method([1, 2, 3]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-rest-not-final-obj.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-rest-not-final-obj.js new file mode 100644 index 0000000000..fd1fec1cf2 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-rest-not-final-obj.js @@ -0,0 +1,86 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-obj.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static.template +/*--- +description: Rest element (object binding pattern) may not be followed by any element (private static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, generators, destructuring-binding] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var callCount = 0; +class C { + static * #method([...{ x }, y]) { + + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method([1, 2, 3]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-rest-obj-id.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-rest-obj-id.js new file mode 100644 index 0000000000..c7e9e928fb --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-rest-obj-id.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-id.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static.template +/*--- +description: Rest element containing an object binding pattern (private static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ + +var callCount = 0; +class C { + static * #method([...{ length }]) { + assert.sameValue(length, 3); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method([1, 2, 3]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-rest-obj-prop-id.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-rest-obj-prop-id.js new file mode 100644 index 0000000000..bf51b08840 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-ary-ptrn-rest-obj-prop-id.js @@ -0,0 +1,97 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-prop-id.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static.template +/*--- +description: Rest element containing an object binding pattern (private static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ +let length = "outer"; + +var callCount = 0; +class C { + static * #method([...{ 0: v, 1: w, 2: x, 3: y, length: z }]) { + assert.sameValue(v, 7); + assert.sameValue(w, 8); + assert.sameValue(x, 9); + assert.sameValue(y, undefined); + assert.sameValue(z, 3); + + assert.sameValue(length, "outer", "the length prop is not set as a binding name"); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method([7, 8, 9]).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-init-iter-close.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-init-iter-close.js new file mode 100644 index 0000000000..93e8efb994 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-init-iter-close.js @@ -0,0 +1,100 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-close.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static-dflt.template +/*--- +description: Iterator is closed when not exhausted by pattern evaluation (private static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [Symbol.iterator, class, class-static-methods-private, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: false }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var callCount = 0; +class C { + static * #method([x] = iter) { + assert.sameValue(doneCallCount, 1); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-init-iter-no-close.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-init-iter-no-close.js new file mode 100644 index 0000000000..7d385d15d7 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-init-iter-no-close.js @@ -0,0 +1,100 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-no-close.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static-dflt.template +/*--- +description: Iterator is not closed when exhausted by pattern evaluation (private static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [Symbol.iterator, class, class-static-methods-private, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: true }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var callCount = 0; +class C { + static * #method([x] = iter) { + assert.sameValue(doneCallCount, 0); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-name-iter-val.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-name-iter-val.js new file mode 100644 index 0000000000..b6461f9c61 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-name-iter-val.js @@ -0,0 +1,99 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-name-iter-val.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static-dflt.template +/*--- +description: SingleNameBinding with normal value iteration (private static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static * #method([x, y, z] = [1, 2, 3]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-elem-ary-elem-init.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-elem-ary-elem-init.js new file mode 100644 index 0000000000..014e13d47a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-elem-ary-elem-init.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-init.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (private static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + static * #method([[x, y, z] = [4, 5, 6]] = []) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-elem-ary-elem-iter.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-elem-ary-elem-iter.js new file mode 100644 index 0000000000..9744e916a1 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-elem-ary-elem-iter.js @@ -0,0 +1,92 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-iter.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (private static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + static * #method([[x, y, z] = [4, 5, 6]] = [[7, 8, 9]]) { + assert.sameValue(x, 7); + assert.sameValue(y, 8); + assert.sameValue(z, 9); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-elem-ary-elision-init.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-elem-ary-elision-init.js new file mode 100644 index 0000000000..5c4d67f420 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-elem-ary-elision-init.js @@ -0,0 +1,98 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-init.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (private static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, class, class-static-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +class C { + static * #method([[,] = g()] = []) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-elem-ary-elision-iter.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-elem-ary-elision-iter.js new file mode 100644 index 0000000000..8d64a6fa67 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-elem-ary-elision-iter.js @@ -0,0 +1,95 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-iter.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (private static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, class, class-static-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var callCount = 0; +function* g() { + callCount += 1; +}; + +var callCount = 0; +class C { + static * #method([[,] = g()] = [[]]) { + assert.sameValue(callCount, 0); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-elem-ary-empty-init.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-elem-ary-empty-init.js new file mode 100644 index 0000000000..0bf17c9718 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-elem-ary-empty-init.js @@ -0,0 +1,94 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-init.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (private static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, class, class-static-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var initCount = 0; +var iterCount = 0; +var iter = function*() { iterCount += 1; }(); + +var callCount = 0; +class C { + static * #method([[] = function() { initCount += 1; return iter; }()] = []) { + assert.sameValue(initCount, 1); + assert.sameValue(iterCount, 0); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-elem-ary-empty-iter.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-elem-ary-empty-iter.js new file mode 100644 index 0000000000..2b58d43bec --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-elem-ary-empty-iter.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-iter.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (private static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var initCount = 0; + +var callCount = 0; +class C { + static * #method([[] = function() { initCount += 1; }()] = [[23]]) { + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-elem-ary-rest-init.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-elem-ary-rest-init.js new file mode 100644 index 0000000000..bf711c5690 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-elem-ary-rest-init.js @@ -0,0 +1,95 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-init.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (private static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; + +var callCount = 0; +class C { + static * #method([[...x] = values] = []) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-elem-ary-rest-iter.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-elem-ary-rest-iter.js new file mode 100644 index 0000000000..eaaf9f8737 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-elem-ary-rest-iter.js @@ -0,0 +1,98 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-iter.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (private static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; +var initCount = 0; + +var callCount = 0; +class C { + static * #method([[...x] = function() { initCount += 1; }()] = [values]) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-elem-id-init-exhausted.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-elem-id-init-exhausted.js new file mode 100644 index 0000000000..ac83e65726 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-elem-id-init-exhausted.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-exhausted.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static-dflt.template +/*--- +description: Destructuring initializer with an exhausted iterator (private static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static * #method([x = 23] = []) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..93d4296816 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-arrow.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static-dflt.template +/*--- +description: SingleNameBinding does assign name to arrow functions (private static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static * #method([arrow = () => {}] = []) { + assert.sameValue(arrow.name, 'arrow'); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-class.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-class.js new file mode 100644 index 0000000000..7f883119c1 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-class.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-class.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static-dflt.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (private static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static * #method([cls = class {}, xCls = class X {}, xCls2 = class { static name() {} }] = []) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + assert.notSameValue(xCls2.name, 'xCls2'); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-cover.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-cover.js new file mode 100644 index 0000000000..a82d02a636 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-cover.js @@ -0,0 +1,92 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-cover.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static-dflt.template +/*--- +description: SingleNameBinding does assign name to "anonymous" functions "through" cover grammar (private static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static * #method([cover = (function () {}), xCover = (0, function() {})] = []) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-fn.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-fn.js new file mode 100644 index 0000000000..0a1ac078b5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-fn.js @@ -0,0 +1,92 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-fn.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (private static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static * #method([fn = function () {}, xFn = function x() {}] = []) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-gen.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-gen.js new file mode 100644 index 0000000000..57379d6be8 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-gen.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-gen.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (private static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, class, class-static-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). + +---*/ + +var callCount = 0; +class C { + static * #method([gen = function* () {}, xGen = function* x() {}] = []) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-elem-id-init-hole.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-elem-id-init-hole.js new file mode 100644 index 0000000000..8efab8fe79 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-elem-id-init-hole.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-hole.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static-dflt.template +/*--- +description: Destructuring initializer with a "hole" (private static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + [...] + 7. If environment is undefined, return PutValue(lhs, v). 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static * #method([x = 23] = [,]) { + assert.sameValue(x, 23); + // another statement + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-elem-id-init-skipped.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-elem-id-init-skipped.js new file mode 100644 index 0000000000..7e79b330ef --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-elem-id-init-skipped.js @@ -0,0 +1,95 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-skipped.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static-dflt.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (private static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +class C { + static * #method([w = counter(), x = counter(), y = counter(), z = counter()] = [null, 0, false, '']) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-elem-id-init-undef.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-elem-id-init-undef.js new file mode 100644 index 0000000000..ada5adb6b5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-elem-id-init-undef.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-undef.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static-dflt.template +/*--- +description: Destructuring initializer with an undefined value (private static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static * #method([x = 23] = [undefined]) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-elem-id-iter-complete.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-elem-id-iter-complete.js new file mode 100644 index 0000000000..7a41ca20c4 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-elem-id-iter-complete.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-complete.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static-dflt.template +/*--- +description: SingleNameBinding when value iteration completes (private static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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, + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static * #method([x] = []) { + assert.sameValue(x, undefined); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-elem-id-iter-done.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-elem-id-iter-done.js new file mode 100644 index 0000000000..a9674abee6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-elem-id-iter-done.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-done.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static-dflt.template +/*--- +description: SingleNameBinding when value iteration was completed previously (private static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static * #method([_, x] = []) { + assert.sameValue(x, undefined); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-elem-id-iter-val-array-prototype.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-elem-id-iter-val-array-prototype.js new file mode 100644 index 0000000000..061cec1b0f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-elem-id-iter-val-array-prototype.js @@ -0,0 +1,109 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val-array-prototype.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static-dflt.template +/*--- +description: Array destructuring uses overriden Array.prototype[Symbol.iterator] (private static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [Symbol.iterator, generators, class, class-static-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializer_opt + + 1. Let bindingId be StringValue of BindingIdentifier. + 2. Let lhs be ? ResolveBinding(bindingId, environment). + 3. If iteratorRecord.[[Done]] is false, then + a. Let next be IteratorStep(iteratorRecord). + 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). + [...] + 7. Return InitializeReferencedBinding(lhs, v). + +---*/ +Array.prototype[Symbol.iterator] = function* () { + if (this.length > 0) { + yield this[0]; + } + if (this.length > 1) { + yield this[1]; + } + if (this.length > 2) { + yield 42; + } +}; + +var callCount = 0; +class C { + static * #method([x, y, z] = [1, 2, 3]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 42); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-elem-id-iter-val.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-elem-id-iter-val.js new file mode 100644 index 0000000000..c333b22617 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-elem-id-iter-val.js @@ -0,0 +1,99 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static-dflt.template +/*--- +description: SingleNameBinding when value iteration was completed previously (private static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static * #method([x, y, z] = [1, 2, 3]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-elem-obj-id-init.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-elem-obj-id-init.js new file mode 100644 index 0000000000..428f27a538 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-elem-obj-id-init.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id-init.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is used (private static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + static * #method([{ x, y, z } = { x: 44, y: 55, z: 66 }] = []) { + assert.sameValue(x, 44); + assert.sameValue(y, 55); + assert.sameValue(z, 66); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-elem-obj-id.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-elem-obj-id.js new file mode 100644 index 0000000000..e668c063aa --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-elem-obj-id.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (private static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + static * #method([{ x, y, z } = { x: 44, y: 55, z: 66 }] = [{ x: 11, y: 22, z: 33 }]) { + assert.sameValue(x, 11); + assert.sameValue(y, 22); + assert.sameValue(z, 33); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-elem-obj-prop-id-init.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-elem-obj-prop-id-init.js new file mode 100644 index 0000000000..0856018c6e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-elem-obj-prop-id-init.js @@ -0,0 +1,101 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id-init.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is used (private static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + static * #method([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] = []) { + assert.sameValue(v, 444); + assert.sameValue(x, 555); + assert.sameValue(z, 666); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-elem-obj-prop-id.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-elem-obj-prop-id.js new file mode 100644 index 0000000000..a720f8a56c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-elem-obj-prop-id.js @@ -0,0 +1,101 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (private static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + static * #method([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] = [{ u: 777, w: 888, y: 999 }]) { + assert.sameValue(v, 777); + assert.sameValue(x, 888); + assert.sameValue(z, 999); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-elision-exhausted.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-elision-exhausted.js new file mode 100644 index 0000000000..7ae8335341 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-elision-exhausted.js @@ -0,0 +1,96 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-exhausted.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static-dflt.template +/*--- +description: Elision accepts exhausted iterator (private static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, class, class-static-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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 + [...] + 2. Return NormalCompletion(empty). + +---*/ +var iter = function*() {}(); +iter.next(); + +var callCount = 0; +class C { + static * #method([,] = iter) { + + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-elision.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-elision.js new file mode 100644 index 0000000000..c51414d3fe --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-elision.js @@ -0,0 +1,105 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static-dflt.template +/*--- +description: Elision advances iterator (private static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, class, class-static-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +class C { + static * #method([,] = g()) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-empty.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-empty.js new file mode 100644 index 0000000000..50e3c97c2c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-empty.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-empty.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static-dflt.template +/*--- +description: No iteration occurs for an "empty" array binding pattern (private static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, class, class-static-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var callCount = 0; +class C { + static * #method([] = iter) { + assert.sameValue(iterations, 0); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-rest-ary-elem.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-rest-ary-elem.js new file mode 100644 index 0000000000..37b616dbb9 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-rest-ary-elem.js @@ -0,0 +1,112 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elem.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static-dflt.template +/*--- +description: Rest element containing an array BindingElementList pattern (private static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the 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). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static * #method([...[x, y, z]] = [3, 4, 5]) { + assert.sameValue(x, 3); + assert.sameValue(y, 4); + assert.sameValue(z, 5); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-rest-ary-elision.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-rest-ary-elision.js new file mode 100644 index 0000000000..8f02c70ddd --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-rest-ary-elision.js @@ -0,0 +1,118 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elision.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static-dflt.template +/*--- +description: Rest element containing an elision (private static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, class, class-static-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the 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). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +class C { + static * #method([...[,]] = g()) { + assert.sameValue(first, 1); + assert.sameValue(second, 1); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-rest-ary-empty.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-rest-ary-empty.js new file mode 100644 index 0000000000..0c593ee363 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-rest-ary-empty.js @@ -0,0 +1,101 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-empty.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static-dflt.template +/*--- +description: Rest element containing an "empty" array pattern (private static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, class, class-static-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var callCount = 0; +class C { + static * #method([...[]] = iter) { + assert.sameValue(iterations, 1); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-rest-ary-rest.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-rest-ary-rest.js new file mode 100644 index 0000000000..ccd05a513e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-rest-ary-rest.js @@ -0,0 +1,97 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-rest.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static-dflt.template +/*--- +description: Rest element containing a rest element (private static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ +var values = [1, 2, 3]; + +var callCount = 0; +class C { + static * #method([...[...x]] = values) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-rest-id-direct.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-rest-id-direct.js new file mode 100644 index 0000000000..6e80363cf5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-rest-id-direct.js @@ -0,0 +1,92 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-direct.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static-dflt.template +/*--- +description: Lone rest element (direct binding) (private static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, generators, destructuring-binding, default-parameters] +flags: [generated] +includes: [compareArray.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingIdentifier + + [...] + 2. Let A be ! ArrayCreate(0). + 3. Let n be 0. + 4. Repeat, + [...] + f. Perform ! CreateDataPropertyOrThrow(A, ! ToString(n), nextValue). + g. Set n to n + 1. + +---*/ + +var callCount = 0; +class C { + static * #method([...x] = [1]) { + assert(Array.isArray(x)); + assert.compareArray(x, [1]); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-rest-id-elision.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-rest-id-elision.js new file mode 100644 index 0000000000..e347414f1f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-rest-id-elision.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static-dflt.template +/*--- +description: Rest element following elision elements (private static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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 values = [1, 2, 3, 4, 5]; + +var callCount = 0; +class C { + static * #method([ , , ...x] = values) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 3); + assert.sameValue(x[1], 4); + assert.sameValue(x[2], 5); + assert.notSameValue(x, values); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-rest-id-exhausted.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-rest-id-exhausted.js new file mode 100644 index 0000000000..1e67162ab6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-rest-id-exhausted.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-exhausted.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static-dflt.template +/*--- +description: RestElement applied to an exhausted iterator (private static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [Symbol.iterator, class, class-static-methods-private, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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, + [...] + b. If iteratorRecord.[[done]] is true, then + i. If environment is undefined, return PutValue(lhs, A). + ii. Return InitializeReferencedBinding(lhs, A). + +---*/ + +var callCount = 0; +class C { + static * #method([, , ...x] = [1, 2]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 0); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-rest-id.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-rest-id.js new file mode 100644 index 0000000000..a078ffb200 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-rest-id.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static-dflt.template +/*--- +description: Lone rest element (private static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + [...] 3. Let A be ArrayCreate(0). [...] 5. Repeat + [...] + f. Let status be CreateDataProperty(A, ToString (n), nextValue). + [...] +---*/ +var values = [1, 2, 3]; + +var callCount = 0; +class C { + static * #method([...x] = values) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-rest-init-ary.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-rest-init-ary.js new file mode 100644 index 0000000000..21745f3e65 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-rest-init-ary.js @@ -0,0 +1,86 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-ary.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static-dflt.template +/*--- +description: Rest element (nested array pattern) does not support initializer (private static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, generators, destructuring-binding, default-parameters] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var callCount = 0; +class C { + static * #method([...[ x ] = []] = []) { + + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-rest-init-id.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-rest-init-id.js new file mode 100644 index 0000000000..2d3b34b647 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-rest-init-id.js @@ -0,0 +1,86 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-id.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static-dflt.template +/*--- +description: Rest element (identifier) does not support initializer (private static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, generators, destructuring-binding, default-parameters] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var callCount = 0; +class C { + static * #method([...x = []] = []) { + + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-rest-init-obj.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-rest-init-obj.js new file mode 100644 index 0000000000..33203306c8 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-rest-init-obj.js @@ -0,0 +1,86 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-obj.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static-dflt.template +/*--- +description: Rest element (nested object pattern) does not support initializer (private static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, generators, destructuring-binding, default-parameters] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var callCount = 0; +class C { + static * #method([...{ x } = []] = []) { + + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-rest-not-final-ary.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-rest-not-final-ary.js new file mode 100644 index 0000000000..17f882f817 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-rest-not-final-ary.js @@ -0,0 +1,86 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-ary.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static-dflt.template +/*--- +description: Rest element (array binding pattern) may not be followed by any element (private static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, generators, destructuring-binding, default-parameters] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var callCount = 0; +class C { + static * #method([...[x], y] = [1, 2, 3]) { + + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-rest-not-final-id.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-rest-not-final-id.js new file mode 100644 index 0000000000..50de85084f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-rest-not-final-id.js @@ -0,0 +1,86 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-id.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static-dflt.template +/*--- +description: Rest element (identifier) may not be followed by any element (private static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, generators, destructuring-binding, default-parameters] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var callCount = 0; +class C { + static * #method([...x, y] = [1, 2, 3]) { + + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-rest-not-final-obj.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-rest-not-final-obj.js new file mode 100644 index 0000000000..e94b86d533 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-rest-not-final-obj.js @@ -0,0 +1,86 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-obj.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static-dflt.template +/*--- +description: Rest element (object binding pattern) may not be followed by any element (private static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, generators, destructuring-binding, default-parameters] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var callCount = 0; +class C { + static * #method([...{ x }, y] = [1, 2, 3]) { + + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-rest-obj-id.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-rest-obj-id.js new file mode 100644 index 0000000000..a6b62d5f53 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-rest-obj-id.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-id.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static-dflt.template +/*--- +description: Rest element containing an object binding pattern (private static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ + +var callCount = 0; +class C { + static * #method([...{ length }] = [1, 2, 3]) { + assert.sameValue(length, 3); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-rest-obj-prop-id.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-rest-obj-prop-id.js new file mode 100644 index 0000000000..2fd7a669cf --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-ary-ptrn-rest-obj-prop-id.js @@ -0,0 +1,97 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-prop-id.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static-dflt.template +/*--- +description: Rest element containing an object binding pattern (private static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ +let length = "outer"; + +var callCount = 0; +class C { + static * #method([...{ 0: v, 1: w, 2: x, 3: y, length: z }] = [7, 8, 9]) { + assert.sameValue(v, 7); + assert.sameValue(w, 8); + assert.sameValue(x, 9); + assert.sameValue(y, undefined); + assert.sameValue(z, 3); + + assert.sameValue(length, "outer", "the length prop is not set as a binding name"); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-obj-ptrn-empty.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-obj-ptrn-empty.js new file mode 100644 index 0000000000..f53cd60905 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-obj-ptrn-empty.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-empty.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static-dflt.template +/*--- +description: No property access occurs for an "empty" object binding pattern (private static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ +var accessCount = 0; +var obj = Object.defineProperty({}, 'attr', { + get: function() { + accessCount += 1; + } +}); + +var callCount = 0; +class C { + static * #method({} = obj) { + assert.sameValue(accessCount, 0); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-obj-ptrn-id-init-fn-name-arrow.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-obj-ptrn-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..53e9be9cf0 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-obj-ptrn-id-init-fn-name-arrow.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-arrow.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static-dflt.template +/*--- +description: SingleNameBinding assigns `name` to arrow functions (private static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +class C { + static * #method({ arrow = () => {} } = {}) { + assert.sameValue(arrow.name, 'arrow'); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-obj-ptrn-id-init-fn-name-class.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-obj-ptrn-id-init-fn-name-class.js new file mode 100644 index 0000000000..c0cdbb5846 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-obj-ptrn-id-init-fn-name-class.js @@ -0,0 +1,92 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-class.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static-dflt.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (private static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +class C { + static * #method({ cls = class {}, xCls = class X {}, xCls2 = class { static name() {} } } = {}) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + assert.notSameValue(xCls2.name, 'xCls2'); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-obj-ptrn-id-init-fn-name-cover.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-obj-ptrn-id-init-fn-name-cover.js new file mode 100644 index 0000000000..096e11af4f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-obj-ptrn-id-init-fn-name-cover.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-cover.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static-dflt.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" functions "through" cover grammar (private static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +class C { + static * #method({ cover = (function () {}), xCover = (0, function() {}) } = {}) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-obj-ptrn-id-init-fn-name-fn.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-obj-ptrn-id-init-fn-name-fn.js new file mode 100644 index 0000000000..3a8f97be53 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-obj-ptrn-id-init-fn-name-fn.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-fn.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (private static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +class C { + static * #method({ fn = function () {}, xFn = function x() {} } = {}) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-obj-ptrn-id-init-fn-name-gen.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-obj-ptrn-id-init-fn-name-gen.js new file mode 100644 index 0000000000..5305891559 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-obj-ptrn-id-init-fn-name-gen.js @@ -0,0 +1,92 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-gen.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (private static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, class, class-static-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). + +---*/ + +var callCount = 0; +class C { + static * #method({ gen = function* () {}, xGen = function* x() {} } = {}) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-obj-ptrn-id-init-skipped.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-obj-ptrn-id-init-skipped.js new file mode 100644 index 0000000000..0322d8fc04 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-obj-ptrn-id-init-skipped.js @@ -0,0 +1,94 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-skipped.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static-dflt.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (private static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +class C { + static * #method({ w = counter(), x = counter(), y = counter(), z = counter() } = { w: null, x: 0, y: false, z: '' }) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-obj-ptrn-id-trailing-comma.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-obj-ptrn-id-trailing-comma.js new file mode 100644 index 0000000000..a74701c403 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-obj-ptrn-id-trailing-comma.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-trailing-comma.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static-dflt.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (private static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +class C { + static * #method({ x, } = { x: 23 }) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-obj-ptrn-prop-ary-init.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-obj-ptrn-prop-ary-init.js new file mode 100644 index 0000000000..85ffc85b34 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-obj-ptrn-prop-ary-init.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-init.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static-dflt.template +/*--- +description: Object binding pattern with "nested" array binding pattern using initializer (private static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 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). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +class C { + static * #method({ w: [x, y, z] = [4, 5, 6] } = {}) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-obj-ptrn-prop-ary-trailing-comma.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-obj-ptrn-prop-ary-trailing-comma.js new file mode 100644 index 0000000000..7ba68d5bdc --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-obj-ptrn-prop-ary-trailing-comma.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-trailing-comma.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static-dflt.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (private static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +class C { + static * #method({ x: [y], } = { x: [45] }) { + assert.sameValue(y,45); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-obj-ptrn-prop-ary.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-obj-ptrn-prop-ary.js new file mode 100644 index 0000000000..ad13e6224e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-obj-ptrn-prop-ary.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static-dflt.template +/*--- +description: Object binding pattern with "nested" array binding pattern not using initializer (private static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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. +---*/ + +var callCount = 0; +class C { + static * #method({ w: [x, y, z] = [4, 5, 6] } = { w: [7, undefined, ] }) { + assert.sameValue(x, 7); + assert.sameValue(y, undefined); + assert.sameValue(z, undefined); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-obj-ptrn-prop-id-init-skipped.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-obj-ptrn-prop-id-init-skipped.js new file mode 100644 index 0000000000..2c94cce370 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-obj-ptrn-prop-id-init-skipped.js @@ -0,0 +1,106 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-skipped.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static-dflt.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (private static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +class C { + static * #method({ s: t = counter(), u: v = counter(), w: x = counter(), y: z = counter() } = { s: null, u: 0, w: false, y: '' }) { + assert.sameValue(t, null); + assert.sameValue(v, 0); + assert.sameValue(x, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + + assert.throws(ReferenceError, function() { + s; + }); + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-obj-ptrn-prop-id-init.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-obj-ptrn-prop-id-init.js new file mode 100644 index 0000000000..16ff749460 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-obj-ptrn-prop-id-init.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static-dflt.template +/*--- +description: Binding as specified via property name, identifier, and initializer (private static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static * #method({ x: y = 33 } = { }) { + assert.sameValue(y, 33); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-obj-ptrn-prop-id-trailing-comma.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-obj-ptrn-prop-id-trailing-comma.js new file mode 100644 index 0000000000..1025b98f30 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-obj-ptrn-prop-id-trailing-comma.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-trailing-comma.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static-dflt.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (private static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +class C { + static * #method({ x: y, } = { x: 23 }) { + assert.sameValue(y, 23); + + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-obj-ptrn-prop-id.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-obj-ptrn-prop-id.js new file mode 100644 index 0000000000..204d83334e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-obj-ptrn-prop-id.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static-dflt.template +/*--- +description: Binding as specified via property name and identifier (private static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static * #method({ x: y } = { x: 23 }) { + assert.sameValue(y, 23); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-obj-ptrn-prop-obj-init.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-obj-ptrn-prop-obj-init.js new file mode 100644 index 0000000000..029e9841ac --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-obj-ptrn-prop-obj-init.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-init.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern using initializer (private static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 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). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +class C { + static * #method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } } = { w: undefined }) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-obj-ptrn-prop-obj.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-obj-ptrn-prop-obj.js new file mode 100644 index 0000000000..a0f1cf1196 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-obj-ptrn-prop-obj.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern not using initializer (private static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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. +---*/ + +var callCount = 0; +class C { + static * #method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } } = { w: { x: undefined, z: 7 } }) { + assert.sameValue(x, undefined); + assert.sameValue(y, undefined); + assert.sameValue(z, 7); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-obj-ptrn-rest-getter.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-obj-ptrn-rest-getter.js new file mode 100644 index 0000000000..8aaf613f2a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-obj-ptrn-rest-getter.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-getter.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static-dflt.template +/*--- +description: Getter is called when obj is being deconstructed to a rest Object (private static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [object-rest, class, class-static-methods-private, generators, destructuring-binding, default-parameters] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var count = 0; + +var callCount = 0; +class C { + static * #method({...x} = { get v() { count++; return 2; } }) { + assert.sameValue(count, 1); + + verifyProperty(x, "v", { + enumerable: true, + writable: true, + configurable: true, + value: 2 + }); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-obj-ptrn-rest-skip-non-enumerable.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-obj-ptrn-rest-skip-non-enumerable.js new file mode 100644 index 0000000000..6e5fa48892 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-obj-ptrn-rest-skip-non-enumerable.js @@ -0,0 +1,94 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-skip-non-enumerable.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static-dflt.template +/*--- +description: Rest object doesn't contain non-enumerable properties (private static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [object-rest, class, class-static-methods-private, generators, destructuring-binding, default-parameters] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var o = {a: 3, b: 4}; +Object.defineProperty(o, "x", { value: 4, enumerable: false }); + +var callCount = 0; +class C { + static * #method({...rest} = o) { + assert.sameValue(rest.x, undefined); + + verifyProperty(rest, "a", { + enumerable: true, + writable: true, + configurable: true, + value: 3 + }); + + verifyProperty(rest, "b", { + enumerable: true, + writable: true, + configurable: true, + value: 4 + }); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-obj-ptrn-rest-val-obj.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-obj-ptrn-rest-val-obj.js new file mode 100644 index 0000000000..eb89e8c38a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-dflt-obj-ptrn-rest-val-obj.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-val-obj.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static-dflt.template +/*--- +description: Rest object contains just unextracted data (private static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [object-rest, class, class-static-methods-private, generators, destructuring-binding, default-parameters] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +class C { + static * #method({a, b, ...rest} = {x: 1, y: 2, a: 5, b: 3}) { + assert.sameValue(rest.a, undefined); + assert.sameValue(rest.b, undefined); + + verifyProperty(rest, "x", { + enumerable: true, + writable: true, + configurable: true, + value: 1 + }); + + verifyProperty(rest, "y", { + enumerable: true, + writable: true, + configurable: true, + value: 2 + }); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-obj-ptrn-empty.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-obj-ptrn-empty.js new file mode 100644 index 0000000000..1fffaa6251 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-obj-ptrn-empty.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-empty.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static.template +/*--- +description: No property access occurs for an "empty" object binding pattern (private static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ +var accessCount = 0; +var obj = Object.defineProperty({}, 'attr', { + get: function() { + accessCount += 1; + } +}); + +var callCount = 0; +class C { + static * #method({}) { + assert.sameValue(accessCount, 0); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method(obj).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-obj-ptrn-id-init-fn-name-arrow.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-obj-ptrn-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..f737f64f05 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-obj-ptrn-id-init-fn-name-arrow.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-arrow.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static.template +/*--- +description: SingleNameBinding assigns `name` to arrow functions (private static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +class C { + static * #method({ arrow = () => {} }) { + assert.sameValue(arrow.name, 'arrow'); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method({}).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-obj-ptrn-id-init-fn-name-class.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-obj-ptrn-id-init-fn-name-class.js new file mode 100644 index 0000000000..3824f5549b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-obj-ptrn-id-init-fn-name-class.js @@ -0,0 +1,92 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-class.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (private static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +class C { + static * #method({ cls = class {}, xCls = class X {}, xCls2 = class { static name() {} } }) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + assert.notSameValue(xCls2.name, 'xCls2'); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method({}).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-obj-ptrn-id-init-fn-name-cover.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-obj-ptrn-id-init-fn-name-cover.js new file mode 100644 index 0000000000..42be5450c2 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-obj-ptrn-id-init-fn-name-cover.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-cover.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" functions "through" cover grammar (private static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +class C { + static * #method({ cover = (function () {}), xCover = (0, function() {}) }) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method({}).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-obj-ptrn-id-init-fn-name-fn.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-obj-ptrn-id-init-fn-name-fn.js new file mode 100644 index 0000000000..e4c5198faf --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-obj-ptrn-id-init-fn-name-fn.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-fn.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (private static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +class C { + static * #method({ fn = function () {}, xFn = function x() {} }) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method({}).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-obj-ptrn-id-init-fn-name-gen.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-obj-ptrn-id-init-fn-name-gen.js new file mode 100644 index 0000000000..f89005dad8 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-obj-ptrn-id-init-fn-name-gen.js @@ -0,0 +1,92 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-gen.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (private static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, class, class-static-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). + +---*/ + +var callCount = 0; +class C { + static * #method({ gen = function* () {}, xGen = function* x() {} }) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method({}).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-obj-ptrn-id-init-skipped.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-obj-ptrn-id-init-skipped.js new file mode 100644 index 0000000000..8a3870b9f5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-obj-ptrn-id-init-skipped.js @@ -0,0 +1,94 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-skipped.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (private static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +class C { + static * #method({ w = counter(), x = counter(), y = counter(), z = counter() }) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method({ w: null, x: 0, y: false, z: '' }).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-obj-ptrn-id-trailing-comma.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-obj-ptrn-id-trailing-comma.js new file mode 100644 index 0000000000..b9251d2ef8 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-obj-ptrn-id-trailing-comma.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-trailing-comma.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (private static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +class C { + static * #method({ x, }) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method({ x: 23 }).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-obj-ptrn-prop-ary-init.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-obj-ptrn-prop-ary-init.js new file mode 100644 index 0000000000..27390ef80a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-obj-ptrn-prop-ary-init.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-init.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static.template +/*--- +description: Object binding pattern with "nested" array binding pattern using initializer (private static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 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). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +class C { + static * #method({ w: [x, y, z] = [4, 5, 6] }) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method({}).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-obj-ptrn-prop-ary-trailing-comma.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-obj-ptrn-prop-ary-trailing-comma.js new file mode 100644 index 0000000000..d3a8f48c77 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-obj-ptrn-prop-ary-trailing-comma.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-trailing-comma.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (private static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +class C { + static * #method({ x: [y], }) { + assert.sameValue(y,45); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method({ x: [45] }).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-obj-ptrn-prop-ary.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-obj-ptrn-prop-ary.js new file mode 100644 index 0000000000..71896ded79 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-obj-ptrn-prop-ary.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static.template +/*--- +description: Object binding pattern with "nested" array binding pattern not using initializer (private static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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. +---*/ + +var callCount = 0; +class C { + static * #method({ w: [x, y, z] = [4, 5, 6] }) { + assert.sameValue(x, 7); + assert.sameValue(y, undefined); + assert.sameValue(z, undefined); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method({ w: [7, undefined, ] }).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-obj-ptrn-prop-id-init-skipped.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-obj-ptrn-prop-id-init-skipped.js new file mode 100644 index 0000000000..b633c84655 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-obj-ptrn-prop-id-init-skipped.js @@ -0,0 +1,106 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-skipped.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (private static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +class C { + static * #method({ s: t = counter(), u: v = counter(), w: x = counter(), y: z = counter() }) { + assert.sameValue(t, null); + assert.sameValue(v, 0); + assert.sameValue(x, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + + assert.throws(ReferenceError, function() { + s; + }); + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method({ s: null, u: 0, w: false, y: '' }).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-obj-ptrn-prop-id-init.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-obj-ptrn-prop-id-init.js new file mode 100644 index 0000000000..2139b734c9 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-obj-ptrn-prop-id-init.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static.template +/*--- +description: Binding as specified via property name, identifier, and initializer (private static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static * #method({ x: y = 33 }) { + assert.sameValue(y, 33); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method({ }).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-obj-ptrn-prop-id-trailing-comma.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-obj-ptrn-prop-id-trailing-comma.js new file mode 100644 index 0000000000..382fe94c8e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-obj-ptrn-prop-id-trailing-comma.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-trailing-comma.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (private static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +class C { + static * #method({ x: y, }) { + assert.sameValue(y, 23); + + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method({ x: 23 }).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-obj-ptrn-prop-id.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-obj-ptrn-prop-id.js new file mode 100644 index 0000000000..5555927ec6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-obj-ptrn-prop-id.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static.template +/*--- +description: Binding as specified via property name and identifier (private static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static * #method({ x: y }) { + assert.sameValue(y, 23); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method({ x: 23 }).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-obj-ptrn-prop-obj-init.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-obj-ptrn-prop-obj-init.js new file mode 100644 index 0000000000..d2d132a25f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-obj-ptrn-prop-obj-init.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-init.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static.template +/*--- +description: Object binding pattern with "nested" object binding pattern using initializer (private static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 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). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +class C { + static * #method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } }) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method({ w: undefined }).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-obj-ptrn-prop-obj.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-obj-ptrn-prop-obj.js new file mode 100644 index 0000000000..1dec9e2a75 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-obj-ptrn-prop-obj.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static.template +/*--- +description: Object binding pattern with "nested" object binding pattern not using initializer (private static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, generators, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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. +---*/ + +var callCount = 0; +class C { + static * #method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } }) { + assert.sameValue(x, undefined); + assert.sameValue(y, undefined); + assert.sameValue(z, 7); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method({ w: { x: undefined, z: 7 } }).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-obj-ptrn-rest-getter.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-obj-ptrn-rest-getter.js new file mode 100644 index 0000000000..518777f02d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-obj-ptrn-rest-getter.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-getter.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static.template +/*--- +description: Getter is called when obj is being deconstructed to a rest Object (private static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [object-rest, class, class-static-methods-private, generators, destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var count = 0; + +var callCount = 0; +class C { + static * #method({...x}) { + assert.sameValue(count, 1); + + verifyProperty(x, "v", { + enumerable: true, + writable: true, + configurable: true, + value: 2 + }); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method({ get v() { count++; return 2; } }).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-obj-ptrn-rest-skip-non-enumerable.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-obj-ptrn-rest-skip-non-enumerable.js new file mode 100644 index 0000000000..660628a74c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-obj-ptrn-rest-skip-non-enumerable.js @@ -0,0 +1,94 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-skip-non-enumerable.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static.template +/*--- +description: Rest object doesn't contain non-enumerable properties (private static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [object-rest, class, class-static-methods-private, generators, destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var o = {a: 3, b: 4}; +Object.defineProperty(o, "x", { value: 4, enumerable: false }); + +var callCount = 0; +class C { + static * #method({...rest}) { + assert.sameValue(rest.x, undefined); + + verifyProperty(rest, "a", { + enumerable: true, + writable: true, + configurable: true, + value: 3 + }); + + verifyProperty(rest, "b", { + enumerable: true, + writable: true, + configurable: true, + value: 4 + }); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method(o).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-obj-ptrn-rest-val-obj.js b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-obj-ptrn-rest-val-obj.js new file mode 100644 index 0000000000..5f18d266b4 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-gen-meth-static-obj-ptrn-rest-val-obj.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-val-obj.case +// - src/dstr-binding/default/cls-decl-private-gen-meth-static.template +/*--- +description: Rest object contains just unextracted data (private static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [object-rest, class, class-static-methods-private, generators, destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +class C { + static * #method({a, b, ...rest}) { + assert.sameValue(rest.a, undefined); + assert.sameValue(rest.b, undefined); + + verifyProperty(rest, "x", { + enumerable: true, + writable: true, + configurable: true, + value: 1 + }); + + verifyProperty(rest, "y", { + enumerable: true, + writable: true, + configurable: true, + value: 2 + }); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method({x: 1, y: 2, a: 5, b: 3}).next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-init-iter-close.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-init-iter-close.js new file mode 100644 index 0000000000..e67f314cf9 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-init-iter-close.js @@ -0,0 +1,98 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-close.case +// - src/dstr-binding/default/cls-decl-private-meth.template +/*--- +description: Iterator is closed when not exhausted by pattern evaluation (private class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [Symbol.iterator, class, class-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: false }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var callCount = 0; +class C { + #method([x]) { + assert.sameValue(doneCallCount, 1); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method(iter); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-init-iter-no-close.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-init-iter-no-close.js new file mode 100644 index 0000000000..80eafc152b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-init-iter-no-close.js @@ -0,0 +1,98 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-no-close.case +// - src/dstr-binding/default/cls-decl-private-meth.template +/*--- +description: Iterator is not closed when exhausted by pattern evaluation (private class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [Symbol.iterator, class, class-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: true }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var callCount = 0; +class C { + #method([x]) { + assert.sameValue(doneCallCount, 0); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method(iter); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-name-iter-val.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-name-iter-val.js new file mode 100644 index 0000000000..027780a582 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-name-iter-val.js @@ -0,0 +1,97 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-name-iter-val.case +// - src/dstr-binding/default/cls-decl-private-meth.template +/*--- +description: SingleNameBinding with normal value iteration (private class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + #method([x, y, z]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method([1, 2, 3]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-elem-ary-elem-init.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-elem-ary-elem-init.js new file mode 100644 index 0000000000..bf66e3f137 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-elem-ary-elem-init.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-init.case +// - src/dstr-binding/default/cls-decl-private-meth.template +/*--- +description: BindingElement with array binding pattern and initializer is used (private class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + #method([[x, y, z] = [4, 5, 6]]) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-elem-ary-elem-iter.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-elem-ary-elem-iter.js new file mode 100644 index 0000000000..e1b2d300b2 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-elem-ary-elem-iter.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-iter.case +// - src/dstr-binding/default/cls-decl-private-meth.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (private class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + #method([[x, y, z] = [4, 5, 6]]) { + assert.sameValue(x, 7); + assert.sameValue(y, 8); + assert.sameValue(z, 9); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method([[7, 8, 9]]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-elem-ary-elision-init.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-elem-ary-elision-init.js new file mode 100644 index 0000000000..3d0edf64e3 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-elem-ary-elision-init.js @@ -0,0 +1,96 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-init.case +// - src/dstr-binding/default/cls-decl-private-meth.template +/*--- +description: BindingElement with array binding pattern and initializer is used (private class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, class, class-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +class C { + #method([[,] = g()]) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-elem-ary-elision-iter.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-elem-ary-elision-iter.js new file mode 100644 index 0000000000..41b0bbd28e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-elem-ary-elision-iter.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-iter.case +// - src/dstr-binding/default/cls-decl-private-meth.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (private class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, class, class-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var callCount = 0; +function* g() { + callCount += 1; +}; + +var callCount = 0; +class C { + #method([[,] = g()]) { + assert.sameValue(callCount, 0); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method([[]]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-elem-ary-empty-init.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-elem-ary-empty-init.js new file mode 100644 index 0000000000..a15d5f03b4 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-elem-ary-empty-init.js @@ -0,0 +1,92 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-init.case +// - src/dstr-binding/default/cls-decl-private-meth.template +/*--- +description: BindingElement with array binding pattern and initializer is used (private class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, class, class-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var initCount = 0; +var iterCount = 0; +var iter = function*() { iterCount += 1; }(); + +var callCount = 0; +class C { + #method([[] = function() { initCount += 1; return iter; }()]) { + assert.sameValue(initCount, 1); + assert.sameValue(iterCount, 0); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-elem-ary-empty-iter.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-elem-ary-empty-iter.js new file mode 100644 index 0000000000..15a6a738f1 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-elem-ary-empty-iter.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-iter.case +// - src/dstr-binding/default/cls-decl-private-meth.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (private class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var initCount = 0; + +var callCount = 0; +class C { + #method([[] = function() { initCount += 1; }()]) { + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method([[23]]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-elem-ary-rest-init.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-elem-ary-rest-init.js new file mode 100644 index 0000000000..07b66e65fa --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-elem-ary-rest-init.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-init.case +// - src/dstr-binding/default/cls-decl-private-meth.template +/*--- +description: BindingElement with array binding pattern and initializer is used (private class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; + +var callCount = 0; +class C { + #method([[...x] = values]) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-elem-ary-rest-iter.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-elem-ary-rest-iter.js new file mode 100644 index 0000000000..859c676e53 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-elem-ary-rest-iter.js @@ -0,0 +1,96 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-iter.case +// - src/dstr-binding/default/cls-decl-private-meth.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (private class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; +var initCount = 0; + +var callCount = 0; +class C { + #method([[...x] = function() { initCount += 1; }()]) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method([values]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-elem-id-init-exhausted.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-elem-id-init-exhausted.js new file mode 100644 index 0000000000..73bda913c4 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-elem-id-init-exhausted.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-exhausted.case +// - src/dstr-binding/default/cls-decl-private-meth.template +/*--- +description: Destructuring initializer with an exhausted iterator (private class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + #method([x = 23]) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-elem-id-init-fn-name-arrow.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-elem-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..530f7fb021 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-elem-id-init-fn-name-arrow.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-arrow.case +// - src/dstr-binding/default/cls-decl-private-meth.template +/*--- +description: SingleNameBinding does assign name to arrow functions (private class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + #method([arrow = () => {}]) { + assert.sameValue(arrow.name, 'arrow'); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-elem-id-init-fn-name-class.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-elem-id-init-fn-name-class.js new file mode 100644 index 0000000000..a20b579192 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-elem-id-init-fn-name-class.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-class.case +// - src/dstr-binding/default/cls-decl-private-meth.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (private class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + #method([cls = class {}, xCls = class X {}, xCls2 = class { static name() {} }]) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + assert.notSameValue(xCls2.name, 'xCls2'); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-elem-id-init-fn-name-cover.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-elem-id-init-fn-name-cover.js new file mode 100644 index 0000000000..2cf571fbde --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-elem-id-init-fn-name-cover.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-cover.case +// - src/dstr-binding/default/cls-decl-private-meth.template +/*--- +description: SingleNameBinding does assign name to "anonymous" functions "through" cover grammar (private class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + #method([cover = (function () {}), xCover = (0, function() {})]) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-elem-id-init-fn-name-fn.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-elem-id-init-fn-name-fn.js new file mode 100644 index 0000000000..7f69ab7bcb --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-elem-id-init-fn-name-fn.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-fn.case +// - src/dstr-binding/default/cls-decl-private-meth.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (private class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + #method([fn = function () {}, xFn = function x() {}]) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-elem-id-init-fn-name-gen.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-elem-id-init-fn-name-gen.js new file mode 100644 index 0000000000..71080d2f59 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-elem-id-init-fn-name-gen.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-gen.case +// - src/dstr-binding/default/cls-decl-private-meth.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (private class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, class, class-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). + +---*/ + +var callCount = 0; +class C { + #method([gen = function* () {}, xGen = function* x() {}]) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-elem-id-init-hole.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-elem-id-init-hole.js new file mode 100644 index 0000000000..b1f9271bde --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-elem-id-init-hole.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-hole.case +// - src/dstr-binding/default/cls-decl-private-meth.template +/*--- +description: Destructuring initializer with a "hole" (private class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + [...] + 7. If environment is undefined, return PutValue(lhs, v). 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + #method([x = 23]) { + assert.sameValue(x, 23); + // another statement + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method([,]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-elem-id-init-skipped.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-elem-id-init-skipped.js new file mode 100644 index 0000000000..98e8938e8f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-elem-id-init-skipped.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-skipped.case +// - src/dstr-binding/default/cls-decl-private-meth.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (private class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +class C { + #method([w = counter(), x = counter(), y = counter(), z = counter()]) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method([null, 0, false, '']); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-elem-id-init-undef.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-elem-id-init-undef.js new file mode 100644 index 0000000000..b4bf7edd2f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-elem-id-init-undef.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-undef.case +// - src/dstr-binding/default/cls-decl-private-meth.template +/*--- +description: Destructuring initializer with an undefined value (private class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + #method([x = 23]) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method([undefined]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-elem-id-iter-complete.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-elem-id-iter-complete.js new file mode 100644 index 0000000000..9d796f54b9 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-elem-id-iter-complete.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-complete.case +// - src/dstr-binding/default/cls-decl-private-meth.template +/*--- +description: SingleNameBinding when value iteration completes (private class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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, + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + #method([x]) { + assert.sameValue(x, undefined); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-elem-id-iter-done.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-elem-id-iter-done.js new file mode 100644 index 0000000000..3526bd3efb --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-elem-id-iter-done.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-done.case +// - src/dstr-binding/default/cls-decl-private-meth.template +/*--- +description: SingleNameBinding when value iteration was completed previously (private class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + #method([_, x]) { + assert.sameValue(x, undefined); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-elem-id-iter-val-array-prototype.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-elem-id-iter-val-array-prototype.js new file mode 100644 index 0000000000..4485b87315 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-elem-id-iter-val-array-prototype.js @@ -0,0 +1,107 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val-array-prototype.case +// - src/dstr-binding/default/cls-decl-private-meth.template +/*--- +description: Array destructuring uses overriden Array.prototype[Symbol.iterator] (private class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [Symbol.iterator, generators, class, class-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializer_opt + + 1. Let bindingId be StringValue of BindingIdentifier. + 2. Let lhs be ? ResolveBinding(bindingId, environment). + 3. If iteratorRecord.[[Done]] is false, then + a. Let next be IteratorStep(iteratorRecord). + 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). + [...] + 7. Return InitializeReferencedBinding(lhs, v). + +---*/ +Array.prototype[Symbol.iterator] = function* () { + if (this.length > 0) { + yield this[0]; + } + if (this.length > 1) { + yield this[1]; + } + if (this.length > 2) { + yield 42; + } +}; + +var callCount = 0; +class C { + #method([x, y, z]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 42); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method([1, 2, 3]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-elem-id-iter-val.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-elem-id-iter-val.js new file mode 100644 index 0000000000..7b6b625439 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-elem-id-iter-val.js @@ -0,0 +1,97 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val.case +// - src/dstr-binding/default/cls-decl-private-meth.template +/*--- +description: SingleNameBinding when value iteration was completed previously (private class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + #method([x, y, z]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method([1, 2, 3]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-elem-obj-id-init.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-elem-obj-id-init.js new file mode 100644 index 0000000000..cfc80094cf --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-elem-obj-id-init.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id-init.case +// - src/dstr-binding/default/cls-decl-private-meth.template +/*--- +description: BindingElement with object binding pattern and initializer is used (private class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + #method([{ x, y, z } = { x: 44, y: 55, z: 66 }]) { + assert.sameValue(x, 44); + assert.sameValue(y, 55); + assert.sameValue(z, 66); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-elem-obj-id.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-elem-obj-id.js new file mode 100644 index 0000000000..da9b35a11f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-elem-obj-id.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id.case +// - src/dstr-binding/default/cls-decl-private-meth.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (private class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + #method([{ x, y, z } = { x: 44, y: 55, z: 66 }]) { + assert.sameValue(x, 11); + assert.sameValue(y, 22); + assert.sameValue(z, 33); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method([{ x: 11, y: 22, z: 33 }]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-elem-obj-prop-id-init.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-elem-obj-prop-id-init.js new file mode 100644 index 0000000000..78d4f98170 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-elem-obj-prop-id-init.js @@ -0,0 +1,99 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id-init.case +// - src/dstr-binding/default/cls-decl-private-meth.template +/*--- +description: BindingElement with object binding pattern and initializer is used (private class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + #method([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }]) { + assert.sameValue(v, 444); + assert.sameValue(x, 555); + assert.sameValue(z, 666); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-elem-obj-prop-id.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-elem-obj-prop-id.js new file mode 100644 index 0000000000..26f2957c1b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-elem-obj-prop-id.js @@ -0,0 +1,99 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id.case +// - src/dstr-binding/default/cls-decl-private-meth.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (private class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + #method([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }]) { + assert.sameValue(v, 777); + assert.sameValue(x, 888); + assert.sameValue(z, 999); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method([{ u: 777, w: 888, y: 999 }]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-elision-exhausted.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-elision-exhausted.js new file mode 100644 index 0000000000..867d9001d9 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-elision-exhausted.js @@ -0,0 +1,94 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-exhausted.case +// - src/dstr-binding/default/cls-decl-private-meth.template +/*--- +description: Elision accepts exhausted iterator (private class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, class, class-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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 + [...] + 2. Return NormalCompletion(empty). + +---*/ +var iter = function*() {}(); +iter.next(); + +var callCount = 0; +class C { + #method([,]) { + + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method(iter); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-elision.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-elision.js new file mode 100644 index 0000000000..c1cf084dd6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-elision.js @@ -0,0 +1,103 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision.case +// - src/dstr-binding/default/cls-decl-private-meth.template +/*--- +description: Elision advances iterator (private class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, class, class-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +class C { + #method([,]) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method(g()); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-empty.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-empty.js new file mode 100644 index 0000000000..01e416e359 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-empty.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-empty.case +// - src/dstr-binding/default/cls-decl-private-meth.template +/*--- +description: No iteration occurs for an "empty" array binding pattern (private class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, class, class-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var callCount = 0; +class C { + #method([]) { + assert.sameValue(iterations, 0); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method(iter); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-rest-ary-elem.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-rest-ary-elem.js new file mode 100644 index 0000000000..62abf52a4b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-rest-ary-elem.js @@ -0,0 +1,110 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elem.case +// - src/dstr-binding/default/cls-decl-private-meth.template +/*--- +description: Rest element containing an array BindingElementList pattern (private class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the 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). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + #method([...[x, y, z]]) { + assert.sameValue(x, 3); + assert.sameValue(y, 4); + assert.sameValue(z, 5); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method([3, 4, 5]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-rest-ary-elision.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-rest-ary-elision.js new file mode 100644 index 0000000000..885840c43b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-rest-ary-elision.js @@ -0,0 +1,116 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elision.case +// - src/dstr-binding/default/cls-decl-private-meth.template +/*--- +description: Rest element containing an elision (private class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, class, class-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the 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). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +class C { + #method([...[,]]) { + assert.sameValue(first, 1); + assert.sameValue(second, 1); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method(g()); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-rest-ary-empty.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-rest-ary-empty.js new file mode 100644 index 0000000000..c98ab4b72f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-rest-ary-empty.js @@ -0,0 +1,99 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-empty.case +// - src/dstr-binding/default/cls-decl-private-meth.template +/*--- +description: Rest element containing an "empty" array pattern (private class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, class, class-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var callCount = 0; +class C { + #method([...[]]) { + assert.sameValue(iterations, 1); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method(iter); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-rest-ary-rest.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-rest-ary-rest.js new file mode 100644 index 0000000000..a271cd9742 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-rest-ary-rest.js @@ -0,0 +1,95 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-rest.case +// - src/dstr-binding/default/cls-decl-private-meth.template +/*--- +description: Rest element containing a rest element (private class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ +var values = [1, 2, 3]; + +var callCount = 0; +class C { + #method([...[...x]]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method(values); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-rest-id-direct.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-rest-id-direct.js new file mode 100644 index 0000000000..41b1e92abc --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-rest-id-direct.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-direct.case +// - src/dstr-binding/default/cls-decl-private-meth.template +/*--- +description: Lone rest element (direct binding) (private class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-methods-private, destructuring-binding] +flags: [generated] +includes: [compareArray.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingIdentifier + + [...] + 2. Let A be ! ArrayCreate(0). + 3. Let n be 0. + 4. Repeat, + [...] + f. Perform ! CreateDataPropertyOrThrow(A, ! ToString(n), nextValue). + g. Set n to n + 1. + +---*/ + +var callCount = 0; +class C { + #method([...x]) { + assert(Array.isArray(x)); + assert.compareArray(x, [1]); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method([1]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-rest-id-elision.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-rest-id-elision.js new file mode 100644 index 0000000000..0fea03cdf7 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-rest-id-elision.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision.case +// - src/dstr-binding/default/cls-decl-private-meth.template +/*--- +description: Rest element following elision elements (private class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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 values = [1, 2, 3, 4, 5]; + +var callCount = 0; +class C { + #method([ , , ...x]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 3); + assert.sameValue(x[1], 4); + assert.sameValue(x[2], 5); + assert.notSameValue(x, values); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method(values); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-rest-id-exhausted.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-rest-id-exhausted.js new file mode 100644 index 0000000000..70926f7d70 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-rest-id-exhausted.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-exhausted.case +// - src/dstr-binding/default/cls-decl-private-meth.template +/*--- +description: RestElement applied to an exhausted iterator (private class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [Symbol.iterator, class, class-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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, + [...] + b. If iteratorRecord.[[done]] is true, then + i. If environment is undefined, return PutValue(lhs, A). + ii. Return InitializeReferencedBinding(lhs, A). + +---*/ + +var callCount = 0; +class C { + #method([, , ...x]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 0); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method([1, 2]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-rest-id.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-rest-id.js new file mode 100644 index 0000000000..4a062e5923 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-rest-id.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id.case +// - src/dstr-binding/default/cls-decl-private-meth.template +/*--- +description: Lone rest element (private class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + [...] 3. Let A be ArrayCreate(0). [...] 5. Repeat + [...] + f. Let status be CreateDataProperty(A, ToString (n), nextValue). + [...] +---*/ +var values = [1, 2, 3]; + +var callCount = 0; +class C { + #method([...x]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method(values); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-rest-init-ary.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-rest-init-ary.js new file mode 100644 index 0000000000..1caf23d11d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-rest-init-ary.js @@ -0,0 +1,84 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-ary.case +// - src/dstr-binding/default/cls-decl-private-meth.template +/*--- +description: Rest element (nested array pattern) does not support initializer (private class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-methods-private, destructuring-binding] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var callCount = 0; +class C { + #method([...[ x ] = []]) { + + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-rest-init-id.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-rest-init-id.js new file mode 100644 index 0000000000..e951bf6636 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-rest-init-id.js @@ -0,0 +1,84 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-id.case +// - src/dstr-binding/default/cls-decl-private-meth.template +/*--- +description: Rest element (identifier) does not support initializer (private class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-methods-private, destructuring-binding] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var callCount = 0; +class C { + #method([...x = []]) { + + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-rest-init-obj.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-rest-init-obj.js new file mode 100644 index 0000000000..dd5a1a293d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-rest-init-obj.js @@ -0,0 +1,84 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-obj.case +// - src/dstr-binding/default/cls-decl-private-meth.template +/*--- +description: Rest element (nested object pattern) does not support initializer (private class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-methods-private, destructuring-binding] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var callCount = 0; +class C { + #method([...{ x } = []]) { + + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-rest-not-final-ary.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-rest-not-final-ary.js new file mode 100644 index 0000000000..7d85a99478 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-rest-not-final-ary.js @@ -0,0 +1,84 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-ary.case +// - src/dstr-binding/default/cls-decl-private-meth.template +/*--- +description: Rest element (array binding pattern) may not be followed by any element (private class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-methods-private, destructuring-binding] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var callCount = 0; +class C { + #method([...[x], y]) { + + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method([1, 2, 3]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-rest-not-final-id.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-rest-not-final-id.js new file mode 100644 index 0000000000..564123314c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-rest-not-final-id.js @@ -0,0 +1,84 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-id.case +// - src/dstr-binding/default/cls-decl-private-meth.template +/*--- +description: Rest element (identifier) may not be followed by any element (private class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-methods-private, destructuring-binding] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var callCount = 0; +class C { + #method([...x, y]) { + + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method([1, 2, 3]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-rest-not-final-obj.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-rest-not-final-obj.js new file mode 100644 index 0000000000..3b293c3670 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-rest-not-final-obj.js @@ -0,0 +1,84 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-obj.case +// - src/dstr-binding/default/cls-decl-private-meth.template +/*--- +description: Rest element (object binding pattern) may not be followed by any element (private class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-methods-private, destructuring-binding] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var callCount = 0; +class C { + #method([...{ x }, y]) { + + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method([1, 2, 3]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-rest-obj-id.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-rest-obj-id.js new file mode 100644 index 0000000000..0813d1068f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-rest-obj-id.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-id.case +// - src/dstr-binding/default/cls-decl-private-meth.template +/*--- +description: Rest element containing an object binding pattern (private class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ + +var callCount = 0; +class C { + #method([...{ length }]) { + assert.sameValue(length, 3); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method([1, 2, 3]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-rest-obj-prop-id.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-rest-obj-prop-id.js new file mode 100644 index 0000000000..dd166a1b45 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-ary-ptrn-rest-obj-prop-id.js @@ -0,0 +1,95 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-prop-id.case +// - src/dstr-binding/default/cls-decl-private-meth.template +/*--- +description: Rest element containing an object binding pattern (private class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ +let length = "outer"; + +var callCount = 0; +class C { + #method([...{ 0: v, 1: w, 2: x, 3: y, length: z }]) { + assert.sameValue(v, 7); + assert.sameValue(w, 8); + assert.sameValue(x, 9); + assert.sameValue(y, undefined); + assert.sameValue(z, 3); + + assert.sameValue(length, "outer", "the length prop is not set as a binding name"); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method([7, 8, 9]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-init-iter-close.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-init-iter-close.js new file mode 100644 index 0000000000..9a9529a6c9 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-init-iter-close.js @@ -0,0 +1,98 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-close.case +// - src/dstr-binding/default/cls-decl-private-meth-dflt.template +/*--- +description: Iterator is closed when not exhausted by pattern evaluation (private class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [Symbol.iterator, class, class-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: false }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var callCount = 0; +class C { + #method([x] = iter) { + assert.sameValue(doneCallCount, 1); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-init-iter-no-close.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-init-iter-no-close.js new file mode 100644 index 0000000000..25e96952e7 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-init-iter-no-close.js @@ -0,0 +1,98 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-no-close.case +// - src/dstr-binding/default/cls-decl-private-meth-dflt.template +/*--- +description: Iterator is not closed when exhausted by pattern evaluation (private class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [Symbol.iterator, class, class-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: true }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var callCount = 0; +class C { + #method([x] = iter) { + assert.sameValue(doneCallCount, 0); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-name-iter-val.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-name-iter-val.js new file mode 100644 index 0000000000..3f2f674dd4 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-name-iter-val.js @@ -0,0 +1,97 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-name-iter-val.case +// - src/dstr-binding/default/cls-decl-private-meth-dflt.template +/*--- +description: SingleNameBinding with normal value iteration (private class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + #method([x, y, z] = [1, 2, 3]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-elem-ary-elem-init.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-elem-ary-elem-init.js new file mode 100644 index 0000000000..c0c419b439 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-elem-ary-elem-init.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-init.case +// - src/dstr-binding/default/cls-decl-private-meth-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (private class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + #method([[x, y, z] = [4, 5, 6]] = []) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-elem-ary-elem-iter.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-elem-ary-elem-iter.js new file mode 100644 index 0000000000..49db54bded --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-elem-ary-elem-iter.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-iter.case +// - src/dstr-binding/default/cls-decl-private-meth-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (private class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + #method([[x, y, z] = [4, 5, 6]] = [[7, 8, 9]]) { + assert.sameValue(x, 7); + assert.sameValue(y, 8); + assert.sameValue(z, 9); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-elem-ary-elision-init.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-elem-ary-elision-init.js new file mode 100644 index 0000000000..213ce44ec1 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-elem-ary-elision-init.js @@ -0,0 +1,96 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-init.case +// - src/dstr-binding/default/cls-decl-private-meth-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (private class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, class, class-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +class C { + #method([[,] = g()] = []) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-elem-ary-elision-iter.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-elem-ary-elision-iter.js new file mode 100644 index 0000000000..6cf5fa2f1c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-elem-ary-elision-iter.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-iter.case +// - src/dstr-binding/default/cls-decl-private-meth-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (private class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, class, class-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var callCount = 0; +function* g() { + callCount += 1; +}; + +var callCount = 0; +class C { + #method([[,] = g()] = [[]]) { + assert.sameValue(callCount, 0); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-elem-ary-empty-init.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-elem-ary-empty-init.js new file mode 100644 index 0000000000..b6a61f3488 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-elem-ary-empty-init.js @@ -0,0 +1,92 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-init.case +// - src/dstr-binding/default/cls-decl-private-meth-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (private class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, class, class-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var initCount = 0; +var iterCount = 0; +var iter = function*() { iterCount += 1; }(); + +var callCount = 0; +class C { + #method([[] = function() { initCount += 1; return iter; }()] = []) { + assert.sameValue(initCount, 1); + assert.sameValue(iterCount, 0); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-elem-ary-empty-iter.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-elem-ary-empty-iter.js new file mode 100644 index 0000000000..6e035507d2 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-elem-ary-empty-iter.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-iter.case +// - src/dstr-binding/default/cls-decl-private-meth-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (private class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var initCount = 0; + +var callCount = 0; +class C { + #method([[] = function() { initCount += 1; }()] = [[23]]) { + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-elem-ary-rest-init.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-elem-ary-rest-init.js new file mode 100644 index 0000000000..051f06268b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-elem-ary-rest-init.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-init.case +// - src/dstr-binding/default/cls-decl-private-meth-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (private class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; + +var callCount = 0; +class C { + #method([[...x] = values] = []) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-elem-ary-rest-iter.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-elem-ary-rest-iter.js new file mode 100644 index 0000000000..65bc609182 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-elem-ary-rest-iter.js @@ -0,0 +1,96 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-iter.case +// - src/dstr-binding/default/cls-decl-private-meth-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (private class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; +var initCount = 0; + +var callCount = 0; +class C { + #method([[...x] = function() { initCount += 1; }()] = [values]) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-elem-id-init-exhausted.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-elem-id-init-exhausted.js new file mode 100644 index 0000000000..61be2a8e69 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-elem-id-init-exhausted.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-exhausted.case +// - src/dstr-binding/default/cls-decl-private-meth-dflt.template +/*--- +description: Destructuring initializer with an exhausted iterator (private class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + #method([x = 23] = []) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..08d3628327 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-arrow.case +// - src/dstr-binding/default/cls-decl-private-meth-dflt.template +/*--- +description: SingleNameBinding does assign name to arrow functions (private class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + #method([arrow = () => {}] = []) { + assert.sameValue(arrow.name, 'arrow'); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-elem-id-init-fn-name-class.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-elem-id-init-fn-name-class.js new file mode 100644 index 0000000000..6cb3dd7dc3 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-elem-id-init-fn-name-class.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-class.case +// - src/dstr-binding/default/cls-decl-private-meth-dflt.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (private class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + #method([cls = class {}, xCls = class X {}, xCls2 = class { static name() {} }] = []) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + assert.notSameValue(xCls2.name, 'xCls2'); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-elem-id-init-fn-name-cover.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-elem-id-init-fn-name-cover.js new file mode 100644 index 0000000000..e3695c9aa0 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-elem-id-init-fn-name-cover.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-cover.case +// - src/dstr-binding/default/cls-decl-private-meth-dflt.template +/*--- +description: SingleNameBinding does assign name to "anonymous" functions "through" cover grammar (private class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + #method([cover = (function () {}), xCover = (0, function() {})] = []) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-elem-id-init-fn-name-fn.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-elem-id-init-fn-name-fn.js new file mode 100644 index 0000000000..d479070e87 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-elem-id-init-fn-name-fn.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-fn.case +// - src/dstr-binding/default/cls-decl-private-meth-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (private class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + #method([fn = function () {}, xFn = function x() {}] = []) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-elem-id-init-fn-name-gen.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-elem-id-init-fn-name-gen.js new file mode 100644 index 0000000000..c4e5267b8e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-elem-id-init-fn-name-gen.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-gen.case +// - src/dstr-binding/default/cls-decl-private-meth-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (private class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, class, class-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). + +---*/ + +var callCount = 0; +class C { + #method([gen = function* () {}, xGen = function* x() {}] = []) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-elem-id-init-hole.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-elem-id-init-hole.js new file mode 100644 index 0000000000..01bf4e1e62 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-elem-id-init-hole.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-hole.case +// - src/dstr-binding/default/cls-decl-private-meth-dflt.template +/*--- +description: Destructuring initializer with a "hole" (private class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + [...] + 7. If environment is undefined, return PutValue(lhs, v). 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + #method([x = 23] = [,]) { + assert.sameValue(x, 23); + // another statement + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-elem-id-init-skipped.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-elem-id-init-skipped.js new file mode 100644 index 0000000000..7158fd9163 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-elem-id-init-skipped.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-skipped.case +// - src/dstr-binding/default/cls-decl-private-meth-dflt.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (private class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +class C { + #method([w = counter(), x = counter(), y = counter(), z = counter()] = [null, 0, false, '']) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-elem-id-init-undef.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-elem-id-init-undef.js new file mode 100644 index 0000000000..803968e748 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-elem-id-init-undef.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-undef.case +// - src/dstr-binding/default/cls-decl-private-meth-dflt.template +/*--- +description: Destructuring initializer with an undefined value (private class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + #method([x = 23] = [undefined]) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-elem-id-iter-complete.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-elem-id-iter-complete.js new file mode 100644 index 0000000000..81cb2bf874 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-elem-id-iter-complete.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-complete.case +// - src/dstr-binding/default/cls-decl-private-meth-dflt.template +/*--- +description: SingleNameBinding when value iteration completes (private class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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, + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + #method([x] = []) { + assert.sameValue(x, undefined); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-elem-id-iter-done.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-elem-id-iter-done.js new file mode 100644 index 0000000000..f6a7172213 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-elem-id-iter-done.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-done.case +// - src/dstr-binding/default/cls-decl-private-meth-dflt.template +/*--- +description: SingleNameBinding when value iteration was completed previously (private class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + #method([_, x] = []) { + assert.sameValue(x, undefined); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-elem-id-iter-val-array-prototype.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-elem-id-iter-val-array-prototype.js new file mode 100644 index 0000000000..d9df8bda9d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-elem-id-iter-val-array-prototype.js @@ -0,0 +1,107 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val-array-prototype.case +// - src/dstr-binding/default/cls-decl-private-meth-dflt.template +/*--- +description: Array destructuring uses overriden Array.prototype[Symbol.iterator] (private class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [Symbol.iterator, generators, class, class-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializer_opt + + 1. Let bindingId be StringValue of BindingIdentifier. + 2. Let lhs be ? ResolveBinding(bindingId, environment). + 3. If iteratorRecord.[[Done]] is false, then + a. Let next be IteratorStep(iteratorRecord). + 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). + [...] + 7. Return InitializeReferencedBinding(lhs, v). + +---*/ +Array.prototype[Symbol.iterator] = function* () { + if (this.length > 0) { + yield this[0]; + } + if (this.length > 1) { + yield this[1]; + } + if (this.length > 2) { + yield 42; + } +}; + +var callCount = 0; +class C { + #method([x, y, z] = [1, 2, 3]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 42); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-elem-id-iter-val.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-elem-id-iter-val.js new file mode 100644 index 0000000000..05fab51268 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-elem-id-iter-val.js @@ -0,0 +1,97 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val.case +// - src/dstr-binding/default/cls-decl-private-meth-dflt.template +/*--- +description: SingleNameBinding when value iteration was completed previously (private class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + #method([x, y, z] = [1, 2, 3]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-elem-obj-id-init.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-elem-obj-id-init.js new file mode 100644 index 0000000000..1c906c9262 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-elem-obj-id-init.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id-init.case +// - src/dstr-binding/default/cls-decl-private-meth-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is used (private class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + #method([{ x, y, z } = { x: 44, y: 55, z: 66 }] = []) { + assert.sameValue(x, 44); + assert.sameValue(y, 55); + assert.sameValue(z, 66); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-elem-obj-id.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-elem-obj-id.js new file mode 100644 index 0000000000..27db293fbb --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-elem-obj-id.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id.case +// - src/dstr-binding/default/cls-decl-private-meth-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (private class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + #method([{ x, y, z } = { x: 44, y: 55, z: 66 }] = [{ x: 11, y: 22, z: 33 }]) { + assert.sameValue(x, 11); + assert.sameValue(y, 22); + assert.sameValue(z, 33); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-elem-obj-prop-id-init.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-elem-obj-prop-id-init.js new file mode 100644 index 0000000000..70f555da9d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-elem-obj-prop-id-init.js @@ -0,0 +1,99 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id-init.case +// - src/dstr-binding/default/cls-decl-private-meth-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is used (private class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + #method([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] = []) { + assert.sameValue(v, 444); + assert.sameValue(x, 555); + assert.sameValue(z, 666); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-elem-obj-prop-id.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-elem-obj-prop-id.js new file mode 100644 index 0000000000..41c1420324 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-elem-obj-prop-id.js @@ -0,0 +1,99 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id.case +// - src/dstr-binding/default/cls-decl-private-meth-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (private class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + #method([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] = [{ u: 777, w: 888, y: 999 }]) { + assert.sameValue(v, 777); + assert.sameValue(x, 888); + assert.sameValue(z, 999); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-elision-exhausted.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-elision-exhausted.js new file mode 100644 index 0000000000..6d67bd0032 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-elision-exhausted.js @@ -0,0 +1,94 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-exhausted.case +// - src/dstr-binding/default/cls-decl-private-meth-dflt.template +/*--- +description: Elision accepts exhausted iterator (private class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, class, class-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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 + [...] + 2. Return NormalCompletion(empty). + +---*/ +var iter = function*() {}(); +iter.next(); + +var callCount = 0; +class C { + #method([,] = iter) { + + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-elision.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-elision.js new file mode 100644 index 0000000000..c83d9d705e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-elision.js @@ -0,0 +1,103 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision.case +// - src/dstr-binding/default/cls-decl-private-meth-dflt.template +/*--- +description: Elision advances iterator (private class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, class, class-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +class C { + #method([,] = g()) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-empty.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-empty.js new file mode 100644 index 0000000000..ec1ab86696 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-empty.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-empty.case +// - src/dstr-binding/default/cls-decl-private-meth-dflt.template +/*--- +description: No iteration occurs for an "empty" array binding pattern (private class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, class, class-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var callCount = 0; +class C { + #method([] = iter) { + assert.sameValue(iterations, 0); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-rest-ary-elem.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-rest-ary-elem.js new file mode 100644 index 0000000000..624564c5b7 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-rest-ary-elem.js @@ -0,0 +1,110 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elem.case +// - src/dstr-binding/default/cls-decl-private-meth-dflt.template +/*--- +description: Rest element containing an array BindingElementList pattern (private class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the 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). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + #method([...[x, y, z]] = [3, 4, 5]) { + assert.sameValue(x, 3); + assert.sameValue(y, 4); + assert.sameValue(z, 5); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-rest-ary-elision.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-rest-ary-elision.js new file mode 100644 index 0000000000..457bd3334d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-rest-ary-elision.js @@ -0,0 +1,116 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elision.case +// - src/dstr-binding/default/cls-decl-private-meth-dflt.template +/*--- +description: Rest element containing an elision (private class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, class, class-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the 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). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +class C { + #method([...[,]] = g()) { + assert.sameValue(first, 1); + assert.sameValue(second, 1); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-rest-ary-empty.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-rest-ary-empty.js new file mode 100644 index 0000000000..08361b0b02 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-rest-ary-empty.js @@ -0,0 +1,99 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-empty.case +// - src/dstr-binding/default/cls-decl-private-meth-dflt.template +/*--- +description: Rest element containing an "empty" array pattern (private class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, class, class-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var callCount = 0; +class C { + #method([...[]] = iter) { + assert.sameValue(iterations, 1); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-rest-ary-rest.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-rest-ary-rest.js new file mode 100644 index 0000000000..41faa91bfb --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-rest-ary-rest.js @@ -0,0 +1,95 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-rest.case +// - src/dstr-binding/default/cls-decl-private-meth-dflt.template +/*--- +description: Rest element containing a rest element (private class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ +var values = [1, 2, 3]; + +var callCount = 0; +class C { + #method([...[...x]] = values) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-rest-id-direct.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-rest-id-direct.js new file mode 100644 index 0000000000..cb25bdd0f4 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-rest-id-direct.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-direct.case +// - src/dstr-binding/default/cls-decl-private-meth-dflt.template +/*--- +description: Lone rest element (direct binding) (private class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-methods-private, destructuring-binding, default-parameters] +flags: [generated] +includes: [compareArray.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingIdentifier + + [...] + 2. Let A be ! ArrayCreate(0). + 3. Let n be 0. + 4. Repeat, + [...] + f. Perform ! CreateDataPropertyOrThrow(A, ! ToString(n), nextValue). + g. Set n to n + 1. + +---*/ + +var callCount = 0; +class C { + #method([...x] = [1]) { + assert(Array.isArray(x)); + assert.compareArray(x, [1]); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-rest-id-elision.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-rest-id-elision.js new file mode 100644 index 0000000000..ce84f0b190 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-rest-id-elision.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision.case +// - src/dstr-binding/default/cls-decl-private-meth-dflt.template +/*--- +description: Rest element following elision elements (private class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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 values = [1, 2, 3, 4, 5]; + +var callCount = 0; +class C { + #method([ , , ...x] = values) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 3); + assert.sameValue(x[1], 4); + assert.sameValue(x[2], 5); + assert.notSameValue(x, values); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-rest-id-exhausted.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-rest-id-exhausted.js new file mode 100644 index 0000000000..d275436ada --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-rest-id-exhausted.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-exhausted.case +// - src/dstr-binding/default/cls-decl-private-meth-dflt.template +/*--- +description: RestElement applied to an exhausted iterator (private class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [Symbol.iterator, class, class-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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, + [...] + b. If iteratorRecord.[[done]] is true, then + i. If environment is undefined, return PutValue(lhs, A). + ii. Return InitializeReferencedBinding(lhs, A). + +---*/ + +var callCount = 0; +class C { + #method([, , ...x] = [1, 2]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 0); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-rest-id.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-rest-id.js new file mode 100644 index 0000000000..6cde98bae8 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-rest-id.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id.case +// - src/dstr-binding/default/cls-decl-private-meth-dflt.template +/*--- +description: Lone rest element (private class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + [...] 3. Let A be ArrayCreate(0). [...] 5. Repeat + [...] + f. Let status be CreateDataProperty(A, ToString (n), nextValue). + [...] +---*/ +var values = [1, 2, 3]; + +var callCount = 0; +class C { + #method([...x] = values) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-rest-init-ary.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-rest-init-ary.js new file mode 100644 index 0000000000..5a897fd714 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-rest-init-ary.js @@ -0,0 +1,84 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-ary.case +// - src/dstr-binding/default/cls-decl-private-meth-dflt.template +/*--- +description: Rest element (nested array pattern) does not support initializer (private class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-methods-private, destructuring-binding, default-parameters] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var callCount = 0; +class C { + #method([...[ x ] = []] = []) { + + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-rest-init-id.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-rest-init-id.js new file mode 100644 index 0000000000..f659b3f79e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-rest-init-id.js @@ -0,0 +1,84 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-id.case +// - src/dstr-binding/default/cls-decl-private-meth-dflt.template +/*--- +description: Rest element (identifier) does not support initializer (private class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-methods-private, destructuring-binding, default-parameters] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var callCount = 0; +class C { + #method([...x = []] = []) { + + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-rest-init-obj.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-rest-init-obj.js new file mode 100644 index 0000000000..949cd85abc --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-rest-init-obj.js @@ -0,0 +1,84 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-obj.case +// - src/dstr-binding/default/cls-decl-private-meth-dflt.template +/*--- +description: Rest element (nested object pattern) does not support initializer (private class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-methods-private, destructuring-binding, default-parameters] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var callCount = 0; +class C { + #method([...{ x } = []] = []) { + + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-rest-not-final-ary.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-rest-not-final-ary.js new file mode 100644 index 0000000000..5dc3556f1c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-rest-not-final-ary.js @@ -0,0 +1,84 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-ary.case +// - src/dstr-binding/default/cls-decl-private-meth-dflt.template +/*--- +description: Rest element (array binding pattern) may not be followed by any element (private class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-methods-private, destructuring-binding, default-parameters] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var callCount = 0; +class C { + #method([...[x], y] = [1, 2, 3]) { + + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-rest-not-final-id.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-rest-not-final-id.js new file mode 100644 index 0000000000..3d87f97704 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-rest-not-final-id.js @@ -0,0 +1,84 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-id.case +// - src/dstr-binding/default/cls-decl-private-meth-dflt.template +/*--- +description: Rest element (identifier) may not be followed by any element (private class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-methods-private, destructuring-binding, default-parameters] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var callCount = 0; +class C { + #method([...x, y] = [1, 2, 3]) { + + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-rest-not-final-obj.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-rest-not-final-obj.js new file mode 100644 index 0000000000..35419eb270 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-rest-not-final-obj.js @@ -0,0 +1,84 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-obj.case +// - src/dstr-binding/default/cls-decl-private-meth-dflt.template +/*--- +description: Rest element (object binding pattern) may not be followed by any element (private class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-methods-private, destructuring-binding, default-parameters] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var callCount = 0; +class C { + #method([...{ x }, y] = [1, 2, 3]) { + + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-rest-obj-id.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-rest-obj-id.js new file mode 100644 index 0000000000..b7c3b6186a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-rest-obj-id.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-id.case +// - src/dstr-binding/default/cls-decl-private-meth-dflt.template +/*--- +description: Rest element containing an object binding pattern (private class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ + +var callCount = 0; +class C { + #method([...{ length }] = [1, 2, 3]) { + assert.sameValue(length, 3); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-rest-obj-prop-id.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-rest-obj-prop-id.js new file mode 100644 index 0000000000..59877ad529 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-ary-ptrn-rest-obj-prop-id.js @@ -0,0 +1,95 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-prop-id.case +// - src/dstr-binding/default/cls-decl-private-meth-dflt.template +/*--- +description: Rest element containing an object binding pattern (private class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ +let length = "outer"; + +var callCount = 0; +class C { + #method([...{ 0: v, 1: w, 2: x, 3: y, length: z }] = [7, 8, 9]) { + assert.sameValue(v, 7); + assert.sameValue(w, 8); + assert.sameValue(x, 9); + assert.sameValue(y, undefined); + assert.sameValue(z, 3); + + assert.sameValue(length, "outer", "the length prop is not set as a binding name"); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-obj-ptrn-empty.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-obj-ptrn-empty.js new file mode 100644 index 0000000000..9a14bb6f69 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-obj-ptrn-empty.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-empty.case +// - src/dstr-binding/default/cls-decl-private-meth-dflt.template +/*--- +description: No property access occurs for an "empty" object binding pattern (private class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ +var accessCount = 0; +var obj = Object.defineProperty({}, 'attr', { + get: function() { + accessCount += 1; + } +}); + +var callCount = 0; +class C { + #method({} = obj) { + assert.sameValue(accessCount, 0); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-obj-ptrn-id-init-fn-name-arrow.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-obj-ptrn-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..1f5df25586 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-obj-ptrn-id-init-fn-name-arrow.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-arrow.case +// - src/dstr-binding/default/cls-decl-private-meth-dflt.template +/*--- +description: SingleNameBinding assigns `name` to arrow functions (private class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +class C { + #method({ arrow = () => {} } = {}) { + assert.sameValue(arrow.name, 'arrow'); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-obj-ptrn-id-init-fn-name-class.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-obj-ptrn-id-init-fn-name-class.js new file mode 100644 index 0000000000..7e2f45b612 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-obj-ptrn-id-init-fn-name-class.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-class.case +// - src/dstr-binding/default/cls-decl-private-meth-dflt.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (private class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +class C { + #method({ cls = class {}, xCls = class X {}, xCls2 = class { static name() {} } } = {}) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + assert.notSameValue(xCls2.name, 'xCls2'); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-obj-ptrn-id-init-fn-name-cover.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-obj-ptrn-id-init-fn-name-cover.js new file mode 100644 index 0000000000..44e84582ce --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-obj-ptrn-id-init-fn-name-cover.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-cover.case +// - src/dstr-binding/default/cls-decl-private-meth-dflt.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" functions "through" cover grammar (private class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +class C { + #method({ cover = (function () {}), xCover = (0, function() {}) } = {}) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-obj-ptrn-id-init-fn-name-fn.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-obj-ptrn-id-init-fn-name-fn.js new file mode 100644 index 0000000000..8f1b11c85f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-obj-ptrn-id-init-fn-name-fn.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-fn.case +// - src/dstr-binding/default/cls-decl-private-meth-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (private class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +class C { + #method({ fn = function () {}, xFn = function x() {} } = {}) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-obj-ptrn-id-init-fn-name-gen.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-obj-ptrn-id-init-fn-name-gen.js new file mode 100644 index 0000000000..fade38e1b0 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-obj-ptrn-id-init-fn-name-gen.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-gen.case +// - src/dstr-binding/default/cls-decl-private-meth-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (private class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, class, class-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). + +---*/ + +var callCount = 0; +class C { + #method({ gen = function* () {}, xGen = function* x() {} } = {}) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-obj-ptrn-id-init-skipped.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-obj-ptrn-id-init-skipped.js new file mode 100644 index 0000000000..eaa3b6bd2f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-obj-ptrn-id-init-skipped.js @@ -0,0 +1,92 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-skipped.case +// - src/dstr-binding/default/cls-decl-private-meth-dflt.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (private class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +class C { + #method({ w = counter(), x = counter(), y = counter(), z = counter() } = { w: null, x: 0, y: false, z: '' }) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-obj-ptrn-id-trailing-comma.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-obj-ptrn-id-trailing-comma.js new file mode 100644 index 0000000000..57f52851fb --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-obj-ptrn-id-trailing-comma.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-trailing-comma.case +// - src/dstr-binding/default/cls-decl-private-meth-dflt.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (private class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +class C { + #method({ x, } = { x: 23 }) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-obj-ptrn-prop-ary-init.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-obj-ptrn-prop-ary-init.js new file mode 100644 index 0000000000..99fd8affa7 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-obj-ptrn-prop-ary-init.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-init.case +// - src/dstr-binding/default/cls-decl-private-meth-dflt.template +/*--- +description: Object binding pattern with "nested" array binding pattern using initializer (private class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 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). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +class C { + #method({ w: [x, y, z] = [4, 5, 6] } = {}) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-obj-ptrn-prop-ary-trailing-comma.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-obj-ptrn-prop-ary-trailing-comma.js new file mode 100644 index 0000000000..212dc77a49 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-obj-ptrn-prop-ary-trailing-comma.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-trailing-comma.case +// - src/dstr-binding/default/cls-decl-private-meth-dflt.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (private class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +class C { + #method({ x: [y], } = { x: [45] }) { + assert.sameValue(y,45); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-obj-ptrn-prop-ary.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-obj-ptrn-prop-ary.js new file mode 100644 index 0000000000..a5209a9c97 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-obj-ptrn-prop-ary.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary.case +// - src/dstr-binding/default/cls-decl-private-meth-dflt.template +/*--- +description: Object binding pattern with "nested" array binding pattern not using initializer (private class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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. +---*/ + +var callCount = 0; +class C { + #method({ w: [x, y, z] = [4, 5, 6] } = { w: [7, undefined, ] }) { + assert.sameValue(x, 7); + assert.sameValue(y, undefined); + assert.sameValue(z, undefined); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-obj-ptrn-prop-id-init-skipped.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-obj-ptrn-prop-id-init-skipped.js new file mode 100644 index 0000000000..c9007f940b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-obj-ptrn-prop-id-init-skipped.js @@ -0,0 +1,104 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-skipped.case +// - src/dstr-binding/default/cls-decl-private-meth-dflt.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (private class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +class C { + #method({ s: t = counter(), u: v = counter(), w: x = counter(), y: z = counter() } = { s: null, u: 0, w: false, y: '' }) { + assert.sameValue(t, null); + assert.sameValue(v, 0); + assert.sameValue(x, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + + assert.throws(ReferenceError, function() { + s; + }); + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-obj-ptrn-prop-id-init.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-obj-ptrn-prop-id-init.js new file mode 100644 index 0000000000..880544be5e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-obj-ptrn-prop-id-init.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init.case +// - src/dstr-binding/default/cls-decl-private-meth-dflt.template +/*--- +description: Binding as specified via property name, identifier, and initializer (private class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + #method({ x: y = 33 } = { }) { + assert.sameValue(y, 33); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-obj-ptrn-prop-id-trailing-comma.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-obj-ptrn-prop-id-trailing-comma.js new file mode 100644 index 0000000000..5b23b7fe7a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-obj-ptrn-prop-id-trailing-comma.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-trailing-comma.case +// - src/dstr-binding/default/cls-decl-private-meth-dflt.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (private class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +class C { + #method({ x: y, } = { x: 23 }) { + assert.sameValue(y, 23); + + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-obj-ptrn-prop-id.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-obj-ptrn-prop-id.js new file mode 100644 index 0000000000..2acafc5edf --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-obj-ptrn-prop-id.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id.case +// - src/dstr-binding/default/cls-decl-private-meth-dflt.template +/*--- +description: Binding as specified via property name and identifier (private class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + #method({ x: y } = { x: 23 }) { + assert.sameValue(y, 23); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-obj-ptrn-prop-obj-init.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-obj-ptrn-prop-obj-init.js new file mode 100644 index 0000000000..9778adeb4b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-obj-ptrn-prop-obj-init.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-init.case +// - src/dstr-binding/default/cls-decl-private-meth-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern using initializer (private class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 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). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +class C { + #method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } } = { w: undefined }) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-obj-ptrn-prop-obj.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-obj-ptrn-prop-obj.js new file mode 100644 index 0000000000..5842f1912c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-obj-ptrn-prop-obj.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj.case +// - src/dstr-binding/default/cls-decl-private-meth-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern not using initializer (private class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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. +---*/ + +var callCount = 0; +class C { + #method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } } = { w: { x: undefined, z: 7 } }) { + assert.sameValue(x, undefined); + assert.sameValue(y, undefined); + assert.sameValue(z, 7); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-obj-ptrn-rest-getter.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-obj-ptrn-rest-getter.js new file mode 100644 index 0000000000..15f34504d9 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-obj-ptrn-rest-getter.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-getter.case +// - src/dstr-binding/default/cls-decl-private-meth-dflt.template +/*--- +description: Getter is called when obj is being deconstructed to a rest Object (private class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [object-rest, class, class-methods-private, destructuring-binding, default-parameters] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var count = 0; + +var callCount = 0; +class C { + #method({...x} = { get v() { count++; return 2; } }) { + assert.sameValue(count, 1); + + verifyProperty(x, "v", { + enumerable: true, + writable: true, + configurable: true, + value: 2 + }); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-obj-ptrn-rest-skip-non-enumerable.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-obj-ptrn-rest-skip-non-enumerable.js new file mode 100644 index 0000000000..9a4f251c65 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-obj-ptrn-rest-skip-non-enumerable.js @@ -0,0 +1,92 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-skip-non-enumerable.case +// - src/dstr-binding/default/cls-decl-private-meth-dflt.template +/*--- +description: Rest object doesn't contain non-enumerable properties (private class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [object-rest, class, class-methods-private, destructuring-binding, default-parameters] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var o = {a: 3, b: 4}; +Object.defineProperty(o, "x", { value: 4, enumerable: false }); + +var callCount = 0; +class C { + #method({...rest} = o) { + assert.sameValue(rest.x, undefined); + + verifyProperty(rest, "a", { + enumerable: true, + writable: true, + configurable: true, + value: 3 + }); + + verifyProperty(rest, "b", { + enumerable: true, + writable: true, + configurable: true, + value: 4 + }); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-obj-ptrn-rest-val-obj.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-obj-ptrn-rest-val-obj.js new file mode 100644 index 0000000000..5437d9d9bc --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-dflt-obj-ptrn-rest-val-obj.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-val-obj.case +// - src/dstr-binding/default/cls-decl-private-meth-dflt.template +/*--- +description: Rest object contains just unextracted data (private class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [object-rest, class, class-methods-private, destructuring-binding, default-parameters] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +class C { + #method({a, b, ...rest} = {x: 1, y: 2, a: 5, b: 3}) { + assert.sameValue(rest.a, undefined); + assert.sameValue(rest.b, undefined); + + verifyProperty(rest, "x", { + enumerable: true, + writable: true, + configurable: true, + value: 1 + }); + + verifyProperty(rest, "y", { + enumerable: true, + writable: true, + configurable: true, + value: 2 + }); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-obj-ptrn-empty.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-obj-ptrn-empty.js new file mode 100644 index 0000000000..c0e13217a1 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-obj-ptrn-empty.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-empty.case +// - src/dstr-binding/default/cls-decl-private-meth.template +/*--- +description: No property access occurs for an "empty" object binding pattern (private class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ +var accessCount = 0; +var obj = Object.defineProperty({}, 'attr', { + get: function() { + accessCount += 1; + } +}); + +var callCount = 0; +class C { + #method({}) { + assert.sameValue(accessCount, 0); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method(obj); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-obj-ptrn-id-init-fn-name-arrow.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-obj-ptrn-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..2330d077b2 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-obj-ptrn-id-init-fn-name-arrow.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-arrow.case +// - src/dstr-binding/default/cls-decl-private-meth.template +/*--- +description: SingleNameBinding assigns `name` to arrow functions (private class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +class C { + #method({ arrow = () => {} }) { + assert.sameValue(arrow.name, 'arrow'); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method({}); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-obj-ptrn-id-init-fn-name-class.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-obj-ptrn-id-init-fn-name-class.js new file mode 100644 index 0000000000..4af2ecddda --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-obj-ptrn-id-init-fn-name-class.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-class.case +// - src/dstr-binding/default/cls-decl-private-meth.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (private class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +class C { + #method({ cls = class {}, xCls = class X {}, xCls2 = class { static name() {} } }) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + assert.notSameValue(xCls2.name, 'xCls2'); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method({}); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-obj-ptrn-id-init-fn-name-cover.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-obj-ptrn-id-init-fn-name-cover.js new file mode 100644 index 0000000000..ecbe73d7b1 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-obj-ptrn-id-init-fn-name-cover.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-cover.case +// - src/dstr-binding/default/cls-decl-private-meth.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" functions "through" cover grammar (private class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +class C { + #method({ cover = (function () {}), xCover = (0, function() {}) }) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method({}); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-obj-ptrn-id-init-fn-name-fn.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-obj-ptrn-id-init-fn-name-fn.js new file mode 100644 index 0000000000..e63746391e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-obj-ptrn-id-init-fn-name-fn.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-fn.case +// - src/dstr-binding/default/cls-decl-private-meth.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (private class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +class C { + #method({ fn = function () {}, xFn = function x() {} }) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method({}); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-obj-ptrn-id-init-fn-name-gen.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-obj-ptrn-id-init-fn-name-gen.js new file mode 100644 index 0000000000..0303047613 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-obj-ptrn-id-init-fn-name-gen.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-gen.case +// - src/dstr-binding/default/cls-decl-private-meth.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (private class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, class, class-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). + +---*/ + +var callCount = 0; +class C { + #method({ gen = function* () {}, xGen = function* x() {} }) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method({}); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-obj-ptrn-id-init-skipped.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-obj-ptrn-id-init-skipped.js new file mode 100644 index 0000000000..8235421dd3 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-obj-ptrn-id-init-skipped.js @@ -0,0 +1,92 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-skipped.case +// - src/dstr-binding/default/cls-decl-private-meth.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (private class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +class C { + #method({ w = counter(), x = counter(), y = counter(), z = counter() }) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method({ w: null, x: 0, y: false, z: '' }); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-obj-ptrn-id-trailing-comma.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-obj-ptrn-id-trailing-comma.js new file mode 100644 index 0000000000..6a82712de9 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-obj-ptrn-id-trailing-comma.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-trailing-comma.case +// - src/dstr-binding/default/cls-decl-private-meth.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (private class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +class C { + #method({ x, }) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method({ x: 23 }); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-obj-ptrn-prop-ary-init.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-obj-ptrn-prop-ary-init.js new file mode 100644 index 0000000000..1093eadb3c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-obj-ptrn-prop-ary-init.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-init.case +// - src/dstr-binding/default/cls-decl-private-meth.template +/*--- +description: Object binding pattern with "nested" array binding pattern using initializer (private class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 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). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +class C { + #method({ w: [x, y, z] = [4, 5, 6] }) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method({}); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-obj-ptrn-prop-ary-trailing-comma.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-obj-ptrn-prop-ary-trailing-comma.js new file mode 100644 index 0000000000..dcab838f14 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-obj-ptrn-prop-ary-trailing-comma.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-trailing-comma.case +// - src/dstr-binding/default/cls-decl-private-meth.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (private class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +class C { + #method({ x: [y], }) { + assert.sameValue(y,45); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method({ x: [45] }); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-obj-ptrn-prop-ary.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-obj-ptrn-prop-ary.js new file mode 100644 index 0000000000..334f8b2c57 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-obj-ptrn-prop-ary.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary.case +// - src/dstr-binding/default/cls-decl-private-meth.template +/*--- +description: Object binding pattern with "nested" array binding pattern not using initializer (private class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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. +---*/ + +var callCount = 0; +class C { + #method({ w: [x, y, z] = [4, 5, 6] }) { + assert.sameValue(x, 7); + assert.sameValue(y, undefined); + assert.sameValue(z, undefined); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method({ w: [7, undefined, ] }); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-obj-ptrn-prop-id-init-skipped.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-obj-ptrn-prop-id-init-skipped.js new file mode 100644 index 0000000000..c271947ded --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-obj-ptrn-prop-id-init-skipped.js @@ -0,0 +1,104 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-skipped.case +// - src/dstr-binding/default/cls-decl-private-meth.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (private class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +class C { + #method({ s: t = counter(), u: v = counter(), w: x = counter(), y: z = counter() }) { + assert.sameValue(t, null); + assert.sameValue(v, 0); + assert.sameValue(x, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + + assert.throws(ReferenceError, function() { + s; + }); + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method({ s: null, u: 0, w: false, y: '' }); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-obj-ptrn-prop-id-init.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-obj-ptrn-prop-id-init.js new file mode 100644 index 0000000000..ea288eb7dc --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-obj-ptrn-prop-id-init.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init.case +// - src/dstr-binding/default/cls-decl-private-meth.template +/*--- +description: Binding as specified via property name, identifier, and initializer (private class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + #method({ x: y = 33 }) { + assert.sameValue(y, 33); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method({ }); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-obj-ptrn-prop-id-trailing-comma.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-obj-ptrn-prop-id-trailing-comma.js new file mode 100644 index 0000000000..ac53632f7a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-obj-ptrn-prop-id-trailing-comma.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-trailing-comma.case +// - src/dstr-binding/default/cls-decl-private-meth.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (private class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +class C { + #method({ x: y, }) { + assert.sameValue(y, 23); + + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method({ x: 23 }); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-obj-ptrn-prop-id.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-obj-ptrn-prop-id.js new file mode 100644 index 0000000000..06d30c1eb3 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-obj-ptrn-prop-id.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id.case +// - src/dstr-binding/default/cls-decl-private-meth.template +/*--- +description: Binding as specified via property name and identifier (private class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + #method({ x: y }) { + assert.sameValue(y, 23); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method({ x: 23 }); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-obj-ptrn-prop-obj-init.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-obj-ptrn-prop-obj-init.js new file mode 100644 index 0000000000..b8199b954a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-obj-ptrn-prop-obj-init.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-init.case +// - src/dstr-binding/default/cls-decl-private-meth.template +/*--- +description: Object binding pattern with "nested" object binding pattern using initializer (private class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 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). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +class C { + #method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } }) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method({ w: undefined }); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-obj-ptrn-prop-obj.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-obj-ptrn-prop-obj.js new file mode 100644 index 0000000000..9b785b3758 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-obj-ptrn-prop-obj.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj.case +// - src/dstr-binding/default/cls-decl-private-meth.template +/*--- +description: Object binding pattern with "nested" object binding pattern not using initializer (private class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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. +---*/ + +var callCount = 0; +class C { + #method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } }) { + assert.sameValue(x, undefined); + assert.sameValue(y, undefined); + assert.sameValue(z, 7); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method({ w: { x: undefined, z: 7 } }); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-obj-ptrn-rest-getter.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-obj-ptrn-rest-getter.js new file mode 100644 index 0000000000..48a01f4bd3 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-obj-ptrn-rest-getter.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-getter.case +// - src/dstr-binding/default/cls-decl-private-meth.template +/*--- +description: Getter is called when obj is being deconstructed to a rest Object (private class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [object-rest, class, class-methods-private, destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var count = 0; + +var callCount = 0; +class C { + #method({...x}) { + assert.sameValue(count, 1); + + verifyProperty(x, "v", { + enumerable: true, + writable: true, + configurable: true, + value: 2 + }); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method({ get v() { count++; return 2; } }); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-obj-ptrn-rest-skip-non-enumerable.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-obj-ptrn-rest-skip-non-enumerable.js new file mode 100644 index 0000000000..53c2d12d13 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-obj-ptrn-rest-skip-non-enumerable.js @@ -0,0 +1,92 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-skip-non-enumerable.case +// - src/dstr-binding/default/cls-decl-private-meth.template +/*--- +description: Rest object doesn't contain non-enumerable properties (private class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [object-rest, class, class-methods-private, destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var o = {a: 3, b: 4}; +Object.defineProperty(o, "x", { value: 4, enumerable: false }); + +var callCount = 0; +class C { + #method({...rest}) { + assert.sameValue(rest.x, undefined); + + verifyProperty(rest, "a", { + enumerable: true, + writable: true, + configurable: true, + value: 3 + }); + + verifyProperty(rest, "b", { + enumerable: true, + writable: true, + configurable: true, + value: 4 + }); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method(o); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-obj-ptrn-rest-val-obj.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-obj-ptrn-rest-val-obj.js new file mode 100644 index 0000000000..ce05388c5c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-obj-ptrn-rest-val-obj.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-val-obj.case +// - src/dstr-binding/default/cls-decl-private-meth.template +/*--- +description: Rest object contains just unextracted data (private class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [object-rest, class, class-methods-private, destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +class C { + #method({a, b, ...rest}) { + assert.sameValue(rest.a, undefined); + assert.sameValue(rest.b, undefined); + + verifyProperty(rest, "x", { + enumerable: true, + writable: true, + configurable: true, + value: 1 + }); + + verifyProperty(rest, "y", { + enumerable: true, + writable: true, + configurable: true, + value: 2 + }); + callCount = callCount + 1; + } + + get method() { + return this.#method; + } +}; + +new C().method({x: 1, y: 2, a: 5, b: 3}); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-init-iter-close.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-init-iter-close.js new file mode 100644 index 0000000000..67fef4ff99 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-init-iter-close.js @@ -0,0 +1,98 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-close.case +// - src/dstr-binding/default/cls-decl-private-meth-static.template +/*--- +description: Iterator is closed when not exhausted by pattern evaluation (private static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [Symbol.iterator, class, class-static-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: false }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var callCount = 0; +class C { + static #method([x]) { + assert.sameValue(doneCallCount, 1); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method(iter); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-init-iter-no-close.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-init-iter-no-close.js new file mode 100644 index 0000000000..86276e0d00 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-init-iter-no-close.js @@ -0,0 +1,98 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-no-close.case +// - src/dstr-binding/default/cls-decl-private-meth-static.template +/*--- +description: Iterator is not closed when exhausted by pattern evaluation (private static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [Symbol.iterator, class, class-static-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: true }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var callCount = 0; +class C { + static #method([x]) { + assert.sameValue(doneCallCount, 0); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method(iter); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-name-iter-val.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-name-iter-val.js new file mode 100644 index 0000000000..dddf6a08aa --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-name-iter-val.js @@ -0,0 +1,97 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-name-iter-val.case +// - src/dstr-binding/default/cls-decl-private-meth-static.template +/*--- +description: SingleNameBinding with normal value iteration (private static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static #method([x, y, z]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method([1, 2, 3]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-elem-ary-elem-init.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-elem-ary-elem-init.js new file mode 100644 index 0000000000..6013316089 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-elem-ary-elem-init.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-init.case +// - src/dstr-binding/default/cls-decl-private-meth-static.template +/*--- +description: BindingElement with array binding pattern and initializer is used (private static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + static #method([[x, y, z] = [4, 5, 6]]) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-elem-ary-elem-iter.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-elem-ary-elem-iter.js new file mode 100644 index 0000000000..ce59e7de59 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-elem-ary-elem-iter.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-iter.case +// - src/dstr-binding/default/cls-decl-private-meth-static.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (private static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + static #method([[x, y, z] = [4, 5, 6]]) { + assert.sameValue(x, 7); + assert.sameValue(y, 8); + assert.sameValue(z, 9); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method([[7, 8, 9]]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-elem-ary-elision-init.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-elem-ary-elision-init.js new file mode 100644 index 0000000000..9074589b89 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-elem-ary-elision-init.js @@ -0,0 +1,96 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-init.case +// - src/dstr-binding/default/cls-decl-private-meth-static.template +/*--- +description: BindingElement with array binding pattern and initializer is used (private static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, class, class-static-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +class C { + static #method([[,] = g()]) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-elem-ary-elision-iter.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-elem-ary-elision-iter.js new file mode 100644 index 0000000000..d8c4a42cef --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-elem-ary-elision-iter.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-iter.case +// - src/dstr-binding/default/cls-decl-private-meth-static.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (private static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, class, class-static-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var callCount = 0; +function* g() { + callCount += 1; +}; + +var callCount = 0; +class C { + static #method([[,] = g()]) { + assert.sameValue(callCount, 0); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method([[]]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-elem-ary-empty-init.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-elem-ary-empty-init.js new file mode 100644 index 0000000000..e92c218389 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-elem-ary-empty-init.js @@ -0,0 +1,92 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-init.case +// - src/dstr-binding/default/cls-decl-private-meth-static.template +/*--- +description: BindingElement with array binding pattern and initializer is used (private static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, class, class-static-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var initCount = 0; +var iterCount = 0; +var iter = function*() { iterCount += 1; }(); + +var callCount = 0; +class C { + static #method([[] = function() { initCount += 1; return iter; }()]) { + assert.sameValue(initCount, 1); + assert.sameValue(iterCount, 0); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-elem-ary-empty-iter.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-elem-ary-empty-iter.js new file mode 100644 index 0000000000..fe07210890 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-elem-ary-empty-iter.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-iter.case +// - src/dstr-binding/default/cls-decl-private-meth-static.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (private static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var initCount = 0; + +var callCount = 0; +class C { + static #method([[] = function() { initCount += 1; }()]) { + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method([[23]]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-elem-ary-rest-init.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-elem-ary-rest-init.js new file mode 100644 index 0000000000..463888fafa --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-elem-ary-rest-init.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-init.case +// - src/dstr-binding/default/cls-decl-private-meth-static.template +/*--- +description: BindingElement with array binding pattern and initializer is used (private static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; + +var callCount = 0; +class C { + static #method([[...x] = values]) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-elem-ary-rest-iter.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-elem-ary-rest-iter.js new file mode 100644 index 0000000000..d0bd01db36 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-elem-ary-rest-iter.js @@ -0,0 +1,96 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-iter.case +// - src/dstr-binding/default/cls-decl-private-meth-static.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (private static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; +var initCount = 0; + +var callCount = 0; +class C { + static #method([[...x] = function() { initCount += 1; }()]) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method([values]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-elem-id-init-exhausted.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-elem-id-init-exhausted.js new file mode 100644 index 0000000000..b2888b6bed --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-elem-id-init-exhausted.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-exhausted.case +// - src/dstr-binding/default/cls-decl-private-meth-static.template +/*--- +description: Destructuring initializer with an exhausted iterator (private static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static #method([x = 23]) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-elem-id-init-fn-name-arrow.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-elem-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..3dbb00a948 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-elem-id-init-fn-name-arrow.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-arrow.case +// - src/dstr-binding/default/cls-decl-private-meth-static.template +/*--- +description: SingleNameBinding does assign name to arrow functions (private static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static #method([arrow = () => {}]) { + assert.sameValue(arrow.name, 'arrow'); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-elem-id-init-fn-name-class.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-elem-id-init-fn-name-class.js new file mode 100644 index 0000000000..8ccc0e9836 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-elem-id-init-fn-name-class.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-class.case +// - src/dstr-binding/default/cls-decl-private-meth-static.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (private static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static #method([cls = class {}, xCls = class X {}, xCls2 = class { static name() {} }]) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + assert.notSameValue(xCls2.name, 'xCls2'); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-elem-id-init-fn-name-cover.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-elem-id-init-fn-name-cover.js new file mode 100644 index 0000000000..19951201fe --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-elem-id-init-fn-name-cover.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-cover.case +// - src/dstr-binding/default/cls-decl-private-meth-static.template +/*--- +description: SingleNameBinding does assign name to "anonymous" functions "through" cover grammar (private static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static #method([cover = (function () {}), xCover = (0, function() {})]) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-elem-id-init-fn-name-fn.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-elem-id-init-fn-name-fn.js new file mode 100644 index 0000000000..55b63b4054 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-elem-id-init-fn-name-fn.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-fn.case +// - src/dstr-binding/default/cls-decl-private-meth-static.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (private static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static #method([fn = function () {}, xFn = function x() {}]) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-elem-id-init-fn-name-gen.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-elem-id-init-fn-name-gen.js new file mode 100644 index 0000000000..205f141eaf --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-elem-id-init-fn-name-gen.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-gen.case +// - src/dstr-binding/default/cls-decl-private-meth-static.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (private static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, class, class-static-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). + +---*/ + +var callCount = 0; +class C { + static #method([gen = function* () {}, xGen = function* x() {}]) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-elem-id-init-hole.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-elem-id-init-hole.js new file mode 100644 index 0000000000..2b8aa58d8b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-elem-id-init-hole.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-hole.case +// - src/dstr-binding/default/cls-decl-private-meth-static.template +/*--- +description: Destructuring initializer with a "hole" (private static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + [...] + 7. If environment is undefined, return PutValue(lhs, v). 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static #method([x = 23]) { + assert.sameValue(x, 23); + // another statement + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method([,]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-elem-id-init-skipped.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-elem-id-init-skipped.js new file mode 100644 index 0000000000..b6c585290c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-elem-id-init-skipped.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-skipped.case +// - src/dstr-binding/default/cls-decl-private-meth-static.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (private static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +class C { + static #method([w = counter(), x = counter(), y = counter(), z = counter()]) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method([null, 0, false, '']); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-elem-id-init-undef.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-elem-id-init-undef.js new file mode 100644 index 0000000000..b090428f87 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-elem-id-init-undef.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-undef.case +// - src/dstr-binding/default/cls-decl-private-meth-static.template +/*--- +description: Destructuring initializer with an undefined value (private static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static #method([x = 23]) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method([undefined]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-elem-id-iter-complete.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-elem-id-iter-complete.js new file mode 100644 index 0000000000..5a156fa06e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-elem-id-iter-complete.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-complete.case +// - src/dstr-binding/default/cls-decl-private-meth-static.template +/*--- +description: SingleNameBinding when value iteration completes (private static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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, + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static #method([x]) { + assert.sameValue(x, undefined); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-elem-id-iter-done.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-elem-id-iter-done.js new file mode 100644 index 0000000000..75cf9a72a5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-elem-id-iter-done.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-done.case +// - src/dstr-binding/default/cls-decl-private-meth-static.template +/*--- +description: SingleNameBinding when value iteration was completed previously (private static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static #method([_, x]) { + assert.sameValue(x, undefined); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-elem-id-iter-val-array-prototype.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-elem-id-iter-val-array-prototype.js new file mode 100644 index 0000000000..7139764c6f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-elem-id-iter-val-array-prototype.js @@ -0,0 +1,107 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val-array-prototype.case +// - src/dstr-binding/default/cls-decl-private-meth-static.template +/*--- +description: Array destructuring uses overriden Array.prototype[Symbol.iterator] (private static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [Symbol.iterator, generators, class, class-static-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializer_opt + + 1. Let bindingId be StringValue of BindingIdentifier. + 2. Let lhs be ? ResolveBinding(bindingId, environment). + 3. If iteratorRecord.[[Done]] is false, then + a. Let next be IteratorStep(iteratorRecord). + 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). + [...] + 7. Return InitializeReferencedBinding(lhs, v). + +---*/ +Array.prototype[Symbol.iterator] = function* () { + if (this.length > 0) { + yield this[0]; + } + if (this.length > 1) { + yield this[1]; + } + if (this.length > 2) { + yield 42; + } +}; + +var callCount = 0; +class C { + static #method([x, y, z]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 42); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method([1, 2, 3]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-elem-id-iter-val.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-elem-id-iter-val.js new file mode 100644 index 0000000000..ecac85ffc5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-elem-id-iter-val.js @@ -0,0 +1,97 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val.case +// - src/dstr-binding/default/cls-decl-private-meth-static.template +/*--- +description: SingleNameBinding when value iteration was completed previously (private static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static #method([x, y, z]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method([1, 2, 3]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-elem-obj-id-init.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-elem-obj-id-init.js new file mode 100644 index 0000000000..d2151a8aee --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-elem-obj-id-init.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id-init.case +// - src/dstr-binding/default/cls-decl-private-meth-static.template +/*--- +description: BindingElement with object binding pattern and initializer is used (private static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + static #method([{ x, y, z } = { x: 44, y: 55, z: 66 }]) { + assert.sameValue(x, 44); + assert.sameValue(y, 55); + assert.sameValue(z, 66); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-elem-obj-id.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-elem-obj-id.js new file mode 100644 index 0000000000..246df99536 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-elem-obj-id.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id.case +// - src/dstr-binding/default/cls-decl-private-meth-static.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (private static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + static #method([{ x, y, z } = { x: 44, y: 55, z: 66 }]) { + assert.sameValue(x, 11); + assert.sameValue(y, 22); + assert.sameValue(z, 33); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method([{ x: 11, y: 22, z: 33 }]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-elem-obj-prop-id-init.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-elem-obj-prop-id-init.js new file mode 100644 index 0000000000..1338f7693e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-elem-obj-prop-id-init.js @@ -0,0 +1,99 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id-init.case +// - src/dstr-binding/default/cls-decl-private-meth-static.template +/*--- +description: BindingElement with object binding pattern and initializer is used (private static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + static #method([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }]) { + assert.sameValue(v, 444); + assert.sameValue(x, 555); + assert.sameValue(z, 666); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-elem-obj-prop-id.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-elem-obj-prop-id.js new file mode 100644 index 0000000000..306233bfb9 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-elem-obj-prop-id.js @@ -0,0 +1,99 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id.case +// - src/dstr-binding/default/cls-decl-private-meth-static.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (private static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + static #method([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }]) { + assert.sameValue(v, 777); + assert.sameValue(x, 888); + assert.sameValue(z, 999); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method([{ u: 777, w: 888, y: 999 }]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-elision-exhausted.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-elision-exhausted.js new file mode 100644 index 0000000000..8fa86fd5fb --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-elision-exhausted.js @@ -0,0 +1,94 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-exhausted.case +// - src/dstr-binding/default/cls-decl-private-meth-static.template +/*--- +description: Elision accepts exhausted iterator (private static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, class, class-static-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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 + [...] + 2. Return NormalCompletion(empty). + +---*/ +var iter = function*() {}(); +iter.next(); + +var callCount = 0; +class C { + static #method([,]) { + + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method(iter); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-elision.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-elision.js new file mode 100644 index 0000000000..40dccdcdc1 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-elision.js @@ -0,0 +1,103 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision.case +// - src/dstr-binding/default/cls-decl-private-meth-static.template +/*--- +description: Elision advances iterator (private static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, class, class-static-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +class C { + static #method([,]) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method(g()); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-empty.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-empty.js new file mode 100644 index 0000000000..7b8c255b6a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-empty.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-empty.case +// - src/dstr-binding/default/cls-decl-private-meth-static.template +/*--- +description: No iteration occurs for an "empty" array binding pattern (private static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, class, class-static-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var callCount = 0; +class C { + static #method([]) { + assert.sameValue(iterations, 0); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method(iter); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-rest-ary-elem.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-rest-ary-elem.js new file mode 100644 index 0000000000..bd6f465685 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-rest-ary-elem.js @@ -0,0 +1,110 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elem.case +// - src/dstr-binding/default/cls-decl-private-meth-static.template +/*--- +description: Rest element containing an array BindingElementList pattern (private static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the 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). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static #method([...[x, y, z]]) { + assert.sameValue(x, 3); + assert.sameValue(y, 4); + assert.sameValue(z, 5); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method([3, 4, 5]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-rest-ary-elision.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-rest-ary-elision.js new file mode 100644 index 0000000000..6eb2d733b2 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-rest-ary-elision.js @@ -0,0 +1,116 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elision.case +// - src/dstr-binding/default/cls-decl-private-meth-static.template +/*--- +description: Rest element containing an elision (private static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, class, class-static-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the 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). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +class C { + static #method([...[,]]) { + assert.sameValue(first, 1); + assert.sameValue(second, 1); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method(g()); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-rest-ary-empty.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-rest-ary-empty.js new file mode 100644 index 0000000000..0526dd7ea9 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-rest-ary-empty.js @@ -0,0 +1,99 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-empty.case +// - src/dstr-binding/default/cls-decl-private-meth-static.template +/*--- +description: Rest element containing an "empty" array pattern (private static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, class, class-static-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var callCount = 0; +class C { + static #method([...[]]) { + assert.sameValue(iterations, 1); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method(iter); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-rest-ary-rest.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-rest-ary-rest.js new file mode 100644 index 0000000000..239bd18659 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-rest-ary-rest.js @@ -0,0 +1,95 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-rest.case +// - src/dstr-binding/default/cls-decl-private-meth-static.template +/*--- +description: Rest element containing a rest element (private static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ +var values = [1, 2, 3]; + +var callCount = 0; +class C { + static #method([...[...x]]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method(values); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-rest-id-direct.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-rest-id-direct.js new file mode 100644 index 0000000000..c2bf23e660 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-rest-id-direct.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-direct.case +// - src/dstr-binding/default/cls-decl-private-meth-static.template +/*--- +description: Lone rest element (direct binding) (private static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, destructuring-binding] +flags: [generated] +includes: [compareArray.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingIdentifier + + [...] + 2. Let A be ! ArrayCreate(0). + 3. Let n be 0. + 4. Repeat, + [...] + f. Perform ! CreateDataPropertyOrThrow(A, ! ToString(n), nextValue). + g. Set n to n + 1. + +---*/ + +var callCount = 0; +class C { + static #method([...x]) { + assert(Array.isArray(x)); + assert.compareArray(x, [1]); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method([1]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-rest-id-elision.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-rest-id-elision.js new file mode 100644 index 0000000000..0dd975f7a8 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-rest-id-elision.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision.case +// - src/dstr-binding/default/cls-decl-private-meth-static.template +/*--- +description: Rest element following elision elements (private static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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 values = [1, 2, 3, 4, 5]; + +var callCount = 0; +class C { + static #method([ , , ...x]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 3); + assert.sameValue(x[1], 4); + assert.sameValue(x[2], 5); + assert.notSameValue(x, values); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method(values); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-rest-id-exhausted.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-rest-id-exhausted.js new file mode 100644 index 0000000000..d157abe604 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-rest-id-exhausted.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-exhausted.case +// - src/dstr-binding/default/cls-decl-private-meth-static.template +/*--- +description: RestElement applied to an exhausted iterator (private static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [Symbol.iterator, class, class-static-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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, + [...] + b. If iteratorRecord.[[done]] is true, then + i. If environment is undefined, return PutValue(lhs, A). + ii. Return InitializeReferencedBinding(lhs, A). + +---*/ + +var callCount = 0; +class C { + static #method([, , ...x]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 0); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method([1, 2]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-rest-id.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-rest-id.js new file mode 100644 index 0000000000..6033c1228a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-rest-id.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id.case +// - src/dstr-binding/default/cls-decl-private-meth-static.template +/*--- +description: Lone rest element (private static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + [...] 3. Let A be ArrayCreate(0). [...] 5. Repeat + [...] + f. Let status be CreateDataProperty(A, ToString (n), nextValue). + [...] +---*/ +var values = [1, 2, 3]; + +var callCount = 0; +class C { + static #method([...x]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method(values); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-rest-init-ary.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-rest-init-ary.js new file mode 100644 index 0000000000..950b8b2665 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-rest-init-ary.js @@ -0,0 +1,84 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-ary.case +// - src/dstr-binding/default/cls-decl-private-meth-static.template +/*--- +description: Rest element (nested array pattern) does not support initializer (private static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, destructuring-binding] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var callCount = 0; +class C { + static #method([...[ x ] = []]) { + + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-rest-init-id.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-rest-init-id.js new file mode 100644 index 0000000000..123354e379 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-rest-init-id.js @@ -0,0 +1,84 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-id.case +// - src/dstr-binding/default/cls-decl-private-meth-static.template +/*--- +description: Rest element (identifier) does not support initializer (private static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, destructuring-binding] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var callCount = 0; +class C { + static #method([...x = []]) { + + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-rest-init-obj.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-rest-init-obj.js new file mode 100644 index 0000000000..59279e3f46 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-rest-init-obj.js @@ -0,0 +1,84 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-obj.case +// - src/dstr-binding/default/cls-decl-private-meth-static.template +/*--- +description: Rest element (nested object pattern) does not support initializer (private static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, destructuring-binding] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var callCount = 0; +class C { + static #method([...{ x } = []]) { + + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method([]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-rest-not-final-ary.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-rest-not-final-ary.js new file mode 100644 index 0000000000..e2ecaed254 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-rest-not-final-ary.js @@ -0,0 +1,84 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-ary.case +// - src/dstr-binding/default/cls-decl-private-meth-static.template +/*--- +description: Rest element (array binding pattern) may not be followed by any element (private static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, destructuring-binding] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var callCount = 0; +class C { + static #method([...[x], y]) { + + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method([1, 2, 3]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-rest-not-final-id.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-rest-not-final-id.js new file mode 100644 index 0000000000..3217fbee28 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-rest-not-final-id.js @@ -0,0 +1,84 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-id.case +// - src/dstr-binding/default/cls-decl-private-meth-static.template +/*--- +description: Rest element (identifier) may not be followed by any element (private static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, destructuring-binding] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var callCount = 0; +class C { + static #method([...x, y]) { + + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method([1, 2, 3]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-rest-not-final-obj.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-rest-not-final-obj.js new file mode 100644 index 0000000000..fd51675b7f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-rest-not-final-obj.js @@ -0,0 +1,84 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-obj.case +// - src/dstr-binding/default/cls-decl-private-meth-static.template +/*--- +description: Rest element (object binding pattern) may not be followed by any element (private static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, destructuring-binding] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var callCount = 0; +class C { + static #method([...{ x }, y]) { + + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method([1, 2, 3]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-rest-obj-id.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-rest-obj-id.js new file mode 100644 index 0000000000..db91ba3dbd --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-rest-obj-id.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-id.case +// - src/dstr-binding/default/cls-decl-private-meth-static.template +/*--- +description: Rest element containing an object binding pattern (private static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ + +var callCount = 0; +class C { + static #method([...{ length }]) { + assert.sameValue(length, 3); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method([1, 2, 3]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-rest-obj-prop-id.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-rest-obj-prop-id.js new file mode 100644 index 0000000000..5dab0a6c60 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-ary-ptrn-rest-obj-prop-id.js @@ -0,0 +1,95 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-prop-id.case +// - src/dstr-binding/default/cls-decl-private-meth-static.template +/*--- +description: Rest element containing an object binding pattern (private static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ +let length = "outer"; + +var callCount = 0; +class C { + static #method([...{ 0: v, 1: w, 2: x, 3: y, length: z }]) { + assert.sameValue(v, 7); + assert.sameValue(w, 8); + assert.sameValue(x, 9); + assert.sameValue(y, undefined); + assert.sameValue(z, 3); + + assert.sameValue(length, "outer", "the length prop is not set as a binding name"); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method([7, 8, 9]); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-init-iter-close.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-init-iter-close.js new file mode 100644 index 0000000000..1887cf6e5f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-init-iter-close.js @@ -0,0 +1,98 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-close.case +// - src/dstr-binding/default/cls-decl-private-meth-static-dflt.template +/*--- +description: Iterator is closed when not exhausted by pattern evaluation (private static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [Symbol.iterator, class, class-static-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: false }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var callCount = 0; +class C { + static #method([x] = iter) { + assert.sameValue(doneCallCount, 1); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-init-iter-no-close.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-init-iter-no-close.js new file mode 100644 index 0000000000..885c4f67c5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-init-iter-no-close.js @@ -0,0 +1,98 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-no-close.case +// - src/dstr-binding/default/cls-decl-private-meth-static-dflt.template +/*--- +description: Iterator is not closed when exhausted by pattern evaluation (private static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [Symbol.iterator, class, class-static-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: true }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var callCount = 0; +class C { + static #method([x] = iter) { + assert.sameValue(doneCallCount, 0); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-name-iter-val.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-name-iter-val.js new file mode 100644 index 0000000000..ac72b2656c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-name-iter-val.js @@ -0,0 +1,97 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-name-iter-val.case +// - src/dstr-binding/default/cls-decl-private-meth-static-dflt.template +/*--- +description: SingleNameBinding with normal value iteration (private static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static #method([x, y, z] = [1, 2, 3]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-elem-ary-elem-init.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-elem-ary-elem-init.js new file mode 100644 index 0000000000..543ec000b3 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-elem-ary-elem-init.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-init.case +// - src/dstr-binding/default/cls-decl-private-meth-static-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (private static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + static #method([[x, y, z] = [4, 5, 6]] = []) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-elem-ary-elem-iter.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-elem-ary-elem-iter.js new file mode 100644 index 0000000000..96ff3f7c46 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-elem-ary-elem-iter.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-iter.case +// - src/dstr-binding/default/cls-decl-private-meth-static-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (private static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + static #method([[x, y, z] = [4, 5, 6]] = [[7, 8, 9]]) { + assert.sameValue(x, 7); + assert.sameValue(y, 8); + assert.sameValue(z, 9); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-elem-ary-elision-init.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-elem-ary-elision-init.js new file mode 100644 index 0000000000..1ec8532a26 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-elem-ary-elision-init.js @@ -0,0 +1,96 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-init.case +// - src/dstr-binding/default/cls-decl-private-meth-static-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (private static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, class, class-static-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +class C { + static #method([[,] = g()] = []) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-elem-ary-elision-iter.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-elem-ary-elision-iter.js new file mode 100644 index 0000000000..15ea70f430 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-elem-ary-elision-iter.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-iter.case +// - src/dstr-binding/default/cls-decl-private-meth-static-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (private static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, class, class-static-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var callCount = 0; +function* g() { + callCount += 1; +}; + +var callCount = 0; +class C { + static #method([[,] = g()] = [[]]) { + assert.sameValue(callCount, 0); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-elem-ary-empty-init.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-elem-ary-empty-init.js new file mode 100644 index 0000000000..41ea47e7f4 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-elem-ary-empty-init.js @@ -0,0 +1,92 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-init.case +// - src/dstr-binding/default/cls-decl-private-meth-static-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (private static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, class, class-static-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var initCount = 0; +var iterCount = 0; +var iter = function*() { iterCount += 1; }(); + +var callCount = 0; +class C { + static #method([[] = function() { initCount += 1; return iter; }()] = []) { + assert.sameValue(initCount, 1); + assert.sameValue(iterCount, 0); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-elem-ary-empty-iter.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-elem-ary-empty-iter.js new file mode 100644 index 0000000000..365b93402d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-elem-ary-empty-iter.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-iter.case +// - src/dstr-binding/default/cls-decl-private-meth-static-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (private static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var initCount = 0; + +var callCount = 0; +class C { + static #method([[] = function() { initCount += 1; }()] = [[23]]) { + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-elem-ary-rest-init.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-elem-ary-rest-init.js new file mode 100644 index 0000000000..bb2383e60c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-elem-ary-rest-init.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-init.case +// - src/dstr-binding/default/cls-decl-private-meth-static-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (private static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; + +var callCount = 0; +class C { + static #method([[...x] = values] = []) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-elem-ary-rest-iter.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-elem-ary-rest-iter.js new file mode 100644 index 0000000000..6f648b7b8a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-elem-ary-rest-iter.js @@ -0,0 +1,96 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-iter.case +// - src/dstr-binding/default/cls-decl-private-meth-static-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (private static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; +var initCount = 0; + +var callCount = 0; +class C { + static #method([[...x] = function() { initCount += 1; }()] = [values]) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-elem-id-init-exhausted.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-elem-id-init-exhausted.js new file mode 100644 index 0000000000..7c8b1be34e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-elem-id-init-exhausted.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-exhausted.case +// - src/dstr-binding/default/cls-decl-private-meth-static-dflt.template +/*--- +description: Destructuring initializer with an exhausted iterator (private static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static #method([x = 23] = []) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..b9f0d35f7f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-arrow.case +// - src/dstr-binding/default/cls-decl-private-meth-static-dflt.template +/*--- +description: SingleNameBinding does assign name to arrow functions (private static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static #method([arrow = () => {}] = []) { + assert.sameValue(arrow.name, 'arrow'); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-class.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-class.js new file mode 100644 index 0000000000..257ddc0b23 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-class.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-class.case +// - src/dstr-binding/default/cls-decl-private-meth-static-dflt.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (private static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static #method([cls = class {}, xCls = class X {}, xCls2 = class { static name() {} }] = []) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + assert.notSameValue(xCls2.name, 'xCls2'); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-cover.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-cover.js new file mode 100644 index 0000000000..37524d12eb --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-cover.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-cover.case +// - src/dstr-binding/default/cls-decl-private-meth-static-dflt.template +/*--- +description: SingleNameBinding does assign name to "anonymous" functions "through" cover grammar (private static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static #method([cover = (function () {}), xCover = (0, function() {})] = []) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-fn.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-fn.js new file mode 100644 index 0000000000..97c8cc6ffe --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-fn.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-fn.case +// - src/dstr-binding/default/cls-decl-private-meth-static-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (private static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static #method([fn = function () {}, xFn = function x() {}] = []) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-gen.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-gen.js new file mode 100644 index 0000000000..6dff2face9 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-gen.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-gen.case +// - src/dstr-binding/default/cls-decl-private-meth-static-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (private static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, class, class-static-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). + +---*/ + +var callCount = 0; +class C { + static #method([gen = function* () {}, xGen = function* x() {}] = []) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-elem-id-init-hole.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-elem-id-init-hole.js new file mode 100644 index 0000000000..8f68bcb24e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-elem-id-init-hole.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-hole.case +// - src/dstr-binding/default/cls-decl-private-meth-static-dflt.template +/*--- +description: Destructuring initializer with a "hole" (private static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + [...] + 7. If environment is undefined, return PutValue(lhs, v). 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static #method([x = 23] = [,]) { + assert.sameValue(x, 23); + // another statement + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-elem-id-init-skipped.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-elem-id-init-skipped.js new file mode 100644 index 0000000000..fb8ae2242e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-elem-id-init-skipped.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-skipped.case +// - src/dstr-binding/default/cls-decl-private-meth-static-dflt.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (private static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +class C { + static #method([w = counter(), x = counter(), y = counter(), z = counter()] = [null, 0, false, '']) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-elem-id-init-undef.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-elem-id-init-undef.js new file mode 100644 index 0000000000..90e17f939a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-elem-id-init-undef.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-undef.case +// - src/dstr-binding/default/cls-decl-private-meth-static-dflt.template +/*--- +description: Destructuring initializer with an undefined value (private static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static #method([x = 23] = [undefined]) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-elem-id-iter-complete.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-elem-id-iter-complete.js new file mode 100644 index 0000000000..af815e2508 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-elem-id-iter-complete.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-complete.case +// - src/dstr-binding/default/cls-decl-private-meth-static-dflt.template +/*--- +description: SingleNameBinding when value iteration completes (private static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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, + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static #method([x] = []) { + assert.sameValue(x, undefined); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-elem-id-iter-done.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-elem-id-iter-done.js new file mode 100644 index 0000000000..ddf3bfe61f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-elem-id-iter-done.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-done.case +// - src/dstr-binding/default/cls-decl-private-meth-static-dflt.template +/*--- +description: SingleNameBinding when value iteration was completed previously (private static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static #method([_, x] = []) { + assert.sameValue(x, undefined); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-elem-id-iter-val-array-prototype.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-elem-id-iter-val-array-prototype.js new file mode 100644 index 0000000000..85f7fc70de --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-elem-id-iter-val-array-prototype.js @@ -0,0 +1,107 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val-array-prototype.case +// - src/dstr-binding/default/cls-decl-private-meth-static-dflt.template +/*--- +description: Array destructuring uses overriden Array.prototype[Symbol.iterator] (private static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [Symbol.iterator, generators, class, class-static-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializer_opt + + 1. Let bindingId be StringValue of BindingIdentifier. + 2. Let lhs be ? ResolveBinding(bindingId, environment). + 3. If iteratorRecord.[[Done]] is false, then + a. Let next be IteratorStep(iteratorRecord). + 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). + [...] + 7. Return InitializeReferencedBinding(lhs, v). + +---*/ +Array.prototype[Symbol.iterator] = function* () { + if (this.length > 0) { + yield this[0]; + } + if (this.length > 1) { + yield this[1]; + } + if (this.length > 2) { + yield 42; + } +}; + +var callCount = 0; +class C { + static #method([x, y, z] = [1, 2, 3]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 42); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-elem-id-iter-val.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-elem-id-iter-val.js new file mode 100644 index 0000000000..a7f4633384 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-elem-id-iter-val.js @@ -0,0 +1,97 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val.case +// - src/dstr-binding/default/cls-decl-private-meth-static-dflt.template +/*--- +description: SingleNameBinding when value iteration was completed previously (private static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static #method([x, y, z] = [1, 2, 3]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-elem-obj-id-init.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-elem-obj-id-init.js new file mode 100644 index 0000000000..7c751e1e55 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-elem-obj-id-init.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id-init.case +// - src/dstr-binding/default/cls-decl-private-meth-static-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is used (private static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + static #method([{ x, y, z } = { x: 44, y: 55, z: 66 }] = []) { + assert.sameValue(x, 44); + assert.sameValue(y, 55); + assert.sameValue(z, 66); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-elem-obj-id.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-elem-obj-id.js new file mode 100644 index 0000000000..c702b2cba0 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-elem-obj-id.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id.case +// - src/dstr-binding/default/cls-decl-private-meth-static-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (private static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + static #method([{ x, y, z } = { x: 44, y: 55, z: 66 }] = [{ x: 11, y: 22, z: 33 }]) { + assert.sameValue(x, 11); + assert.sameValue(y, 22); + assert.sameValue(z, 33); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-elem-obj-prop-id-init.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-elem-obj-prop-id-init.js new file mode 100644 index 0000000000..70178f28c6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-elem-obj-prop-id-init.js @@ -0,0 +1,99 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id-init.case +// - src/dstr-binding/default/cls-decl-private-meth-static-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is used (private static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + static #method([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] = []) { + assert.sameValue(v, 444); + assert.sameValue(x, 555); + assert.sameValue(z, 666); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-elem-obj-prop-id.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-elem-obj-prop-id.js new file mode 100644 index 0000000000..0bf680efbd --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-elem-obj-prop-id.js @@ -0,0 +1,99 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id.case +// - src/dstr-binding/default/cls-decl-private-meth-static-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (private static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 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). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + static #method([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] = [{ u: 777, w: 888, y: 999 }]) { + assert.sameValue(v, 777); + assert.sameValue(x, 888); + assert.sameValue(z, 999); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-elision-exhausted.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-elision-exhausted.js new file mode 100644 index 0000000000..e256757602 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-elision-exhausted.js @@ -0,0 +1,94 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-exhausted.case +// - src/dstr-binding/default/cls-decl-private-meth-static-dflt.template +/*--- +description: Elision accepts exhausted iterator (private static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, class, class-static-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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 + [...] + 2. Return NormalCompletion(empty). + +---*/ +var iter = function*() {}(); +iter.next(); + +var callCount = 0; +class C { + static #method([,] = iter) { + + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-elision.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-elision.js new file mode 100644 index 0000000000..cd4ae586ed --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-elision.js @@ -0,0 +1,103 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision.case +// - src/dstr-binding/default/cls-decl-private-meth-static-dflt.template +/*--- +description: Elision advances iterator (private static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, class, class-static-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +class C { + static #method([,] = g()) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-empty.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-empty.js new file mode 100644 index 0000000000..ec22da64b8 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-empty.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-empty.case +// - src/dstr-binding/default/cls-decl-private-meth-static-dflt.template +/*--- +description: No iteration occurs for an "empty" array binding pattern (private static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, class, class-static-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var callCount = 0; +class C { + static #method([] = iter) { + assert.sameValue(iterations, 0); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-rest-ary-elem.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-rest-ary-elem.js new file mode 100644 index 0000000000..2607eaf454 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-rest-ary-elem.js @@ -0,0 +1,110 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elem.case +// - src/dstr-binding/default/cls-decl-private-meth-static-dflt.template +/*--- +description: Rest element containing an array BindingElementList pattern (private static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the 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). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static #method([...[x, y, z]] = [3, 4, 5]) { + assert.sameValue(x, 3); + assert.sameValue(y, 4); + assert.sameValue(z, 5); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-rest-ary-elision.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-rest-ary-elision.js new file mode 100644 index 0000000000..35078291d3 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-rest-ary-elision.js @@ -0,0 +1,116 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elision.case +// - src/dstr-binding/default/cls-decl-private-meth-static-dflt.template +/*--- +description: Rest element containing an elision (private static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, class, class-static-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the 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). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +class C { + static #method([...[,]] = g()) { + assert.sameValue(first, 1); + assert.sameValue(second, 1); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-rest-ary-empty.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-rest-ary-empty.js new file mode 100644 index 0000000000..14432e9b54 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-rest-ary-empty.js @@ -0,0 +1,99 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-empty.case +// - src/dstr-binding/default/cls-decl-private-meth-static-dflt.template +/*--- +description: Rest element containing an "empty" array pattern (private static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, class, class-static-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var callCount = 0; +class C { + static #method([...[]] = iter) { + assert.sameValue(iterations, 1); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-rest-ary-rest.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-rest-ary-rest.js new file mode 100644 index 0000000000..fceae6e266 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-rest-ary-rest.js @@ -0,0 +1,95 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-rest.case +// - src/dstr-binding/default/cls-decl-private-meth-static-dflt.template +/*--- +description: Rest element containing a rest element (private static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ +var values = [1, 2, 3]; + +var callCount = 0; +class C { + static #method([...[...x]] = values) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-rest-id-direct.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-rest-id-direct.js new file mode 100644 index 0000000000..e45d9b9050 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-rest-id-direct.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-direct.case +// - src/dstr-binding/default/cls-decl-private-meth-static-dflt.template +/*--- +description: Lone rest element (direct binding) (private static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, destructuring-binding, default-parameters] +flags: [generated] +includes: [compareArray.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingIdentifier + + [...] + 2. Let A be ! ArrayCreate(0). + 3. Let n be 0. + 4. Repeat, + [...] + f. Perform ! CreateDataPropertyOrThrow(A, ! ToString(n), nextValue). + g. Set n to n + 1. + +---*/ + +var callCount = 0; +class C { + static #method([...x] = [1]) { + assert(Array.isArray(x)); + assert.compareArray(x, [1]); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-rest-id-elision.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-rest-id-elision.js new file mode 100644 index 0000000000..74b7ac453c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-rest-id-elision.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision.case +// - src/dstr-binding/default/cls-decl-private-meth-static-dflt.template +/*--- +description: Rest element following elision elements (private static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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 values = [1, 2, 3, 4, 5]; + +var callCount = 0; +class C { + static #method([ , , ...x] = values) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 3); + assert.sameValue(x[1], 4); + assert.sameValue(x[2], 5); + assert.notSameValue(x, values); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-rest-id-exhausted.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-rest-id-exhausted.js new file mode 100644 index 0000000000..cd7f0b4dfa --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-rest-id-exhausted.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-exhausted.case +// - src/dstr-binding/default/cls-decl-private-meth-static-dflt.template +/*--- +description: RestElement applied to an exhausted iterator (private static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [Symbol.iterator, class, class-static-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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, + [...] + b. If iteratorRecord.[[done]] is true, then + i. If environment is undefined, return PutValue(lhs, A). + ii. Return InitializeReferencedBinding(lhs, A). + +---*/ + +var callCount = 0; +class C { + static #method([, , ...x] = [1, 2]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 0); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-rest-id.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-rest-id.js new file mode 100644 index 0000000000..ab58474e1b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-rest-id.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id.case +// - src/dstr-binding/default/cls-decl-private-meth-static-dflt.template +/*--- +description: Lone rest element (private static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + [...] 3. Let A be ArrayCreate(0). [...] 5. Repeat + [...] + f. Let status be CreateDataProperty(A, ToString (n), nextValue). + [...] +---*/ +var values = [1, 2, 3]; + +var callCount = 0; +class C { + static #method([...x] = values) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-rest-init-ary.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-rest-init-ary.js new file mode 100644 index 0000000000..b32f8f8f83 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-rest-init-ary.js @@ -0,0 +1,84 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-ary.case +// - src/dstr-binding/default/cls-decl-private-meth-static-dflt.template +/*--- +description: Rest element (nested array pattern) does not support initializer (private static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, destructuring-binding, default-parameters] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var callCount = 0; +class C { + static #method([...[ x ] = []] = []) { + + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-rest-init-id.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-rest-init-id.js new file mode 100644 index 0000000000..50b58ccc44 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-rest-init-id.js @@ -0,0 +1,84 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-id.case +// - src/dstr-binding/default/cls-decl-private-meth-static-dflt.template +/*--- +description: Rest element (identifier) does not support initializer (private static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, destructuring-binding, default-parameters] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var callCount = 0; +class C { + static #method([...x = []] = []) { + + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-rest-init-obj.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-rest-init-obj.js new file mode 100644 index 0000000000..515b36e176 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-rest-init-obj.js @@ -0,0 +1,84 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-obj.case +// - src/dstr-binding/default/cls-decl-private-meth-static-dflt.template +/*--- +description: Rest element (nested object pattern) does not support initializer (private static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, destructuring-binding, default-parameters] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var callCount = 0; +class C { + static #method([...{ x } = []] = []) { + + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-rest-not-final-ary.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-rest-not-final-ary.js new file mode 100644 index 0000000000..f0aeff0761 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-rest-not-final-ary.js @@ -0,0 +1,84 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-ary.case +// - src/dstr-binding/default/cls-decl-private-meth-static-dflt.template +/*--- +description: Rest element (array binding pattern) may not be followed by any element (private static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, destructuring-binding, default-parameters] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var callCount = 0; +class C { + static #method([...[x], y] = [1, 2, 3]) { + + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-rest-not-final-id.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-rest-not-final-id.js new file mode 100644 index 0000000000..d3d6881ab1 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-rest-not-final-id.js @@ -0,0 +1,84 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-id.case +// - src/dstr-binding/default/cls-decl-private-meth-static-dflt.template +/*--- +description: Rest element (identifier) may not be followed by any element (private static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, destructuring-binding, default-parameters] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var callCount = 0; +class C { + static #method([...x, y] = [1, 2, 3]) { + + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-rest-not-final-obj.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-rest-not-final-obj.js new file mode 100644 index 0000000000..e93ed26e0d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-rest-not-final-obj.js @@ -0,0 +1,84 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-obj.case +// - src/dstr-binding/default/cls-decl-private-meth-static-dflt.template +/*--- +description: Rest element (object binding pattern) may not be followed by any element (private static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, destructuring-binding, default-parameters] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ +$DONOTEVALUATE(); + +var callCount = 0; +class C { + static #method([...{ x }, y] = [1, 2, 3]) { + + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-rest-obj-id.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-rest-obj-id.js new file mode 100644 index 0000000000..c26920b995 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-rest-obj-id.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-id.case +// - src/dstr-binding/default/cls-decl-private-meth-static-dflt.template +/*--- +description: Rest element containing an object binding pattern (private static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ + +var callCount = 0; +class C { + static #method([...{ length }] = [1, 2, 3]) { + assert.sameValue(length, 3); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-rest-obj-prop-id.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-rest-obj-prop-id.js new file mode 100644 index 0000000000..e346444e39 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-ary-ptrn-rest-obj-prop-id.js @@ -0,0 +1,95 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-prop-id.case +// - src/dstr-binding/default/cls-decl-private-meth-static-dflt.template +/*--- +description: Rest element containing an object binding pattern (private static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ +let length = "outer"; + +var callCount = 0; +class C { + static #method([...{ 0: v, 1: w, 2: x, 3: y, length: z }] = [7, 8, 9]) { + assert.sameValue(v, 7); + assert.sameValue(w, 8); + assert.sameValue(x, 9); + assert.sameValue(y, undefined); + assert.sameValue(z, 3); + + assert.sameValue(length, "outer", "the length prop is not set as a binding name"); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-obj-ptrn-empty.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-obj-ptrn-empty.js new file mode 100644 index 0000000000..88f8d653b4 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-obj-ptrn-empty.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-empty.case +// - src/dstr-binding/default/cls-decl-private-meth-static-dflt.template +/*--- +description: No property access occurs for an "empty" object binding pattern (private static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ +var accessCount = 0; +var obj = Object.defineProperty({}, 'attr', { + get: function() { + accessCount += 1; + } +}); + +var callCount = 0; +class C { + static #method({} = obj) { + assert.sameValue(accessCount, 0); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-obj-ptrn-id-init-fn-name-arrow.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-obj-ptrn-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..435aee1ab6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-obj-ptrn-id-init-fn-name-arrow.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-arrow.case +// - src/dstr-binding/default/cls-decl-private-meth-static-dflt.template +/*--- +description: SingleNameBinding assigns `name` to arrow functions (private static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +class C { + static #method({ arrow = () => {} } = {}) { + assert.sameValue(arrow.name, 'arrow'); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-obj-ptrn-id-init-fn-name-class.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-obj-ptrn-id-init-fn-name-class.js new file mode 100644 index 0000000000..0071f451d3 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-obj-ptrn-id-init-fn-name-class.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-class.case +// - src/dstr-binding/default/cls-decl-private-meth-static-dflt.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (private static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +class C { + static #method({ cls = class {}, xCls = class X {}, xCls2 = class { static name() {} } } = {}) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + assert.notSameValue(xCls2.name, 'xCls2'); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-obj-ptrn-id-init-fn-name-cover.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-obj-ptrn-id-init-fn-name-cover.js new file mode 100644 index 0000000000..e3b53773bc --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-obj-ptrn-id-init-fn-name-cover.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-cover.case +// - src/dstr-binding/default/cls-decl-private-meth-static-dflt.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" functions "through" cover grammar (private static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +class C { + static #method({ cover = (function () {}), xCover = (0, function() {}) } = {}) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-obj-ptrn-id-init-fn-name-fn.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-obj-ptrn-id-init-fn-name-fn.js new file mode 100644 index 0000000000..e201800a28 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-obj-ptrn-id-init-fn-name-fn.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-fn.case +// - src/dstr-binding/default/cls-decl-private-meth-static-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (private static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +class C { + static #method({ fn = function () {}, xFn = function x() {} } = {}) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-obj-ptrn-id-init-fn-name-gen.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-obj-ptrn-id-init-fn-name-gen.js new file mode 100644 index 0000000000..99bca0477d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-obj-ptrn-id-init-fn-name-gen.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-gen.case +// - src/dstr-binding/default/cls-decl-private-meth-static-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (private static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, class, class-static-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). + +---*/ + +var callCount = 0; +class C { + static #method({ gen = function* () {}, xGen = function* x() {} } = {}) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-obj-ptrn-id-init-skipped.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-obj-ptrn-id-init-skipped.js new file mode 100644 index 0000000000..e3bc0889cf --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-obj-ptrn-id-init-skipped.js @@ -0,0 +1,92 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-skipped.case +// - src/dstr-binding/default/cls-decl-private-meth-static-dflt.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (private static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +class C { + static #method({ w = counter(), x = counter(), y = counter(), z = counter() } = { w: null, x: 0, y: false, z: '' }) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-obj-ptrn-id-trailing-comma.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-obj-ptrn-id-trailing-comma.js new file mode 100644 index 0000000000..efd4e14b89 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-obj-ptrn-id-trailing-comma.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-trailing-comma.case +// - src/dstr-binding/default/cls-decl-private-meth-static-dflt.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (private static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +class C { + static #method({ x, } = { x: 23 }) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-obj-ptrn-prop-ary-init.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-obj-ptrn-prop-ary-init.js new file mode 100644 index 0000000000..770939a957 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-obj-ptrn-prop-ary-init.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-init.case +// - src/dstr-binding/default/cls-decl-private-meth-static-dflt.template +/*--- +description: Object binding pattern with "nested" array binding pattern using initializer (private static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 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). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +class C { + static #method({ w: [x, y, z] = [4, 5, 6] } = {}) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-obj-ptrn-prop-ary-trailing-comma.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-obj-ptrn-prop-ary-trailing-comma.js new file mode 100644 index 0000000000..7a9044161d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-obj-ptrn-prop-ary-trailing-comma.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-trailing-comma.case +// - src/dstr-binding/default/cls-decl-private-meth-static-dflt.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (private static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +class C { + static #method({ x: [y], } = { x: [45] }) { + assert.sameValue(y,45); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-obj-ptrn-prop-ary.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-obj-ptrn-prop-ary.js new file mode 100644 index 0000000000..d9774777ad --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-obj-ptrn-prop-ary.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary.case +// - src/dstr-binding/default/cls-decl-private-meth-static-dflt.template +/*--- +description: Object binding pattern with "nested" array binding pattern not using initializer (private static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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. +---*/ + +var callCount = 0; +class C { + static #method({ w: [x, y, z] = [4, 5, 6] } = { w: [7, undefined, ] }) { + assert.sameValue(x, 7); + assert.sameValue(y, undefined); + assert.sameValue(z, undefined); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-obj-ptrn-prop-id-init-skipped.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-obj-ptrn-prop-id-init-skipped.js new file mode 100644 index 0000000000..d09b25c420 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-obj-ptrn-prop-id-init-skipped.js @@ -0,0 +1,104 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-skipped.case +// - src/dstr-binding/default/cls-decl-private-meth-static-dflt.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (private static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +class C { + static #method({ s: t = counter(), u: v = counter(), w: x = counter(), y: z = counter() } = { s: null, u: 0, w: false, y: '' }) { + assert.sameValue(t, null); + assert.sameValue(v, 0); + assert.sameValue(x, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + + assert.throws(ReferenceError, function() { + s; + }); + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-obj-ptrn-prop-id-init.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-obj-ptrn-prop-id-init.js new file mode 100644 index 0000000000..d351ac5afe --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-obj-ptrn-prop-id-init.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init.case +// - src/dstr-binding/default/cls-decl-private-meth-static-dflt.template +/*--- +description: Binding as specified via property name, identifier, and initializer (private static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static #method({ x: y = 33 } = { }) { + assert.sameValue(y, 33); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-obj-ptrn-prop-id-trailing-comma.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-obj-ptrn-prop-id-trailing-comma.js new file mode 100644 index 0000000000..ab4ecf7b62 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-obj-ptrn-prop-id-trailing-comma.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-trailing-comma.case +// - src/dstr-binding/default/cls-decl-private-meth-static-dflt.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (private static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +class C { + static #method({ x: y, } = { x: 23 }) { + assert.sameValue(y, 23); + + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-obj-ptrn-prop-id.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-obj-ptrn-prop-id.js new file mode 100644 index 0000000000..39f15c0ae5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-obj-ptrn-prop-id.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id.case +// - src/dstr-binding/default/cls-decl-private-meth-static-dflt.template +/*--- +description: Binding as specified via property name and identifier (private static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static #method({ x: y } = { x: 23 }) { + assert.sameValue(y, 23); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-obj-ptrn-prop-obj-init.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-obj-ptrn-prop-obj-init.js new file mode 100644 index 0000000000..2a6871aec1 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-obj-ptrn-prop-obj-init.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-init.case +// - src/dstr-binding/default/cls-decl-private-meth-static-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern using initializer (private static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 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). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +class C { + static #method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } } = { w: undefined }) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-obj-ptrn-prop-obj.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-obj-ptrn-prop-obj.js new file mode 100644 index 0000000000..ce24fef3c4 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-obj-ptrn-prop-obj.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj.case +// - src/dstr-binding/default/cls-decl-private-meth-static-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern not using initializer (private static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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. +---*/ + +var callCount = 0; +class C { + static #method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } } = { w: { x: undefined, z: 7 } }) { + assert.sameValue(x, undefined); + assert.sameValue(y, undefined); + assert.sameValue(z, 7); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-obj-ptrn-rest-getter.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-obj-ptrn-rest-getter.js new file mode 100644 index 0000000000..cb0e46ae21 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-obj-ptrn-rest-getter.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-getter.case +// - src/dstr-binding/default/cls-decl-private-meth-static-dflt.template +/*--- +description: Getter is called when obj is being deconstructed to a rest Object (private static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [object-rest, class, class-static-methods-private, destructuring-binding, default-parameters] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var count = 0; + +var callCount = 0; +class C { + static #method({...x} = { get v() { count++; return 2; } }) { + assert.sameValue(count, 1); + + verifyProperty(x, "v", { + enumerable: true, + writable: true, + configurable: true, + value: 2 + }); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-obj-ptrn-rest-skip-non-enumerable.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-obj-ptrn-rest-skip-non-enumerable.js new file mode 100644 index 0000000000..a5f96d22fd --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-obj-ptrn-rest-skip-non-enumerable.js @@ -0,0 +1,92 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-skip-non-enumerable.case +// - src/dstr-binding/default/cls-decl-private-meth-static-dflt.template +/*--- +description: Rest object doesn't contain non-enumerable properties (private static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [object-rest, class, class-static-methods-private, destructuring-binding, default-parameters] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var o = {a: 3, b: 4}; +Object.defineProperty(o, "x", { value: 4, enumerable: false }); + +var callCount = 0; +class C { + static #method({...rest} = o) { + assert.sameValue(rest.x, undefined); + + verifyProperty(rest, "a", { + enumerable: true, + writable: true, + configurable: true, + value: 3 + }); + + verifyProperty(rest, "b", { + enumerable: true, + writable: true, + configurable: true, + value: 4 + }); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-obj-ptrn-rest-val-obj.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-obj-ptrn-rest-val-obj.js new file mode 100644 index 0000000000..277bda2fe2 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-dflt-obj-ptrn-rest-val-obj.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-val-obj.case +// - src/dstr-binding/default/cls-decl-private-meth-static-dflt.template +/*--- +description: Rest object contains just unextracted data (private static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [object-rest, class, class-static-methods-private, destructuring-binding, default-parameters] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +class C { + static #method({a, b, ...rest} = {x: 1, y: 2, a: 5, b: 3}) { + assert.sameValue(rest.a, undefined); + assert.sameValue(rest.b, undefined); + + verifyProperty(rest, "x", { + enumerable: true, + writable: true, + configurable: true, + value: 1 + }); + + verifyProperty(rest, "y", { + enumerable: true, + writable: true, + configurable: true, + value: 2 + }); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-obj-ptrn-empty.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-obj-ptrn-empty.js new file mode 100644 index 0000000000..ad80335aea --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-obj-ptrn-empty.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-empty.case +// - src/dstr-binding/default/cls-decl-private-meth-static.template +/*--- +description: No property access occurs for an "empty" object binding pattern (private static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ +var accessCount = 0; +var obj = Object.defineProperty({}, 'attr', { + get: function() { + accessCount += 1; + } +}); + +var callCount = 0; +class C { + static #method({}) { + assert.sameValue(accessCount, 0); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method(obj); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-obj-ptrn-id-init-fn-name-arrow.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-obj-ptrn-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..c7f15b925a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-obj-ptrn-id-init-fn-name-arrow.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-arrow.case +// - src/dstr-binding/default/cls-decl-private-meth-static.template +/*--- +description: SingleNameBinding assigns `name` to arrow functions (private static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +class C { + static #method({ arrow = () => {} }) { + assert.sameValue(arrow.name, 'arrow'); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method({}); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-obj-ptrn-id-init-fn-name-class.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-obj-ptrn-id-init-fn-name-class.js new file mode 100644 index 0000000000..41654d52fe --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-obj-ptrn-id-init-fn-name-class.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-class.case +// - src/dstr-binding/default/cls-decl-private-meth-static.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (private static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +class C { + static #method({ cls = class {}, xCls = class X {}, xCls2 = class { static name() {} } }) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + assert.notSameValue(xCls2.name, 'xCls2'); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method({}); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-obj-ptrn-id-init-fn-name-cover.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-obj-ptrn-id-init-fn-name-cover.js new file mode 100644 index 0000000000..e3292e120e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-obj-ptrn-id-init-fn-name-cover.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-cover.case +// - src/dstr-binding/default/cls-decl-private-meth-static.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" functions "through" cover grammar (private static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +class C { + static #method({ cover = (function () {}), xCover = (0, function() {}) }) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method({}); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-obj-ptrn-id-init-fn-name-fn.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-obj-ptrn-id-init-fn-name-fn.js new file mode 100644 index 0000000000..04c75fa9d6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-obj-ptrn-id-init-fn-name-fn.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-fn.case +// - src/dstr-binding/default/cls-decl-private-meth-static.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (private static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +class C { + static #method({ fn = function () {}, xFn = function x() {} }) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method({}); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-obj-ptrn-id-init-fn-name-gen.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-obj-ptrn-id-init-fn-name-gen.js new file mode 100644 index 0000000000..1c45df27ab --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-obj-ptrn-id-init-fn-name-gen.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-gen.case +// - src/dstr-binding/default/cls-decl-private-meth-static.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (private static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators, class, class-static-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). + +---*/ + +var callCount = 0; +class C { + static #method({ gen = function* () {}, xGen = function* x() {} }) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method({}); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-obj-ptrn-id-init-skipped.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-obj-ptrn-id-init-skipped.js new file mode 100644 index 0000000000..3f12a20fcf --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-obj-ptrn-id-init-skipped.js @@ -0,0 +1,92 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-skipped.case +// - src/dstr-binding/default/cls-decl-private-meth-static.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (private static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +class C { + static #method({ w = counter(), x = counter(), y = counter(), z = counter() }) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method({ w: null, x: 0, y: false, z: '' }); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-obj-ptrn-id-trailing-comma.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-obj-ptrn-id-trailing-comma.js new file mode 100644 index 0000000000..57eed183a8 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-obj-ptrn-id-trailing-comma.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-trailing-comma.case +// - src/dstr-binding/default/cls-decl-private-meth-static.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (private static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +class C { + static #method({ x, }) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method({ x: 23 }); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-obj-ptrn-prop-ary-init.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-obj-ptrn-prop-ary-init.js new file mode 100644 index 0000000000..b988415e5b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-obj-ptrn-prop-ary-init.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-init.case +// - src/dstr-binding/default/cls-decl-private-meth-static.template +/*--- +description: Object binding pattern with "nested" array binding pattern using initializer (private static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 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). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +class C { + static #method({ w: [x, y, z] = [4, 5, 6] }) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method({}); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-obj-ptrn-prop-ary-trailing-comma.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-obj-ptrn-prop-ary-trailing-comma.js new file mode 100644 index 0000000000..3d9554b564 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-obj-ptrn-prop-ary-trailing-comma.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-trailing-comma.case +// - src/dstr-binding/default/cls-decl-private-meth-static.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (private static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +class C { + static #method({ x: [y], }) { + assert.sameValue(y,45); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method({ x: [45] }); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-obj-ptrn-prop-ary.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-obj-ptrn-prop-ary.js new file mode 100644 index 0000000000..d443705739 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-obj-ptrn-prop-ary.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary.case +// - src/dstr-binding/default/cls-decl-private-meth-static.template +/*--- +description: Object binding pattern with "nested" array binding pattern not using initializer (private static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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. +---*/ + +var callCount = 0; +class C { + static #method({ w: [x, y, z] = [4, 5, 6] }) { + assert.sameValue(x, 7); + assert.sameValue(y, undefined); + assert.sameValue(z, undefined); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method({ w: [7, undefined, ] }); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-obj-ptrn-prop-id-init-skipped.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-obj-ptrn-prop-id-init-skipped.js new file mode 100644 index 0000000000..3427ed5583 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-obj-ptrn-prop-id-init-skipped.js @@ -0,0 +1,104 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-skipped.case +// - src/dstr-binding/default/cls-decl-private-meth-static.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (private static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +class C { + static #method({ s: t = counter(), u: v = counter(), w: x = counter(), y: z = counter() }) { + assert.sameValue(t, null); + assert.sameValue(v, 0); + assert.sameValue(x, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + + assert.throws(ReferenceError, function() { + s; + }); + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method({ s: null, u: 0, w: false, y: '' }); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-obj-ptrn-prop-id-init.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-obj-ptrn-prop-id-init.js new file mode 100644 index 0000000000..da00572f52 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-obj-ptrn-prop-id-init.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init.case +// - src/dstr-binding/default/cls-decl-private-meth-static.template +/*--- +description: Binding as specified via property name, identifier, and initializer (private static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static #method({ x: y = 33 }) { + assert.sameValue(y, 33); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method({ }); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-obj-ptrn-prop-id-trailing-comma.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-obj-ptrn-prop-id-trailing-comma.js new file mode 100644 index 0000000000..dd2b10246e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-obj-ptrn-prop-id-trailing-comma.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-trailing-comma.case +// - src/dstr-binding/default/cls-decl-private-meth-static.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (private static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +class C { + static #method({ x: y, }) { + assert.sameValue(y, 23); + + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method({ x: 23 }); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-obj-ptrn-prop-id.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-obj-ptrn-prop-id.js new file mode 100644 index 0000000000..4c4f7311b5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-obj-ptrn-prop-id.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id.case +// - src/dstr-binding/default/cls-decl-private-meth-static.template +/*--- +description: Binding as specified via property name and identifier (private static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static #method({ x: y }) { + assert.sameValue(y, 23); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method({ x: 23 }); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-obj-ptrn-prop-obj-init.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-obj-ptrn-prop-obj-init.js new file mode 100644 index 0000000000..42e0831d98 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-obj-ptrn-prop-obj-init.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-init.case +// - src/dstr-binding/default/cls-decl-private-meth-static.template +/*--- +description: Object binding pattern with "nested" object binding pattern using initializer (private static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 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). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +class C { + static #method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } }) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method({ w: undefined }); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-obj-ptrn-prop-obj.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-obj-ptrn-prop-obj.js new file mode 100644 index 0000000000..c1caf23a4e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-obj-ptrn-prop-obj.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj.case +// - src/dstr-binding/default/cls-decl-private-meth-static.template +/*--- +description: Object binding pattern with "nested" object binding pattern not using initializer (private static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, class-static-methods-private, destructuring-binding] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env 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. +---*/ + +var callCount = 0; +class C { + static #method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } }) { + assert.sameValue(x, undefined); + assert.sameValue(y, undefined); + assert.sameValue(z, 7); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method({ w: { x: undefined, z: 7 } }); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-obj-ptrn-rest-getter.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-obj-ptrn-rest-getter.js new file mode 100644 index 0000000000..658d09f678 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-obj-ptrn-rest-getter.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-getter.case +// - src/dstr-binding/default/cls-decl-private-meth-static.template +/*--- +description: Getter is called when obj is being deconstructed to a rest Object (private static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [object-rest, class, class-static-methods-private, destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var count = 0; + +var callCount = 0; +class C { + static #method({...x}) { + assert.sameValue(count, 1); + + verifyProperty(x, "v", { + enumerable: true, + writable: true, + configurable: true, + value: 2 + }); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method({ get v() { count++; return 2; } }); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-obj-ptrn-rest-skip-non-enumerable.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-obj-ptrn-rest-skip-non-enumerable.js new file mode 100644 index 0000000000..c2bbf73cb3 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-obj-ptrn-rest-skip-non-enumerable.js @@ -0,0 +1,92 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-skip-non-enumerable.case +// - src/dstr-binding/default/cls-decl-private-meth-static.template +/*--- +description: Rest object doesn't contain non-enumerable properties (private static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [object-rest, class, class-static-methods-private, destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var o = {a: 3, b: 4}; +Object.defineProperty(o, "x", { value: 4, enumerable: false }); + +var callCount = 0; +class C { + static #method({...rest}) { + assert.sameValue(rest.x, undefined); + + verifyProperty(rest, "a", { + enumerable: true, + writable: true, + configurable: true, + value: 3 + }); + + verifyProperty(rest, "b", { + enumerable: true, + writable: true, + configurable: true, + value: 4 + }); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method(o); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/private-meth-static-obj-ptrn-rest-val-obj.js b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-obj-ptrn-rest-val-obj.js new file mode 100644 index 0000000000..2e8bbdc4c7 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/dstr/private-meth-static-obj-ptrn-rest-val-obj.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-rest-val-obj.case +// - src/dstr-binding/default/cls-decl-private-meth-static.template +/*--- +description: Rest object contains just unextracted data (private static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [object-rest, class, class-static-methods-private, destructuring-binding] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +class C { + static #method({a, b, ...rest}) { + assert.sameValue(rest.a, undefined); + assert.sameValue(rest.b, undefined); + + verifyProperty(rest, "x", { + enumerable: true, + writable: true, + configurable: true, + value: 1 + }); + + verifyProperty(rest, "y", { + enumerable: true, + writable: true, + configurable: true, + value: 2 + }); + callCount = callCount + 1; + } + + static get method() { + return this.#method; + } +}; + +C.method({x: 1, y: 2, a: 5, b: 3}); +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/dstr/shell.js b/js/src/tests/test262/language/statements/class/dstr/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/elements/abrupt-completition-on-field-initializer.js b/js/src/tests/test262/language/statements/class/elements/abrupt-completition-on-field-initializer.js new file mode 100644 index 0000000000..e2ea7199ab --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/abrupt-completition-on-field-initializer.js @@ -0,0 +1,55 @@ +// Copyright (C) 2019 Caio Lima (Igalia SL). All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: If an initializer returns an abrupt completion, other initializers should not execute +esid: sec-ecmascript-function-objects-construct-argumentslist-newtarget +info: | + [[Construct]] ( argumentsList, newTarget) + ... + 8. If kind is "base", then + a. Perform OrdinaryCallBindThis(F, calleeContext, thisArgument). + b. Let result be InitializeInstanceFields(thisArgument, F). + c. If result is an abrupt completion, then + i. Remove calleeContext from execution context stack and restore callerContext as the running execution context. + ii. Return Completion(result). + ... + + ClassTail : ClassHeritage { ClassBody } + ... + 34. For each item fieldRecord in order from staticFields, + a. Perform ? DefineField(F, field). + ... + +features: [class-fields-public, class-static-fields-public, class] +---*/ + +function abruptCompletion() { + throw new Test262Error(); +} + +let neverExecuted = false; + +function sideEffect() { + neverExecuted = true; +} + +class C { + a = abruptCompletion(); + b = sideEffect(); +} + +assert.throws(Test262Error, function() { + let c = new C(); +}, 'field initializer should end with abrupt completion'); +assert.sameValue(neverExecuted, false); + +assert.throws(Test262Error, function() { + class D { + static a = abruptCompletion(); + static b = sideEffect(); + } +}, 'static field initializer should end with abrupt completion'); +assert.sameValue(neverExecuted, false); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-gen-computed-names.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-gen-computed-names.js new file mode 100644 index 0000000000..c058f478e6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-gen-computed-names.js @@ -0,0 +1,107 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/computed-names.case +// - src/class-elements/productions/cls-decl-after-same-line-gen.template +/*--- +description: Computed property names (field definitions after a generator in the same line) +esid: prod-FieldDefinition +features: [class-fields-public, computed-property-names, generators, class] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PropertyName + +---*/ +var x = "b"; + + + +class C { + *m() { return 42; } [x] = 42; [10] = "meep"; ["not initialized"]; + +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "b"), + "b doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "b"), + "b doesn't appear as an own property on C constructor" +); + +verifyProperty(c, "b", { + value: 42, + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "x"), + "x doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "x"), + "x doesn't appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "x"), + "x doesn't appear as an own property on C instance" +); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "10"), + "10 doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "10"), + "10 doesn't appear as an own property on C constructor" +); + +verifyProperty(c, "10", { + value: "meep", + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "not initialized"), + "'not initialized' doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "not initialized"), + "'not initialized' doesn't appear as an own property on C constructor" +); + +verifyProperty(c, "not initialized", { + value: undefined, + enumerable: true, + writable: true, + configurable: true +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-gen-computed-symbol-names.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-gen-computed-symbol-names.js new file mode 100644 index 0000000000..173e0ce9df --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-gen-computed-symbol-names.js @@ -0,0 +1,105 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/computed-symbol-names.case +// - src/class-elements/productions/cls-decl-after-same-line-gen.template +/*--- +description: Computed property symbol names (field definitions after a generator in the same line) +esid: prod-FieldDefinition +features: [class-fields-public, Symbol, computed-property-names, generators, class] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PropertyName + +---*/ +var x = Symbol(); +var y = Symbol(); + + + +class C { + *m() { return 42; } [x]; [y] = 42; + +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, x), + "Symbol x doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, x), + "Symbol x doesn't appear as an own property on C constructor" +); + +verifyProperty(c, x, { + value: undefined, + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, y), + "Symbol y doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, y), + "Symbol y doesn't appear as an own property on C constructor" +); + +verifyProperty(c, y, { + value: 42, + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "x"), + "x doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "x"), + "x doesn't appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "x"), + "x doesn't appear as an own property on C instance" +); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "y"), + "y doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "y"), + "y doesn't appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "y"), + "y doesn't appear as an own property on C instance" +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-gen-grammar-privatename-identifier-semantics-stringvalue.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-gen-grammar-privatename-identifier-semantics-stringvalue.js new file mode 100644 index 0000000000..52c1458c45 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-gen-grammar-privatename-identifier-semantics-stringvalue.js @@ -0,0 +1,109 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-privatename-identifier-semantics-stringvalue.case +// - src/class-elements/productions/cls-decl-after-same-line-gen.template +/*--- +description: PrivateName Static Semantics, StringValue (field definitions after a generator in the same line) +esid: prod-FieldDefinition +features: [class-fields-private, generators, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + + + 1. Return the String value consisting of the sequence of code + units corresponding to PrivateName. In determining the sequence + any occurrences of \ UnicodeEscapeSequence are first replaced + with the code point represented by the UnicodeEscapeSequence + and then the code points of the entire PrivateName are converted + to code units by UTF16Encoding (10.1.1) each code point. + +---*/ + + +class C { + *m() { return 42; } #\u{6F}; + #\u2118; + #ZW_\u200C_NJ; + #ZW_\u200D_J;; + o(value) { + this.#o = value; + return this.#o; + } + ℘(value) { + this.#℘ = value; + return this.#℘; + } + ZW_‌_NJ(value) { // DO NOT CHANGE THE NAME OF THIS METHOD + this.#ZW_‌_NJ = value; + return this.#ZW_‌_NJ; + } + ZW_‍_J(value) { // DO NOT CHANGE THE NAME OF THIS METHOD + this.#ZW_‍_J = value; + return this.#ZW_‍_J; + } +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.o(1), 1); +assert.sameValue(c.℘(1), 1); +assert.sameValue(c.ZW_‌_NJ(1), 1); +assert.sameValue(c.ZW_‍_J(1), 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-gen-literal-names-asi.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-gen-literal-names-asi.js new file mode 100644 index 0000000000..a1b21dfe49 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-gen-literal-names-asi.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/literal-names-asi.case +// - src/class-elements/productions/cls-decl-after-same-line-gen.template +/*--- +description: Literal property names with ASI (field definitions after a generator in the same line) +esid: prod-FieldDefinition +features: [class-fields-public, generators, class] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PropertyName + +---*/ + + +class C { + *m() { return 42; } a + b = 42;; + +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "a"), + "a doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "a"), + "a doesn't appear as an own property on C constructor" +); + +verifyProperty(c, "a", { + value: undefined, + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "b"), + "b doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "b"), + "b doesn't appear as an own property on C constructor" +); + +verifyProperty(c, "b", { + value: 42, + enumerable: true, + writable: true, + configurable: true +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-gen-literal-names.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-gen-literal-names.js new file mode 100644 index 0000000000..41e2472d2f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-gen-literal-names.js @@ -0,0 +1,96 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/literal-names.case +// - src/class-elements/productions/cls-decl-after-same-line-gen.template +/*--- +description: Literal property names (field definitions after a generator in the same line) +esid: prod-FieldDefinition +features: [class-fields-public, generators, class] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PropertyName + +---*/ +const fn = function() {} + + + +class C { + *m() { return 42; } a; b = 42; + c = fn; + +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "a"), + "a doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "a"), + "a doesn't appear as an own property on C constructor" +); + +verifyProperty(c, "a", { + value: undefined, + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "b"), + "b doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "b"), + "b doesn't appear as an own property on C constructor" +); + +verifyProperty(c, "b", { + value: 42, + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "c"), + "c doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "c"), + "c doesn't appear as an own property on C constructor" +); + +verifyProperty(c, "c", { + value: fn, + enumerable: true, + writable: true, + configurable: true +}); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-gen-private-field-usage.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-gen-private-field-usage.js new file mode 100644 index 0000000000..fc35a281db --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-gen-private-field-usage.js @@ -0,0 +1,49 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/private-field-usage.case +// - src/class-elements/productions/cls-decl-after-same-line-gen.template +/*--- +description: PrivateName CallExpression usage (private field) (field definitions after a generator in the same line) +esid: prod-FieldDefinition +features: [class-fields-private, generators, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + Updated Productions + + CallExpression[Yield, Await]: + CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await] + SuperCall[?Yield, ?Await] + CallExpression[?Yield, ?Await]Arguments[?Yield, ?Await] + CallExpression[?Yield, ?Await][Expression[+In, ?Yield, ?Await]] + CallExpression[?Yield, ?Await].IdentifierName + CallExpression[?Yield, ?Await]TemplateLiteral[?Yield, ?Await] + CallExpression[?Yield, ?Await].PrivateName + +---*/ + + +class C { + *m() { return 42; } #m = 'test262';; + method() { + return this.#m; + } +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.method(), 'test262'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-gen-private-method-getter-usage.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-gen-private-method-getter-usage.js new file mode 100644 index 0000000000..fcc9a1ae25 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-gen-private-method-getter-usage.js @@ -0,0 +1,49 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/private-method-getter-usage.case +// - src/class-elements/productions/cls-decl-after-same-line-gen.template +/*--- +description: PrivateName CallExpression usage (Accesor get method) (field definitions after a generator in the same line) +esid: prod-FieldDefinition +features: [class-methods-private, generators, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + Updated Productions + + CallExpression[Yield, Await]: + CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await] + SuperCall[?Yield, ?Await] + CallExpression[?Yield, ?Await]Arguments[?Yield, ?Await] + CallExpression[?Yield, ?Await][Expression[+In, ?Yield, ?Await]] + CallExpression[?Yield, ?Await].IdentifierName + CallExpression[?Yield, ?Await]TemplateLiteral[?Yield, ?Await] + CallExpression[?Yield, ?Await].PrivateName + +---*/ + + +class C { + *m() { return 42; } get #m() { return 'test262'; }; + method() { + return this.#m; + } +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.method(), 'test262'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-gen-private-method-usage.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-gen-private-method-usage.js new file mode 100644 index 0000000000..bc73bd1d89 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-gen-private-method-usage.js @@ -0,0 +1,49 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/private-method-usage.case +// - src/class-elements/productions/cls-decl-after-same-line-gen.template +/*--- +description: PrivateName CallExpression usage (private method) (field definitions after a generator in the same line) +esid: prod-FieldDefinition +features: [class-methods-private, generators, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + Updated Productions + + CallExpression[Yield, Await]: + CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await] + SuperCall[?Yield, ?Await] + CallExpression[?Yield, ?Await]Arguments[?Yield, ?Await] + CallExpression[?Yield, ?Await][Expression[+In, ?Yield, ?Await]] + CallExpression[?Yield, ?Await].IdentifierName + CallExpression[?Yield, ?Await]TemplateLiteral[?Yield, ?Await] + CallExpression[?Yield, ?Await].PrivateName + +---*/ + + +class C { + *m() { return 42; } #m() { return 'test262'; }; + method() { + return this.#m(); + } +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.method(), 'test262'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-gen-private-names.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-gen-private-names.js new file mode 100644 index 0000000000..7dd4170fea --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-gen-private-names.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/private-names.case +// - src/class-elements/productions/cls-decl-after-same-line-gen.template +/*--- +description: private names (field definitions after a generator in the same line) +esid: prod-FieldDefinition +features: [class-fields-private, generators, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + ... + FieldDefinition ; + + FieldDefinition : + ClassElementName Initializer_opt + + ClassElementName : + PrivateName + + PrivateName : + # IdentifierName + +---*/ + + +class C { + *m() { return 42; } #x; #y; + x() { + this.#x = 42; + return this.#x; + } + y() { + this.#y = 43; + return this.#y; + } +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +// Test the private fields do not appear as properties before set to value +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#x"), "test 1"); +assert(!Object.prototype.hasOwnProperty.call(C, "#x"), "test 2"); +assert(!Object.prototype.hasOwnProperty.call(c, "#x"), "test 3"); + +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#y"), "test 4"); +assert(!Object.prototype.hasOwnProperty.call(C, "#y"), "test 5"); +assert(!Object.prototype.hasOwnProperty.call(c, "#y"), "test 6"); + +// Test if private fields can be sucessfully accessed and set to value +assert.sameValue(c.x(), 42, "test 7"); +assert.sameValue(c.y(), 43, "test 8"); + +// Test the private fields do not appear as properties before after set to value +assert(!Object.prototype.hasOwnProperty.call(c, "#x"), "test 9"); +assert(!Object.prototype.hasOwnProperty.call(c, "#y"), "test 10"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-gen-rs-field-identifier-initializer.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-gen-rs-field-identifier-initializer.js new file mode 100644 index 0000000000..172ea6f780 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-gen-rs-field-identifier-initializer.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-field-identifier-initializer.case +// - src/class-elements/productions/cls-decl-after-same-line-gen.template +/*--- +description: Valid FieldDefinition (field definitions after a generator in the same line) +esid: prod-FieldDefinition +features: [class-fields-public, generators, class] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + ... + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + + PropertyName : + LiteralPropertyName + ComputedPropertyName + + LiteralPropertyName : + IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + *m() { return 42; } $ = 1; _ = 1; \u{6F} = 1; \u2118 = 1; ZW_\u200C_NJ = 1; ZW_\u200D_J = 1; + +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.$, 1); +assert.sameValue(c._, 1); +assert.sameValue(c.\u{6F}, 1); +assert.sameValue(c.\u2118, 1); +assert.sameValue(c.ZW_\u200C_NJ, 1); +assert.sameValue(c.ZW_\u200D_J, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-gen-rs-field-identifier.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-gen-rs-field-identifier.js new file mode 100644 index 0000000000..cb7c71f67a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-gen-rs-field-identifier.js @@ -0,0 +1,94 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-field-identifier.case +// - src/class-elements/productions/cls-decl-after-same-line-gen.template +/*--- +description: Valid FieldDefinition (field definitions after a generator in the same line) +esid: prod-FieldDefinition +features: [class-fields-public, generators, class] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + ... + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + + PropertyName : + LiteralPropertyName + ComputedPropertyName + + LiteralPropertyName : + IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + *m() { return 42; } $; _; \u{6F}; \u2118; ZW_\u200C_NJ; ZW_\u200D_J; + +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +c.$ = 1; +c._ = 1; +c.\u{6F} = 1; +c.\u2118 = 1; +c.ZW_\u200C_NJ = 1; +c.ZW_\u200D_J = 1; + +assert.sameValue(c.$, 1); +assert.sameValue(c._, 1); +assert.sameValue(c.\u{6F}, 1); +assert.sameValue(c.\u2118, 1); +assert.sameValue(c.ZW_\u200C_NJ, 1); +assert.sameValue(c.ZW_\u200D_J, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-gen-rs-private-getter-alt.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-gen-rs-private-getter-alt.js new file mode 100644 index 0000000000..696990eecd --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-gen-rs-private-getter-alt.js @@ -0,0 +1,128 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-private-getter-alt.case +// - src/class-elements/productions/cls-decl-after-same-line-gen.template +/*--- +description: Valid PrivateName as private getter (field definitions after a generator in the same line) +esid: prod-FieldDefinition +features: [class-methods-private, class-fields-private, generators, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + ... + ; + + MethodDefinition : + ... + get ClassElementName ( ){ FunctionBody } + ... + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + *m() { return 42; } #$_; #__; #\u{6F}_; #℘_; #ZW_‌_NJ_; #ZW_‍_J_; + get #$() { + return this.#$_; + } + get #_() { + return this.#__; + } + get #\u{6F}() { + return this.#\u{6F}_; + } + get #℘() { + return this.#℘_; + } + get #ZW_‌_NJ() { + return this.#ZW_‌_NJ_; + } + get #ZW_‍_J() { + return this.#ZW_‍_J_; + } +; + $(value) { + this.#$_ = value; + return this.#$; + } + _(value) { + this.#__ = value; + return this.#_; + } + \u{6F}(value) { + this.#\u{6F}_ = value; + return this.#\u{6F}; + } + ℘(value) { + this.#℘_ = value; + return this.#℘; + } + ZW_‌_NJ(value) { + this.#ZW_‌_NJ_ = value; + return this.#ZW_‌_NJ; + } + ZW_‍_J(value) { + this.#ZW_‍_J_ = value; + return this.#ZW_‍_J; + } + +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.$(1), 1); +assert.sameValue(c._(1), 1); +assert.sameValue(c.\u{6F}(1), 1); +assert.sameValue(c.℘(1), 1); +assert.sameValue(c.ZW_‌_NJ(1), 1); +assert.sameValue(c.ZW_‍_J(1), 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-gen-rs-private-getter.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-gen-rs-private-getter.js new file mode 100644 index 0000000000..93a9435e91 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-gen-rs-private-getter.js @@ -0,0 +1,128 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-private-getter.case +// - src/class-elements/productions/cls-decl-after-same-line-gen.template +/*--- +description: Valid PrivateName as private getter (field definitions after a generator in the same line) +esid: prod-FieldDefinition +features: [class-methods-private, class-fields-private, generators, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + ... + ; + + MethodDefinition : + ... + get ClassElementName ( ){ FunctionBody } + ... + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + *m() { return 42; } #$_; #__; #\u{6F}_; #\u2118_; #ZW_\u200C_NJ_; #ZW_\u200D_J_; + get #$() { + return this.#$_; + } + get #_() { + return this.#__; + } + get #\u{6F}() { + return this.#\u{6F}_; + } + get #\u2118() { + return this.#\u2118_; + } + get #ZW_\u200C_NJ() { + return this.#ZW_\u200C_NJ_; + } + get #ZW_\u200D_J() { + return this.#ZW_\u200D_J_; + } +; + $(value) { + this.#$_ = value; + return this.#$; + } + _(value) { + this.#__ = value; + return this.#_; + } + \u{6F}(value) { + this.#\u{6F}_ = value; + return this.#\u{6F}; + } + \u2118(value) { + this.#\u2118_ = value; + return this.#\u2118; + } + ZW_\u200C_NJ(value) { + this.#ZW_\u200C_NJ_ = value; + return this.#ZW_\u200C_NJ; + } + ZW_\u200D_J(value) { + this.#ZW_\u200D_J_ = value; + return this.#ZW_\u200D_J; + } + +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.$(1), 1); +assert.sameValue(c._(1), 1); +assert.sameValue(c.\u{6F}(1), 1); +assert.sameValue(c.\u2118(1), 1); +assert.sameValue(c.ZW_\u200C_NJ(1), 1); +assert.sameValue(c.ZW_\u200D_J(1), 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-gen-rs-private-method-alt.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-gen-rs-private-method-alt.js new file mode 100644 index 0000000000..6992d38b0f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-gen-rs-private-method-alt.js @@ -0,0 +1,127 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-private-method-alt.case +// - src/class-elements/productions/cls-decl-after-same-line-gen.template +/*--- +description: Valid PrivateName as private method (field definitions after a generator in the same line) +esid: prod-FieldDefinition +features: [class-methods-private, class-fields-private, generators, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + ... + ; + + MethodDefinition : + ClassElementName ( UniqueFormalParameters ) { FunctionBody } + ... + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + *m() { return 42; } #$_; #__; #\u{6F}_; #℘_; #ZW_‌_NJ_; #ZW_‍_J_; + #$() { + return this.#$_; + } + #_() { + return this.#__; + } + #\u{6F}() { + return this.#\u{6F}_; + } + #℘() { + return this.#℘_; + } + #ZW_‌_NJ() { + return this.#ZW_‌_NJ_; + } + #ZW_‍_J() { + return this.#ZW_‍_J_; + } +; + $(value) { + this.#$_ = value; + return this.#$(); + } + _(value) { + this.#__ = value; + return this.#_(); + } + \u{6F}(value) { + this.#\u{6F}_ = value; + return this.#\u{6F}(); + } + ℘(value) { + this.#℘_ = value; + return this.#℘(); + } + ZW_‌_NJ(value) { + this.#ZW_‌_NJ_ = value; + return this.#ZW_‌_NJ(); + } + ZW_‍_J(value) { + this.#ZW_‍_J_ = value; + return this.#ZW_‍_J(); + } + +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.$(1), 1); +assert.sameValue(c._(1), 1); +assert.sameValue(c.\u{6F}(1), 1); +assert.sameValue(c.℘(1), 1); +assert.sameValue(c.ZW_‌_NJ(1), 1); +assert.sameValue(c.ZW_‍_J(1), 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-gen-rs-private-method.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-gen-rs-private-method.js new file mode 100644 index 0000000000..8029c97052 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-gen-rs-private-method.js @@ -0,0 +1,127 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-private-method.case +// - src/class-elements/productions/cls-decl-after-same-line-gen.template +/*--- +description: Valid PrivateName as private method (field definitions after a generator in the same line) +esid: prod-FieldDefinition +features: [class-methods-private, class-fields-private, generators, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + ... + ; + + MethodDefinition : + ClassElementName ( UniqueFormalParameters ) { FunctionBody } + ... + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + *m() { return 42; } #$_; #__; #\u{6F}_; #\u2118_; #ZW_\u200C_NJ_; #ZW_\u200D_J_; + #$() { + return this.#$_; + } + #_() { + return this.#__; + } + #\u{6F}() { + return this.#\u{6F}_; + } + #\u2118() { + return this.#\u2118_; + } + #ZW_\u200C_NJ() { + return this.#ZW_\u200C_NJ_; + } + #ZW_\u200D_J() { + return this.#ZW_\u200D_J_; + } +; + $(value) { + this.#$_ = value; + return this.#$(); + } + _(value) { + this.#__ = value; + return this.#_(); + } + \u{6F}(value) { + this.#\u{6F}_ = value; + return this.#\u{6F}(); + } + \u2118(value) { + this.#\u2118_ = value; + return this.#\u2118(); + } + ZW_\u200C_NJ(value) { + this.#ZW_\u200C_NJ_ = value; + return this.#ZW_\u200C_NJ(); + } + ZW_\u200D_J(value) { + this.#ZW_\u200D_J_ = value; + return this.#ZW_\u200D_J(); + } + +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.$(1), 1); +assert.sameValue(c._(1), 1); +assert.sameValue(c.\u{6F}(1), 1); +assert.sameValue(c.\u2118(1), 1); +assert.sameValue(c.ZW_\u200C_NJ(1), 1); +assert.sameValue(c.ZW_\u200D_J(1), 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-gen-rs-private-setter-alt.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-gen-rs-private-setter-alt.js new file mode 100644 index 0000000000..dbcdb8e611 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-gen-rs-private-setter-alt.js @@ -0,0 +1,127 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-private-setter-alt.case +// - src/class-elements/productions/cls-decl-after-same-line-gen.template +/*--- +description: Valid PrivateName as private setter (field definitions after a generator in the same line) +esid: prod-FieldDefinition +features: [class-methods-private, class-fields-private, generators, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + ... + ; + + MethodDefinition : + ... + set ClassElementName ( PropertySetParameterList ) { FunctionBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + *m() { return 42; } #$_; #__; #\u{6F}_; #℘_; #ZW_‌_NJ_; #ZW_‍_J_; + set #$(value) { + this.#$_ = value; + } + set #_(value) { + this.#__ = value; + } + set #\u{6F}(value) { + this.#\u{6F}_ = value; + } + set #℘(value) { + this.#℘_ = value; + } + set #ZW_‌_NJ(value) { + this.#ZW_‌_NJ_ = value; + } + set #ZW_‍_J(value) { + this.#ZW_‍_J_ = value; + } +; + $(value) { + this.#$ = value; + return this.#$_; + } + _(value) { + this.#_ = value; + return this.#__; + } + \u{6F}(value) { + this.#\u{6F} = value; + return this.#\u{6F}_; + } + ℘(value) { + this.#℘ = value; + return this.#℘_; + } + ZW_‌_NJ(value) { + this.#ZW_‌_NJ = value; + return this.#ZW_‌_NJ_; + } + ZW_‍_J(value) { + this.#ZW_‍_J = value; + return this.#ZW_‍_J_; + } + +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.$(1), 1); +assert.sameValue(c._(1), 1); +assert.sameValue(c.\u{6F}(1), 1); +assert.sameValue(c.℘(1), 1); +assert.sameValue(c.ZW_‌_NJ(1), 1); +assert.sameValue(c.ZW_‍_J(1), 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-gen-rs-private-setter.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-gen-rs-private-setter.js new file mode 100644 index 0000000000..978c424473 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-gen-rs-private-setter.js @@ -0,0 +1,127 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-private-setter.case +// - src/class-elements/productions/cls-decl-after-same-line-gen.template +/*--- +description: Valid PrivateName as private setter (field definitions after a generator in the same line) +esid: prod-FieldDefinition +features: [class-methods-private, class-fields-private, generators, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + ... + ; + + MethodDefinition : + ... + set ClassElementName ( PropertySetParameterList ) { FunctionBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + *m() { return 42; } #$_; #__; #\u{6F}_; #\u2118_; #ZW_\u200C_NJ_; #ZW_\u200D_J_; + set #$(value) { + this.#$_ = value; + } + set #_(value) { + this.#__ = value; + } + set #\u{6F}(value) { + this.#\u{6F}_ = value; + } + set #\u2118(value) { + this.#\u2118_ = value; + } + set #ZW_\u200C_NJ(value) { + this.#ZW_\u200C_NJ_ = value; + } + set #ZW_\u200D_J(value) { + this.#ZW_\u200D_J_ = value; + } +; + $(value) { + this.#$ = value; + return this.#$_; + } + _(value) { + this.#_ = value; + return this.#__; + } + \u{6F}(value) { + this.#\u{6F} = value; + return this.#\u{6F}_; + } + \u2118(value) { + this.#\u2118 = value; + return this.#\u2118_; + } + ZW_\u200C_NJ(value) { + this.#ZW_\u200C_NJ = value; + return this.#ZW_\u200C_NJ_; + } + ZW_\u200D_J(value) { + this.#ZW_\u200D_J = value; + return this.#ZW_\u200D_J_; + } + +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.$(1), 1); +assert.sameValue(c._(1), 1); +assert.sameValue(c.\u{6F}(1), 1); +assert.sameValue(c.\u2118(1), 1); +assert.sameValue(c.ZW_\u200C_NJ(1), 1); +assert.sameValue(c.ZW_\u200D_J(1), 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-gen-rs-privatename-identifier-alt.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-gen-rs-privatename-identifier-alt.js new file mode 100644 index 0000000000..56913af500 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-gen-rs-privatename-identifier-alt.js @@ -0,0 +1,109 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-privatename-identifier-alt.case +// - src/class-elements/productions/cls-decl-after-same-line-gen.template +/*--- +description: Valid PrivateName (field definitions after a generator in the same line) +esid: prod-FieldDefinition +features: [class-fields-private, generators, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + *m() { return 42; } #$; #_; #\u{6F}; #℘; #ZW_‌_NJ; #ZW_‍_J; + $(value) { + this.#$ = value; + return this.#$; + } + _(value) { + this.#_ = value; + return this.#_; + } + \u{6F}(value) { + this.#\u{6F} = value; + return this.#\u{6F}; + } + ℘(value) { + this.#℘ = value; + return this.#℘; + } + ZW_‌_NJ(value) { + this.#ZW_‌_NJ = value; + return this.#ZW_‌_NJ; + } + ZW_‍_J(value) { + this.#ZW_‍_J = value; + return this.#ZW_‍_J; + } +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.$(1), 1); +assert.sameValue(c._(1), 1); +assert.sameValue(c.\u{6F}(1), 1); +assert.sameValue(c.℘(1), 1); +assert.sameValue(c.ZW_‌_NJ(1), 1); +assert.sameValue(c.ZW_‍_J(1), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-gen-rs-privatename-identifier-initializer-alt.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-gen-rs-privatename-identifier-initializer-alt.js new file mode 100644 index 0000000000..531b66c1cd --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-gen-rs-privatename-identifier-initializer-alt.js @@ -0,0 +1,103 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-privatename-identifier-initializer-alt.case +// - src/class-elements/productions/cls-decl-after-same-line-gen.template +/*--- +description: Valid PrivateName (field definitions after a generator in the same line) +esid: prod-FieldDefinition +features: [class-fields-private, generators, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + *m() { return 42; } #$ = 1; #_ = 1; #\u{6F} = 1; #℘ = 1; #ZW_‌_NJ = 1; #ZW_‍_J = 1; + $() { + return this.#$; + } + _() { + return this.#_; + } + \u{6F}() { + return this.#\u{6F}; + } + ℘() { + return this.#℘; + } + ZW_‌_NJ() { + return this.#ZW_‌_NJ; + } + ZW_‍_J() { + return this.#ZW_‍_J; + } +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.$(), 1); +assert.sameValue(c._(), 1); +assert.sameValue(c.\u{6F}(), 1); +assert.sameValue(c.℘(), 1); +assert.sameValue(c.ZW_‌_NJ(), 1); +assert.sameValue(c.ZW_‍_J(), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-gen-rs-privatename-identifier-initializer.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-gen-rs-privatename-identifier-initializer.js new file mode 100644 index 0000000000..e46db7f945 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-gen-rs-privatename-identifier-initializer.js @@ -0,0 +1,103 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-privatename-identifier-initializer.case +// - src/class-elements/productions/cls-decl-after-same-line-gen.template +/*--- +description: Valid PrivateName (field definitions after a generator in the same line) +esid: prod-FieldDefinition +features: [class-fields-private, generators, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + *m() { return 42; } #$ = 1; #_ = 1; #\u{6F} = 1; #\u2118 = 1; #ZW_\u200C_NJ = 1; #ZW_\u200D_J = 1; + $() { + return this.#$; + } + _() { + return this.#_; + } + \u{6F}() { + return this.#\u{6F}; + } + \u2118() { + return this.#\u2118; + } + ZW_\u200C_NJ() { + return this.#ZW_\u200C_NJ; + } + ZW_\u200D_J() { + return this.#ZW_\u200D_J; + } +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.$(), 1); +assert.sameValue(c._(), 1); +assert.sameValue(c.\u{6F}(), 1); +assert.sameValue(c.\u2118(), 1); +assert.sameValue(c.ZW_\u200C_NJ(), 1); +assert.sameValue(c.ZW_\u200D_J(), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-gen-rs-privatename-identifier.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-gen-rs-privatename-identifier.js new file mode 100644 index 0000000000..df7ed6d89c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-gen-rs-privatename-identifier.js @@ -0,0 +1,109 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-privatename-identifier.case +// - src/class-elements/productions/cls-decl-after-same-line-gen.template +/*--- +description: Valid PrivateName (field definitions after a generator in the same line) +esid: prod-FieldDefinition +features: [class-fields-private, generators, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + *m() { return 42; } #$; #_; #\u{6F}; #\u2118; #ZW_\u200C_NJ; #ZW_\u200D_J; + $(value) { + this.#$ = value; + return this.#$; + } + _(value) { + this.#_ = value; + return this.#_; + } + \u{6F}(value) { + this.#\u{6F} = value; + return this.#\u{6F}; + } + \u2118(value) { + this.#\u2118 = value; + return this.#\u2118; + } + ZW_\u200C_NJ(value) { + this.#ZW_\u200C_NJ = value; + return this.#ZW_\u200C_NJ; + } + ZW_\u200D_J(value) { + this.#ZW_\u200D_J = value; + return this.#ZW_\u200D_J; + } +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.$(1), 1); +assert.sameValue(c._(1), 1); +assert.sameValue(c.\u{6F}(1), 1); +assert.sameValue(c.\u2118(1), 1); +assert.sameValue(c.ZW_\u200C_NJ(1), 1); +assert.sameValue(c.ZW_\u200D_J(1), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-gen-rs-static-async-generator-method-privatename-identifier-alt.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-gen-rs-static-async-generator-method-privatename-identifier-alt.js new file mode 100644 index 0000000000..8210868664 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-gen-rs-static-async-generator-method-privatename-identifier-alt.js @@ -0,0 +1,134 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-async-generator-method-privatename-identifier-alt.case +// - src/class-elements/productions/cls-decl-after-same-line-gen.template +/*--- +description: Valid Static AsyncGeneratorMethod PrivateName (field definitions after a generator in the same line) +esid: prod-FieldDefinition +features: [class-static-methods-private, generators, class, class-fields-public] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + AsyncGeneratorMethod + + AsyncGeneratorMethod : + async [no LineTerminator here] * ClassElementName ( UniqueFormalParameters){ AsyncGeneratorBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + *m() { return 42; } static async * #$(value) { + yield * await value; + } + static async * #_(value) { + yield * await value; + } + static async * #o(value) { + yield * await value; + } + static async * #℘(value) { + yield * await value; + } + static async * #ZW_‌_NJ(value) { + yield * await value; + } + static async * #ZW_‍_J(value) { + yield * await value; + }; + static get $() { + return this.#$; + } + static get _() { + return this.#_; + } + static get o() { + return this.#o; + } + static get ℘() { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#℘; + } + static get ZW_‌_NJ() { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#ZW_‌_NJ; + } + static get ZW_‍_J() { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#ZW_‍_J; + } + +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +Promise.all([ + C.$([1]).next(), + C._([1]).next(), + C.o([1]).next(), + C.℘([1]).next(), // DO NOT CHANGE THE NAME OF THIS FIELD + C.ZW_‌_NJ([1]).next(), // DO NOT CHANGE THE NAME OF THIS FIELD + C.ZW_‍_J([1]).next(), // DO NOT CHANGE THE NAME OF THIS FIELD +]).then(results => { + + assert.sameValue(results[0].value, 1); + assert.sameValue(results[1].value, 1); + assert.sameValue(results[2].value, 1); + assert.sameValue(results[3].value, 1); + assert.sameValue(results[4].value, 1); + assert.sameValue(results[5].value, 1); + +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-gen-rs-static-async-generator-method-privatename-identifier.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-gen-rs-static-async-generator-method-privatename-identifier.js new file mode 100644 index 0000000000..a25cdabbb8 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-gen-rs-static-async-generator-method-privatename-identifier.js @@ -0,0 +1,135 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-async-generator-method-privatename-identifier.case +// - src/class-elements/productions/cls-decl-after-same-line-gen.template +/*--- +description: Valid Static AsyncGeneratorMethod PrivateName (field definitions after a generator in the same line) +esid: prod-FieldDefinition +features: [class-static-methods-private, generators, class, class-fields-public] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + AsyncGeneratorMethod + + AsyncGeneratorMethod : + async [no LineTerminator here] * ClassElementName ( UniqueFormalParameters){ AsyncGeneratorBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + *m() { return 42; } static async * #$(value) { + yield * await value; + } + static async * #_(value) { + yield * await value; + } + static async * #\u{6F}(value) { + yield * await value; + } + static async * #\u2118(value) { + yield * await value; + } + static async * #ZW_\u200C_NJ(value) { + yield * await value; + } + static async * #ZW_\u200D_J(value) { + yield * await value; + }; + static get $() { + return this.#$; + } + static get _() { + return this.#_; + } + static get \u{6F}() { + return this.#\u{6F}; + } + static get \u2118() { + return this.#\u2118; + } + static get ZW_\u200C_NJ() { + return this.#ZW_\u200C_NJ; + } + static get ZW_\u200D_J() { + return this.#ZW_\u200D_J; + } + +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +Promise.all([ + C.$([1]).next(), + C._([1]).next(), + C.\u{6F}([1]).next(), + C.\u2118([1]).next(), + C.ZW_\u200C_NJ([1]).next(), + C.ZW_\u200D_J([1]).next(), +]).then(results => { + + assert.sameValue(results[0].value, 1); + assert.sameValue(results[1].value, 1); + assert.sameValue(results[2].value, 1); + assert.sameValue(results[3].value, 1); + assert.sameValue(results[4].value, 1); + assert.sameValue(results[5].value, 1); + +}).then($DONE, $DONE); + diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-gen-rs-static-async-method-privatename-identifier-alt.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-gen-rs-static-async-method-privatename-identifier-alt.js new file mode 100644 index 0000000000..ee67688f06 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-gen-rs-static-async-method-privatename-identifier-alt.js @@ -0,0 +1,134 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-async-method-privatename-identifier-alt.case +// - src/class-elements/productions/cls-decl-after-same-line-gen.template +/*--- +description: Valid Static AsyncMethod PrivateName (field definitions after a generator in the same line) +esid: prod-FieldDefinition +features: [class-static-methods-private, generators, class, class-fields-public] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + AsyncMethod + + AsyncMethod : + async [no LineTerminator here] ClassElementName ( UniqueFormalParameters ){ AsyncFunctionBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + *m() { return 42; } static async #$(value) { + return await value; + } + static async #_(value) { + return await value; + } + static async #o(value) { + return await value; + } + static async #℘(value) { + return await value; + } + static async #ZW_‌_NJ(value) { + return await value; + } + static async #ZW_‍_J(value) { + return await value; + }; + static async $(value) { + return await this.#$(value); + } + static async _(value) { + return await this.#_(value); + } + static async o(value) { + return await this.#o(value); + } + static async ℘(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + return await this.#℘(value); + } + static async ZW_‌_NJ(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + return await this.#ZW_‌_NJ(value); + } + static async ZW_‍_J(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + return await this.#ZW_‍_J(value); + } + +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +Promise.all([ + C.$(1), + C._(1), + C.o(1), + C.℘(1), // DO NOT CHANGE THE NAME OF THIS FIELD + C.ZW_‌_NJ(1), // DO NOT CHANGE THE NAME OF THIS FIELD + C.ZW_‍_J(1), // DO NOT CHANGE THE NAME OF THIS FIELD +]).then(results => { + + assert.sameValue(results[0], 1); + assert.sameValue(results[1], 1); + assert.sameValue(results[2], 1); + assert.sameValue(results[3], 1); + assert.sameValue(results[4], 1); + assert.sameValue(results[5], 1); + +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-gen-rs-static-async-method-privatename-identifier.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-gen-rs-static-async-method-privatename-identifier.js new file mode 100644 index 0000000000..ab0f8b9975 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-gen-rs-static-async-method-privatename-identifier.js @@ -0,0 +1,135 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-async-method-privatename-identifier.case +// - src/class-elements/productions/cls-decl-after-same-line-gen.template +/*--- +description: Valid Static AsyncMethod PrivateName (field definitions after a generator in the same line) +esid: prod-FieldDefinition +features: [class-static-methods-private, generators, class, class-fields-public] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + AsyncMethod + + AsyncMethod : + async [no LineTerminator here] ClassElementName ( UniqueFormalParameters ){ AsyncFunctionBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + *m() { return 42; } static async #$(value) { + return await value; + } + static async #_(value) { + return await value; + } + static async #\u{6F}(value) { + return await value; + } + static async #\u2118(value) { + return await value; + } + static async #ZW_\u200C_NJ(value) { + return await value; + } + static async #ZW_\u200D_J(value) { + return await value; + }; + static async $(value) { + return await this.#$(value); + } + static async _(value) { + return await this.#_(value); + } + static async \u{6F}(value) { + return await this.#\u{6F}(value); + } + static async \u2118(value) { + return await this.#\u2118(value); + } + static async ZW_\u200C_NJ(value) { + return await this.#ZW_\u200C_NJ(value); + } + static async ZW_\u200D_J(value) { + return await this.#ZW_\u200D_J(value); + } + +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +Promise.all([ + C.$(1), + C._(1), + C.\u{6F}(1), + C.\u2118(1), + C.ZW_\u200C_NJ(1), + C.ZW_\u200D_J(1), +]).then(results => { + + assert.sameValue(results[0], 1); + assert.sameValue(results[1], 1); + assert.sameValue(results[2], 1); + assert.sameValue(results[3], 1); + assert.sameValue(results[4], 1); + assert.sameValue(results[5], 1); + +}).then($DONE, $DONE); + diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-gen-rs-static-generator-method-privatename-identifier-alt.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-gen-rs-static-generator-method-privatename-identifier-alt.js new file mode 100644 index 0000000000..582f3c5241 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-gen-rs-static-generator-method-privatename-identifier-alt.js @@ -0,0 +1,124 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-generator-method-privatename-identifier-alt.case +// - src/class-elements/productions/cls-decl-after-same-line-gen.template +/*--- +description: Valid Static GeneratorMethod PrivateName (field definitions after a generator in the same line) +esid: prod-FieldDefinition +features: [class-static-methods-private, generators, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + GeneratorMethod + + GeneratorMethod : + * ClassElementName ( UniqueFormalParameters ){ GeneratorBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + *m() { return 42; } static * #$(value) { + yield * value; + } + static * #_(value) { + yield * value; + } + static * #o(value) { + yield * value; + } + static * #℘(value) { + yield * value; + } + static * #ZW_‌_NJ(value) { + yield * value; + } + static * #ZW_‍_J(value) { + yield * value; + }; + static get $() { + return this.#$; + } + static get _() { + return this.#_; + } + static get o() { + return this.#o; + } + static get ℘() { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#℘; + } + static get ZW_‌_NJ() { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#ZW_‌_NJ; + } + static get ZW_‍_J() { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#ZW_‍_J; + } + +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(C.$([1]).next().value, 1); +assert.sameValue(C._([1]).next().value, 1); +assert.sameValue(C.o([1]).next().value, 1); +assert.sameValue(C.℘([1]).next().value, 1); +assert.sameValue(C.ZW_‌_NJ([1]).next().value, 1); +assert.sameValue(C.ZW_‍_J([1]).next().value, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-gen-rs-static-generator-method-privatename-identifier.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-gen-rs-static-generator-method-privatename-identifier.js new file mode 100644 index 0000000000..c9cdec139c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-gen-rs-static-generator-method-privatename-identifier.js @@ -0,0 +1,125 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-generator-method-privatename-identifier.case +// - src/class-elements/productions/cls-decl-after-same-line-gen.template +/*--- +description: Valid Static GeneratorMethod PrivateName (field definitions after a generator in the same line) +esid: prod-FieldDefinition +features: [class-static-methods-private, generators, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + GeneratorMethod + + GeneratorMethod : + * ClassElementName ( UniqueFormalParameters ){ GeneratorBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + *m() { return 42; } static * #$(value) { + yield * value; + } + static * #_(value) { + yield * value; + } + static * #\u{6F}(value) { + yield * value; + } + static * #\u2118(value) { + yield * value; + } + static * #ZW_\u200C_NJ(value) { + yield * value; + } + static * #ZW_\u200D_J(value) { + yield * value; + }; + static get $() { + return this.#$; + } + static get _() { + return this.#_; + } + static get \u{6F}() { + return this.#\u{6F}; + } + static get \u2118() { + return this.#\u2118; + } + static get ZW_\u200C_NJ() { + return this.#ZW_\u200C_NJ; + } + static get ZW_\u200D_J() { + return this.#ZW_\u200D_J; + } + +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(C.$([1]).next().value, 1); +assert.sameValue(C._([1]).next().value, 1); +assert.sameValue(C.\u{6F}([1]).next().value, 1); +assert.sameValue(C.\u2118([1]).next().value, 1); +assert.sameValue(C.ZW_\u200C_NJ([1]).next().value, 1); +assert.sameValue(C.ZW_\u200D_J([1]).next().value, 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-gen-rs-static-method-privatename-identifier-alt.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-gen-rs-static-method-privatename-identifier-alt.js new file mode 100644 index 0000000000..a8dde27dbf --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-gen-rs-static-method-privatename-identifier-alt.js @@ -0,0 +1,122 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-method-privatename-identifier-alt.case +// - src/class-elements/productions/cls-decl-after-same-line-gen.template +/*--- +description: Valid Static Method PrivateName (field definitions after a generator in the same line) +esid: prod-FieldDefinition +features: [class-static-methods-private, generators, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + ClassElementName ( UniqueFormalParameters ){ FunctionBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + *m() { return 42; } static #$(value) { + return value; + } + static #_(value) { + return value; + } + static #o(value) { + return value; + } + static #℘(value) { + return value; + } + static #ZW_‌_NJ(value) { + return value; + } + static #ZW_‍_J(value) { + return value; + }; + static $(value) { + return this.#$(value); + } + static _(value) { + return this.#_(value); + } + static o(value) { + return this.#o(value); + } + static ℘(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#℘(value); + } + static ZW_‌_NJ(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#ZW_‌_NJ(value); + } + static ZW_‍_J(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#ZW_‍_J(value); + } + +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(C.$(1), 1); +assert.sameValue(C._(1), 1); +assert.sameValue(C.o(1), 1); +assert.sameValue(C.℘(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD +assert.sameValue(C.ZW_‌_NJ(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD +assert.sameValue(C.ZW_‍_J(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-gen-rs-static-method-privatename-identifier.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-gen-rs-static-method-privatename-identifier.js new file mode 100644 index 0000000000..fa198c8a53 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-gen-rs-static-method-privatename-identifier.js @@ -0,0 +1,122 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-method-privatename-identifier.case +// - src/class-elements/productions/cls-decl-after-same-line-gen.template +/*--- +description: Valid Static Method PrivateName (field definitions after a generator in the same line) +esid: prod-FieldDefinition +features: [class-static-methods-private, generators, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + ClassElementName ( UniqueFormalParameters ){ FunctionBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + *m() { return 42; } static #$(value) { + return value; + } + static #_(value) { + return value; + } + static #\u{6F}(value) { + return value; + } + static #\u2118(value) { + return value; + } + static #ZW_\u200C_NJ(value) { + return value; + } + static #ZW_\u200D_J(value) { + return value; + }; + static $(value) { + return this.#$(value); + } + static _(value) { + return this.#_(value); + } + static \u{6F}(value) { + return this.#\u{6F}(value); + } + static \u2118(value) { + return this.#\u2118(value); + } + static ZW_\u200C_NJ(value) { + return this.#ZW_\u200C_NJ(value); + } + static ZW_\u200D_J(value) { + return this.#ZW_\u200D_J(value); + } + +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(C.$(1), 1); +assert.sameValue(C._(1), 1); +assert.sameValue(C.\u{6F}(1), 1); +assert.sameValue(C.\u2118(1), 1); +assert.sameValue(C.ZW_\u200C_NJ(1), 1); +assert.sameValue(C.ZW_\u200D_J(1), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-gen-rs-static-privatename-identifier-alt-by-classname.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-gen-rs-static-privatename-identifier-alt-by-classname.js new file mode 100644 index 0000000000..9e74a42de8 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-gen-rs-static-privatename-identifier-alt-by-classname.js @@ -0,0 +1,110 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-privatename-identifier-alt-by-classname.case +// - src/class-elements/productions/cls-decl-after-same-line-gen.template +/*--- +description: Valid Static PrivateName (field definitions after a generator in the same line) +esid: prod-FieldDefinition +features: [class-static-fields-private, generators, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + *m() { return 42; } static #$; static #_; static #\u{6F}; static #℘; static #ZW_‌_NJ; static #ZW_‍_J; + static $(value) { + C.#$ = value; + return C.#$; + } + static _(value) { + C.#_ = value; + return C.#_; + } + static o(value) { + C.#\u{6F} = value; + return C.#\u{6F}; + } + static ℘(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + C.#℘ = value; + return C.#℘; + } + static ZW_‌_NJ(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + C.#ZW_‌_NJ = value; + return C.#ZW_‌_NJ; + } + static ZW_‍_J(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + C.#ZW_‍_J = value; + return C.#ZW_‍_J; + } +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(C.$(1), 1); +assert.sameValue(C._(1), 1); +assert.sameValue(C.o(1), 1); +assert.sameValue(C.℘(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD +assert.sameValue(C.ZW_‌_NJ(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD +assert.sameValue(C.ZW_‍_J(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-gen-rs-static-privatename-identifier-alt.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-gen-rs-static-privatename-identifier-alt.js new file mode 100644 index 0000000000..cedc2876cd --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-gen-rs-static-privatename-identifier-alt.js @@ -0,0 +1,110 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-privatename-identifier-alt.case +// - src/class-elements/productions/cls-decl-after-same-line-gen.template +/*--- +description: Valid Static PrivateName (field definitions after a generator in the same line) +esid: prod-FieldDefinition +features: [class-static-fields-private, generators, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + *m() { return 42; } static #$; static #_; static #\u{6F}; static #℘; static #ZW_‌_NJ; static #ZW_‍_J; + static $(value) { + this.#$ = value; + return this.#$; + } + static _(value) { + this.#_ = value; + return this.#_; + } + static o(value) { + this.#\u{6F} = value; + return this.#\u{6F}; + } + static ℘(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + this.#℘ = value; + return this.#℘; + } + static ZW_‌_NJ(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + this.#ZW_‌_NJ = value; + return this.#ZW_‌_NJ; + } + static ZW_‍_J(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + this.#ZW_‍_J = value; + return this.#ZW_‍_J; + } +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(C.$(1), 1); +assert.sameValue(C._(1), 1); +assert.sameValue(C.o(1), 1); +assert.sameValue(C.℘(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD +assert.sameValue(C.ZW_‌_NJ(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD +assert.sameValue(C.ZW_‍_J(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-gen-rs-static-privatename-identifier-by-classname.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-gen-rs-static-privatename-identifier-by-classname.js new file mode 100644 index 0000000000..1557b9651e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-gen-rs-static-privatename-identifier-by-classname.js @@ -0,0 +1,110 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-privatename-identifier-by-classname.case +// - src/class-elements/productions/cls-decl-after-same-line-gen.template +/*--- +description: Valid Static PrivateName (field definitions after a generator in the same line) +esid: prod-FieldDefinition +features: [class-static-fields-private, generators, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + *m() { return 42; } static #$; static #_; static #\u{6F}; static #\u2118; static #ZW_\u200C_NJ; static #ZW_\u200D_J; + static $(value) { + C.#$ = value; + return C.#$; + } + static _(value) { + C.#_ = value; + return C.#_; + } + static \u{6F}(value) { + C.#\u{6F} = value; + return C.#\u{6F}; + } + static \u2118(value) { + C.#\u2118 = value; + return C.#\u2118; + } + static ZW_\u200C_NJ(value) { + C.#ZW_\u200C_NJ = value; + return C.#ZW_\u200C_NJ; + } + static ZW_\u200D_J(value) { + C.#ZW_\u200D_J = value; + return C.#ZW_\u200D_J; + } +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(C.$(1), 1); +assert.sameValue(C._(1), 1); +assert.sameValue(C.\u{6F}(1), 1); +assert.sameValue(C.\u2118(1), 1); +assert.sameValue(C.ZW_\u200C_NJ(1), 1); +assert.sameValue(C.ZW_\u200D_J(1), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-gen-rs-static-privatename-identifier-initializer-alt-by-classname.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-gen-rs-static-privatename-identifier-initializer-alt-by-classname.js new file mode 100644 index 0000000000..4fd22ea158 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-gen-rs-static-privatename-identifier-initializer-alt-by-classname.js @@ -0,0 +1,104 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-privatename-identifier-initializer-alt-by-classname.case +// - src/class-elements/productions/cls-decl-after-same-line-gen.template +/*--- +description: Valid Static PrivateName (field definitions after a generator in the same line) +esid: prod-FieldDefinition +features: [class-static-fields-private, generators, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + *m() { return 42; } static #$ = 1; static #_ = 1; static #\u{6F} = 1; static #℘ = 1; static #ZW_‌_NJ = 1; static #ZW_‍_J = 1; + static $() { + return C.#$; + } + static _() { + return C.#_; + } + static \u{6F}() { + return C.#\u{6F}; + } + static ℘() { + return C.#℘; + } + static ZW_‌_NJ() { + return C.#ZW_‌_NJ; + } + static ZW_‍_J() { + return C.#ZW_‍_J; + } +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(C.$(), 1); +assert.sameValue(C._(), 1); +assert.sameValue(C.\u{6F}(), 1); +assert.sameValue(C.℘(), 1); +assert.sameValue(C.ZW_‌_NJ(), 1); +assert.sameValue(C.ZW_‍_J(), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-gen-rs-static-privatename-identifier-initializer-alt.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-gen-rs-static-privatename-identifier-initializer-alt.js new file mode 100644 index 0000000000..4771398de9 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-gen-rs-static-privatename-identifier-initializer-alt.js @@ -0,0 +1,104 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-privatename-identifier-initializer-alt.case +// - src/class-elements/productions/cls-decl-after-same-line-gen.template +/*--- +description: Valid Static PrivateName (field definitions after a generator in the same line) +esid: prod-FieldDefinition +features: [class-static-fields-private, generators, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + *m() { return 42; } static #$ = 1; static #_ = 1; static #\u{6F} = 1; static #℘ = 1; static #ZW_‌_NJ = 1; static #ZW_‍_J = 1; + static $() { + return this.#$; + } + static _() { + return this.#_; + } + static \u{6F}() { + return this.#\u{6F}; + } + static ℘() { + return this.#℘; + } + static ZW_‌_NJ() { + return this.#ZW_‌_NJ; + } + static ZW_‍_J() { + return this.#ZW_‍_J; + } +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(C.$(), 1); +assert.sameValue(C._(), 1); +assert.sameValue(C.\u{6F}(), 1); +assert.sameValue(C.℘(), 1); +assert.sameValue(C.ZW_‌_NJ(), 1); +assert.sameValue(C.ZW_‍_J(), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-gen-rs-static-privatename-identifier-initializer.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-gen-rs-static-privatename-identifier-initializer.js new file mode 100644 index 0000000000..610964b743 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-gen-rs-static-privatename-identifier-initializer.js @@ -0,0 +1,104 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-privatename-identifier-initializer.case +// - src/class-elements/productions/cls-decl-after-same-line-gen.template +/*--- +description: Valid Static PrivateName (field definitions after a generator in the same line) +esid: prod-FieldDefinition +features: [class-static-fields-private, generators, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + *m() { return 42; } static #$ = 1; static #_ = 1; static #\u{6F} = 1; static #\u2118 = 1; static #ZW_\u200C_NJ = 1; static #ZW_\u200D_J = 1; + static $() { + return this.#$; + } + static _() { + return this.#_; + } + static \u{6F}() { + return this.#\u{6F}; + } + static \u2118() { + return this.#\u2118; + } + static ZW_\u200C_NJ() { + return this.#ZW_\u200C_NJ; + } + static ZW_\u200D_J() { + return this.#ZW_\u200D_J; + } +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(C.$(), 1); +assert.sameValue(C._(), 1); +assert.sameValue(C.\u{6F}(), 1); +assert.sameValue(C.\u2118(), 1); +assert.sameValue(C.ZW_\u200C_NJ(), 1); +assert.sameValue(C.ZW_\u200D_J(), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-gen-rs-static-privatename-identifier.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-gen-rs-static-privatename-identifier.js new file mode 100644 index 0000000000..f6421e1262 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-gen-rs-static-privatename-identifier.js @@ -0,0 +1,110 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-privatename-identifier.case +// - src/class-elements/productions/cls-decl-after-same-line-gen.template +/*--- +description: Valid Static PrivateName (field definitions after a generator in the same line) +esid: prod-FieldDefinition +features: [class-static-fields-private, generators, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + *m() { return 42; } static #$; static #_; static #\u{6F}; static #\u2118; static #ZW_\u200C_NJ; static #ZW_\u200D_J; + static $(value) { + this.#$ = value; + return this.#$; + } + static _(value) { + this.#_ = value; + return this.#_; + } + static \u{6F}(value) { + this.#\u{6F} = value; + return this.#\u{6F}; + } + static \u2118(value) { + this.#\u2118 = value; + return this.#\u2118; + } + static ZW_\u200C_NJ(value) { + this.#ZW_\u200C_NJ = value; + return this.#ZW_\u200C_NJ; + } + static ZW_\u200D_J(value) { + this.#ZW_\u200D_J = value; + return this.#ZW_\u200D_J; + } +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(C.$(1), 1); +assert.sameValue(C._(1), 1); +assert.sameValue(C.\u{6F}(1), 1); +assert.sameValue(C.\u2118(1), 1); +assert.sameValue(C.ZW_\u200C_NJ(1), 1); +assert.sameValue(C.ZW_\u200D_J(1), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-gen-static-private-fields.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-gen-static-private-fields.js new file mode 100644 index 0000000000..cde71d4fb1 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-gen-static-private-fields.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/static-private-fields.case +// - src/class-elements/productions/cls-decl-after-same-line-gen.template +/*--- +description: static private fields (field definitions after a generator in the same line) +esid: prod-FieldDefinition +features: [class-static-fields-private, generators, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + ... + static FieldDefinition ; + + FieldDefinition : + ClassElementName Initializer_opt + + ClassElementName : + PrivateName + + PrivateName : + # IdentifierName + +---*/ + + +class C { + *m() { return 42; } static #x; static #y; + static x() { + this.#x = 42; + return this.#x; + } + static y() { + this.#y = 43; + return this.#y; + } +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +// Test the private fields do not appear as properties before set to value +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#x"), "test 1"); +assert(!Object.prototype.hasOwnProperty.call(C, "#x"), "test 2"); +assert(!Object.prototype.hasOwnProperty.call(c, "#x"), "test 3"); + +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#y"), "test 4"); +assert(!Object.prototype.hasOwnProperty.call(C, "#y"), "test 5"); +assert(!Object.prototype.hasOwnProperty.call(c, "#y"), "test 6"); + +// Test if private fields can be sucessfully accessed and set to value +assert.sameValue(C.x(), 42, "test 7"); +assert.sameValue(C.y(), 43, "test 8"); + +// Test the private fields do not appear as properties before after set to value +assert(!Object.prototype.hasOwnProperty.call(C, "#x"), "test 9"); +assert(!Object.prototype.hasOwnProperty.call(C, "#y"), "test 10"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-gen-static-private-methods-with-fields.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-gen-static-private-methods-with-fields.js new file mode 100644 index 0000000000..7d8b009597 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-gen-static-private-methods-with-fields.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/static-private-methods-with-fields.case +// - src/class-elements/productions/cls-decl-after-same-line-gen.template +/*--- +description: static private methods with fields (field definitions after a generator in the same line) +esid: prod-FieldDefinition +features: [class-static-methods-private, class-static-fields-private, generators, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + ... + static FieldDefinition ; + + FieldDefinition : + ClassElementName Initializer_opt + + ClassElementName : + PrivateName + + PrivateName : + # IdentifierName + +---*/ + + +class C { + *m() { return 42; } static #xVal; static #yVal; + static #x(value) { + this.#xVal = value; + return this.#xVal; + } + static #y(value) { + this.#yVal = value; + return this.#yVal; + } + static x() { + return this.#x(42); + } + static y() { + return this.#y(43); + } +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +// Test the private methods do not appear as properties before set to value +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#x"), "test 1"); +assert(!Object.prototype.hasOwnProperty.call(C, "#x"), "test 2"); +assert(!Object.prototype.hasOwnProperty.call(c, "#x"), "test 3"); + +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#y"), "test 4"); +assert(!Object.prototype.hasOwnProperty.call(C, "#y"), "test 5"); +assert(!Object.prototype.hasOwnProperty.call(c, "#y"), "test 6"); + +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#xVal"), "test 7"); +assert(!Object.prototype.hasOwnProperty.call(C, "#xVal"), "test 8"); +assert(!Object.prototype.hasOwnProperty.call(c, "#xVal"), "test 9"); + +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#yVal"), "test 10"); +assert(!Object.prototype.hasOwnProperty.call(C, "#yVal"), "test 11"); +assert(!Object.prototype.hasOwnProperty.call(c, "#yVal"), "test 12"); + +// Test if private fields can be sucessfully accessed and set to value +assert.sameValue(C.x(), 42, "test 13"); +assert.sameValue(C.y(), 43, "test 14"); + +// Test the private fields do not appear as properties before after set to value +assert(!Object.prototype.hasOwnProperty.call(C, "#x"), "test 15"); +assert(!Object.prototype.hasOwnProperty.call(C, "#y"), "test 16"); + +assert(!Object.prototype.hasOwnProperty.call(C, "#xVal"), "test 17"); +assert(!Object.prototype.hasOwnProperty.call(C, "#yVal"), "test 18"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-gen-static-private-methods.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-gen-static-private-methods.js new file mode 100644 index 0000000000..c9c05cceb5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-gen-static-private-methods.js @@ -0,0 +1,75 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/static-private-methods.case +// - src/class-elements/productions/cls-decl-after-same-line-gen.template +/*--- +description: static private methods (field definitions after a generator in the same line) +esid: prod-FieldDefinition +features: [class-static-methods-private, generators, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + ... + static FieldDefinition ; + + FieldDefinition : + ClassElementName Initializer_opt + + ClassElementName : + PrivateName + + PrivateName : + # IdentifierName + +---*/ + + +class C { + *m() { return 42; } ; + static #x(value) { + return value / 2; + } + static #y(value) { + return value * 2; + } + static x() { + return this.#x(84); + } + static y() { + return this.#y(43); + } +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +// Test the private methods do not appear as properties before set to value +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#x"), "test 1"); +assert(!Object.prototype.hasOwnProperty.call(C, "#x"), "test 2"); +assert(!Object.prototype.hasOwnProperty.call(c, "#x"), "test 3"); + +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#y"), "test 4"); +assert(!Object.prototype.hasOwnProperty.call(C, "#y"), "test 5"); +assert(!Object.prototype.hasOwnProperty.call(c, "#y"), "test 6"); + +// Test if private fields can be sucessfully accessed and set to value +assert.sameValue(C.x(), 42, "test 7"); +assert.sameValue(C.y(), 86, "test 8"); + +// Test the private fields do not appear as properties before after set to value +assert(!Object.prototype.hasOwnProperty.call(C, "#x"), "test 9"); +assert(!Object.prototype.hasOwnProperty.call(C, "#y"), "test 10"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-gen-string-literal-names.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-gen-string-literal-names.js new file mode 100644 index 0000000000..e3b392da02 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-gen-string-literal-names.js @@ -0,0 +1,109 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/string-literal-names.case +// - src/class-elements/productions/cls-decl-after-same-line-gen.template +/*--- +description: String literal names (field definitions after a generator in the same line) +esid: prod-FieldDefinition +features: [class-fields-public, generators, class] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PropertyName + +---*/ + + +class C { + *m() { return 42; } 'a'; "b"; 'c' = 39; + "d" = 42; + +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "a"), + "a does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "a"), + "a does not appear as an own property on C constructor" +); + +verifyProperty(c, "a", { + value: undefined, + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "b"), + "b does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "b"), + "b does not appear as an own property on C constructor" +); + +verifyProperty(c, "b", { + value: undefined, + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "c"), + "c does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "c"), + "c does not appear as an own property on C constructor" +); + +verifyProperty(c, "c", { + value: 39, + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "d"), + "d does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "d"), + "d does not appear as an own property on C constructor" +); + +verifyProperty(c, "d", { + value: 42, + enumerable: true, + writable: true, + configurable: true +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-method-computed-names.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-method-computed-names.js new file mode 100644 index 0000000000..823d115970 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-method-computed-names.js @@ -0,0 +1,107 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/computed-names.case +// - src/class-elements/productions/cls-decl-after-same-line-method.template +/*--- +description: Computed property names (field definitions after a method in the same line) +esid: prod-FieldDefinition +features: [class-fields-public, computed-property-names, class] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PropertyName + +---*/ +var x = "b"; + + + +class C { + m() { return 42; } [x] = 42; [10] = "meep"; ["not initialized"]; + +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "b"), + "b doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "b"), + "b doesn't appear as an own property on C constructor" +); + +verifyProperty(c, "b", { + value: 42, + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "x"), + "x doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "x"), + "x doesn't appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "x"), + "x doesn't appear as an own property on C instance" +); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "10"), + "10 doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "10"), + "10 doesn't appear as an own property on C constructor" +); + +verifyProperty(c, "10", { + value: "meep", + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "not initialized"), + "'not initialized' doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "not initialized"), + "'not initialized' doesn't appear as an own property on C constructor" +); + +verifyProperty(c, "not initialized", { + value: undefined, + enumerable: true, + writable: true, + configurable: true +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-method-computed-symbol-names.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-method-computed-symbol-names.js new file mode 100644 index 0000000000..807cdea551 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-method-computed-symbol-names.js @@ -0,0 +1,105 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/computed-symbol-names.case +// - src/class-elements/productions/cls-decl-after-same-line-method.template +/*--- +description: Computed property symbol names (field definitions after a method in the same line) +esid: prod-FieldDefinition +features: [class-fields-public, Symbol, computed-property-names, class] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PropertyName + +---*/ +var x = Symbol(); +var y = Symbol(); + + + +class C { + m() { return 42; } [x]; [y] = 42; + +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, x), + "Symbol x doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, x), + "Symbol x doesn't appear as an own property on C constructor" +); + +verifyProperty(c, x, { + value: undefined, + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, y), + "Symbol y doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, y), + "Symbol y doesn't appear as an own property on C constructor" +); + +verifyProperty(c, y, { + value: 42, + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "x"), + "x doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "x"), + "x doesn't appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "x"), + "x doesn't appear as an own property on C instance" +); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "y"), + "y doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "y"), + "y doesn't appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "y"), + "y doesn't appear as an own property on C instance" +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-method-grammar-privatename-identifier-semantics-stringvalue.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-method-grammar-privatename-identifier-semantics-stringvalue.js new file mode 100644 index 0000000000..0269dc17de --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-method-grammar-privatename-identifier-semantics-stringvalue.js @@ -0,0 +1,109 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-privatename-identifier-semantics-stringvalue.case +// - src/class-elements/productions/cls-decl-after-same-line-method.template +/*--- +description: PrivateName Static Semantics, StringValue (field definitions after a method in the same line) +esid: prod-FieldDefinition +features: [class-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + + + 1. Return the String value consisting of the sequence of code + units corresponding to PrivateName. In determining the sequence + any occurrences of \ UnicodeEscapeSequence are first replaced + with the code point represented by the UnicodeEscapeSequence + and then the code points of the entire PrivateName are converted + to code units by UTF16Encoding (10.1.1) each code point. + +---*/ + + +class C { + m() { return 42; } #\u{6F}; + #\u2118; + #ZW_\u200C_NJ; + #ZW_\u200D_J;; + o(value) { + this.#o = value; + return this.#o; + } + ℘(value) { + this.#℘ = value; + return this.#℘; + } + ZW_‌_NJ(value) { // DO NOT CHANGE THE NAME OF THIS METHOD + this.#ZW_‌_NJ = value; + return this.#ZW_‌_NJ; + } + ZW_‍_J(value) { // DO NOT CHANGE THE NAME OF THIS METHOD + this.#ZW_‍_J = value; + return this.#ZW_‍_J; + } +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.o(1), 1); +assert.sameValue(c.℘(1), 1); +assert.sameValue(c.ZW_‌_NJ(1), 1); +assert.sameValue(c.ZW_‍_J(1), 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-method-literal-names-asi.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-method-literal-names-asi.js new file mode 100644 index 0000000000..20c136ee2d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-method-literal-names-asi.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/literal-names-asi.case +// - src/class-elements/productions/cls-decl-after-same-line-method.template +/*--- +description: Literal property names with ASI (field definitions after a method in the same line) +esid: prod-FieldDefinition +features: [class-fields-public, class] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PropertyName + +---*/ + + +class C { + m() { return 42; } a + b = 42;; + +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "a"), + "a doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "a"), + "a doesn't appear as an own property on C constructor" +); + +verifyProperty(c, "a", { + value: undefined, + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "b"), + "b doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "b"), + "b doesn't appear as an own property on C constructor" +); + +verifyProperty(c, "b", { + value: 42, + enumerable: true, + writable: true, + configurable: true +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-method-literal-names.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-method-literal-names.js new file mode 100644 index 0000000000..13faccf1b9 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-method-literal-names.js @@ -0,0 +1,96 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/literal-names.case +// - src/class-elements/productions/cls-decl-after-same-line-method.template +/*--- +description: Literal property names (field definitions after a method in the same line) +esid: prod-FieldDefinition +features: [class-fields-public, class] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PropertyName + +---*/ +const fn = function() {} + + + +class C { + m() { return 42; } a; b = 42; + c = fn; + +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "a"), + "a doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "a"), + "a doesn't appear as an own property on C constructor" +); + +verifyProperty(c, "a", { + value: undefined, + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "b"), + "b doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "b"), + "b doesn't appear as an own property on C constructor" +); + +verifyProperty(c, "b", { + value: 42, + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "c"), + "c doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "c"), + "c doesn't appear as an own property on C constructor" +); + +verifyProperty(c, "c", { + value: fn, + enumerable: true, + writable: true, + configurable: true +}); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-method-private-field-usage.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-method-private-field-usage.js new file mode 100644 index 0000000000..54e661f267 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-method-private-field-usage.js @@ -0,0 +1,49 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/private-field-usage.case +// - src/class-elements/productions/cls-decl-after-same-line-method.template +/*--- +description: PrivateName CallExpression usage (private field) (field definitions after a method in the same line) +esid: prod-FieldDefinition +features: [class-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + Updated Productions + + CallExpression[Yield, Await]: + CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await] + SuperCall[?Yield, ?Await] + CallExpression[?Yield, ?Await]Arguments[?Yield, ?Await] + CallExpression[?Yield, ?Await][Expression[+In, ?Yield, ?Await]] + CallExpression[?Yield, ?Await].IdentifierName + CallExpression[?Yield, ?Await]TemplateLiteral[?Yield, ?Await] + CallExpression[?Yield, ?Await].PrivateName + +---*/ + + +class C { + m() { return 42; } #m = 'test262';; + method() { + return this.#m; + } +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.method(), 'test262'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-method-private-method-getter-usage.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-method-private-method-getter-usage.js new file mode 100644 index 0000000000..5fb9643d51 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-method-private-method-getter-usage.js @@ -0,0 +1,49 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/private-method-getter-usage.case +// - src/class-elements/productions/cls-decl-after-same-line-method.template +/*--- +description: PrivateName CallExpression usage (Accesor get method) (field definitions after a method in the same line) +esid: prod-FieldDefinition +features: [class-methods-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + Updated Productions + + CallExpression[Yield, Await]: + CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await] + SuperCall[?Yield, ?Await] + CallExpression[?Yield, ?Await]Arguments[?Yield, ?Await] + CallExpression[?Yield, ?Await][Expression[+In, ?Yield, ?Await]] + CallExpression[?Yield, ?Await].IdentifierName + CallExpression[?Yield, ?Await]TemplateLiteral[?Yield, ?Await] + CallExpression[?Yield, ?Await].PrivateName + +---*/ + + +class C { + m() { return 42; } get #m() { return 'test262'; }; + method() { + return this.#m; + } +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.method(), 'test262'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-method-private-method-usage.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-method-private-method-usage.js new file mode 100644 index 0000000000..ed4c12cfed --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-method-private-method-usage.js @@ -0,0 +1,49 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/private-method-usage.case +// - src/class-elements/productions/cls-decl-after-same-line-method.template +/*--- +description: PrivateName CallExpression usage (private method) (field definitions after a method in the same line) +esid: prod-FieldDefinition +features: [class-methods-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + Updated Productions + + CallExpression[Yield, Await]: + CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await] + SuperCall[?Yield, ?Await] + CallExpression[?Yield, ?Await]Arguments[?Yield, ?Await] + CallExpression[?Yield, ?Await][Expression[+In, ?Yield, ?Await]] + CallExpression[?Yield, ?Await].IdentifierName + CallExpression[?Yield, ?Await]TemplateLiteral[?Yield, ?Await] + CallExpression[?Yield, ?Await].PrivateName + +---*/ + + +class C { + m() { return 42; } #m() { return 'test262'; }; + method() { + return this.#m(); + } +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.method(), 'test262'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-method-private-names.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-method-private-names.js new file mode 100644 index 0000000000..1609214656 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-method-private-names.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/private-names.case +// - src/class-elements/productions/cls-decl-after-same-line-method.template +/*--- +description: private names (field definitions after a method in the same line) +esid: prod-FieldDefinition +features: [class-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + ... + FieldDefinition ; + + FieldDefinition : + ClassElementName Initializer_opt + + ClassElementName : + PrivateName + + PrivateName : + # IdentifierName + +---*/ + + +class C { + m() { return 42; } #x; #y; + x() { + this.#x = 42; + return this.#x; + } + y() { + this.#y = 43; + return this.#y; + } +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +// Test the private fields do not appear as properties before set to value +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#x"), "test 1"); +assert(!Object.prototype.hasOwnProperty.call(C, "#x"), "test 2"); +assert(!Object.prototype.hasOwnProperty.call(c, "#x"), "test 3"); + +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#y"), "test 4"); +assert(!Object.prototype.hasOwnProperty.call(C, "#y"), "test 5"); +assert(!Object.prototype.hasOwnProperty.call(c, "#y"), "test 6"); + +// Test if private fields can be sucessfully accessed and set to value +assert.sameValue(c.x(), 42, "test 7"); +assert.sameValue(c.y(), 43, "test 8"); + +// Test the private fields do not appear as properties before after set to value +assert(!Object.prototype.hasOwnProperty.call(c, "#x"), "test 9"); +assert(!Object.prototype.hasOwnProperty.call(c, "#y"), "test 10"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-method-rs-field-identifier-initializer.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-method-rs-field-identifier-initializer.js new file mode 100644 index 0000000000..94601464dc --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-method-rs-field-identifier-initializer.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-field-identifier-initializer.case +// - src/class-elements/productions/cls-decl-after-same-line-method.template +/*--- +description: Valid FieldDefinition (field definitions after a method in the same line) +esid: prod-FieldDefinition +features: [class-fields-public, class] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + ... + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + + PropertyName : + LiteralPropertyName + ComputedPropertyName + + LiteralPropertyName : + IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + m() { return 42; } $ = 1; _ = 1; \u{6F} = 1; \u2118 = 1; ZW_\u200C_NJ = 1; ZW_\u200D_J = 1; + +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.$, 1); +assert.sameValue(c._, 1); +assert.sameValue(c.\u{6F}, 1); +assert.sameValue(c.\u2118, 1); +assert.sameValue(c.ZW_\u200C_NJ, 1); +assert.sameValue(c.ZW_\u200D_J, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-method-rs-field-identifier.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-method-rs-field-identifier.js new file mode 100644 index 0000000000..68db2471db --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-method-rs-field-identifier.js @@ -0,0 +1,94 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-field-identifier.case +// - src/class-elements/productions/cls-decl-after-same-line-method.template +/*--- +description: Valid FieldDefinition (field definitions after a method in the same line) +esid: prod-FieldDefinition +features: [class-fields-public, class] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + ... + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + + PropertyName : + LiteralPropertyName + ComputedPropertyName + + LiteralPropertyName : + IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + m() { return 42; } $; _; \u{6F}; \u2118; ZW_\u200C_NJ; ZW_\u200D_J; + +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +c.$ = 1; +c._ = 1; +c.\u{6F} = 1; +c.\u2118 = 1; +c.ZW_\u200C_NJ = 1; +c.ZW_\u200D_J = 1; + +assert.sameValue(c.$, 1); +assert.sameValue(c._, 1); +assert.sameValue(c.\u{6F}, 1); +assert.sameValue(c.\u2118, 1); +assert.sameValue(c.ZW_\u200C_NJ, 1); +assert.sameValue(c.ZW_\u200D_J, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-method-rs-private-getter-alt.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-method-rs-private-getter-alt.js new file mode 100644 index 0000000000..862349ac53 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-method-rs-private-getter-alt.js @@ -0,0 +1,128 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-private-getter-alt.case +// - src/class-elements/productions/cls-decl-after-same-line-method.template +/*--- +description: Valid PrivateName as private getter (field definitions after a method in the same line) +esid: prod-FieldDefinition +features: [class-methods-private, class-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + ... + ; + + MethodDefinition : + ... + get ClassElementName ( ){ FunctionBody } + ... + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + m() { return 42; } #$_; #__; #\u{6F}_; #℘_; #ZW_‌_NJ_; #ZW_‍_J_; + get #$() { + return this.#$_; + } + get #_() { + return this.#__; + } + get #\u{6F}() { + return this.#\u{6F}_; + } + get #℘() { + return this.#℘_; + } + get #ZW_‌_NJ() { + return this.#ZW_‌_NJ_; + } + get #ZW_‍_J() { + return this.#ZW_‍_J_; + } +; + $(value) { + this.#$_ = value; + return this.#$; + } + _(value) { + this.#__ = value; + return this.#_; + } + \u{6F}(value) { + this.#\u{6F}_ = value; + return this.#\u{6F}; + } + ℘(value) { + this.#℘_ = value; + return this.#℘; + } + ZW_‌_NJ(value) { + this.#ZW_‌_NJ_ = value; + return this.#ZW_‌_NJ; + } + ZW_‍_J(value) { + this.#ZW_‍_J_ = value; + return this.#ZW_‍_J; + } + +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.$(1), 1); +assert.sameValue(c._(1), 1); +assert.sameValue(c.\u{6F}(1), 1); +assert.sameValue(c.℘(1), 1); +assert.sameValue(c.ZW_‌_NJ(1), 1); +assert.sameValue(c.ZW_‍_J(1), 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-method-rs-private-getter.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-method-rs-private-getter.js new file mode 100644 index 0000000000..c55a585343 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-method-rs-private-getter.js @@ -0,0 +1,128 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-private-getter.case +// - src/class-elements/productions/cls-decl-after-same-line-method.template +/*--- +description: Valid PrivateName as private getter (field definitions after a method in the same line) +esid: prod-FieldDefinition +features: [class-methods-private, class-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + ... + ; + + MethodDefinition : + ... + get ClassElementName ( ){ FunctionBody } + ... + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + m() { return 42; } #$_; #__; #\u{6F}_; #\u2118_; #ZW_\u200C_NJ_; #ZW_\u200D_J_; + get #$() { + return this.#$_; + } + get #_() { + return this.#__; + } + get #\u{6F}() { + return this.#\u{6F}_; + } + get #\u2118() { + return this.#\u2118_; + } + get #ZW_\u200C_NJ() { + return this.#ZW_\u200C_NJ_; + } + get #ZW_\u200D_J() { + return this.#ZW_\u200D_J_; + } +; + $(value) { + this.#$_ = value; + return this.#$; + } + _(value) { + this.#__ = value; + return this.#_; + } + \u{6F}(value) { + this.#\u{6F}_ = value; + return this.#\u{6F}; + } + \u2118(value) { + this.#\u2118_ = value; + return this.#\u2118; + } + ZW_\u200C_NJ(value) { + this.#ZW_\u200C_NJ_ = value; + return this.#ZW_\u200C_NJ; + } + ZW_\u200D_J(value) { + this.#ZW_\u200D_J_ = value; + return this.#ZW_\u200D_J; + } + +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.$(1), 1); +assert.sameValue(c._(1), 1); +assert.sameValue(c.\u{6F}(1), 1); +assert.sameValue(c.\u2118(1), 1); +assert.sameValue(c.ZW_\u200C_NJ(1), 1); +assert.sameValue(c.ZW_\u200D_J(1), 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-method-rs-private-method-alt.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-method-rs-private-method-alt.js new file mode 100644 index 0000000000..cc30e5ebdb --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-method-rs-private-method-alt.js @@ -0,0 +1,127 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-private-method-alt.case +// - src/class-elements/productions/cls-decl-after-same-line-method.template +/*--- +description: Valid PrivateName as private method (field definitions after a method in the same line) +esid: prod-FieldDefinition +features: [class-methods-private, class-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + ... + ; + + MethodDefinition : + ClassElementName ( UniqueFormalParameters ) { FunctionBody } + ... + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + m() { return 42; } #$_; #__; #\u{6F}_; #℘_; #ZW_‌_NJ_; #ZW_‍_J_; + #$() { + return this.#$_; + } + #_() { + return this.#__; + } + #\u{6F}() { + return this.#\u{6F}_; + } + #℘() { + return this.#℘_; + } + #ZW_‌_NJ() { + return this.#ZW_‌_NJ_; + } + #ZW_‍_J() { + return this.#ZW_‍_J_; + } +; + $(value) { + this.#$_ = value; + return this.#$(); + } + _(value) { + this.#__ = value; + return this.#_(); + } + \u{6F}(value) { + this.#\u{6F}_ = value; + return this.#\u{6F}(); + } + ℘(value) { + this.#℘_ = value; + return this.#℘(); + } + ZW_‌_NJ(value) { + this.#ZW_‌_NJ_ = value; + return this.#ZW_‌_NJ(); + } + ZW_‍_J(value) { + this.#ZW_‍_J_ = value; + return this.#ZW_‍_J(); + } + +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.$(1), 1); +assert.sameValue(c._(1), 1); +assert.sameValue(c.\u{6F}(1), 1); +assert.sameValue(c.℘(1), 1); +assert.sameValue(c.ZW_‌_NJ(1), 1); +assert.sameValue(c.ZW_‍_J(1), 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-method-rs-private-method.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-method-rs-private-method.js new file mode 100644 index 0000000000..f6f5151869 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-method-rs-private-method.js @@ -0,0 +1,127 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-private-method.case +// - src/class-elements/productions/cls-decl-after-same-line-method.template +/*--- +description: Valid PrivateName as private method (field definitions after a method in the same line) +esid: prod-FieldDefinition +features: [class-methods-private, class-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + ... + ; + + MethodDefinition : + ClassElementName ( UniqueFormalParameters ) { FunctionBody } + ... + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + m() { return 42; } #$_; #__; #\u{6F}_; #\u2118_; #ZW_\u200C_NJ_; #ZW_\u200D_J_; + #$() { + return this.#$_; + } + #_() { + return this.#__; + } + #\u{6F}() { + return this.#\u{6F}_; + } + #\u2118() { + return this.#\u2118_; + } + #ZW_\u200C_NJ() { + return this.#ZW_\u200C_NJ_; + } + #ZW_\u200D_J() { + return this.#ZW_\u200D_J_; + } +; + $(value) { + this.#$_ = value; + return this.#$(); + } + _(value) { + this.#__ = value; + return this.#_(); + } + \u{6F}(value) { + this.#\u{6F}_ = value; + return this.#\u{6F}(); + } + \u2118(value) { + this.#\u2118_ = value; + return this.#\u2118(); + } + ZW_\u200C_NJ(value) { + this.#ZW_\u200C_NJ_ = value; + return this.#ZW_\u200C_NJ(); + } + ZW_\u200D_J(value) { + this.#ZW_\u200D_J_ = value; + return this.#ZW_\u200D_J(); + } + +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.$(1), 1); +assert.sameValue(c._(1), 1); +assert.sameValue(c.\u{6F}(1), 1); +assert.sameValue(c.\u2118(1), 1); +assert.sameValue(c.ZW_\u200C_NJ(1), 1); +assert.sameValue(c.ZW_\u200D_J(1), 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-method-rs-private-setter-alt.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-method-rs-private-setter-alt.js new file mode 100644 index 0000000000..e2063f85d5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-method-rs-private-setter-alt.js @@ -0,0 +1,127 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-private-setter-alt.case +// - src/class-elements/productions/cls-decl-after-same-line-method.template +/*--- +description: Valid PrivateName as private setter (field definitions after a method in the same line) +esid: prod-FieldDefinition +features: [class-methods-private, class-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + ... + ; + + MethodDefinition : + ... + set ClassElementName ( PropertySetParameterList ) { FunctionBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + m() { return 42; } #$_; #__; #\u{6F}_; #℘_; #ZW_‌_NJ_; #ZW_‍_J_; + set #$(value) { + this.#$_ = value; + } + set #_(value) { + this.#__ = value; + } + set #\u{6F}(value) { + this.#\u{6F}_ = value; + } + set #℘(value) { + this.#℘_ = value; + } + set #ZW_‌_NJ(value) { + this.#ZW_‌_NJ_ = value; + } + set #ZW_‍_J(value) { + this.#ZW_‍_J_ = value; + } +; + $(value) { + this.#$ = value; + return this.#$_; + } + _(value) { + this.#_ = value; + return this.#__; + } + \u{6F}(value) { + this.#\u{6F} = value; + return this.#\u{6F}_; + } + ℘(value) { + this.#℘ = value; + return this.#℘_; + } + ZW_‌_NJ(value) { + this.#ZW_‌_NJ = value; + return this.#ZW_‌_NJ_; + } + ZW_‍_J(value) { + this.#ZW_‍_J = value; + return this.#ZW_‍_J_; + } + +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.$(1), 1); +assert.sameValue(c._(1), 1); +assert.sameValue(c.\u{6F}(1), 1); +assert.sameValue(c.℘(1), 1); +assert.sameValue(c.ZW_‌_NJ(1), 1); +assert.sameValue(c.ZW_‍_J(1), 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-method-rs-private-setter.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-method-rs-private-setter.js new file mode 100644 index 0000000000..809832b036 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-method-rs-private-setter.js @@ -0,0 +1,127 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-private-setter.case +// - src/class-elements/productions/cls-decl-after-same-line-method.template +/*--- +description: Valid PrivateName as private setter (field definitions after a method in the same line) +esid: prod-FieldDefinition +features: [class-methods-private, class-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + ... + ; + + MethodDefinition : + ... + set ClassElementName ( PropertySetParameterList ) { FunctionBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + m() { return 42; } #$_; #__; #\u{6F}_; #\u2118_; #ZW_\u200C_NJ_; #ZW_\u200D_J_; + set #$(value) { + this.#$_ = value; + } + set #_(value) { + this.#__ = value; + } + set #\u{6F}(value) { + this.#\u{6F}_ = value; + } + set #\u2118(value) { + this.#\u2118_ = value; + } + set #ZW_\u200C_NJ(value) { + this.#ZW_\u200C_NJ_ = value; + } + set #ZW_\u200D_J(value) { + this.#ZW_\u200D_J_ = value; + } +; + $(value) { + this.#$ = value; + return this.#$_; + } + _(value) { + this.#_ = value; + return this.#__; + } + \u{6F}(value) { + this.#\u{6F} = value; + return this.#\u{6F}_; + } + \u2118(value) { + this.#\u2118 = value; + return this.#\u2118_; + } + ZW_\u200C_NJ(value) { + this.#ZW_\u200C_NJ = value; + return this.#ZW_\u200C_NJ_; + } + ZW_\u200D_J(value) { + this.#ZW_\u200D_J = value; + return this.#ZW_\u200D_J_; + } + +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.$(1), 1); +assert.sameValue(c._(1), 1); +assert.sameValue(c.\u{6F}(1), 1); +assert.sameValue(c.\u2118(1), 1); +assert.sameValue(c.ZW_\u200C_NJ(1), 1); +assert.sameValue(c.ZW_\u200D_J(1), 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-method-rs-privatename-identifier-alt.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-method-rs-privatename-identifier-alt.js new file mode 100644 index 0000000000..e483dfc68f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-method-rs-privatename-identifier-alt.js @@ -0,0 +1,109 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-privatename-identifier-alt.case +// - src/class-elements/productions/cls-decl-after-same-line-method.template +/*--- +description: Valid PrivateName (field definitions after a method in the same line) +esid: prod-FieldDefinition +features: [class-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + m() { return 42; } #$; #_; #\u{6F}; #℘; #ZW_‌_NJ; #ZW_‍_J; + $(value) { + this.#$ = value; + return this.#$; + } + _(value) { + this.#_ = value; + return this.#_; + } + \u{6F}(value) { + this.#\u{6F} = value; + return this.#\u{6F}; + } + ℘(value) { + this.#℘ = value; + return this.#℘; + } + ZW_‌_NJ(value) { + this.#ZW_‌_NJ = value; + return this.#ZW_‌_NJ; + } + ZW_‍_J(value) { + this.#ZW_‍_J = value; + return this.#ZW_‍_J; + } +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.$(1), 1); +assert.sameValue(c._(1), 1); +assert.sameValue(c.\u{6F}(1), 1); +assert.sameValue(c.℘(1), 1); +assert.sameValue(c.ZW_‌_NJ(1), 1); +assert.sameValue(c.ZW_‍_J(1), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-method-rs-privatename-identifier-initializer-alt.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-method-rs-privatename-identifier-initializer-alt.js new file mode 100644 index 0000000000..f4ad70edab --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-method-rs-privatename-identifier-initializer-alt.js @@ -0,0 +1,103 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-privatename-identifier-initializer-alt.case +// - src/class-elements/productions/cls-decl-after-same-line-method.template +/*--- +description: Valid PrivateName (field definitions after a method in the same line) +esid: prod-FieldDefinition +features: [class-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + m() { return 42; } #$ = 1; #_ = 1; #\u{6F} = 1; #℘ = 1; #ZW_‌_NJ = 1; #ZW_‍_J = 1; + $() { + return this.#$; + } + _() { + return this.#_; + } + \u{6F}() { + return this.#\u{6F}; + } + ℘() { + return this.#℘; + } + ZW_‌_NJ() { + return this.#ZW_‌_NJ; + } + ZW_‍_J() { + return this.#ZW_‍_J; + } +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.$(), 1); +assert.sameValue(c._(), 1); +assert.sameValue(c.\u{6F}(), 1); +assert.sameValue(c.℘(), 1); +assert.sameValue(c.ZW_‌_NJ(), 1); +assert.sameValue(c.ZW_‍_J(), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-method-rs-privatename-identifier-initializer.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-method-rs-privatename-identifier-initializer.js new file mode 100644 index 0000000000..599a9ac8fa --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-method-rs-privatename-identifier-initializer.js @@ -0,0 +1,103 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-privatename-identifier-initializer.case +// - src/class-elements/productions/cls-decl-after-same-line-method.template +/*--- +description: Valid PrivateName (field definitions after a method in the same line) +esid: prod-FieldDefinition +features: [class-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + m() { return 42; } #$ = 1; #_ = 1; #\u{6F} = 1; #\u2118 = 1; #ZW_\u200C_NJ = 1; #ZW_\u200D_J = 1; + $() { + return this.#$; + } + _() { + return this.#_; + } + \u{6F}() { + return this.#\u{6F}; + } + \u2118() { + return this.#\u2118; + } + ZW_\u200C_NJ() { + return this.#ZW_\u200C_NJ; + } + ZW_\u200D_J() { + return this.#ZW_\u200D_J; + } +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.$(), 1); +assert.sameValue(c._(), 1); +assert.sameValue(c.\u{6F}(), 1); +assert.sameValue(c.\u2118(), 1); +assert.sameValue(c.ZW_\u200C_NJ(), 1); +assert.sameValue(c.ZW_\u200D_J(), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-method-rs-privatename-identifier.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-method-rs-privatename-identifier.js new file mode 100644 index 0000000000..5a08e76397 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-method-rs-privatename-identifier.js @@ -0,0 +1,109 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-privatename-identifier.case +// - src/class-elements/productions/cls-decl-after-same-line-method.template +/*--- +description: Valid PrivateName (field definitions after a method in the same line) +esid: prod-FieldDefinition +features: [class-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + m() { return 42; } #$; #_; #\u{6F}; #\u2118; #ZW_\u200C_NJ; #ZW_\u200D_J; + $(value) { + this.#$ = value; + return this.#$; + } + _(value) { + this.#_ = value; + return this.#_; + } + \u{6F}(value) { + this.#\u{6F} = value; + return this.#\u{6F}; + } + \u2118(value) { + this.#\u2118 = value; + return this.#\u2118; + } + ZW_\u200C_NJ(value) { + this.#ZW_\u200C_NJ = value; + return this.#ZW_\u200C_NJ; + } + ZW_\u200D_J(value) { + this.#ZW_\u200D_J = value; + return this.#ZW_\u200D_J; + } +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.$(1), 1); +assert.sameValue(c._(1), 1); +assert.sameValue(c.\u{6F}(1), 1); +assert.sameValue(c.\u2118(1), 1); +assert.sameValue(c.ZW_\u200C_NJ(1), 1); +assert.sameValue(c.ZW_\u200D_J(1), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-method-rs-static-async-generator-method-privatename-identifier-alt.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-method-rs-static-async-generator-method-privatename-identifier-alt.js new file mode 100644 index 0000000000..197216f455 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-method-rs-static-async-generator-method-privatename-identifier-alt.js @@ -0,0 +1,134 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-async-generator-method-privatename-identifier-alt.case +// - src/class-elements/productions/cls-decl-after-same-line-method.template +/*--- +description: Valid Static AsyncGeneratorMethod PrivateName (field definitions after a method in the same line) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + AsyncGeneratorMethod + + AsyncGeneratorMethod : + async [no LineTerminator here] * ClassElementName ( UniqueFormalParameters){ AsyncGeneratorBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + m() { return 42; } static async * #$(value) { + yield * await value; + } + static async * #_(value) { + yield * await value; + } + static async * #o(value) { + yield * await value; + } + static async * #℘(value) { + yield * await value; + } + static async * #ZW_‌_NJ(value) { + yield * await value; + } + static async * #ZW_‍_J(value) { + yield * await value; + }; + static get $() { + return this.#$; + } + static get _() { + return this.#_; + } + static get o() { + return this.#o; + } + static get ℘() { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#℘; + } + static get ZW_‌_NJ() { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#ZW_‌_NJ; + } + static get ZW_‍_J() { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#ZW_‍_J; + } + +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +Promise.all([ + C.$([1]).next(), + C._([1]).next(), + C.o([1]).next(), + C.℘([1]).next(), // DO NOT CHANGE THE NAME OF THIS FIELD + C.ZW_‌_NJ([1]).next(), // DO NOT CHANGE THE NAME OF THIS FIELD + C.ZW_‍_J([1]).next(), // DO NOT CHANGE THE NAME OF THIS FIELD +]).then(results => { + + assert.sameValue(results[0].value, 1); + assert.sameValue(results[1].value, 1); + assert.sameValue(results[2].value, 1); + assert.sameValue(results[3].value, 1); + assert.sameValue(results[4].value, 1); + assert.sameValue(results[5].value, 1); + +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-method-rs-static-async-generator-method-privatename-identifier.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-method-rs-static-async-generator-method-privatename-identifier.js new file mode 100644 index 0000000000..a3f00b9df6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-method-rs-static-async-generator-method-privatename-identifier.js @@ -0,0 +1,135 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-async-generator-method-privatename-identifier.case +// - src/class-elements/productions/cls-decl-after-same-line-method.template +/*--- +description: Valid Static AsyncGeneratorMethod PrivateName (field definitions after a method in the same line) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + AsyncGeneratorMethod + + AsyncGeneratorMethod : + async [no LineTerminator here] * ClassElementName ( UniqueFormalParameters){ AsyncGeneratorBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + m() { return 42; } static async * #$(value) { + yield * await value; + } + static async * #_(value) { + yield * await value; + } + static async * #\u{6F}(value) { + yield * await value; + } + static async * #\u2118(value) { + yield * await value; + } + static async * #ZW_\u200C_NJ(value) { + yield * await value; + } + static async * #ZW_\u200D_J(value) { + yield * await value; + }; + static get $() { + return this.#$; + } + static get _() { + return this.#_; + } + static get \u{6F}() { + return this.#\u{6F}; + } + static get \u2118() { + return this.#\u2118; + } + static get ZW_\u200C_NJ() { + return this.#ZW_\u200C_NJ; + } + static get ZW_\u200D_J() { + return this.#ZW_\u200D_J; + } + +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +Promise.all([ + C.$([1]).next(), + C._([1]).next(), + C.\u{6F}([1]).next(), + C.\u2118([1]).next(), + C.ZW_\u200C_NJ([1]).next(), + C.ZW_\u200D_J([1]).next(), +]).then(results => { + + assert.sameValue(results[0].value, 1); + assert.sameValue(results[1].value, 1); + assert.sameValue(results[2].value, 1); + assert.sameValue(results[3].value, 1); + assert.sameValue(results[4].value, 1); + assert.sameValue(results[5].value, 1); + +}).then($DONE, $DONE); + diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-method-rs-static-async-method-privatename-identifier-alt.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-method-rs-static-async-method-privatename-identifier-alt.js new file mode 100644 index 0000000000..6becb08bc5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-method-rs-static-async-method-privatename-identifier-alt.js @@ -0,0 +1,134 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-async-method-privatename-identifier-alt.case +// - src/class-elements/productions/cls-decl-after-same-line-method.template +/*--- +description: Valid Static AsyncMethod PrivateName (field definitions after a method in the same line) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + AsyncMethod + + AsyncMethod : + async [no LineTerminator here] ClassElementName ( UniqueFormalParameters ){ AsyncFunctionBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + m() { return 42; } static async #$(value) { + return await value; + } + static async #_(value) { + return await value; + } + static async #o(value) { + return await value; + } + static async #℘(value) { + return await value; + } + static async #ZW_‌_NJ(value) { + return await value; + } + static async #ZW_‍_J(value) { + return await value; + }; + static async $(value) { + return await this.#$(value); + } + static async _(value) { + return await this.#_(value); + } + static async o(value) { + return await this.#o(value); + } + static async ℘(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + return await this.#℘(value); + } + static async ZW_‌_NJ(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + return await this.#ZW_‌_NJ(value); + } + static async ZW_‍_J(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + return await this.#ZW_‍_J(value); + } + +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +Promise.all([ + C.$(1), + C._(1), + C.o(1), + C.℘(1), // DO NOT CHANGE THE NAME OF THIS FIELD + C.ZW_‌_NJ(1), // DO NOT CHANGE THE NAME OF THIS FIELD + C.ZW_‍_J(1), // DO NOT CHANGE THE NAME OF THIS FIELD +]).then(results => { + + assert.sameValue(results[0], 1); + assert.sameValue(results[1], 1); + assert.sameValue(results[2], 1); + assert.sameValue(results[3], 1); + assert.sameValue(results[4], 1); + assert.sameValue(results[5], 1); + +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-method-rs-static-async-method-privatename-identifier.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-method-rs-static-async-method-privatename-identifier.js new file mode 100644 index 0000000000..456f7860e3 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-method-rs-static-async-method-privatename-identifier.js @@ -0,0 +1,135 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-async-method-privatename-identifier.case +// - src/class-elements/productions/cls-decl-after-same-line-method.template +/*--- +description: Valid Static AsyncMethod PrivateName (field definitions after a method in the same line) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + AsyncMethod + + AsyncMethod : + async [no LineTerminator here] ClassElementName ( UniqueFormalParameters ){ AsyncFunctionBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + m() { return 42; } static async #$(value) { + return await value; + } + static async #_(value) { + return await value; + } + static async #\u{6F}(value) { + return await value; + } + static async #\u2118(value) { + return await value; + } + static async #ZW_\u200C_NJ(value) { + return await value; + } + static async #ZW_\u200D_J(value) { + return await value; + }; + static async $(value) { + return await this.#$(value); + } + static async _(value) { + return await this.#_(value); + } + static async \u{6F}(value) { + return await this.#\u{6F}(value); + } + static async \u2118(value) { + return await this.#\u2118(value); + } + static async ZW_\u200C_NJ(value) { + return await this.#ZW_\u200C_NJ(value); + } + static async ZW_\u200D_J(value) { + return await this.#ZW_\u200D_J(value); + } + +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +Promise.all([ + C.$(1), + C._(1), + C.\u{6F}(1), + C.\u2118(1), + C.ZW_\u200C_NJ(1), + C.ZW_\u200D_J(1), +]).then(results => { + + assert.sameValue(results[0], 1); + assert.sameValue(results[1], 1); + assert.sameValue(results[2], 1); + assert.sameValue(results[3], 1); + assert.sameValue(results[4], 1); + assert.sameValue(results[5], 1); + +}).then($DONE, $DONE); + diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-method-rs-static-generator-method-privatename-identifier-alt.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-method-rs-static-generator-method-privatename-identifier-alt.js new file mode 100644 index 0000000000..f9616e0a3c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-method-rs-static-generator-method-privatename-identifier-alt.js @@ -0,0 +1,124 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-generator-method-privatename-identifier-alt.case +// - src/class-elements/productions/cls-decl-after-same-line-method.template +/*--- +description: Valid Static GeneratorMethod PrivateName (field definitions after a method in the same line) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + GeneratorMethod + + GeneratorMethod : + * ClassElementName ( UniqueFormalParameters ){ GeneratorBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + m() { return 42; } static * #$(value) { + yield * value; + } + static * #_(value) { + yield * value; + } + static * #o(value) { + yield * value; + } + static * #℘(value) { + yield * value; + } + static * #ZW_‌_NJ(value) { + yield * value; + } + static * #ZW_‍_J(value) { + yield * value; + }; + static get $() { + return this.#$; + } + static get _() { + return this.#_; + } + static get o() { + return this.#o; + } + static get ℘() { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#℘; + } + static get ZW_‌_NJ() { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#ZW_‌_NJ; + } + static get ZW_‍_J() { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#ZW_‍_J; + } + +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(C.$([1]).next().value, 1); +assert.sameValue(C._([1]).next().value, 1); +assert.sameValue(C.o([1]).next().value, 1); +assert.sameValue(C.℘([1]).next().value, 1); +assert.sameValue(C.ZW_‌_NJ([1]).next().value, 1); +assert.sameValue(C.ZW_‍_J([1]).next().value, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-method-rs-static-generator-method-privatename-identifier.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-method-rs-static-generator-method-privatename-identifier.js new file mode 100644 index 0000000000..658f1ab968 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-method-rs-static-generator-method-privatename-identifier.js @@ -0,0 +1,125 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-generator-method-privatename-identifier.case +// - src/class-elements/productions/cls-decl-after-same-line-method.template +/*--- +description: Valid Static GeneratorMethod PrivateName (field definitions after a method in the same line) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + GeneratorMethod + + GeneratorMethod : + * ClassElementName ( UniqueFormalParameters ){ GeneratorBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + m() { return 42; } static * #$(value) { + yield * value; + } + static * #_(value) { + yield * value; + } + static * #\u{6F}(value) { + yield * value; + } + static * #\u2118(value) { + yield * value; + } + static * #ZW_\u200C_NJ(value) { + yield * value; + } + static * #ZW_\u200D_J(value) { + yield * value; + }; + static get $() { + return this.#$; + } + static get _() { + return this.#_; + } + static get \u{6F}() { + return this.#\u{6F}; + } + static get \u2118() { + return this.#\u2118; + } + static get ZW_\u200C_NJ() { + return this.#ZW_\u200C_NJ; + } + static get ZW_\u200D_J() { + return this.#ZW_\u200D_J; + } + +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(C.$([1]).next().value, 1); +assert.sameValue(C._([1]).next().value, 1); +assert.sameValue(C.\u{6F}([1]).next().value, 1); +assert.sameValue(C.\u2118([1]).next().value, 1); +assert.sameValue(C.ZW_\u200C_NJ([1]).next().value, 1); +assert.sameValue(C.ZW_\u200D_J([1]).next().value, 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-method-rs-static-method-privatename-identifier-alt.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-method-rs-static-method-privatename-identifier-alt.js new file mode 100644 index 0000000000..6de252c327 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-method-rs-static-method-privatename-identifier-alt.js @@ -0,0 +1,122 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-method-privatename-identifier-alt.case +// - src/class-elements/productions/cls-decl-after-same-line-method.template +/*--- +description: Valid Static Method PrivateName (field definitions after a method in the same line) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + ClassElementName ( UniqueFormalParameters ){ FunctionBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + m() { return 42; } static #$(value) { + return value; + } + static #_(value) { + return value; + } + static #o(value) { + return value; + } + static #℘(value) { + return value; + } + static #ZW_‌_NJ(value) { + return value; + } + static #ZW_‍_J(value) { + return value; + }; + static $(value) { + return this.#$(value); + } + static _(value) { + return this.#_(value); + } + static o(value) { + return this.#o(value); + } + static ℘(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#℘(value); + } + static ZW_‌_NJ(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#ZW_‌_NJ(value); + } + static ZW_‍_J(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#ZW_‍_J(value); + } + +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(C.$(1), 1); +assert.sameValue(C._(1), 1); +assert.sameValue(C.o(1), 1); +assert.sameValue(C.℘(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD +assert.sameValue(C.ZW_‌_NJ(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD +assert.sameValue(C.ZW_‍_J(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-method-rs-static-method-privatename-identifier.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-method-rs-static-method-privatename-identifier.js new file mode 100644 index 0000000000..58092cfd01 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-method-rs-static-method-privatename-identifier.js @@ -0,0 +1,122 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-method-privatename-identifier.case +// - src/class-elements/productions/cls-decl-after-same-line-method.template +/*--- +description: Valid Static Method PrivateName (field definitions after a method in the same line) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + ClassElementName ( UniqueFormalParameters ){ FunctionBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + m() { return 42; } static #$(value) { + return value; + } + static #_(value) { + return value; + } + static #\u{6F}(value) { + return value; + } + static #\u2118(value) { + return value; + } + static #ZW_\u200C_NJ(value) { + return value; + } + static #ZW_\u200D_J(value) { + return value; + }; + static $(value) { + return this.#$(value); + } + static _(value) { + return this.#_(value); + } + static \u{6F}(value) { + return this.#\u{6F}(value); + } + static \u2118(value) { + return this.#\u2118(value); + } + static ZW_\u200C_NJ(value) { + return this.#ZW_\u200C_NJ(value); + } + static ZW_\u200D_J(value) { + return this.#ZW_\u200D_J(value); + } + +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(C.$(1), 1); +assert.sameValue(C._(1), 1); +assert.sameValue(C.\u{6F}(1), 1); +assert.sameValue(C.\u2118(1), 1); +assert.sameValue(C.ZW_\u200C_NJ(1), 1); +assert.sameValue(C.ZW_\u200D_J(1), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-method-rs-static-privatename-identifier-alt-by-classname.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-method-rs-static-privatename-identifier-alt-by-classname.js new file mode 100644 index 0000000000..9f258beec7 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-method-rs-static-privatename-identifier-alt-by-classname.js @@ -0,0 +1,110 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-privatename-identifier-alt-by-classname.case +// - src/class-elements/productions/cls-decl-after-same-line-method.template +/*--- +description: Valid Static PrivateName (field definitions after a method in the same line) +esid: prod-FieldDefinition +features: [class-static-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + m() { return 42; } static #$; static #_; static #\u{6F}; static #℘; static #ZW_‌_NJ; static #ZW_‍_J; + static $(value) { + C.#$ = value; + return C.#$; + } + static _(value) { + C.#_ = value; + return C.#_; + } + static o(value) { + C.#\u{6F} = value; + return C.#\u{6F}; + } + static ℘(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + C.#℘ = value; + return C.#℘; + } + static ZW_‌_NJ(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + C.#ZW_‌_NJ = value; + return C.#ZW_‌_NJ; + } + static ZW_‍_J(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + C.#ZW_‍_J = value; + return C.#ZW_‍_J; + } +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(C.$(1), 1); +assert.sameValue(C._(1), 1); +assert.sameValue(C.o(1), 1); +assert.sameValue(C.℘(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD +assert.sameValue(C.ZW_‌_NJ(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD +assert.sameValue(C.ZW_‍_J(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-method-rs-static-privatename-identifier-alt.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-method-rs-static-privatename-identifier-alt.js new file mode 100644 index 0000000000..25f4ca7c49 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-method-rs-static-privatename-identifier-alt.js @@ -0,0 +1,110 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-privatename-identifier-alt.case +// - src/class-elements/productions/cls-decl-after-same-line-method.template +/*--- +description: Valid Static PrivateName (field definitions after a method in the same line) +esid: prod-FieldDefinition +features: [class-static-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + m() { return 42; } static #$; static #_; static #\u{6F}; static #℘; static #ZW_‌_NJ; static #ZW_‍_J; + static $(value) { + this.#$ = value; + return this.#$; + } + static _(value) { + this.#_ = value; + return this.#_; + } + static o(value) { + this.#\u{6F} = value; + return this.#\u{6F}; + } + static ℘(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + this.#℘ = value; + return this.#℘; + } + static ZW_‌_NJ(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + this.#ZW_‌_NJ = value; + return this.#ZW_‌_NJ; + } + static ZW_‍_J(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + this.#ZW_‍_J = value; + return this.#ZW_‍_J; + } +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(C.$(1), 1); +assert.sameValue(C._(1), 1); +assert.sameValue(C.o(1), 1); +assert.sameValue(C.℘(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD +assert.sameValue(C.ZW_‌_NJ(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD +assert.sameValue(C.ZW_‍_J(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-method-rs-static-privatename-identifier-by-classname.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-method-rs-static-privatename-identifier-by-classname.js new file mode 100644 index 0000000000..f7319852b3 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-method-rs-static-privatename-identifier-by-classname.js @@ -0,0 +1,110 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-privatename-identifier-by-classname.case +// - src/class-elements/productions/cls-decl-after-same-line-method.template +/*--- +description: Valid Static PrivateName (field definitions after a method in the same line) +esid: prod-FieldDefinition +features: [class-static-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + m() { return 42; } static #$; static #_; static #\u{6F}; static #\u2118; static #ZW_\u200C_NJ; static #ZW_\u200D_J; + static $(value) { + C.#$ = value; + return C.#$; + } + static _(value) { + C.#_ = value; + return C.#_; + } + static \u{6F}(value) { + C.#\u{6F} = value; + return C.#\u{6F}; + } + static \u2118(value) { + C.#\u2118 = value; + return C.#\u2118; + } + static ZW_\u200C_NJ(value) { + C.#ZW_\u200C_NJ = value; + return C.#ZW_\u200C_NJ; + } + static ZW_\u200D_J(value) { + C.#ZW_\u200D_J = value; + return C.#ZW_\u200D_J; + } +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(C.$(1), 1); +assert.sameValue(C._(1), 1); +assert.sameValue(C.\u{6F}(1), 1); +assert.sameValue(C.\u2118(1), 1); +assert.sameValue(C.ZW_\u200C_NJ(1), 1); +assert.sameValue(C.ZW_\u200D_J(1), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-method-rs-static-privatename-identifier-initializer-alt-by-classname.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-method-rs-static-privatename-identifier-initializer-alt-by-classname.js new file mode 100644 index 0000000000..ade77c12db --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-method-rs-static-privatename-identifier-initializer-alt-by-classname.js @@ -0,0 +1,104 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-privatename-identifier-initializer-alt-by-classname.case +// - src/class-elements/productions/cls-decl-after-same-line-method.template +/*--- +description: Valid Static PrivateName (field definitions after a method in the same line) +esid: prod-FieldDefinition +features: [class-static-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + m() { return 42; } static #$ = 1; static #_ = 1; static #\u{6F} = 1; static #℘ = 1; static #ZW_‌_NJ = 1; static #ZW_‍_J = 1; + static $() { + return C.#$; + } + static _() { + return C.#_; + } + static \u{6F}() { + return C.#\u{6F}; + } + static ℘() { + return C.#℘; + } + static ZW_‌_NJ() { + return C.#ZW_‌_NJ; + } + static ZW_‍_J() { + return C.#ZW_‍_J; + } +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(C.$(), 1); +assert.sameValue(C._(), 1); +assert.sameValue(C.\u{6F}(), 1); +assert.sameValue(C.℘(), 1); +assert.sameValue(C.ZW_‌_NJ(), 1); +assert.sameValue(C.ZW_‍_J(), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-method-rs-static-privatename-identifier-initializer-alt.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-method-rs-static-privatename-identifier-initializer-alt.js new file mode 100644 index 0000000000..bd7086ce7c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-method-rs-static-privatename-identifier-initializer-alt.js @@ -0,0 +1,104 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-privatename-identifier-initializer-alt.case +// - src/class-elements/productions/cls-decl-after-same-line-method.template +/*--- +description: Valid Static PrivateName (field definitions after a method in the same line) +esid: prod-FieldDefinition +features: [class-static-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + m() { return 42; } static #$ = 1; static #_ = 1; static #\u{6F} = 1; static #℘ = 1; static #ZW_‌_NJ = 1; static #ZW_‍_J = 1; + static $() { + return this.#$; + } + static _() { + return this.#_; + } + static \u{6F}() { + return this.#\u{6F}; + } + static ℘() { + return this.#℘; + } + static ZW_‌_NJ() { + return this.#ZW_‌_NJ; + } + static ZW_‍_J() { + return this.#ZW_‍_J; + } +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(C.$(), 1); +assert.sameValue(C._(), 1); +assert.sameValue(C.\u{6F}(), 1); +assert.sameValue(C.℘(), 1); +assert.sameValue(C.ZW_‌_NJ(), 1); +assert.sameValue(C.ZW_‍_J(), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-method-rs-static-privatename-identifier-initializer.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-method-rs-static-privatename-identifier-initializer.js new file mode 100644 index 0000000000..9a22b5740a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-method-rs-static-privatename-identifier-initializer.js @@ -0,0 +1,104 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-privatename-identifier-initializer.case +// - src/class-elements/productions/cls-decl-after-same-line-method.template +/*--- +description: Valid Static PrivateName (field definitions after a method in the same line) +esid: prod-FieldDefinition +features: [class-static-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + m() { return 42; } static #$ = 1; static #_ = 1; static #\u{6F} = 1; static #\u2118 = 1; static #ZW_\u200C_NJ = 1; static #ZW_\u200D_J = 1; + static $() { + return this.#$; + } + static _() { + return this.#_; + } + static \u{6F}() { + return this.#\u{6F}; + } + static \u2118() { + return this.#\u2118; + } + static ZW_\u200C_NJ() { + return this.#ZW_\u200C_NJ; + } + static ZW_\u200D_J() { + return this.#ZW_\u200D_J; + } +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(C.$(), 1); +assert.sameValue(C._(), 1); +assert.sameValue(C.\u{6F}(), 1); +assert.sameValue(C.\u2118(), 1); +assert.sameValue(C.ZW_\u200C_NJ(), 1); +assert.sameValue(C.ZW_\u200D_J(), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-method-rs-static-privatename-identifier.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-method-rs-static-privatename-identifier.js new file mode 100644 index 0000000000..4b3895a898 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-method-rs-static-privatename-identifier.js @@ -0,0 +1,110 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-privatename-identifier.case +// - src/class-elements/productions/cls-decl-after-same-line-method.template +/*--- +description: Valid Static PrivateName (field definitions after a method in the same line) +esid: prod-FieldDefinition +features: [class-static-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + m() { return 42; } static #$; static #_; static #\u{6F}; static #\u2118; static #ZW_\u200C_NJ; static #ZW_\u200D_J; + static $(value) { + this.#$ = value; + return this.#$; + } + static _(value) { + this.#_ = value; + return this.#_; + } + static \u{6F}(value) { + this.#\u{6F} = value; + return this.#\u{6F}; + } + static \u2118(value) { + this.#\u2118 = value; + return this.#\u2118; + } + static ZW_\u200C_NJ(value) { + this.#ZW_\u200C_NJ = value; + return this.#ZW_\u200C_NJ; + } + static ZW_\u200D_J(value) { + this.#ZW_\u200D_J = value; + return this.#ZW_\u200D_J; + } +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(C.$(1), 1); +assert.sameValue(C._(1), 1); +assert.sameValue(C.\u{6F}(1), 1); +assert.sameValue(C.\u2118(1), 1); +assert.sameValue(C.ZW_\u200C_NJ(1), 1); +assert.sameValue(C.ZW_\u200D_J(1), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-method-static-private-fields.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-method-static-private-fields.js new file mode 100644 index 0000000000..345a9a82fe --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-method-static-private-fields.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/static-private-fields.case +// - src/class-elements/productions/cls-decl-after-same-line-method.template +/*--- +description: static private fields (field definitions after a method in the same line) +esid: prod-FieldDefinition +features: [class-static-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + ... + static FieldDefinition ; + + FieldDefinition : + ClassElementName Initializer_opt + + ClassElementName : + PrivateName + + PrivateName : + # IdentifierName + +---*/ + + +class C { + m() { return 42; } static #x; static #y; + static x() { + this.#x = 42; + return this.#x; + } + static y() { + this.#y = 43; + return this.#y; + } +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +// Test the private fields do not appear as properties before set to value +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#x"), "test 1"); +assert(!Object.prototype.hasOwnProperty.call(C, "#x"), "test 2"); +assert(!Object.prototype.hasOwnProperty.call(c, "#x"), "test 3"); + +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#y"), "test 4"); +assert(!Object.prototype.hasOwnProperty.call(C, "#y"), "test 5"); +assert(!Object.prototype.hasOwnProperty.call(c, "#y"), "test 6"); + +// Test if private fields can be sucessfully accessed and set to value +assert.sameValue(C.x(), 42, "test 7"); +assert.sameValue(C.y(), 43, "test 8"); + +// Test the private fields do not appear as properties before after set to value +assert(!Object.prototype.hasOwnProperty.call(C, "#x"), "test 9"); +assert(!Object.prototype.hasOwnProperty.call(C, "#y"), "test 10"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-method-static-private-methods-with-fields.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-method-static-private-methods-with-fields.js new file mode 100644 index 0000000000..e4fd601e4c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-method-static-private-methods-with-fields.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/static-private-methods-with-fields.case +// - src/class-elements/productions/cls-decl-after-same-line-method.template +/*--- +description: static private methods with fields (field definitions after a method in the same line) +esid: prod-FieldDefinition +features: [class-static-methods-private, class-static-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + ... + static FieldDefinition ; + + FieldDefinition : + ClassElementName Initializer_opt + + ClassElementName : + PrivateName + + PrivateName : + # IdentifierName + +---*/ + + +class C { + m() { return 42; } static #xVal; static #yVal; + static #x(value) { + this.#xVal = value; + return this.#xVal; + } + static #y(value) { + this.#yVal = value; + return this.#yVal; + } + static x() { + return this.#x(42); + } + static y() { + return this.#y(43); + } +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +// Test the private methods do not appear as properties before set to value +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#x"), "test 1"); +assert(!Object.prototype.hasOwnProperty.call(C, "#x"), "test 2"); +assert(!Object.prototype.hasOwnProperty.call(c, "#x"), "test 3"); + +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#y"), "test 4"); +assert(!Object.prototype.hasOwnProperty.call(C, "#y"), "test 5"); +assert(!Object.prototype.hasOwnProperty.call(c, "#y"), "test 6"); + +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#xVal"), "test 7"); +assert(!Object.prototype.hasOwnProperty.call(C, "#xVal"), "test 8"); +assert(!Object.prototype.hasOwnProperty.call(c, "#xVal"), "test 9"); + +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#yVal"), "test 10"); +assert(!Object.prototype.hasOwnProperty.call(C, "#yVal"), "test 11"); +assert(!Object.prototype.hasOwnProperty.call(c, "#yVal"), "test 12"); + +// Test if private fields can be sucessfully accessed and set to value +assert.sameValue(C.x(), 42, "test 13"); +assert.sameValue(C.y(), 43, "test 14"); + +// Test the private fields do not appear as properties before after set to value +assert(!Object.prototype.hasOwnProperty.call(C, "#x"), "test 15"); +assert(!Object.prototype.hasOwnProperty.call(C, "#y"), "test 16"); + +assert(!Object.prototype.hasOwnProperty.call(C, "#xVal"), "test 17"); +assert(!Object.prototype.hasOwnProperty.call(C, "#yVal"), "test 18"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-method-static-private-methods.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-method-static-private-methods.js new file mode 100644 index 0000000000..270229feb7 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-method-static-private-methods.js @@ -0,0 +1,75 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/static-private-methods.case +// - src/class-elements/productions/cls-decl-after-same-line-method.template +/*--- +description: static private methods (field definitions after a method in the same line) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + ... + static FieldDefinition ; + + FieldDefinition : + ClassElementName Initializer_opt + + ClassElementName : + PrivateName + + PrivateName : + # IdentifierName + +---*/ + + +class C { + m() { return 42; } ; + static #x(value) { + return value / 2; + } + static #y(value) { + return value * 2; + } + static x() { + return this.#x(84); + } + static y() { + return this.#y(43); + } +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +// Test the private methods do not appear as properties before set to value +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#x"), "test 1"); +assert(!Object.prototype.hasOwnProperty.call(C, "#x"), "test 2"); +assert(!Object.prototype.hasOwnProperty.call(c, "#x"), "test 3"); + +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#y"), "test 4"); +assert(!Object.prototype.hasOwnProperty.call(C, "#y"), "test 5"); +assert(!Object.prototype.hasOwnProperty.call(c, "#y"), "test 6"); + +// Test if private fields can be sucessfully accessed and set to value +assert.sameValue(C.x(), 42, "test 7"); +assert.sameValue(C.y(), 86, "test 8"); + +// Test the private fields do not appear as properties before after set to value +assert(!Object.prototype.hasOwnProperty.call(C, "#x"), "test 9"); +assert(!Object.prototype.hasOwnProperty.call(C, "#y"), "test 10"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-method-string-literal-names.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-method-string-literal-names.js new file mode 100644 index 0000000000..237438afb9 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-method-string-literal-names.js @@ -0,0 +1,109 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/string-literal-names.case +// - src/class-elements/productions/cls-decl-after-same-line-method.template +/*--- +description: String literal names (field definitions after a method in the same line) +esid: prod-FieldDefinition +features: [class-fields-public, class] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PropertyName + +---*/ + + +class C { + m() { return 42; } 'a'; "b"; 'c' = 39; + "d" = 42; + +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "a"), + "a does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "a"), + "a does not appear as an own property on C constructor" +); + +verifyProperty(c, "a", { + value: undefined, + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "b"), + "b does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "b"), + "b does not appear as an own property on C constructor" +); + +verifyProperty(c, "b", { + value: undefined, + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "c"), + "c does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "c"), + "c does not appear as an own property on C constructor" +); + +verifyProperty(c, "c", { + value: 39, + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "d"), + "d does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "d"), + "d does not appear as an own property on C constructor" +); + +verifyProperty(c, "d", { + value: 42, + enumerable: true, + writable: true, + configurable: true +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-computed-names.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-computed-names.js new file mode 100644 index 0000000000..b35242c6b8 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-computed-names.js @@ -0,0 +1,123 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/computed-names.case +// - src/class-elements/productions/cls-decl-after-same-line-static-async-gen.template +/*--- +description: Computed property names (field definitions after a static async generator in the same line) +esid: prod-FieldDefinition +features: [class-fields-public, computed-property-names, class, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PropertyName + +---*/ +var x = "b"; + + + +class C { + static async *m() { return 42; } [x] = 42; [10] = "meep"; ["not initialized"]; + +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +C.m().next().then(function(v) { + assert.sameValue(v.value, 42); + assert.sameValue(v.done, true); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "b"), + "b doesn't appear as an own property on C prototype" + ); + assert( + !Object.prototype.hasOwnProperty.call(C, "b"), + "b doesn't appear as an own property on C constructor" + ); + + verifyProperty(c, "b", { + value: 42, + enumerable: true, + writable: true, + configurable: true + }); + + assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "x"), + "x doesn't appear as an own property on C prototype" + ); + assert( + !Object.prototype.hasOwnProperty.call(C, "x"), + "x doesn't appear as an own property on C constructor" + ); + assert( + !Object.prototype.hasOwnProperty.call(c, "x"), + "x doesn't appear as an own property on C instance" + ); + + assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "10"), + "10 doesn't appear as an own property on C prototype" + ); + assert( + !Object.prototype.hasOwnProperty.call(C, "10"), + "10 doesn't appear as an own property on C constructor" + ); + + verifyProperty(c, "10", { + value: "meep", + enumerable: true, + writable: true, + configurable: true + }); + + assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "not initialized"), + "'not initialized' doesn't appear as an own property on C prototype" + ); + assert( + !Object.prototype.hasOwnProperty.call(C, "not initialized"), + "'not initialized' doesn't appear as an own property on C constructor" + ); + + verifyProperty(c, "not initialized", { + value: undefined, + enumerable: true, + writable: true, + configurable: true + }); + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-computed-symbol-names.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-computed-symbol-names.js new file mode 100644 index 0000000000..aae8b31c6a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-computed-symbol-names.js @@ -0,0 +1,121 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/computed-symbol-names.case +// - src/class-elements/productions/cls-decl-after-same-line-static-async-gen.template +/*--- +description: Computed property symbol names (field definitions after a static async generator in the same line) +esid: prod-FieldDefinition +features: [class-fields-public, Symbol, computed-property-names, class, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PropertyName + +---*/ +var x = Symbol(); +var y = Symbol(); + + + +class C { + static async *m() { return 42; } [x]; [y] = 42; + +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +C.m().next().then(function(v) { + assert.sameValue(v.value, 42); + assert.sameValue(v.done, true); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert( + !Object.prototype.hasOwnProperty.call(C.prototype, x), + "Symbol x doesn't appear as an own property on C prototype" + ); + assert( + !Object.prototype.hasOwnProperty.call(C, x), + "Symbol x doesn't appear as an own property on C constructor" + ); + + verifyProperty(c, x, { + value: undefined, + enumerable: true, + writable: true, + configurable: true + }); + + assert( + !Object.prototype.hasOwnProperty.call(C.prototype, y), + "Symbol y doesn't appear as an own property on C prototype" + ); + assert( + !Object.prototype.hasOwnProperty.call(C, y), + "Symbol y doesn't appear as an own property on C constructor" + ); + + verifyProperty(c, y, { + value: 42, + enumerable: true, + writable: true, + configurable: true + }); + + assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "x"), + "x doesn't appear as an own property on C prototype" + ); + assert( + !Object.prototype.hasOwnProperty.call(C, "x"), + "x doesn't appear as an own property on C constructor" + ); + assert( + !Object.prototype.hasOwnProperty.call(c, "x"), + "x doesn't appear as an own property on C instance" + ); + + assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "y"), + "y doesn't appear as an own property on C prototype" + ); + assert( + !Object.prototype.hasOwnProperty.call(C, "y"), + "y doesn't appear as an own property on C constructor" + ); + assert( + !Object.prototype.hasOwnProperty.call(c, "y"), + "y doesn't appear as an own property on C instance" + ); + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-grammar-privatename-identifier-semantics-stringvalue.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-grammar-privatename-identifier-semantics-stringvalue.js new file mode 100644 index 0000000000..03f68e5c2d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-grammar-privatename-identifier-semantics-stringvalue.js @@ -0,0 +1,125 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-privatename-identifier-semantics-stringvalue.case +// - src/class-elements/productions/cls-decl-after-same-line-static-async-gen.template +/*--- +description: PrivateName Static Semantics, StringValue (field definitions after a static async generator in the same line) +esid: prod-FieldDefinition +features: [class-fields-private, class, class-fields-public, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + + + 1. Return the String value consisting of the sequence of code + units corresponding to PrivateName. In determining the sequence + any occurrences of \ UnicodeEscapeSequence are first replaced + with the code point represented by the UnicodeEscapeSequence + and then the code points of the entire PrivateName are converted + to code units by UTF16Encoding (10.1.1) each code point. + +---*/ + + +class C { + static async *m() { return 42; } #\u{6F}; + #\u2118; + #ZW_\u200C_NJ; + #ZW_\u200D_J;; + o(value) { + this.#o = value; + return this.#o; + } + ℘(value) { + this.#℘ = value; + return this.#℘; + } + ZW_‌_NJ(value) { // DO NOT CHANGE THE NAME OF THIS METHOD + this.#ZW_‌_NJ = value; + return this.#ZW_‌_NJ; + } + ZW_‍_J(value) { // DO NOT CHANGE THE NAME OF THIS METHOD + this.#ZW_‍_J = value; + return this.#ZW_‍_J; + } +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +C.m().next().then(function(v) { + assert.sameValue(v.value, 42); + assert.sameValue(v.done, true); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert.sameValue(c.o(1), 1); + assert.sameValue(c.℘(1), 1); + assert.sameValue(c.ZW_‌_NJ(1), 1); + assert.sameValue(c.ZW_‍_J(1), 1); + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-literal-names-asi.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-literal-names-asi.js new file mode 100644 index 0000000000..65b1d89ceb --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-literal-names-asi.js @@ -0,0 +1,93 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/literal-names-asi.case +// - src/class-elements/productions/cls-decl-after-same-line-static-async-gen.template +/*--- +description: Literal property names with ASI (field definitions after a static async generator in the same line) +esid: prod-FieldDefinition +features: [class-fields-public, class, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PropertyName + +---*/ + + +class C { + static async *m() { return 42; } a + b = 42;; + +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +C.m().next().then(function(v) { + assert.sameValue(v.value, 42); + assert.sameValue(v.done, true); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "a"), + "a doesn't appear as an own property on C prototype" + ); + assert( + !Object.prototype.hasOwnProperty.call(C, "a"), + "a doesn't appear as an own property on C constructor" + ); + + verifyProperty(c, "a", { + value: undefined, + enumerable: true, + writable: true, + configurable: true + }); + + assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "b"), + "b doesn't appear as an own property on C prototype" + ); + assert( + !Object.prototype.hasOwnProperty.call(C, "b"), + "b doesn't appear as an own property on C constructor" + ); + + verifyProperty(c, "b", { + value: 42, + enumerable: true, + writable: true, + configurable: true + }); + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-literal-names.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-literal-names.js new file mode 100644 index 0000000000..d7b166f66b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-literal-names.js @@ -0,0 +1,112 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/literal-names.case +// - src/class-elements/productions/cls-decl-after-same-line-static-async-gen.template +/*--- +description: Literal property names (field definitions after a static async generator in the same line) +esid: prod-FieldDefinition +features: [class-fields-public, class, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PropertyName + +---*/ +const fn = function() {} + + + +class C { + static async *m() { return 42; } a; b = 42; + c = fn; + +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +C.m().next().then(function(v) { + assert.sameValue(v.value, 42); + assert.sameValue(v.done, true); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "a"), + "a doesn't appear as an own property on C prototype" + ); + assert( + !Object.prototype.hasOwnProperty.call(C, "a"), + "a doesn't appear as an own property on C constructor" + ); + + verifyProperty(c, "a", { + value: undefined, + enumerable: true, + writable: true, + configurable: true + }); + + assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "b"), + "b doesn't appear as an own property on C prototype" + ); + assert( + !Object.prototype.hasOwnProperty.call(C, "b"), + "b doesn't appear as an own property on C constructor" + ); + + verifyProperty(c, "b", { + value: 42, + enumerable: true, + writable: true, + configurable: true + }); + + assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "c"), + "c doesn't appear as an own property on C prototype" + ); + assert( + !Object.prototype.hasOwnProperty.call(C, "c"), + "c doesn't appear as an own property on C constructor" + ); + + verifyProperty(c, "c", { + value: fn, + enumerable: true, + writable: true, + configurable: true + }); + + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-private-field-usage.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-private-field-usage.js new file mode 100644 index 0000000000..b0c07e816e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-private-field-usage.js @@ -0,0 +1,65 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/private-field-usage.case +// - src/class-elements/productions/cls-decl-after-same-line-static-async-gen.template +/*--- +description: PrivateName CallExpression usage (private field) (field definitions after a static async generator in the same line) +esid: prod-FieldDefinition +features: [class-fields-private, class, class-fields-public, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + Updated Productions + + CallExpression[Yield, Await]: + CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await] + SuperCall[?Yield, ?Await] + CallExpression[?Yield, ?Await]Arguments[?Yield, ?Await] + CallExpression[?Yield, ?Await][Expression[+In, ?Yield, ?Await]] + CallExpression[?Yield, ?Await].IdentifierName + CallExpression[?Yield, ?Await]TemplateLiteral[?Yield, ?Await] + CallExpression[?Yield, ?Await].PrivateName + +---*/ + + +class C { + static async *m() { return 42; } #m = 'test262';; + method() { + return this.#m; + } +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +C.m().next().then(function(v) { + assert.sameValue(v.value, 42); + assert.sameValue(v.done, true); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert.sameValue(c.method(), 'test262'); + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-private-method-getter-usage.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-private-method-getter-usage.js new file mode 100644 index 0000000000..5cd30a34b2 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-private-method-getter-usage.js @@ -0,0 +1,65 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/private-method-getter-usage.case +// - src/class-elements/productions/cls-decl-after-same-line-static-async-gen.template +/*--- +description: PrivateName CallExpression usage (Accesor get method) (field definitions after a static async generator in the same line) +esid: prod-FieldDefinition +features: [class-methods-private, class, class-fields-public, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + Updated Productions + + CallExpression[Yield, Await]: + CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await] + SuperCall[?Yield, ?Await] + CallExpression[?Yield, ?Await]Arguments[?Yield, ?Await] + CallExpression[?Yield, ?Await][Expression[+In, ?Yield, ?Await]] + CallExpression[?Yield, ?Await].IdentifierName + CallExpression[?Yield, ?Await]TemplateLiteral[?Yield, ?Await] + CallExpression[?Yield, ?Await].PrivateName + +---*/ + + +class C { + static async *m() { return 42; } get #m() { return 'test262'; }; + method() { + return this.#m; + } +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +C.m().next().then(function(v) { + assert.sameValue(v.value, 42); + assert.sameValue(v.done, true); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert.sameValue(c.method(), 'test262'); + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-private-method-usage.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-private-method-usage.js new file mode 100644 index 0000000000..0d89868a9c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-private-method-usage.js @@ -0,0 +1,65 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/private-method-usage.case +// - src/class-elements/productions/cls-decl-after-same-line-static-async-gen.template +/*--- +description: PrivateName CallExpression usage (private method) (field definitions after a static async generator in the same line) +esid: prod-FieldDefinition +features: [class-methods-private, class, class-fields-public, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + Updated Productions + + CallExpression[Yield, Await]: + CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await] + SuperCall[?Yield, ?Await] + CallExpression[?Yield, ?Await]Arguments[?Yield, ?Await] + CallExpression[?Yield, ?Await][Expression[+In, ?Yield, ?Await]] + CallExpression[?Yield, ?Await].IdentifierName + CallExpression[?Yield, ?Await]TemplateLiteral[?Yield, ?Await] + CallExpression[?Yield, ?Await].PrivateName + +---*/ + + +class C { + static async *m() { return 42; } #m() { return 'test262'; }; + method() { + return this.#m(); + } +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +C.m().next().then(function(v) { + assert.sameValue(v.value, 42); + assert.sameValue(v.done, true); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert.sameValue(c.method(), 'test262'); + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-private-names.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-private-names.js new file mode 100644 index 0000000000..e26beb8ed4 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-private-names.js @@ -0,0 +1,87 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/private-names.case +// - src/class-elements/productions/cls-decl-after-same-line-static-async-gen.template +/*--- +description: private names (field definitions after a static async generator in the same line) +esid: prod-FieldDefinition +features: [class-fields-private, class, class-fields-public, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + ... + FieldDefinition ; + + FieldDefinition : + ClassElementName Initializer_opt + + ClassElementName : + PrivateName + + PrivateName : + # IdentifierName + +---*/ + + +class C { + static async *m() { return 42; } #x; #y; + x() { + this.#x = 42; + return this.#x; + } + y() { + this.#y = 43; + return this.#y; + } +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +C.m().next().then(function(v) { + assert.sameValue(v.value, 42); + assert.sameValue(v.done, true); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + // Test the private fields do not appear as properties before set to value + assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#x"), "test 1"); + assert(!Object.prototype.hasOwnProperty.call(C, "#x"), "test 2"); + assert(!Object.prototype.hasOwnProperty.call(c, "#x"), "test 3"); + + assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#y"), "test 4"); + assert(!Object.prototype.hasOwnProperty.call(C, "#y"), "test 5"); + assert(!Object.prototype.hasOwnProperty.call(c, "#y"), "test 6"); + + // Test if private fields can be sucessfully accessed and set to value + assert.sameValue(c.x(), 42, "test 7"); + assert.sameValue(c.y(), 43, "test 8"); + + // Test the private fields do not appear as properties before after set to value + assert(!Object.prototype.hasOwnProperty.call(c, "#x"), "test 9"); + assert(!Object.prototype.hasOwnProperty.call(c, "#y"), "test 10"); + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-rs-field-identifier-initializer.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-rs-field-identifier-initializer.js new file mode 100644 index 0000000000..4c96073070 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-rs-field-identifier-initializer.js @@ -0,0 +1,103 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-field-identifier-initializer.case +// - src/class-elements/productions/cls-decl-after-same-line-static-async-gen.template +/*--- +description: Valid FieldDefinition (field definitions after a static async generator in the same line) +esid: prod-FieldDefinition +features: [class-fields-public, class, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + ... + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + + PropertyName : + LiteralPropertyName + ComputedPropertyName + + LiteralPropertyName : + IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static async *m() { return 42; } $ = 1; _ = 1; \u{6F} = 1; \u2118 = 1; ZW_\u200C_NJ = 1; ZW_\u200D_J = 1; + +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +C.m().next().then(function(v) { + assert.sameValue(v.value, 42); + assert.sameValue(v.done, true); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert.sameValue(c.$, 1); + assert.sameValue(c._, 1); + assert.sameValue(c.\u{6F}, 1); + assert.sameValue(c.\u2118, 1); + assert.sameValue(c.ZW_\u200C_NJ, 1); + assert.sameValue(c.ZW_\u200D_J, 1); + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-rs-field-identifier.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-rs-field-identifier.js new file mode 100644 index 0000000000..00efefb715 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-rs-field-identifier.js @@ -0,0 +1,110 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-field-identifier.case +// - src/class-elements/productions/cls-decl-after-same-line-static-async-gen.template +/*--- +description: Valid FieldDefinition (field definitions after a static async generator in the same line) +esid: prod-FieldDefinition +features: [class-fields-public, class, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + ... + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + + PropertyName : + LiteralPropertyName + ComputedPropertyName + + LiteralPropertyName : + IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static async *m() { return 42; } $; _; \u{6F}; \u2118; ZW_\u200C_NJ; ZW_\u200D_J; + +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +C.m().next().then(function(v) { + assert.sameValue(v.value, 42); + assert.sameValue(v.done, true); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + c.$ = 1; + c._ = 1; + c.\u{6F} = 1; + c.\u2118 = 1; + c.ZW_\u200C_NJ = 1; + c.ZW_\u200D_J = 1; + + assert.sameValue(c.$, 1); + assert.sameValue(c._, 1); + assert.sameValue(c.\u{6F}, 1); + assert.sameValue(c.\u2118, 1); + assert.sameValue(c.ZW_\u200C_NJ, 1); + assert.sameValue(c.ZW_\u200D_J, 1); + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-rs-private-getter-alt.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-rs-private-getter-alt.js new file mode 100644 index 0000000000..fb12e01736 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-rs-private-getter-alt.js @@ -0,0 +1,144 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-private-getter-alt.case +// - src/class-elements/productions/cls-decl-after-same-line-static-async-gen.template +/*--- +description: Valid PrivateName as private getter (field definitions after a static async generator in the same line) +esid: prod-FieldDefinition +features: [class-methods-private, class-fields-private, class, class-fields-public, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + ... + ; + + MethodDefinition : + ... + get ClassElementName ( ){ FunctionBody } + ... + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static async *m() { return 42; } #$_; #__; #\u{6F}_; #℘_; #ZW_‌_NJ_; #ZW_‍_J_; + get #$() { + return this.#$_; + } + get #_() { + return this.#__; + } + get #\u{6F}() { + return this.#\u{6F}_; + } + get #℘() { + return this.#℘_; + } + get #ZW_‌_NJ() { + return this.#ZW_‌_NJ_; + } + get #ZW_‍_J() { + return this.#ZW_‍_J_; + } +; + $(value) { + this.#$_ = value; + return this.#$; + } + _(value) { + this.#__ = value; + return this.#_; + } + \u{6F}(value) { + this.#\u{6F}_ = value; + return this.#\u{6F}; + } + ℘(value) { + this.#℘_ = value; + return this.#℘; + } + ZW_‌_NJ(value) { + this.#ZW_‌_NJ_ = value; + return this.#ZW_‌_NJ; + } + ZW_‍_J(value) { + this.#ZW_‍_J_ = value; + return this.#ZW_‍_J; + } + +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +C.m().next().then(function(v) { + assert.sameValue(v.value, 42); + assert.sameValue(v.done, true); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert.sameValue(c.$(1), 1); + assert.sameValue(c._(1), 1); + assert.sameValue(c.\u{6F}(1), 1); + assert.sameValue(c.℘(1), 1); + assert.sameValue(c.ZW_‌_NJ(1), 1); + assert.sameValue(c.ZW_‍_J(1), 1); + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-rs-private-getter.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-rs-private-getter.js new file mode 100644 index 0000000000..87bd8dd98d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-rs-private-getter.js @@ -0,0 +1,144 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-private-getter.case +// - src/class-elements/productions/cls-decl-after-same-line-static-async-gen.template +/*--- +description: Valid PrivateName as private getter (field definitions after a static async generator in the same line) +esid: prod-FieldDefinition +features: [class-methods-private, class-fields-private, class, class-fields-public, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + ... + ; + + MethodDefinition : + ... + get ClassElementName ( ){ FunctionBody } + ... + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static async *m() { return 42; } #$_; #__; #\u{6F}_; #\u2118_; #ZW_\u200C_NJ_; #ZW_\u200D_J_; + get #$() { + return this.#$_; + } + get #_() { + return this.#__; + } + get #\u{6F}() { + return this.#\u{6F}_; + } + get #\u2118() { + return this.#\u2118_; + } + get #ZW_\u200C_NJ() { + return this.#ZW_\u200C_NJ_; + } + get #ZW_\u200D_J() { + return this.#ZW_\u200D_J_; + } +; + $(value) { + this.#$_ = value; + return this.#$; + } + _(value) { + this.#__ = value; + return this.#_; + } + \u{6F}(value) { + this.#\u{6F}_ = value; + return this.#\u{6F}; + } + \u2118(value) { + this.#\u2118_ = value; + return this.#\u2118; + } + ZW_\u200C_NJ(value) { + this.#ZW_\u200C_NJ_ = value; + return this.#ZW_\u200C_NJ; + } + ZW_\u200D_J(value) { + this.#ZW_\u200D_J_ = value; + return this.#ZW_\u200D_J; + } + +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +C.m().next().then(function(v) { + assert.sameValue(v.value, 42); + assert.sameValue(v.done, true); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert.sameValue(c.$(1), 1); + assert.sameValue(c._(1), 1); + assert.sameValue(c.\u{6F}(1), 1); + assert.sameValue(c.\u2118(1), 1); + assert.sameValue(c.ZW_\u200C_NJ(1), 1); + assert.sameValue(c.ZW_\u200D_J(1), 1); + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-rs-private-method-alt.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-rs-private-method-alt.js new file mode 100644 index 0000000000..bd308a9e5b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-rs-private-method-alt.js @@ -0,0 +1,143 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-private-method-alt.case +// - src/class-elements/productions/cls-decl-after-same-line-static-async-gen.template +/*--- +description: Valid PrivateName as private method (field definitions after a static async generator in the same line) +esid: prod-FieldDefinition +features: [class-methods-private, class-fields-private, class, class-fields-public, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + ... + ; + + MethodDefinition : + ClassElementName ( UniqueFormalParameters ) { FunctionBody } + ... + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static async *m() { return 42; } #$_; #__; #\u{6F}_; #℘_; #ZW_‌_NJ_; #ZW_‍_J_; + #$() { + return this.#$_; + } + #_() { + return this.#__; + } + #\u{6F}() { + return this.#\u{6F}_; + } + #℘() { + return this.#℘_; + } + #ZW_‌_NJ() { + return this.#ZW_‌_NJ_; + } + #ZW_‍_J() { + return this.#ZW_‍_J_; + } +; + $(value) { + this.#$_ = value; + return this.#$(); + } + _(value) { + this.#__ = value; + return this.#_(); + } + \u{6F}(value) { + this.#\u{6F}_ = value; + return this.#\u{6F}(); + } + ℘(value) { + this.#℘_ = value; + return this.#℘(); + } + ZW_‌_NJ(value) { + this.#ZW_‌_NJ_ = value; + return this.#ZW_‌_NJ(); + } + ZW_‍_J(value) { + this.#ZW_‍_J_ = value; + return this.#ZW_‍_J(); + } + +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +C.m().next().then(function(v) { + assert.sameValue(v.value, 42); + assert.sameValue(v.done, true); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert.sameValue(c.$(1), 1); + assert.sameValue(c._(1), 1); + assert.sameValue(c.\u{6F}(1), 1); + assert.sameValue(c.℘(1), 1); + assert.sameValue(c.ZW_‌_NJ(1), 1); + assert.sameValue(c.ZW_‍_J(1), 1); + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-rs-private-method.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-rs-private-method.js new file mode 100644 index 0000000000..0da6b2f5c9 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-rs-private-method.js @@ -0,0 +1,143 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-private-method.case +// - src/class-elements/productions/cls-decl-after-same-line-static-async-gen.template +/*--- +description: Valid PrivateName as private method (field definitions after a static async generator in the same line) +esid: prod-FieldDefinition +features: [class-methods-private, class-fields-private, class, class-fields-public, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + ... + ; + + MethodDefinition : + ClassElementName ( UniqueFormalParameters ) { FunctionBody } + ... + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static async *m() { return 42; } #$_; #__; #\u{6F}_; #\u2118_; #ZW_\u200C_NJ_; #ZW_\u200D_J_; + #$() { + return this.#$_; + } + #_() { + return this.#__; + } + #\u{6F}() { + return this.#\u{6F}_; + } + #\u2118() { + return this.#\u2118_; + } + #ZW_\u200C_NJ() { + return this.#ZW_\u200C_NJ_; + } + #ZW_\u200D_J() { + return this.#ZW_\u200D_J_; + } +; + $(value) { + this.#$_ = value; + return this.#$(); + } + _(value) { + this.#__ = value; + return this.#_(); + } + \u{6F}(value) { + this.#\u{6F}_ = value; + return this.#\u{6F}(); + } + \u2118(value) { + this.#\u2118_ = value; + return this.#\u2118(); + } + ZW_\u200C_NJ(value) { + this.#ZW_\u200C_NJ_ = value; + return this.#ZW_\u200C_NJ(); + } + ZW_\u200D_J(value) { + this.#ZW_\u200D_J_ = value; + return this.#ZW_\u200D_J(); + } + +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +C.m().next().then(function(v) { + assert.sameValue(v.value, 42); + assert.sameValue(v.done, true); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert.sameValue(c.$(1), 1); + assert.sameValue(c._(1), 1); + assert.sameValue(c.\u{6F}(1), 1); + assert.sameValue(c.\u2118(1), 1); + assert.sameValue(c.ZW_\u200C_NJ(1), 1); + assert.sameValue(c.ZW_\u200D_J(1), 1); + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-rs-private-setter-alt.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-rs-private-setter-alt.js new file mode 100644 index 0000000000..5a836942f5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-rs-private-setter-alt.js @@ -0,0 +1,143 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-private-setter-alt.case +// - src/class-elements/productions/cls-decl-after-same-line-static-async-gen.template +/*--- +description: Valid PrivateName as private setter (field definitions after a static async generator in the same line) +esid: prod-FieldDefinition +features: [class-methods-private, class-fields-private, class, class-fields-public, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + ... + ; + + MethodDefinition : + ... + set ClassElementName ( PropertySetParameterList ) { FunctionBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static async *m() { return 42; } #$_; #__; #\u{6F}_; #℘_; #ZW_‌_NJ_; #ZW_‍_J_; + set #$(value) { + this.#$_ = value; + } + set #_(value) { + this.#__ = value; + } + set #\u{6F}(value) { + this.#\u{6F}_ = value; + } + set #℘(value) { + this.#℘_ = value; + } + set #ZW_‌_NJ(value) { + this.#ZW_‌_NJ_ = value; + } + set #ZW_‍_J(value) { + this.#ZW_‍_J_ = value; + } +; + $(value) { + this.#$ = value; + return this.#$_; + } + _(value) { + this.#_ = value; + return this.#__; + } + \u{6F}(value) { + this.#\u{6F} = value; + return this.#\u{6F}_; + } + ℘(value) { + this.#℘ = value; + return this.#℘_; + } + ZW_‌_NJ(value) { + this.#ZW_‌_NJ = value; + return this.#ZW_‌_NJ_; + } + ZW_‍_J(value) { + this.#ZW_‍_J = value; + return this.#ZW_‍_J_; + } + +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +C.m().next().then(function(v) { + assert.sameValue(v.value, 42); + assert.sameValue(v.done, true); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert.sameValue(c.$(1), 1); + assert.sameValue(c._(1), 1); + assert.sameValue(c.\u{6F}(1), 1); + assert.sameValue(c.℘(1), 1); + assert.sameValue(c.ZW_‌_NJ(1), 1); + assert.sameValue(c.ZW_‍_J(1), 1); + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-rs-private-setter.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-rs-private-setter.js new file mode 100644 index 0000000000..fed08f1199 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-rs-private-setter.js @@ -0,0 +1,143 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-private-setter.case +// - src/class-elements/productions/cls-decl-after-same-line-static-async-gen.template +/*--- +description: Valid PrivateName as private setter (field definitions after a static async generator in the same line) +esid: prod-FieldDefinition +features: [class-methods-private, class-fields-private, class, class-fields-public, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + ... + ; + + MethodDefinition : + ... + set ClassElementName ( PropertySetParameterList ) { FunctionBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static async *m() { return 42; } #$_; #__; #\u{6F}_; #\u2118_; #ZW_\u200C_NJ_; #ZW_\u200D_J_; + set #$(value) { + this.#$_ = value; + } + set #_(value) { + this.#__ = value; + } + set #\u{6F}(value) { + this.#\u{6F}_ = value; + } + set #\u2118(value) { + this.#\u2118_ = value; + } + set #ZW_\u200C_NJ(value) { + this.#ZW_\u200C_NJ_ = value; + } + set #ZW_\u200D_J(value) { + this.#ZW_\u200D_J_ = value; + } +; + $(value) { + this.#$ = value; + return this.#$_; + } + _(value) { + this.#_ = value; + return this.#__; + } + \u{6F}(value) { + this.#\u{6F} = value; + return this.#\u{6F}_; + } + \u2118(value) { + this.#\u2118 = value; + return this.#\u2118_; + } + ZW_\u200C_NJ(value) { + this.#ZW_\u200C_NJ = value; + return this.#ZW_\u200C_NJ_; + } + ZW_\u200D_J(value) { + this.#ZW_\u200D_J = value; + return this.#ZW_\u200D_J_; + } + +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +C.m().next().then(function(v) { + assert.sameValue(v.value, 42); + assert.sameValue(v.done, true); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert.sameValue(c.$(1), 1); + assert.sameValue(c._(1), 1); + assert.sameValue(c.\u{6F}(1), 1); + assert.sameValue(c.\u2118(1), 1); + assert.sameValue(c.ZW_\u200C_NJ(1), 1); + assert.sameValue(c.ZW_\u200D_J(1), 1); + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-rs-privatename-identifier-alt.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-rs-privatename-identifier-alt.js new file mode 100644 index 0000000000..66df105495 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-rs-privatename-identifier-alt.js @@ -0,0 +1,125 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-privatename-identifier-alt.case +// - src/class-elements/productions/cls-decl-after-same-line-static-async-gen.template +/*--- +description: Valid PrivateName (field definitions after a static async generator in the same line) +esid: prod-FieldDefinition +features: [class-fields-private, class, class-fields-public, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static async *m() { return 42; } #$; #_; #\u{6F}; #℘; #ZW_‌_NJ; #ZW_‍_J; + $(value) { + this.#$ = value; + return this.#$; + } + _(value) { + this.#_ = value; + return this.#_; + } + \u{6F}(value) { + this.#\u{6F} = value; + return this.#\u{6F}; + } + ℘(value) { + this.#℘ = value; + return this.#℘; + } + ZW_‌_NJ(value) { + this.#ZW_‌_NJ = value; + return this.#ZW_‌_NJ; + } + ZW_‍_J(value) { + this.#ZW_‍_J = value; + return this.#ZW_‍_J; + } +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +C.m().next().then(function(v) { + assert.sameValue(v.value, 42); + assert.sameValue(v.done, true); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert.sameValue(c.$(1), 1); + assert.sameValue(c._(1), 1); + assert.sameValue(c.\u{6F}(1), 1); + assert.sameValue(c.℘(1), 1); + assert.sameValue(c.ZW_‌_NJ(1), 1); + assert.sameValue(c.ZW_‍_J(1), 1); + + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-rs-privatename-identifier-initializer-alt.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-rs-privatename-identifier-initializer-alt.js new file mode 100644 index 0000000000..7f9f67af2e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-rs-privatename-identifier-initializer-alt.js @@ -0,0 +1,119 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-privatename-identifier-initializer-alt.case +// - src/class-elements/productions/cls-decl-after-same-line-static-async-gen.template +/*--- +description: Valid PrivateName (field definitions after a static async generator in the same line) +esid: prod-FieldDefinition +features: [class-fields-private, class, class-fields-public, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static async *m() { return 42; } #$ = 1; #_ = 1; #\u{6F} = 1; #℘ = 1; #ZW_‌_NJ = 1; #ZW_‍_J = 1; + $() { + return this.#$; + } + _() { + return this.#_; + } + \u{6F}() { + return this.#\u{6F}; + } + ℘() { + return this.#℘; + } + ZW_‌_NJ() { + return this.#ZW_‌_NJ; + } + ZW_‍_J() { + return this.#ZW_‍_J; + } +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +C.m().next().then(function(v) { + assert.sameValue(v.value, 42); + assert.sameValue(v.done, true); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert.sameValue(c.$(), 1); + assert.sameValue(c._(), 1); + assert.sameValue(c.\u{6F}(), 1); + assert.sameValue(c.℘(), 1); + assert.sameValue(c.ZW_‌_NJ(), 1); + assert.sameValue(c.ZW_‍_J(), 1); + + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-rs-privatename-identifier-initializer.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-rs-privatename-identifier-initializer.js new file mode 100644 index 0000000000..7c288c4d25 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-rs-privatename-identifier-initializer.js @@ -0,0 +1,119 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-privatename-identifier-initializer.case +// - src/class-elements/productions/cls-decl-after-same-line-static-async-gen.template +/*--- +description: Valid PrivateName (field definitions after a static async generator in the same line) +esid: prod-FieldDefinition +features: [class-fields-private, class, class-fields-public, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static async *m() { return 42; } #$ = 1; #_ = 1; #\u{6F} = 1; #\u2118 = 1; #ZW_\u200C_NJ = 1; #ZW_\u200D_J = 1; + $() { + return this.#$; + } + _() { + return this.#_; + } + \u{6F}() { + return this.#\u{6F}; + } + \u2118() { + return this.#\u2118; + } + ZW_\u200C_NJ() { + return this.#ZW_\u200C_NJ; + } + ZW_\u200D_J() { + return this.#ZW_\u200D_J; + } +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +C.m().next().then(function(v) { + assert.sameValue(v.value, 42); + assert.sameValue(v.done, true); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert.sameValue(c.$(), 1); + assert.sameValue(c._(), 1); + assert.sameValue(c.\u{6F}(), 1); + assert.sameValue(c.\u2118(), 1); + assert.sameValue(c.ZW_\u200C_NJ(), 1); + assert.sameValue(c.ZW_\u200D_J(), 1); + + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-rs-privatename-identifier.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-rs-privatename-identifier.js new file mode 100644 index 0000000000..2444782434 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-rs-privatename-identifier.js @@ -0,0 +1,125 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-privatename-identifier.case +// - src/class-elements/productions/cls-decl-after-same-line-static-async-gen.template +/*--- +description: Valid PrivateName (field definitions after a static async generator in the same line) +esid: prod-FieldDefinition +features: [class-fields-private, class, class-fields-public, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static async *m() { return 42; } #$; #_; #\u{6F}; #\u2118; #ZW_\u200C_NJ; #ZW_\u200D_J; + $(value) { + this.#$ = value; + return this.#$; + } + _(value) { + this.#_ = value; + return this.#_; + } + \u{6F}(value) { + this.#\u{6F} = value; + return this.#\u{6F}; + } + \u2118(value) { + this.#\u2118 = value; + return this.#\u2118; + } + ZW_\u200C_NJ(value) { + this.#ZW_\u200C_NJ = value; + return this.#ZW_\u200C_NJ; + } + ZW_\u200D_J(value) { + this.#ZW_\u200D_J = value; + return this.#ZW_\u200D_J; + } +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +C.m().next().then(function(v) { + assert.sameValue(v.value, 42); + assert.sameValue(v.done, true); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert.sameValue(c.$(1), 1); + assert.sameValue(c._(1), 1); + assert.sameValue(c.\u{6F}(1), 1); + assert.sameValue(c.\u2118(1), 1); + assert.sameValue(c.ZW_\u200C_NJ(1), 1); + assert.sameValue(c.ZW_\u200D_J(1), 1); + + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-rs-static-async-generator-method-privatename-identifier-alt.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-rs-static-async-generator-method-privatename-identifier-alt.js new file mode 100644 index 0000000000..41d3335fbe --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-rs-static-async-generator-method-privatename-identifier-alt.js @@ -0,0 +1,151 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-async-generator-method-privatename-identifier-alt.case +// - src/class-elements/productions/cls-decl-after-same-line-static-async-gen.template +/*--- +description: Valid Static AsyncGeneratorMethod PrivateName (field definitions after a static async generator in the same line) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + AsyncGeneratorMethod + + AsyncGeneratorMethod : + async [no LineTerminator here] * ClassElementName ( UniqueFormalParameters){ AsyncGeneratorBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static async *m() { return 42; } static async * #$(value) { + yield * await value; + } + static async * #_(value) { + yield * await value; + } + static async * #o(value) { + yield * await value; + } + static async * #℘(value) { + yield * await value; + } + static async * #ZW_‌_NJ(value) { + yield * await value; + } + static async * #ZW_‍_J(value) { + yield * await value; + }; + static get $() { + return this.#$; + } + static get _() { + return this.#_; + } + static get o() { + return this.#o; + } + static get ℘() { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#℘; + } + static get ZW_‌_NJ() { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#ZW_‌_NJ; + } + static get ZW_‍_J() { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#ZW_‍_J; + } + +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +C.m().next().then(function(v) { + assert.sameValue(v.value, 42); + assert.sameValue(v.done, true); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + Promise.all([ + C.$([1]).next(), + C._([1]).next(), + C.o([1]).next(), + C.℘([1]).next(), // DO NOT CHANGE THE NAME OF THIS FIELD + C.ZW_‌_NJ([1]).next(), // DO NOT CHANGE THE NAME OF THIS FIELD + C.ZW_‍_J([1]).next(), // DO NOT CHANGE THE NAME OF THIS FIELD + ]).then(results => { + + assert.sameValue(results[0].value, 1); + assert.sameValue(results[1].value, 1); + assert.sameValue(results[2].value, 1); + assert.sameValue(results[3].value, 1); + assert.sameValue(results[4].value, 1); + assert.sameValue(results[5].value, 1); + + }).then($DONE, $DONE); + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-rs-static-async-generator-method-privatename-identifier.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-rs-static-async-generator-method-privatename-identifier.js new file mode 100644 index 0000000000..b9b0312fcd --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-rs-static-async-generator-method-privatename-identifier.js @@ -0,0 +1,152 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-async-generator-method-privatename-identifier.case +// - src/class-elements/productions/cls-decl-after-same-line-static-async-gen.template +/*--- +description: Valid Static AsyncGeneratorMethod PrivateName (field definitions after a static async generator in the same line) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + AsyncGeneratorMethod + + AsyncGeneratorMethod : + async [no LineTerminator here] * ClassElementName ( UniqueFormalParameters){ AsyncGeneratorBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static async *m() { return 42; } static async * #$(value) { + yield * await value; + } + static async * #_(value) { + yield * await value; + } + static async * #\u{6F}(value) { + yield * await value; + } + static async * #\u2118(value) { + yield * await value; + } + static async * #ZW_\u200C_NJ(value) { + yield * await value; + } + static async * #ZW_\u200D_J(value) { + yield * await value; + }; + static get $() { + return this.#$; + } + static get _() { + return this.#_; + } + static get \u{6F}() { + return this.#\u{6F}; + } + static get \u2118() { + return this.#\u2118; + } + static get ZW_\u200C_NJ() { + return this.#ZW_\u200C_NJ; + } + static get ZW_\u200D_J() { + return this.#ZW_\u200D_J; + } + +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +C.m().next().then(function(v) { + assert.sameValue(v.value, 42); + assert.sameValue(v.done, true); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + Promise.all([ + C.$([1]).next(), + C._([1]).next(), + C.\u{6F}([1]).next(), + C.\u2118([1]).next(), + C.ZW_\u200C_NJ([1]).next(), + C.ZW_\u200D_J([1]).next(), + ]).then(results => { + + assert.sameValue(results[0].value, 1); + assert.sameValue(results[1].value, 1); + assert.sameValue(results[2].value, 1); + assert.sameValue(results[3].value, 1); + assert.sameValue(results[4].value, 1); + assert.sameValue(results[5].value, 1); + + }).then($DONE, $DONE); + + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-rs-static-async-method-privatename-identifier-alt.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-rs-static-async-method-privatename-identifier-alt.js new file mode 100644 index 0000000000..c8393918b5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-rs-static-async-method-privatename-identifier-alt.js @@ -0,0 +1,151 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-async-method-privatename-identifier-alt.case +// - src/class-elements/productions/cls-decl-after-same-line-static-async-gen.template +/*--- +description: Valid Static AsyncMethod PrivateName (field definitions after a static async generator in the same line) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + AsyncMethod + + AsyncMethod : + async [no LineTerminator here] ClassElementName ( UniqueFormalParameters ){ AsyncFunctionBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static async *m() { return 42; } static async #$(value) { + return await value; + } + static async #_(value) { + return await value; + } + static async #o(value) { + return await value; + } + static async #℘(value) { + return await value; + } + static async #ZW_‌_NJ(value) { + return await value; + } + static async #ZW_‍_J(value) { + return await value; + }; + static async $(value) { + return await this.#$(value); + } + static async _(value) { + return await this.#_(value); + } + static async o(value) { + return await this.#o(value); + } + static async ℘(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + return await this.#℘(value); + } + static async ZW_‌_NJ(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + return await this.#ZW_‌_NJ(value); + } + static async ZW_‍_J(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + return await this.#ZW_‍_J(value); + } + +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +C.m().next().then(function(v) { + assert.sameValue(v.value, 42); + assert.sameValue(v.done, true); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + Promise.all([ + C.$(1), + C._(1), + C.o(1), + C.℘(1), // DO NOT CHANGE THE NAME OF THIS FIELD + C.ZW_‌_NJ(1), // DO NOT CHANGE THE NAME OF THIS FIELD + C.ZW_‍_J(1), // DO NOT CHANGE THE NAME OF THIS FIELD + ]).then(results => { + + assert.sameValue(results[0], 1); + assert.sameValue(results[1], 1); + assert.sameValue(results[2], 1); + assert.sameValue(results[3], 1); + assert.sameValue(results[4], 1); + assert.sameValue(results[5], 1); + + }).then($DONE, $DONE); + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-rs-static-async-method-privatename-identifier.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-rs-static-async-method-privatename-identifier.js new file mode 100644 index 0000000000..9d5dda52d9 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-rs-static-async-method-privatename-identifier.js @@ -0,0 +1,152 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-async-method-privatename-identifier.case +// - src/class-elements/productions/cls-decl-after-same-line-static-async-gen.template +/*--- +description: Valid Static AsyncMethod PrivateName (field definitions after a static async generator in the same line) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + AsyncMethod + + AsyncMethod : + async [no LineTerminator here] ClassElementName ( UniqueFormalParameters ){ AsyncFunctionBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static async *m() { return 42; } static async #$(value) { + return await value; + } + static async #_(value) { + return await value; + } + static async #\u{6F}(value) { + return await value; + } + static async #\u2118(value) { + return await value; + } + static async #ZW_\u200C_NJ(value) { + return await value; + } + static async #ZW_\u200D_J(value) { + return await value; + }; + static async $(value) { + return await this.#$(value); + } + static async _(value) { + return await this.#_(value); + } + static async \u{6F}(value) { + return await this.#\u{6F}(value); + } + static async \u2118(value) { + return await this.#\u2118(value); + } + static async ZW_\u200C_NJ(value) { + return await this.#ZW_\u200C_NJ(value); + } + static async ZW_\u200D_J(value) { + return await this.#ZW_\u200D_J(value); + } + +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +C.m().next().then(function(v) { + assert.sameValue(v.value, 42); + assert.sameValue(v.done, true); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + Promise.all([ + C.$(1), + C._(1), + C.\u{6F}(1), + C.\u2118(1), + C.ZW_\u200C_NJ(1), + C.ZW_\u200D_J(1), + ]).then(results => { + + assert.sameValue(results[0], 1); + assert.sameValue(results[1], 1); + assert.sameValue(results[2], 1); + assert.sameValue(results[3], 1); + assert.sameValue(results[4], 1); + assert.sameValue(results[5], 1); + + }).then($DONE, $DONE); + + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-rs-static-generator-method-privatename-identifier-alt.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-rs-static-generator-method-privatename-identifier-alt.js new file mode 100644 index 0000000000..761cece4b6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-rs-static-generator-method-privatename-identifier-alt.js @@ -0,0 +1,140 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-generator-method-privatename-identifier-alt.case +// - src/class-elements/productions/cls-decl-after-same-line-static-async-gen.template +/*--- +description: Valid Static GeneratorMethod PrivateName (field definitions after a static async generator in the same line) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + GeneratorMethod + + GeneratorMethod : + * ClassElementName ( UniqueFormalParameters ){ GeneratorBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static async *m() { return 42; } static * #$(value) { + yield * value; + } + static * #_(value) { + yield * value; + } + static * #o(value) { + yield * value; + } + static * #℘(value) { + yield * value; + } + static * #ZW_‌_NJ(value) { + yield * value; + } + static * #ZW_‍_J(value) { + yield * value; + }; + static get $() { + return this.#$; + } + static get _() { + return this.#_; + } + static get o() { + return this.#o; + } + static get ℘() { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#℘; + } + static get ZW_‌_NJ() { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#ZW_‌_NJ; + } + static get ZW_‍_J() { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#ZW_‍_J; + } + +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +C.m().next().then(function(v) { + assert.sameValue(v.value, 42); + assert.sameValue(v.done, true); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert.sameValue(C.$([1]).next().value, 1); + assert.sameValue(C._([1]).next().value, 1); + assert.sameValue(C.o([1]).next().value, 1); + assert.sameValue(C.℘([1]).next().value, 1); + assert.sameValue(C.ZW_‌_NJ([1]).next().value, 1); + assert.sameValue(C.ZW_‍_J([1]).next().value, 1); + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-rs-static-generator-method-privatename-identifier.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-rs-static-generator-method-privatename-identifier.js new file mode 100644 index 0000000000..3ea2b56719 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-rs-static-generator-method-privatename-identifier.js @@ -0,0 +1,141 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-generator-method-privatename-identifier.case +// - src/class-elements/productions/cls-decl-after-same-line-static-async-gen.template +/*--- +description: Valid Static GeneratorMethod PrivateName (field definitions after a static async generator in the same line) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + GeneratorMethod + + GeneratorMethod : + * ClassElementName ( UniqueFormalParameters ){ GeneratorBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static async *m() { return 42; } static * #$(value) { + yield * value; + } + static * #_(value) { + yield * value; + } + static * #\u{6F}(value) { + yield * value; + } + static * #\u2118(value) { + yield * value; + } + static * #ZW_\u200C_NJ(value) { + yield * value; + } + static * #ZW_\u200D_J(value) { + yield * value; + }; + static get $() { + return this.#$; + } + static get _() { + return this.#_; + } + static get \u{6F}() { + return this.#\u{6F}; + } + static get \u2118() { + return this.#\u2118; + } + static get ZW_\u200C_NJ() { + return this.#ZW_\u200C_NJ; + } + static get ZW_\u200D_J() { + return this.#ZW_\u200D_J; + } + +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +C.m().next().then(function(v) { + assert.sameValue(v.value, 42); + assert.sameValue(v.done, true); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert.sameValue(C.$([1]).next().value, 1); + assert.sameValue(C._([1]).next().value, 1); + assert.sameValue(C.\u{6F}([1]).next().value, 1); + assert.sameValue(C.\u2118([1]).next().value, 1); + assert.sameValue(C.ZW_\u200C_NJ([1]).next().value, 1); + assert.sameValue(C.ZW_\u200D_J([1]).next().value, 1); + + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-rs-static-method-privatename-identifier-alt.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-rs-static-method-privatename-identifier-alt.js new file mode 100644 index 0000000000..91f9274f4b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-rs-static-method-privatename-identifier-alt.js @@ -0,0 +1,138 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-method-privatename-identifier-alt.case +// - src/class-elements/productions/cls-decl-after-same-line-static-async-gen.template +/*--- +description: Valid Static Method PrivateName (field definitions after a static async generator in the same line) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + ClassElementName ( UniqueFormalParameters ){ FunctionBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static async *m() { return 42; } static #$(value) { + return value; + } + static #_(value) { + return value; + } + static #o(value) { + return value; + } + static #℘(value) { + return value; + } + static #ZW_‌_NJ(value) { + return value; + } + static #ZW_‍_J(value) { + return value; + }; + static $(value) { + return this.#$(value); + } + static _(value) { + return this.#_(value); + } + static o(value) { + return this.#o(value); + } + static ℘(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#℘(value); + } + static ZW_‌_NJ(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#ZW_‌_NJ(value); + } + static ZW_‍_J(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#ZW_‍_J(value); + } + +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +C.m().next().then(function(v) { + assert.sameValue(v.value, 42); + assert.sameValue(v.done, true); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert.sameValue(C.$(1), 1); + assert.sameValue(C._(1), 1); + assert.sameValue(C.o(1), 1); + assert.sameValue(C.℘(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD + assert.sameValue(C.ZW_‌_NJ(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD + assert.sameValue(C.ZW_‍_J(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD + + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-rs-static-method-privatename-identifier.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-rs-static-method-privatename-identifier.js new file mode 100644 index 0000000000..a7bf117c42 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-rs-static-method-privatename-identifier.js @@ -0,0 +1,138 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-method-privatename-identifier.case +// - src/class-elements/productions/cls-decl-after-same-line-static-async-gen.template +/*--- +description: Valid Static Method PrivateName (field definitions after a static async generator in the same line) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + ClassElementName ( UniqueFormalParameters ){ FunctionBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static async *m() { return 42; } static #$(value) { + return value; + } + static #_(value) { + return value; + } + static #\u{6F}(value) { + return value; + } + static #\u2118(value) { + return value; + } + static #ZW_\u200C_NJ(value) { + return value; + } + static #ZW_\u200D_J(value) { + return value; + }; + static $(value) { + return this.#$(value); + } + static _(value) { + return this.#_(value); + } + static \u{6F}(value) { + return this.#\u{6F}(value); + } + static \u2118(value) { + return this.#\u2118(value); + } + static ZW_\u200C_NJ(value) { + return this.#ZW_\u200C_NJ(value); + } + static ZW_\u200D_J(value) { + return this.#ZW_\u200D_J(value); + } + +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +C.m().next().then(function(v) { + assert.sameValue(v.value, 42); + assert.sameValue(v.done, true); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert.sameValue(C.$(1), 1); + assert.sameValue(C._(1), 1); + assert.sameValue(C.\u{6F}(1), 1); + assert.sameValue(C.\u2118(1), 1); + assert.sameValue(C.ZW_\u200C_NJ(1), 1); + assert.sameValue(C.ZW_\u200D_J(1), 1); + + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-rs-static-privatename-identifier-alt-by-classname.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-rs-static-privatename-identifier-alt-by-classname.js new file mode 100644 index 0000000000..0f77e9e8eb --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-rs-static-privatename-identifier-alt-by-classname.js @@ -0,0 +1,126 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-privatename-identifier-alt-by-classname.case +// - src/class-elements/productions/cls-decl-after-same-line-static-async-gen.template +/*--- +description: Valid Static PrivateName (field definitions after a static async generator in the same line) +esid: prod-FieldDefinition +features: [class-static-fields-private, class, class-fields-public, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static async *m() { return 42; } static #$; static #_; static #\u{6F}; static #℘; static #ZW_‌_NJ; static #ZW_‍_J; + static $(value) { + C.#$ = value; + return C.#$; + } + static _(value) { + C.#_ = value; + return C.#_; + } + static o(value) { + C.#\u{6F} = value; + return C.#\u{6F}; + } + static ℘(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + C.#℘ = value; + return C.#℘; + } + static ZW_‌_NJ(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + C.#ZW_‌_NJ = value; + return C.#ZW_‌_NJ; + } + static ZW_‍_J(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + C.#ZW_‍_J = value; + return C.#ZW_‍_J; + } +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +C.m().next().then(function(v) { + assert.sameValue(v.value, 42); + assert.sameValue(v.done, true); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert.sameValue(C.$(1), 1); + assert.sameValue(C._(1), 1); + assert.sameValue(C.o(1), 1); + assert.sameValue(C.℘(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD + assert.sameValue(C.ZW_‌_NJ(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD + assert.sameValue(C.ZW_‍_J(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD + + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-rs-static-privatename-identifier-alt.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-rs-static-privatename-identifier-alt.js new file mode 100644 index 0000000000..ae45b1641c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-rs-static-privatename-identifier-alt.js @@ -0,0 +1,126 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-privatename-identifier-alt.case +// - src/class-elements/productions/cls-decl-after-same-line-static-async-gen.template +/*--- +description: Valid Static PrivateName (field definitions after a static async generator in the same line) +esid: prod-FieldDefinition +features: [class-static-fields-private, class, class-fields-public, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static async *m() { return 42; } static #$; static #_; static #\u{6F}; static #℘; static #ZW_‌_NJ; static #ZW_‍_J; + static $(value) { + this.#$ = value; + return this.#$; + } + static _(value) { + this.#_ = value; + return this.#_; + } + static o(value) { + this.#\u{6F} = value; + return this.#\u{6F}; + } + static ℘(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + this.#℘ = value; + return this.#℘; + } + static ZW_‌_NJ(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + this.#ZW_‌_NJ = value; + return this.#ZW_‌_NJ; + } + static ZW_‍_J(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + this.#ZW_‍_J = value; + return this.#ZW_‍_J; + } +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +C.m().next().then(function(v) { + assert.sameValue(v.value, 42); + assert.sameValue(v.done, true); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert.sameValue(C.$(1), 1); + assert.sameValue(C._(1), 1); + assert.sameValue(C.o(1), 1); + assert.sameValue(C.℘(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD + assert.sameValue(C.ZW_‌_NJ(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD + assert.sameValue(C.ZW_‍_J(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD + + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-rs-static-privatename-identifier-by-classname.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-rs-static-privatename-identifier-by-classname.js new file mode 100644 index 0000000000..5f13adfca2 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-rs-static-privatename-identifier-by-classname.js @@ -0,0 +1,126 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-privatename-identifier-by-classname.case +// - src/class-elements/productions/cls-decl-after-same-line-static-async-gen.template +/*--- +description: Valid Static PrivateName (field definitions after a static async generator in the same line) +esid: prod-FieldDefinition +features: [class-static-fields-private, class, class-fields-public, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static async *m() { return 42; } static #$; static #_; static #\u{6F}; static #\u2118; static #ZW_\u200C_NJ; static #ZW_\u200D_J; + static $(value) { + C.#$ = value; + return C.#$; + } + static _(value) { + C.#_ = value; + return C.#_; + } + static \u{6F}(value) { + C.#\u{6F} = value; + return C.#\u{6F}; + } + static \u2118(value) { + C.#\u2118 = value; + return C.#\u2118; + } + static ZW_\u200C_NJ(value) { + C.#ZW_\u200C_NJ = value; + return C.#ZW_\u200C_NJ; + } + static ZW_\u200D_J(value) { + C.#ZW_\u200D_J = value; + return C.#ZW_\u200D_J; + } +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +C.m().next().then(function(v) { + assert.sameValue(v.value, 42); + assert.sameValue(v.done, true); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert.sameValue(C.$(1), 1); + assert.sameValue(C._(1), 1); + assert.sameValue(C.\u{6F}(1), 1); + assert.sameValue(C.\u2118(1), 1); + assert.sameValue(C.ZW_\u200C_NJ(1), 1); + assert.sameValue(C.ZW_\u200D_J(1), 1); + + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-rs-static-privatename-identifier-initializer-alt-by-classname.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-rs-static-privatename-identifier-initializer-alt-by-classname.js new file mode 100644 index 0000000000..c7f4af9477 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-rs-static-privatename-identifier-initializer-alt-by-classname.js @@ -0,0 +1,120 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-privatename-identifier-initializer-alt-by-classname.case +// - src/class-elements/productions/cls-decl-after-same-line-static-async-gen.template +/*--- +description: Valid Static PrivateName (field definitions after a static async generator in the same line) +esid: prod-FieldDefinition +features: [class-static-fields-private, class, class-fields-public, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static async *m() { return 42; } static #$ = 1; static #_ = 1; static #\u{6F} = 1; static #℘ = 1; static #ZW_‌_NJ = 1; static #ZW_‍_J = 1; + static $() { + return C.#$; + } + static _() { + return C.#_; + } + static \u{6F}() { + return C.#\u{6F}; + } + static ℘() { + return C.#℘; + } + static ZW_‌_NJ() { + return C.#ZW_‌_NJ; + } + static ZW_‍_J() { + return C.#ZW_‍_J; + } +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +C.m().next().then(function(v) { + assert.sameValue(v.value, 42); + assert.sameValue(v.done, true); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert.sameValue(C.$(), 1); + assert.sameValue(C._(), 1); + assert.sameValue(C.\u{6F}(), 1); + assert.sameValue(C.℘(), 1); + assert.sameValue(C.ZW_‌_NJ(), 1); + assert.sameValue(C.ZW_‍_J(), 1); + + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-rs-static-privatename-identifier-initializer-alt.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-rs-static-privatename-identifier-initializer-alt.js new file mode 100644 index 0000000000..0a2c38a716 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-rs-static-privatename-identifier-initializer-alt.js @@ -0,0 +1,120 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-privatename-identifier-initializer-alt.case +// - src/class-elements/productions/cls-decl-after-same-line-static-async-gen.template +/*--- +description: Valid Static PrivateName (field definitions after a static async generator in the same line) +esid: prod-FieldDefinition +features: [class-static-fields-private, class, class-fields-public, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static async *m() { return 42; } static #$ = 1; static #_ = 1; static #\u{6F} = 1; static #℘ = 1; static #ZW_‌_NJ = 1; static #ZW_‍_J = 1; + static $() { + return this.#$; + } + static _() { + return this.#_; + } + static \u{6F}() { + return this.#\u{6F}; + } + static ℘() { + return this.#℘; + } + static ZW_‌_NJ() { + return this.#ZW_‌_NJ; + } + static ZW_‍_J() { + return this.#ZW_‍_J; + } +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +C.m().next().then(function(v) { + assert.sameValue(v.value, 42); + assert.sameValue(v.done, true); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert.sameValue(C.$(), 1); + assert.sameValue(C._(), 1); + assert.sameValue(C.\u{6F}(), 1); + assert.sameValue(C.℘(), 1); + assert.sameValue(C.ZW_‌_NJ(), 1); + assert.sameValue(C.ZW_‍_J(), 1); + + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-rs-static-privatename-identifier-initializer.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-rs-static-privatename-identifier-initializer.js new file mode 100644 index 0000000000..aa7d3bac77 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-rs-static-privatename-identifier-initializer.js @@ -0,0 +1,120 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-privatename-identifier-initializer.case +// - src/class-elements/productions/cls-decl-after-same-line-static-async-gen.template +/*--- +description: Valid Static PrivateName (field definitions after a static async generator in the same line) +esid: prod-FieldDefinition +features: [class-static-fields-private, class, class-fields-public, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static async *m() { return 42; } static #$ = 1; static #_ = 1; static #\u{6F} = 1; static #\u2118 = 1; static #ZW_\u200C_NJ = 1; static #ZW_\u200D_J = 1; + static $() { + return this.#$; + } + static _() { + return this.#_; + } + static \u{6F}() { + return this.#\u{6F}; + } + static \u2118() { + return this.#\u2118; + } + static ZW_\u200C_NJ() { + return this.#ZW_\u200C_NJ; + } + static ZW_\u200D_J() { + return this.#ZW_\u200D_J; + } +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +C.m().next().then(function(v) { + assert.sameValue(v.value, 42); + assert.sameValue(v.done, true); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert.sameValue(C.$(), 1); + assert.sameValue(C._(), 1); + assert.sameValue(C.\u{6F}(), 1); + assert.sameValue(C.\u2118(), 1); + assert.sameValue(C.ZW_\u200C_NJ(), 1); + assert.sameValue(C.ZW_\u200D_J(), 1); + + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-rs-static-privatename-identifier.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-rs-static-privatename-identifier.js new file mode 100644 index 0000000000..18b3ba5665 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-rs-static-privatename-identifier.js @@ -0,0 +1,126 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-privatename-identifier.case +// - src/class-elements/productions/cls-decl-after-same-line-static-async-gen.template +/*--- +description: Valid Static PrivateName (field definitions after a static async generator in the same line) +esid: prod-FieldDefinition +features: [class-static-fields-private, class, class-fields-public, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static async *m() { return 42; } static #$; static #_; static #\u{6F}; static #\u2118; static #ZW_\u200C_NJ; static #ZW_\u200D_J; + static $(value) { + this.#$ = value; + return this.#$; + } + static _(value) { + this.#_ = value; + return this.#_; + } + static \u{6F}(value) { + this.#\u{6F} = value; + return this.#\u{6F}; + } + static \u2118(value) { + this.#\u2118 = value; + return this.#\u2118; + } + static ZW_\u200C_NJ(value) { + this.#ZW_\u200C_NJ = value; + return this.#ZW_\u200C_NJ; + } + static ZW_\u200D_J(value) { + this.#ZW_\u200D_J = value; + return this.#ZW_\u200D_J; + } +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +C.m().next().then(function(v) { + assert.sameValue(v.value, 42); + assert.sameValue(v.done, true); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert.sameValue(C.$(1), 1); + assert.sameValue(C._(1), 1); + assert.sameValue(C.\u{6F}(1), 1); + assert.sameValue(C.\u2118(1), 1); + assert.sameValue(C.ZW_\u200C_NJ(1), 1); + assert.sameValue(C.ZW_\u200D_J(1), 1); + + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-static-private-fields.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-static-private-fields.js new file mode 100644 index 0000000000..bd3e1e0cee --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-static-private-fields.js @@ -0,0 +1,87 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/static-private-fields.case +// - src/class-elements/productions/cls-decl-after-same-line-static-async-gen.template +/*--- +description: static private fields (field definitions after a static async generator in the same line) +esid: prod-FieldDefinition +features: [class-static-fields-private, class, class-fields-public, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + ... + static FieldDefinition ; + + FieldDefinition : + ClassElementName Initializer_opt + + ClassElementName : + PrivateName + + PrivateName : + # IdentifierName + +---*/ + + +class C { + static async *m() { return 42; } static #x; static #y; + static x() { + this.#x = 42; + return this.#x; + } + static y() { + this.#y = 43; + return this.#y; + } +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +C.m().next().then(function(v) { + assert.sameValue(v.value, 42); + assert.sameValue(v.done, true); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + // Test the private fields do not appear as properties before set to value + assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#x"), "test 1"); + assert(!Object.prototype.hasOwnProperty.call(C, "#x"), "test 2"); + assert(!Object.prototype.hasOwnProperty.call(c, "#x"), "test 3"); + + assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#y"), "test 4"); + assert(!Object.prototype.hasOwnProperty.call(C, "#y"), "test 5"); + assert(!Object.prototype.hasOwnProperty.call(c, "#y"), "test 6"); + + // Test if private fields can be sucessfully accessed and set to value + assert.sameValue(C.x(), 42, "test 7"); + assert.sameValue(C.y(), 43, "test 8"); + + // Test the private fields do not appear as properties before after set to value + assert(!Object.prototype.hasOwnProperty.call(C, "#x"), "test 9"); + assert(!Object.prototype.hasOwnProperty.call(C, "#y"), "test 10"); + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-static-private-methods-with-fields.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-static-private-methods-with-fields.js new file mode 100644 index 0000000000..e246f8b47e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-static-private-methods-with-fields.js @@ -0,0 +1,104 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/static-private-methods-with-fields.case +// - src/class-elements/productions/cls-decl-after-same-line-static-async-gen.template +/*--- +description: static private methods with fields (field definitions after a static async generator in the same line) +esid: prod-FieldDefinition +features: [class-static-methods-private, class-static-fields-private, class, class-fields-public, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + ... + static FieldDefinition ; + + FieldDefinition : + ClassElementName Initializer_opt + + ClassElementName : + PrivateName + + PrivateName : + # IdentifierName + +---*/ + + +class C { + static async *m() { return 42; } static #xVal; static #yVal; + static #x(value) { + this.#xVal = value; + return this.#xVal; + } + static #y(value) { + this.#yVal = value; + return this.#yVal; + } + static x() { + return this.#x(42); + } + static y() { + return this.#y(43); + } +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +C.m().next().then(function(v) { + assert.sameValue(v.value, 42); + assert.sameValue(v.done, true); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + // Test the private methods do not appear as properties before set to value + assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#x"), "test 1"); + assert(!Object.prototype.hasOwnProperty.call(C, "#x"), "test 2"); + assert(!Object.prototype.hasOwnProperty.call(c, "#x"), "test 3"); + + assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#y"), "test 4"); + assert(!Object.prototype.hasOwnProperty.call(C, "#y"), "test 5"); + assert(!Object.prototype.hasOwnProperty.call(c, "#y"), "test 6"); + + assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#xVal"), "test 7"); + assert(!Object.prototype.hasOwnProperty.call(C, "#xVal"), "test 8"); + assert(!Object.prototype.hasOwnProperty.call(c, "#xVal"), "test 9"); + + assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#yVal"), "test 10"); + assert(!Object.prototype.hasOwnProperty.call(C, "#yVal"), "test 11"); + assert(!Object.prototype.hasOwnProperty.call(c, "#yVal"), "test 12"); + + // Test if private fields can be sucessfully accessed and set to value + assert.sameValue(C.x(), 42, "test 13"); + assert.sameValue(C.y(), 43, "test 14"); + + // Test the private fields do not appear as properties before after set to value + assert(!Object.prototype.hasOwnProperty.call(C, "#x"), "test 15"); + assert(!Object.prototype.hasOwnProperty.call(C, "#y"), "test 16"); + + assert(!Object.prototype.hasOwnProperty.call(C, "#xVal"), "test 17"); + assert(!Object.prototype.hasOwnProperty.call(C, "#yVal"), "test 18"); + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-static-private-methods.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-static-private-methods.js new file mode 100644 index 0000000000..68d55b4ea7 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-static-private-methods.js @@ -0,0 +1,91 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/static-private-methods.case +// - src/class-elements/productions/cls-decl-after-same-line-static-async-gen.template +/*--- +description: static private methods (field definitions after a static async generator in the same line) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + ... + static FieldDefinition ; + + FieldDefinition : + ClassElementName Initializer_opt + + ClassElementName : + PrivateName + + PrivateName : + # IdentifierName + +---*/ + + +class C { + static async *m() { return 42; } ; + static #x(value) { + return value / 2; + } + static #y(value) { + return value * 2; + } + static x() { + return this.#x(84); + } + static y() { + return this.#y(43); + } +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +C.m().next().then(function(v) { + assert.sameValue(v.value, 42); + assert.sameValue(v.done, true); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + // Test the private methods do not appear as properties before set to value + assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#x"), "test 1"); + assert(!Object.prototype.hasOwnProperty.call(C, "#x"), "test 2"); + assert(!Object.prototype.hasOwnProperty.call(c, "#x"), "test 3"); + + assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#y"), "test 4"); + assert(!Object.prototype.hasOwnProperty.call(C, "#y"), "test 5"); + assert(!Object.prototype.hasOwnProperty.call(c, "#y"), "test 6"); + + // Test if private fields can be sucessfully accessed and set to value + assert.sameValue(C.x(), 42, "test 7"); + assert.sameValue(C.y(), 86, "test 8"); + + // Test the private fields do not appear as properties before after set to value + assert(!Object.prototype.hasOwnProperty.call(C, "#x"), "test 9"); + assert(!Object.prototype.hasOwnProperty.call(C, "#y"), "test 10"); + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-string-literal-names.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-string-literal-names.js new file mode 100644 index 0000000000..ec25462639 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-string-literal-names.js @@ -0,0 +1,125 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/string-literal-names.case +// - src/class-elements/productions/cls-decl-after-same-line-static-async-gen.template +/*--- +description: String literal names (field definitions after a static async generator in the same line) +esid: prod-FieldDefinition +features: [class-fields-public, class, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PropertyName + +---*/ + + +class C { + static async *m() { return 42; } 'a'; "b"; 'c' = 39; + "d" = 42; + +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +C.m().next().then(function(v) { + assert.sameValue(v.value, 42); + assert.sameValue(v.done, true); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "a"), + "a does not appear as an own property on C prototype" + ); + assert( + !Object.prototype.hasOwnProperty.call(C, "a"), + "a does not appear as an own property on C constructor" + ); + + verifyProperty(c, "a", { + value: undefined, + enumerable: true, + writable: true, + configurable: true + }); + + assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "b"), + "b does not appear as an own property on C prototype" + ); + assert( + !Object.prototype.hasOwnProperty.call(C, "b"), + "b does not appear as an own property on C constructor" + ); + + verifyProperty(c, "b", { + value: undefined, + enumerable: true, + writable: true, + configurable: true + }); + + assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "c"), + "c does not appear as an own property on C prototype" + ); + assert( + !Object.prototype.hasOwnProperty.call(C, "c"), + "c does not appear as an own property on C constructor" + ); + + verifyProperty(c, "c", { + value: 39, + enumerable: true, + writable: true, + configurable: true + }); + + assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "d"), + "d does not appear as an own property on C prototype" + ); + assert( + !Object.prototype.hasOwnProperty.call(C, "d"), + "d does not appear as an own property on C constructor" + ); + + verifyProperty(c, "d", { + value: 42, + enumerable: true, + writable: true, + configurable: true + }); + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-computed-names.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-computed-names.js new file mode 100644 index 0000000000..45d08b8f74 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-computed-names.js @@ -0,0 +1,122 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/computed-names.case +// - src/class-elements/productions/cls-decl-after-same-line-static-async-method.template +/*--- +description: Computed property names (field definitions after a static async method in the same line) +esid: prod-FieldDefinition +features: [class-fields-public, computed-property-names, class, async-functions] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PropertyName + +---*/ +var x = "b"; + + + +class C { + static async m() { return 42; } [x] = 42; [10] = "meep"; ["not initialized"]; + +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +C.m().then(function(v) { + assert.sameValue(v, 42); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "b"), + "b doesn't appear as an own property on C prototype" + ); + assert( + !Object.prototype.hasOwnProperty.call(C, "b"), + "b doesn't appear as an own property on C constructor" + ); + + verifyProperty(c, "b", { + value: 42, + enumerable: true, + writable: true, + configurable: true + }); + + assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "x"), + "x doesn't appear as an own property on C prototype" + ); + assert( + !Object.prototype.hasOwnProperty.call(C, "x"), + "x doesn't appear as an own property on C constructor" + ); + assert( + !Object.prototype.hasOwnProperty.call(c, "x"), + "x doesn't appear as an own property on C instance" + ); + + assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "10"), + "10 doesn't appear as an own property on C prototype" + ); + assert( + !Object.prototype.hasOwnProperty.call(C, "10"), + "10 doesn't appear as an own property on C constructor" + ); + + verifyProperty(c, "10", { + value: "meep", + enumerable: true, + writable: true, + configurable: true + }); + + assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "not initialized"), + "'not initialized' doesn't appear as an own property on C prototype" + ); + assert( + !Object.prototype.hasOwnProperty.call(C, "not initialized"), + "'not initialized' doesn't appear as an own property on C constructor" + ); + + verifyProperty(c, "not initialized", { + value: undefined, + enumerable: true, + writable: true, + configurable: true + }); + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-computed-symbol-names.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-computed-symbol-names.js new file mode 100644 index 0000000000..84f0a9d350 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-computed-symbol-names.js @@ -0,0 +1,120 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/computed-symbol-names.case +// - src/class-elements/productions/cls-decl-after-same-line-static-async-method.template +/*--- +description: Computed property symbol names (field definitions after a static async method in the same line) +esid: prod-FieldDefinition +features: [class-fields-public, Symbol, computed-property-names, class, async-functions] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PropertyName + +---*/ +var x = Symbol(); +var y = Symbol(); + + + +class C { + static async m() { return 42; } [x]; [y] = 42; + +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +C.m().then(function(v) { + assert.sameValue(v, 42); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert( + !Object.prototype.hasOwnProperty.call(C.prototype, x), + "Symbol x doesn't appear as an own property on C prototype" + ); + assert( + !Object.prototype.hasOwnProperty.call(C, x), + "Symbol x doesn't appear as an own property on C constructor" + ); + + verifyProperty(c, x, { + value: undefined, + enumerable: true, + writable: true, + configurable: true + }); + + assert( + !Object.prototype.hasOwnProperty.call(C.prototype, y), + "Symbol y doesn't appear as an own property on C prototype" + ); + assert( + !Object.prototype.hasOwnProperty.call(C, y), + "Symbol y doesn't appear as an own property on C constructor" + ); + + verifyProperty(c, y, { + value: 42, + enumerable: true, + writable: true, + configurable: true + }); + + assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "x"), + "x doesn't appear as an own property on C prototype" + ); + assert( + !Object.prototype.hasOwnProperty.call(C, "x"), + "x doesn't appear as an own property on C constructor" + ); + assert( + !Object.prototype.hasOwnProperty.call(c, "x"), + "x doesn't appear as an own property on C instance" + ); + + assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "y"), + "y doesn't appear as an own property on C prototype" + ); + assert( + !Object.prototype.hasOwnProperty.call(C, "y"), + "y doesn't appear as an own property on C constructor" + ); + assert( + !Object.prototype.hasOwnProperty.call(c, "y"), + "y doesn't appear as an own property on C instance" + ); + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-grammar-privatename-identifier-semantics-stringvalue.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-grammar-privatename-identifier-semantics-stringvalue.js new file mode 100644 index 0000000000..44434bf5cf --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-grammar-privatename-identifier-semantics-stringvalue.js @@ -0,0 +1,124 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-privatename-identifier-semantics-stringvalue.case +// - src/class-elements/productions/cls-decl-after-same-line-static-async-method.template +/*--- +description: PrivateName Static Semantics, StringValue (field definitions after a static async method in the same line) +esid: prod-FieldDefinition +features: [class-fields-private, class, class-fields-public, async-functions] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + + + 1. Return the String value consisting of the sequence of code + units corresponding to PrivateName. In determining the sequence + any occurrences of \ UnicodeEscapeSequence are first replaced + with the code point represented by the UnicodeEscapeSequence + and then the code points of the entire PrivateName are converted + to code units by UTF16Encoding (10.1.1) each code point. + +---*/ + + +class C { + static async m() { return 42; } #\u{6F}; + #\u2118; + #ZW_\u200C_NJ; + #ZW_\u200D_J;; + o(value) { + this.#o = value; + return this.#o; + } + ℘(value) { + this.#℘ = value; + return this.#℘; + } + ZW_‌_NJ(value) { // DO NOT CHANGE THE NAME OF THIS METHOD + this.#ZW_‌_NJ = value; + return this.#ZW_‌_NJ; + } + ZW_‍_J(value) { // DO NOT CHANGE THE NAME OF THIS METHOD + this.#ZW_‍_J = value; + return this.#ZW_‍_J; + } +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +C.m().then(function(v) { + assert.sameValue(v, 42); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert.sameValue(c.o(1), 1); + assert.sameValue(c.℘(1), 1); + assert.sameValue(c.ZW_‌_NJ(1), 1); + assert.sameValue(c.ZW_‍_J(1), 1); + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-literal-names-asi.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-literal-names-asi.js new file mode 100644 index 0000000000..b8b32df078 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-literal-names-asi.js @@ -0,0 +1,92 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/literal-names-asi.case +// - src/class-elements/productions/cls-decl-after-same-line-static-async-method.template +/*--- +description: Literal property names with ASI (field definitions after a static async method in the same line) +esid: prod-FieldDefinition +features: [class-fields-public, class, async-functions] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PropertyName + +---*/ + + +class C { + static async m() { return 42; } a + b = 42;; + +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +C.m().then(function(v) { + assert.sameValue(v, 42); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "a"), + "a doesn't appear as an own property on C prototype" + ); + assert( + !Object.prototype.hasOwnProperty.call(C, "a"), + "a doesn't appear as an own property on C constructor" + ); + + verifyProperty(c, "a", { + value: undefined, + enumerable: true, + writable: true, + configurable: true + }); + + assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "b"), + "b doesn't appear as an own property on C prototype" + ); + assert( + !Object.prototype.hasOwnProperty.call(C, "b"), + "b doesn't appear as an own property on C constructor" + ); + + verifyProperty(c, "b", { + value: 42, + enumerable: true, + writable: true, + configurable: true + }); + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-literal-names.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-literal-names.js new file mode 100644 index 0000000000..c3e17e41e3 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-literal-names.js @@ -0,0 +1,111 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/literal-names.case +// - src/class-elements/productions/cls-decl-after-same-line-static-async-method.template +/*--- +description: Literal property names (field definitions after a static async method in the same line) +esid: prod-FieldDefinition +features: [class-fields-public, class, async-functions] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PropertyName + +---*/ +const fn = function() {} + + + +class C { + static async m() { return 42; } a; b = 42; + c = fn; + +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +C.m().then(function(v) { + assert.sameValue(v, 42); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "a"), + "a doesn't appear as an own property on C prototype" + ); + assert( + !Object.prototype.hasOwnProperty.call(C, "a"), + "a doesn't appear as an own property on C constructor" + ); + + verifyProperty(c, "a", { + value: undefined, + enumerable: true, + writable: true, + configurable: true + }); + + assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "b"), + "b doesn't appear as an own property on C prototype" + ); + assert( + !Object.prototype.hasOwnProperty.call(C, "b"), + "b doesn't appear as an own property on C constructor" + ); + + verifyProperty(c, "b", { + value: 42, + enumerable: true, + writable: true, + configurable: true + }); + + assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "c"), + "c doesn't appear as an own property on C prototype" + ); + assert( + !Object.prototype.hasOwnProperty.call(C, "c"), + "c doesn't appear as an own property on C constructor" + ); + + verifyProperty(c, "c", { + value: fn, + enumerable: true, + writable: true, + configurable: true + }); + + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-private-field-usage.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-private-field-usage.js new file mode 100644 index 0000000000..d03f6c1397 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-private-field-usage.js @@ -0,0 +1,64 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/private-field-usage.case +// - src/class-elements/productions/cls-decl-after-same-line-static-async-method.template +/*--- +description: PrivateName CallExpression usage (private field) (field definitions after a static async method in the same line) +esid: prod-FieldDefinition +features: [class-fields-private, class, class-fields-public, async-functions] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + Updated Productions + + CallExpression[Yield, Await]: + CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await] + SuperCall[?Yield, ?Await] + CallExpression[?Yield, ?Await]Arguments[?Yield, ?Await] + CallExpression[?Yield, ?Await][Expression[+In, ?Yield, ?Await]] + CallExpression[?Yield, ?Await].IdentifierName + CallExpression[?Yield, ?Await]TemplateLiteral[?Yield, ?Await] + CallExpression[?Yield, ?Await].PrivateName + +---*/ + + +class C { + static async m() { return 42; } #m = 'test262';; + method() { + return this.#m; + } +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +C.m().then(function(v) { + assert.sameValue(v, 42); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert.sameValue(c.method(), 'test262'); + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-private-method-getter-usage.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-private-method-getter-usage.js new file mode 100644 index 0000000000..6aebe67a3a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-private-method-getter-usage.js @@ -0,0 +1,64 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/private-method-getter-usage.case +// - src/class-elements/productions/cls-decl-after-same-line-static-async-method.template +/*--- +description: PrivateName CallExpression usage (Accesor get method) (field definitions after a static async method in the same line) +esid: prod-FieldDefinition +features: [class-methods-private, class, class-fields-public, async-functions] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + Updated Productions + + CallExpression[Yield, Await]: + CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await] + SuperCall[?Yield, ?Await] + CallExpression[?Yield, ?Await]Arguments[?Yield, ?Await] + CallExpression[?Yield, ?Await][Expression[+In, ?Yield, ?Await]] + CallExpression[?Yield, ?Await].IdentifierName + CallExpression[?Yield, ?Await]TemplateLiteral[?Yield, ?Await] + CallExpression[?Yield, ?Await].PrivateName + +---*/ + + +class C { + static async m() { return 42; } get #m() { return 'test262'; }; + method() { + return this.#m; + } +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +C.m().then(function(v) { + assert.sameValue(v, 42); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert.sameValue(c.method(), 'test262'); + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-private-method-usage.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-private-method-usage.js new file mode 100644 index 0000000000..06af954028 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-private-method-usage.js @@ -0,0 +1,64 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/private-method-usage.case +// - src/class-elements/productions/cls-decl-after-same-line-static-async-method.template +/*--- +description: PrivateName CallExpression usage (private method) (field definitions after a static async method in the same line) +esid: prod-FieldDefinition +features: [class-methods-private, class, class-fields-public, async-functions] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + Updated Productions + + CallExpression[Yield, Await]: + CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await] + SuperCall[?Yield, ?Await] + CallExpression[?Yield, ?Await]Arguments[?Yield, ?Await] + CallExpression[?Yield, ?Await][Expression[+In, ?Yield, ?Await]] + CallExpression[?Yield, ?Await].IdentifierName + CallExpression[?Yield, ?Await]TemplateLiteral[?Yield, ?Await] + CallExpression[?Yield, ?Await].PrivateName + +---*/ + + +class C { + static async m() { return 42; } #m() { return 'test262'; }; + method() { + return this.#m(); + } +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +C.m().then(function(v) { + assert.sameValue(v, 42); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert.sameValue(c.method(), 'test262'); + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-private-names.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-private-names.js new file mode 100644 index 0000000000..c708d97643 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-private-names.js @@ -0,0 +1,86 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/private-names.case +// - src/class-elements/productions/cls-decl-after-same-line-static-async-method.template +/*--- +description: private names (field definitions after a static async method in the same line) +esid: prod-FieldDefinition +features: [class-fields-private, class, class-fields-public, async-functions] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + ... + FieldDefinition ; + + FieldDefinition : + ClassElementName Initializer_opt + + ClassElementName : + PrivateName + + PrivateName : + # IdentifierName + +---*/ + + +class C { + static async m() { return 42; } #x; #y; + x() { + this.#x = 42; + return this.#x; + } + y() { + this.#y = 43; + return this.#y; + } +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +C.m().then(function(v) { + assert.sameValue(v, 42); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + // Test the private fields do not appear as properties before set to value + assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#x"), "test 1"); + assert(!Object.prototype.hasOwnProperty.call(C, "#x"), "test 2"); + assert(!Object.prototype.hasOwnProperty.call(c, "#x"), "test 3"); + + assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#y"), "test 4"); + assert(!Object.prototype.hasOwnProperty.call(C, "#y"), "test 5"); + assert(!Object.prototype.hasOwnProperty.call(c, "#y"), "test 6"); + + // Test if private fields can be sucessfully accessed and set to value + assert.sameValue(c.x(), 42, "test 7"); + assert.sameValue(c.y(), 43, "test 8"); + + // Test the private fields do not appear as properties before after set to value + assert(!Object.prototype.hasOwnProperty.call(c, "#x"), "test 9"); + assert(!Object.prototype.hasOwnProperty.call(c, "#y"), "test 10"); + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-rs-field-identifier-initializer.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-rs-field-identifier-initializer.js new file mode 100644 index 0000000000..0478e82a3e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-rs-field-identifier-initializer.js @@ -0,0 +1,102 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-field-identifier-initializer.case +// - src/class-elements/productions/cls-decl-after-same-line-static-async-method.template +/*--- +description: Valid FieldDefinition (field definitions after a static async method in the same line) +esid: prod-FieldDefinition +features: [class-fields-public, class, async-functions] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + ... + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + + PropertyName : + LiteralPropertyName + ComputedPropertyName + + LiteralPropertyName : + IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static async m() { return 42; } $ = 1; _ = 1; \u{6F} = 1; \u2118 = 1; ZW_\u200C_NJ = 1; ZW_\u200D_J = 1; + +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +C.m().then(function(v) { + assert.sameValue(v, 42); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert.sameValue(c.$, 1); + assert.sameValue(c._, 1); + assert.sameValue(c.\u{6F}, 1); + assert.sameValue(c.\u2118, 1); + assert.sameValue(c.ZW_\u200C_NJ, 1); + assert.sameValue(c.ZW_\u200D_J, 1); + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-rs-field-identifier.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-rs-field-identifier.js new file mode 100644 index 0000000000..acc2fc42e6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-rs-field-identifier.js @@ -0,0 +1,109 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-field-identifier.case +// - src/class-elements/productions/cls-decl-after-same-line-static-async-method.template +/*--- +description: Valid FieldDefinition (field definitions after a static async method in the same line) +esid: prod-FieldDefinition +features: [class-fields-public, class, async-functions] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + ... + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + + PropertyName : + LiteralPropertyName + ComputedPropertyName + + LiteralPropertyName : + IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static async m() { return 42; } $; _; \u{6F}; \u2118; ZW_\u200C_NJ; ZW_\u200D_J; + +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +C.m().then(function(v) { + assert.sameValue(v, 42); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + c.$ = 1; + c._ = 1; + c.\u{6F} = 1; + c.\u2118 = 1; + c.ZW_\u200C_NJ = 1; + c.ZW_\u200D_J = 1; + + assert.sameValue(c.$, 1); + assert.sameValue(c._, 1); + assert.sameValue(c.\u{6F}, 1); + assert.sameValue(c.\u2118, 1); + assert.sameValue(c.ZW_\u200C_NJ, 1); + assert.sameValue(c.ZW_\u200D_J, 1); + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-rs-private-getter-alt.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-rs-private-getter-alt.js new file mode 100644 index 0000000000..b6099085f5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-rs-private-getter-alt.js @@ -0,0 +1,143 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-private-getter-alt.case +// - src/class-elements/productions/cls-decl-after-same-line-static-async-method.template +/*--- +description: Valid PrivateName as private getter (field definitions after a static async method in the same line) +esid: prod-FieldDefinition +features: [class-methods-private, class-fields-private, class, class-fields-public, async-functions] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + ... + ; + + MethodDefinition : + ... + get ClassElementName ( ){ FunctionBody } + ... + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static async m() { return 42; } #$_; #__; #\u{6F}_; #℘_; #ZW_‌_NJ_; #ZW_‍_J_; + get #$() { + return this.#$_; + } + get #_() { + return this.#__; + } + get #\u{6F}() { + return this.#\u{6F}_; + } + get #℘() { + return this.#℘_; + } + get #ZW_‌_NJ() { + return this.#ZW_‌_NJ_; + } + get #ZW_‍_J() { + return this.#ZW_‍_J_; + } +; + $(value) { + this.#$_ = value; + return this.#$; + } + _(value) { + this.#__ = value; + return this.#_; + } + \u{6F}(value) { + this.#\u{6F}_ = value; + return this.#\u{6F}; + } + ℘(value) { + this.#℘_ = value; + return this.#℘; + } + ZW_‌_NJ(value) { + this.#ZW_‌_NJ_ = value; + return this.#ZW_‌_NJ; + } + ZW_‍_J(value) { + this.#ZW_‍_J_ = value; + return this.#ZW_‍_J; + } + +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +C.m().then(function(v) { + assert.sameValue(v, 42); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert.sameValue(c.$(1), 1); + assert.sameValue(c._(1), 1); + assert.sameValue(c.\u{6F}(1), 1); + assert.sameValue(c.℘(1), 1); + assert.sameValue(c.ZW_‌_NJ(1), 1); + assert.sameValue(c.ZW_‍_J(1), 1); + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-rs-private-getter.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-rs-private-getter.js new file mode 100644 index 0000000000..98f74abd65 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-rs-private-getter.js @@ -0,0 +1,143 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-private-getter.case +// - src/class-elements/productions/cls-decl-after-same-line-static-async-method.template +/*--- +description: Valid PrivateName as private getter (field definitions after a static async method in the same line) +esid: prod-FieldDefinition +features: [class-methods-private, class-fields-private, class, class-fields-public, async-functions] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + ... + ; + + MethodDefinition : + ... + get ClassElementName ( ){ FunctionBody } + ... + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static async m() { return 42; } #$_; #__; #\u{6F}_; #\u2118_; #ZW_\u200C_NJ_; #ZW_\u200D_J_; + get #$() { + return this.#$_; + } + get #_() { + return this.#__; + } + get #\u{6F}() { + return this.#\u{6F}_; + } + get #\u2118() { + return this.#\u2118_; + } + get #ZW_\u200C_NJ() { + return this.#ZW_\u200C_NJ_; + } + get #ZW_\u200D_J() { + return this.#ZW_\u200D_J_; + } +; + $(value) { + this.#$_ = value; + return this.#$; + } + _(value) { + this.#__ = value; + return this.#_; + } + \u{6F}(value) { + this.#\u{6F}_ = value; + return this.#\u{6F}; + } + \u2118(value) { + this.#\u2118_ = value; + return this.#\u2118; + } + ZW_\u200C_NJ(value) { + this.#ZW_\u200C_NJ_ = value; + return this.#ZW_\u200C_NJ; + } + ZW_\u200D_J(value) { + this.#ZW_\u200D_J_ = value; + return this.#ZW_\u200D_J; + } + +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +C.m().then(function(v) { + assert.sameValue(v, 42); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert.sameValue(c.$(1), 1); + assert.sameValue(c._(1), 1); + assert.sameValue(c.\u{6F}(1), 1); + assert.sameValue(c.\u2118(1), 1); + assert.sameValue(c.ZW_\u200C_NJ(1), 1); + assert.sameValue(c.ZW_\u200D_J(1), 1); + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-rs-private-method-alt.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-rs-private-method-alt.js new file mode 100644 index 0000000000..9487c5a922 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-rs-private-method-alt.js @@ -0,0 +1,142 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-private-method-alt.case +// - src/class-elements/productions/cls-decl-after-same-line-static-async-method.template +/*--- +description: Valid PrivateName as private method (field definitions after a static async method in the same line) +esid: prod-FieldDefinition +features: [class-methods-private, class-fields-private, class, class-fields-public, async-functions] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + ... + ; + + MethodDefinition : + ClassElementName ( UniqueFormalParameters ) { FunctionBody } + ... + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static async m() { return 42; } #$_; #__; #\u{6F}_; #℘_; #ZW_‌_NJ_; #ZW_‍_J_; + #$() { + return this.#$_; + } + #_() { + return this.#__; + } + #\u{6F}() { + return this.#\u{6F}_; + } + #℘() { + return this.#℘_; + } + #ZW_‌_NJ() { + return this.#ZW_‌_NJ_; + } + #ZW_‍_J() { + return this.#ZW_‍_J_; + } +; + $(value) { + this.#$_ = value; + return this.#$(); + } + _(value) { + this.#__ = value; + return this.#_(); + } + \u{6F}(value) { + this.#\u{6F}_ = value; + return this.#\u{6F}(); + } + ℘(value) { + this.#℘_ = value; + return this.#℘(); + } + ZW_‌_NJ(value) { + this.#ZW_‌_NJ_ = value; + return this.#ZW_‌_NJ(); + } + ZW_‍_J(value) { + this.#ZW_‍_J_ = value; + return this.#ZW_‍_J(); + } + +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +C.m().then(function(v) { + assert.sameValue(v, 42); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert.sameValue(c.$(1), 1); + assert.sameValue(c._(1), 1); + assert.sameValue(c.\u{6F}(1), 1); + assert.sameValue(c.℘(1), 1); + assert.sameValue(c.ZW_‌_NJ(1), 1); + assert.sameValue(c.ZW_‍_J(1), 1); + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-rs-private-method.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-rs-private-method.js new file mode 100644 index 0000000000..79d032d5fa --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-rs-private-method.js @@ -0,0 +1,142 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-private-method.case +// - src/class-elements/productions/cls-decl-after-same-line-static-async-method.template +/*--- +description: Valid PrivateName as private method (field definitions after a static async method in the same line) +esid: prod-FieldDefinition +features: [class-methods-private, class-fields-private, class, class-fields-public, async-functions] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + ... + ; + + MethodDefinition : + ClassElementName ( UniqueFormalParameters ) { FunctionBody } + ... + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static async m() { return 42; } #$_; #__; #\u{6F}_; #\u2118_; #ZW_\u200C_NJ_; #ZW_\u200D_J_; + #$() { + return this.#$_; + } + #_() { + return this.#__; + } + #\u{6F}() { + return this.#\u{6F}_; + } + #\u2118() { + return this.#\u2118_; + } + #ZW_\u200C_NJ() { + return this.#ZW_\u200C_NJ_; + } + #ZW_\u200D_J() { + return this.#ZW_\u200D_J_; + } +; + $(value) { + this.#$_ = value; + return this.#$(); + } + _(value) { + this.#__ = value; + return this.#_(); + } + \u{6F}(value) { + this.#\u{6F}_ = value; + return this.#\u{6F}(); + } + \u2118(value) { + this.#\u2118_ = value; + return this.#\u2118(); + } + ZW_\u200C_NJ(value) { + this.#ZW_\u200C_NJ_ = value; + return this.#ZW_\u200C_NJ(); + } + ZW_\u200D_J(value) { + this.#ZW_\u200D_J_ = value; + return this.#ZW_\u200D_J(); + } + +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +C.m().then(function(v) { + assert.sameValue(v, 42); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert.sameValue(c.$(1), 1); + assert.sameValue(c._(1), 1); + assert.sameValue(c.\u{6F}(1), 1); + assert.sameValue(c.\u2118(1), 1); + assert.sameValue(c.ZW_\u200C_NJ(1), 1); + assert.sameValue(c.ZW_\u200D_J(1), 1); + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-rs-private-setter-alt.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-rs-private-setter-alt.js new file mode 100644 index 0000000000..6b74c9edd0 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-rs-private-setter-alt.js @@ -0,0 +1,142 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-private-setter-alt.case +// - src/class-elements/productions/cls-decl-after-same-line-static-async-method.template +/*--- +description: Valid PrivateName as private setter (field definitions after a static async method in the same line) +esid: prod-FieldDefinition +features: [class-methods-private, class-fields-private, class, class-fields-public, async-functions] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + ... + ; + + MethodDefinition : + ... + set ClassElementName ( PropertySetParameterList ) { FunctionBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static async m() { return 42; } #$_; #__; #\u{6F}_; #℘_; #ZW_‌_NJ_; #ZW_‍_J_; + set #$(value) { + this.#$_ = value; + } + set #_(value) { + this.#__ = value; + } + set #\u{6F}(value) { + this.#\u{6F}_ = value; + } + set #℘(value) { + this.#℘_ = value; + } + set #ZW_‌_NJ(value) { + this.#ZW_‌_NJ_ = value; + } + set #ZW_‍_J(value) { + this.#ZW_‍_J_ = value; + } +; + $(value) { + this.#$ = value; + return this.#$_; + } + _(value) { + this.#_ = value; + return this.#__; + } + \u{6F}(value) { + this.#\u{6F} = value; + return this.#\u{6F}_; + } + ℘(value) { + this.#℘ = value; + return this.#℘_; + } + ZW_‌_NJ(value) { + this.#ZW_‌_NJ = value; + return this.#ZW_‌_NJ_; + } + ZW_‍_J(value) { + this.#ZW_‍_J = value; + return this.#ZW_‍_J_; + } + +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +C.m().then(function(v) { + assert.sameValue(v, 42); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert.sameValue(c.$(1), 1); + assert.sameValue(c._(1), 1); + assert.sameValue(c.\u{6F}(1), 1); + assert.sameValue(c.℘(1), 1); + assert.sameValue(c.ZW_‌_NJ(1), 1); + assert.sameValue(c.ZW_‍_J(1), 1); + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-rs-private-setter.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-rs-private-setter.js new file mode 100644 index 0000000000..c5bf8ab5e8 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-rs-private-setter.js @@ -0,0 +1,142 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-private-setter.case +// - src/class-elements/productions/cls-decl-after-same-line-static-async-method.template +/*--- +description: Valid PrivateName as private setter (field definitions after a static async method in the same line) +esid: prod-FieldDefinition +features: [class-methods-private, class-fields-private, class, class-fields-public, async-functions] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + ... + ; + + MethodDefinition : + ... + set ClassElementName ( PropertySetParameterList ) { FunctionBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static async m() { return 42; } #$_; #__; #\u{6F}_; #\u2118_; #ZW_\u200C_NJ_; #ZW_\u200D_J_; + set #$(value) { + this.#$_ = value; + } + set #_(value) { + this.#__ = value; + } + set #\u{6F}(value) { + this.#\u{6F}_ = value; + } + set #\u2118(value) { + this.#\u2118_ = value; + } + set #ZW_\u200C_NJ(value) { + this.#ZW_\u200C_NJ_ = value; + } + set #ZW_\u200D_J(value) { + this.#ZW_\u200D_J_ = value; + } +; + $(value) { + this.#$ = value; + return this.#$_; + } + _(value) { + this.#_ = value; + return this.#__; + } + \u{6F}(value) { + this.#\u{6F} = value; + return this.#\u{6F}_; + } + \u2118(value) { + this.#\u2118 = value; + return this.#\u2118_; + } + ZW_\u200C_NJ(value) { + this.#ZW_\u200C_NJ = value; + return this.#ZW_\u200C_NJ_; + } + ZW_\u200D_J(value) { + this.#ZW_\u200D_J = value; + return this.#ZW_\u200D_J_; + } + +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +C.m().then(function(v) { + assert.sameValue(v, 42); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert.sameValue(c.$(1), 1); + assert.sameValue(c._(1), 1); + assert.sameValue(c.\u{6F}(1), 1); + assert.sameValue(c.\u2118(1), 1); + assert.sameValue(c.ZW_\u200C_NJ(1), 1); + assert.sameValue(c.ZW_\u200D_J(1), 1); + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-rs-privatename-identifier-alt.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-rs-privatename-identifier-alt.js new file mode 100644 index 0000000000..05154e2948 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-rs-privatename-identifier-alt.js @@ -0,0 +1,124 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-privatename-identifier-alt.case +// - src/class-elements/productions/cls-decl-after-same-line-static-async-method.template +/*--- +description: Valid PrivateName (field definitions after a static async method in the same line) +esid: prod-FieldDefinition +features: [class-fields-private, class, class-fields-public, async-functions] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static async m() { return 42; } #$; #_; #\u{6F}; #℘; #ZW_‌_NJ; #ZW_‍_J; + $(value) { + this.#$ = value; + return this.#$; + } + _(value) { + this.#_ = value; + return this.#_; + } + \u{6F}(value) { + this.#\u{6F} = value; + return this.#\u{6F}; + } + ℘(value) { + this.#℘ = value; + return this.#℘; + } + ZW_‌_NJ(value) { + this.#ZW_‌_NJ = value; + return this.#ZW_‌_NJ; + } + ZW_‍_J(value) { + this.#ZW_‍_J = value; + return this.#ZW_‍_J; + } +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +C.m().then(function(v) { + assert.sameValue(v, 42); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert.sameValue(c.$(1), 1); + assert.sameValue(c._(1), 1); + assert.sameValue(c.\u{6F}(1), 1); + assert.sameValue(c.℘(1), 1); + assert.sameValue(c.ZW_‌_NJ(1), 1); + assert.sameValue(c.ZW_‍_J(1), 1); + + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-rs-privatename-identifier-initializer-alt.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-rs-privatename-identifier-initializer-alt.js new file mode 100644 index 0000000000..fa461c0ec8 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-rs-privatename-identifier-initializer-alt.js @@ -0,0 +1,118 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-privatename-identifier-initializer-alt.case +// - src/class-elements/productions/cls-decl-after-same-line-static-async-method.template +/*--- +description: Valid PrivateName (field definitions after a static async method in the same line) +esid: prod-FieldDefinition +features: [class-fields-private, class, class-fields-public, async-functions] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static async m() { return 42; } #$ = 1; #_ = 1; #\u{6F} = 1; #℘ = 1; #ZW_‌_NJ = 1; #ZW_‍_J = 1; + $() { + return this.#$; + } + _() { + return this.#_; + } + \u{6F}() { + return this.#\u{6F}; + } + ℘() { + return this.#℘; + } + ZW_‌_NJ() { + return this.#ZW_‌_NJ; + } + ZW_‍_J() { + return this.#ZW_‍_J; + } +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +C.m().then(function(v) { + assert.sameValue(v, 42); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert.sameValue(c.$(), 1); + assert.sameValue(c._(), 1); + assert.sameValue(c.\u{6F}(), 1); + assert.sameValue(c.℘(), 1); + assert.sameValue(c.ZW_‌_NJ(), 1); + assert.sameValue(c.ZW_‍_J(), 1); + + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-rs-privatename-identifier-initializer.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-rs-privatename-identifier-initializer.js new file mode 100644 index 0000000000..ebe0f2042e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-rs-privatename-identifier-initializer.js @@ -0,0 +1,118 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-privatename-identifier-initializer.case +// - src/class-elements/productions/cls-decl-after-same-line-static-async-method.template +/*--- +description: Valid PrivateName (field definitions after a static async method in the same line) +esid: prod-FieldDefinition +features: [class-fields-private, class, class-fields-public, async-functions] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static async m() { return 42; } #$ = 1; #_ = 1; #\u{6F} = 1; #\u2118 = 1; #ZW_\u200C_NJ = 1; #ZW_\u200D_J = 1; + $() { + return this.#$; + } + _() { + return this.#_; + } + \u{6F}() { + return this.#\u{6F}; + } + \u2118() { + return this.#\u2118; + } + ZW_\u200C_NJ() { + return this.#ZW_\u200C_NJ; + } + ZW_\u200D_J() { + return this.#ZW_\u200D_J; + } +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +C.m().then(function(v) { + assert.sameValue(v, 42); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert.sameValue(c.$(), 1); + assert.sameValue(c._(), 1); + assert.sameValue(c.\u{6F}(), 1); + assert.sameValue(c.\u2118(), 1); + assert.sameValue(c.ZW_\u200C_NJ(), 1); + assert.sameValue(c.ZW_\u200D_J(), 1); + + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-rs-privatename-identifier.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-rs-privatename-identifier.js new file mode 100644 index 0000000000..85bd1d5f6d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-rs-privatename-identifier.js @@ -0,0 +1,124 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-privatename-identifier.case +// - src/class-elements/productions/cls-decl-after-same-line-static-async-method.template +/*--- +description: Valid PrivateName (field definitions after a static async method in the same line) +esid: prod-FieldDefinition +features: [class-fields-private, class, class-fields-public, async-functions] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static async m() { return 42; } #$; #_; #\u{6F}; #\u2118; #ZW_\u200C_NJ; #ZW_\u200D_J; + $(value) { + this.#$ = value; + return this.#$; + } + _(value) { + this.#_ = value; + return this.#_; + } + \u{6F}(value) { + this.#\u{6F} = value; + return this.#\u{6F}; + } + \u2118(value) { + this.#\u2118 = value; + return this.#\u2118; + } + ZW_\u200C_NJ(value) { + this.#ZW_\u200C_NJ = value; + return this.#ZW_\u200C_NJ; + } + ZW_\u200D_J(value) { + this.#ZW_\u200D_J = value; + return this.#ZW_\u200D_J; + } +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +C.m().then(function(v) { + assert.sameValue(v, 42); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert.sameValue(c.$(1), 1); + assert.sameValue(c._(1), 1); + assert.sameValue(c.\u{6F}(1), 1); + assert.sameValue(c.\u2118(1), 1); + assert.sameValue(c.ZW_\u200C_NJ(1), 1); + assert.sameValue(c.ZW_\u200D_J(1), 1); + + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-rs-static-async-generator-method-privatename-identifier-alt.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-rs-static-async-generator-method-privatename-identifier-alt.js new file mode 100644 index 0000000000..bdd718f6cc --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-rs-static-async-generator-method-privatename-identifier-alt.js @@ -0,0 +1,150 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-async-generator-method-privatename-identifier-alt.case +// - src/class-elements/productions/cls-decl-after-same-line-static-async-method.template +/*--- +description: Valid Static AsyncGeneratorMethod PrivateName (field definitions after a static async method in the same line) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public, async-functions] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + AsyncGeneratorMethod + + AsyncGeneratorMethod : + async [no LineTerminator here] * ClassElementName ( UniqueFormalParameters){ AsyncGeneratorBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static async m() { return 42; } static async * #$(value) { + yield * await value; + } + static async * #_(value) { + yield * await value; + } + static async * #o(value) { + yield * await value; + } + static async * #℘(value) { + yield * await value; + } + static async * #ZW_‌_NJ(value) { + yield * await value; + } + static async * #ZW_‍_J(value) { + yield * await value; + }; + static get $() { + return this.#$; + } + static get _() { + return this.#_; + } + static get o() { + return this.#o; + } + static get ℘() { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#℘; + } + static get ZW_‌_NJ() { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#ZW_‌_NJ; + } + static get ZW_‍_J() { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#ZW_‍_J; + } + +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +C.m().then(function(v) { + assert.sameValue(v, 42); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + Promise.all([ + C.$([1]).next(), + C._([1]).next(), + C.o([1]).next(), + C.℘([1]).next(), // DO NOT CHANGE THE NAME OF THIS FIELD + C.ZW_‌_NJ([1]).next(), // DO NOT CHANGE THE NAME OF THIS FIELD + C.ZW_‍_J([1]).next(), // DO NOT CHANGE THE NAME OF THIS FIELD + ]).then(results => { + + assert.sameValue(results[0].value, 1); + assert.sameValue(results[1].value, 1); + assert.sameValue(results[2].value, 1); + assert.sameValue(results[3].value, 1); + assert.sameValue(results[4].value, 1); + assert.sameValue(results[5].value, 1); + + }).then($DONE, $DONE); + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-rs-static-async-generator-method-privatename-identifier.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-rs-static-async-generator-method-privatename-identifier.js new file mode 100644 index 0000000000..d72ce12993 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-rs-static-async-generator-method-privatename-identifier.js @@ -0,0 +1,151 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-async-generator-method-privatename-identifier.case +// - src/class-elements/productions/cls-decl-after-same-line-static-async-method.template +/*--- +description: Valid Static AsyncGeneratorMethod PrivateName (field definitions after a static async method in the same line) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public, async-functions] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + AsyncGeneratorMethod + + AsyncGeneratorMethod : + async [no LineTerminator here] * ClassElementName ( UniqueFormalParameters){ AsyncGeneratorBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static async m() { return 42; } static async * #$(value) { + yield * await value; + } + static async * #_(value) { + yield * await value; + } + static async * #\u{6F}(value) { + yield * await value; + } + static async * #\u2118(value) { + yield * await value; + } + static async * #ZW_\u200C_NJ(value) { + yield * await value; + } + static async * #ZW_\u200D_J(value) { + yield * await value; + }; + static get $() { + return this.#$; + } + static get _() { + return this.#_; + } + static get \u{6F}() { + return this.#\u{6F}; + } + static get \u2118() { + return this.#\u2118; + } + static get ZW_\u200C_NJ() { + return this.#ZW_\u200C_NJ; + } + static get ZW_\u200D_J() { + return this.#ZW_\u200D_J; + } + +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +C.m().then(function(v) { + assert.sameValue(v, 42); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + Promise.all([ + C.$([1]).next(), + C._([1]).next(), + C.\u{6F}([1]).next(), + C.\u2118([1]).next(), + C.ZW_\u200C_NJ([1]).next(), + C.ZW_\u200D_J([1]).next(), + ]).then(results => { + + assert.sameValue(results[0].value, 1); + assert.sameValue(results[1].value, 1); + assert.sameValue(results[2].value, 1); + assert.sameValue(results[3].value, 1); + assert.sameValue(results[4].value, 1); + assert.sameValue(results[5].value, 1); + + }).then($DONE, $DONE); + + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-rs-static-async-method-privatename-identifier-alt.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-rs-static-async-method-privatename-identifier-alt.js new file mode 100644 index 0000000000..344c1f439b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-rs-static-async-method-privatename-identifier-alt.js @@ -0,0 +1,150 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-async-method-privatename-identifier-alt.case +// - src/class-elements/productions/cls-decl-after-same-line-static-async-method.template +/*--- +description: Valid Static AsyncMethod PrivateName (field definitions after a static async method in the same line) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public, async-functions] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + AsyncMethod + + AsyncMethod : + async [no LineTerminator here] ClassElementName ( UniqueFormalParameters ){ AsyncFunctionBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static async m() { return 42; } static async #$(value) { + return await value; + } + static async #_(value) { + return await value; + } + static async #o(value) { + return await value; + } + static async #℘(value) { + return await value; + } + static async #ZW_‌_NJ(value) { + return await value; + } + static async #ZW_‍_J(value) { + return await value; + }; + static async $(value) { + return await this.#$(value); + } + static async _(value) { + return await this.#_(value); + } + static async o(value) { + return await this.#o(value); + } + static async ℘(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + return await this.#℘(value); + } + static async ZW_‌_NJ(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + return await this.#ZW_‌_NJ(value); + } + static async ZW_‍_J(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + return await this.#ZW_‍_J(value); + } + +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +C.m().then(function(v) { + assert.sameValue(v, 42); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + Promise.all([ + C.$(1), + C._(1), + C.o(1), + C.℘(1), // DO NOT CHANGE THE NAME OF THIS FIELD + C.ZW_‌_NJ(1), // DO NOT CHANGE THE NAME OF THIS FIELD + C.ZW_‍_J(1), // DO NOT CHANGE THE NAME OF THIS FIELD + ]).then(results => { + + assert.sameValue(results[0], 1); + assert.sameValue(results[1], 1); + assert.sameValue(results[2], 1); + assert.sameValue(results[3], 1); + assert.sameValue(results[4], 1); + assert.sameValue(results[5], 1); + + }).then($DONE, $DONE); + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-rs-static-async-method-privatename-identifier.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-rs-static-async-method-privatename-identifier.js new file mode 100644 index 0000000000..d2aedfae37 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-rs-static-async-method-privatename-identifier.js @@ -0,0 +1,151 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-async-method-privatename-identifier.case +// - src/class-elements/productions/cls-decl-after-same-line-static-async-method.template +/*--- +description: Valid Static AsyncMethod PrivateName (field definitions after a static async method in the same line) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public, async-functions] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + AsyncMethod + + AsyncMethod : + async [no LineTerminator here] ClassElementName ( UniqueFormalParameters ){ AsyncFunctionBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static async m() { return 42; } static async #$(value) { + return await value; + } + static async #_(value) { + return await value; + } + static async #\u{6F}(value) { + return await value; + } + static async #\u2118(value) { + return await value; + } + static async #ZW_\u200C_NJ(value) { + return await value; + } + static async #ZW_\u200D_J(value) { + return await value; + }; + static async $(value) { + return await this.#$(value); + } + static async _(value) { + return await this.#_(value); + } + static async \u{6F}(value) { + return await this.#\u{6F}(value); + } + static async \u2118(value) { + return await this.#\u2118(value); + } + static async ZW_\u200C_NJ(value) { + return await this.#ZW_\u200C_NJ(value); + } + static async ZW_\u200D_J(value) { + return await this.#ZW_\u200D_J(value); + } + +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +C.m().then(function(v) { + assert.sameValue(v, 42); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + Promise.all([ + C.$(1), + C._(1), + C.\u{6F}(1), + C.\u2118(1), + C.ZW_\u200C_NJ(1), + C.ZW_\u200D_J(1), + ]).then(results => { + + assert.sameValue(results[0], 1); + assert.sameValue(results[1], 1); + assert.sameValue(results[2], 1); + assert.sameValue(results[3], 1); + assert.sameValue(results[4], 1); + assert.sameValue(results[5], 1); + + }).then($DONE, $DONE); + + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-rs-static-generator-method-privatename-identifier-alt.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-rs-static-generator-method-privatename-identifier-alt.js new file mode 100644 index 0000000000..4207291845 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-rs-static-generator-method-privatename-identifier-alt.js @@ -0,0 +1,139 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-generator-method-privatename-identifier-alt.case +// - src/class-elements/productions/cls-decl-after-same-line-static-async-method.template +/*--- +description: Valid Static GeneratorMethod PrivateName (field definitions after a static async method in the same line) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public, async-functions] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + GeneratorMethod + + GeneratorMethod : + * ClassElementName ( UniqueFormalParameters ){ GeneratorBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static async m() { return 42; } static * #$(value) { + yield * value; + } + static * #_(value) { + yield * value; + } + static * #o(value) { + yield * value; + } + static * #℘(value) { + yield * value; + } + static * #ZW_‌_NJ(value) { + yield * value; + } + static * #ZW_‍_J(value) { + yield * value; + }; + static get $() { + return this.#$; + } + static get _() { + return this.#_; + } + static get o() { + return this.#o; + } + static get ℘() { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#℘; + } + static get ZW_‌_NJ() { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#ZW_‌_NJ; + } + static get ZW_‍_J() { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#ZW_‍_J; + } + +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +C.m().then(function(v) { + assert.sameValue(v, 42); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert.sameValue(C.$([1]).next().value, 1); + assert.sameValue(C._([1]).next().value, 1); + assert.sameValue(C.o([1]).next().value, 1); + assert.sameValue(C.℘([1]).next().value, 1); + assert.sameValue(C.ZW_‌_NJ([1]).next().value, 1); + assert.sameValue(C.ZW_‍_J([1]).next().value, 1); + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-rs-static-generator-method-privatename-identifier.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-rs-static-generator-method-privatename-identifier.js new file mode 100644 index 0000000000..e839471025 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-rs-static-generator-method-privatename-identifier.js @@ -0,0 +1,140 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-generator-method-privatename-identifier.case +// - src/class-elements/productions/cls-decl-after-same-line-static-async-method.template +/*--- +description: Valid Static GeneratorMethod PrivateName (field definitions after a static async method in the same line) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public, async-functions] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + GeneratorMethod + + GeneratorMethod : + * ClassElementName ( UniqueFormalParameters ){ GeneratorBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static async m() { return 42; } static * #$(value) { + yield * value; + } + static * #_(value) { + yield * value; + } + static * #\u{6F}(value) { + yield * value; + } + static * #\u2118(value) { + yield * value; + } + static * #ZW_\u200C_NJ(value) { + yield * value; + } + static * #ZW_\u200D_J(value) { + yield * value; + }; + static get $() { + return this.#$; + } + static get _() { + return this.#_; + } + static get \u{6F}() { + return this.#\u{6F}; + } + static get \u2118() { + return this.#\u2118; + } + static get ZW_\u200C_NJ() { + return this.#ZW_\u200C_NJ; + } + static get ZW_\u200D_J() { + return this.#ZW_\u200D_J; + } + +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +C.m().then(function(v) { + assert.sameValue(v, 42); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert.sameValue(C.$([1]).next().value, 1); + assert.sameValue(C._([1]).next().value, 1); + assert.sameValue(C.\u{6F}([1]).next().value, 1); + assert.sameValue(C.\u2118([1]).next().value, 1); + assert.sameValue(C.ZW_\u200C_NJ([1]).next().value, 1); + assert.sameValue(C.ZW_\u200D_J([1]).next().value, 1); + + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-rs-static-method-privatename-identifier-alt.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-rs-static-method-privatename-identifier-alt.js new file mode 100644 index 0000000000..4429dda9bd --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-rs-static-method-privatename-identifier-alt.js @@ -0,0 +1,137 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-method-privatename-identifier-alt.case +// - src/class-elements/productions/cls-decl-after-same-line-static-async-method.template +/*--- +description: Valid Static Method PrivateName (field definitions after a static async method in the same line) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public, async-functions] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + ClassElementName ( UniqueFormalParameters ){ FunctionBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static async m() { return 42; } static #$(value) { + return value; + } + static #_(value) { + return value; + } + static #o(value) { + return value; + } + static #℘(value) { + return value; + } + static #ZW_‌_NJ(value) { + return value; + } + static #ZW_‍_J(value) { + return value; + }; + static $(value) { + return this.#$(value); + } + static _(value) { + return this.#_(value); + } + static o(value) { + return this.#o(value); + } + static ℘(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#℘(value); + } + static ZW_‌_NJ(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#ZW_‌_NJ(value); + } + static ZW_‍_J(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#ZW_‍_J(value); + } + +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +C.m().then(function(v) { + assert.sameValue(v, 42); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert.sameValue(C.$(1), 1); + assert.sameValue(C._(1), 1); + assert.sameValue(C.o(1), 1); + assert.sameValue(C.℘(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD + assert.sameValue(C.ZW_‌_NJ(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD + assert.sameValue(C.ZW_‍_J(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD + + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-rs-static-method-privatename-identifier.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-rs-static-method-privatename-identifier.js new file mode 100644 index 0000000000..07dbb5d6ca --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-rs-static-method-privatename-identifier.js @@ -0,0 +1,137 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-method-privatename-identifier.case +// - src/class-elements/productions/cls-decl-after-same-line-static-async-method.template +/*--- +description: Valid Static Method PrivateName (field definitions after a static async method in the same line) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public, async-functions] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + ClassElementName ( UniqueFormalParameters ){ FunctionBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static async m() { return 42; } static #$(value) { + return value; + } + static #_(value) { + return value; + } + static #\u{6F}(value) { + return value; + } + static #\u2118(value) { + return value; + } + static #ZW_\u200C_NJ(value) { + return value; + } + static #ZW_\u200D_J(value) { + return value; + }; + static $(value) { + return this.#$(value); + } + static _(value) { + return this.#_(value); + } + static \u{6F}(value) { + return this.#\u{6F}(value); + } + static \u2118(value) { + return this.#\u2118(value); + } + static ZW_\u200C_NJ(value) { + return this.#ZW_\u200C_NJ(value); + } + static ZW_\u200D_J(value) { + return this.#ZW_\u200D_J(value); + } + +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +C.m().then(function(v) { + assert.sameValue(v, 42); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert.sameValue(C.$(1), 1); + assert.sameValue(C._(1), 1); + assert.sameValue(C.\u{6F}(1), 1); + assert.sameValue(C.\u2118(1), 1); + assert.sameValue(C.ZW_\u200C_NJ(1), 1); + assert.sameValue(C.ZW_\u200D_J(1), 1); + + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-rs-static-privatename-identifier-alt-by-classname.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-rs-static-privatename-identifier-alt-by-classname.js new file mode 100644 index 0000000000..de741f808a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-rs-static-privatename-identifier-alt-by-classname.js @@ -0,0 +1,125 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-privatename-identifier-alt-by-classname.case +// - src/class-elements/productions/cls-decl-after-same-line-static-async-method.template +/*--- +description: Valid Static PrivateName (field definitions after a static async method in the same line) +esid: prod-FieldDefinition +features: [class-static-fields-private, class, class-fields-public, async-functions] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static async m() { return 42; } static #$; static #_; static #\u{6F}; static #℘; static #ZW_‌_NJ; static #ZW_‍_J; + static $(value) { + C.#$ = value; + return C.#$; + } + static _(value) { + C.#_ = value; + return C.#_; + } + static o(value) { + C.#\u{6F} = value; + return C.#\u{6F}; + } + static ℘(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + C.#℘ = value; + return C.#℘; + } + static ZW_‌_NJ(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + C.#ZW_‌_NJ = value; + return C.#ZW_‌_NJ; + } + static ZW_‍_J(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + C.#ZW_‍_J = value; + return C.#ZW_‍_J; + } +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +C.m().then(function(v) { + assert.sameValue(v, 42); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert.sameValue(C.$(1), 1); + assert.sameValue(C._(1), 1); + assert.sameValue(C.o(1), 1); + assert.sameValue(C.℘(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD + assert.sameValue(C.ZW_‌_NJ(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD + assert.sameValue(C.ZW_‍_J(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD + + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-rs-static-privatename-identifier-alt.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-rs-static-privatename-identifier-alt.js new file mode 100644 index 0000000000..032187502f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-rs-static-privatename-identifier-alt.js @@ -0,0 +1,125 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-privatename-identifier-alt.case +// - src/class-elements/productions/cls-decl-after-same-line-static-async-method.template +/*--- +description: Valid Static PrivateName (field definitions after a static async method in the same line) +esid: prod-FieldDefinition +features: [class-static-fields-private, class, class-fields-public, async-functions] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static async m() { return 42; } static #$; static #_; static #\u{6F}; static #℘; static #ZW_‌_NJ; static #ZW_‍_J; + static $(value) { + this.#$ = value; + return this.#$; + } + static _(value) { + this.#_ = value; + return this.#_; + } + static o(value) { + this.#\u{6F} = value; + return this.#\u{6F}; + } + static ℘(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + this.#℘ = value; + return this.#℘; + } + static ZW_‌_NJ(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + this.#ZW_‌_NJ = value; + return this.#ZW_‌_NJ; + } + static ZW_‍_J(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + this.#ZW_‍_J = value; + return this.#ZW_‍_J; + } +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +C.m().then(function(v) { + assert.sameValue(v, 42); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert.sameValue(C.$(1), 1); + assert.sameValue(C._(1), 1); + assert.sameValue(C.o(1), 1); + assert.sameValue(C.℘(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD + assert.sameValue(C.ZW_‌_NJ(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD + assert.sameValue(C.ZW_‍_J(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD + + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-rs-static-privatename-identifier-by-classname.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-rs-static-privatename-identifier-by-classname.js new file mode 100644 index 0000000000..2b45cd6849 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-rs-static-privatename-identifier-by-classname.js @@ -0,0 +1,125 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-privatename-identifier-by-classname.case +// - src/class-elements/productions/cls-decl-after-same-line-static-async-method.template +/*--- +description: Valid Static PrivateName (field definitions after a static async method in the same line) +esid: prod-FieldDefinition +features: [class-static-fields-private, class, class-fields-public, async-functions] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static async m() { return 42; } static #$; static #_; static #\u{6F}; static #\u2118; static #ZW_\u200C_NJ; static #ZW_\u200D_J; + static $(value) { + C.#$ = value; + return C.#$; + } + static _(value) { + C.#_ = value; + return C.#_; + } + static \u{6F}(value) { + C.#\u{6F} = value; + return C.#\u{6F}; + } + static \u2118(value) { + C.#\u2118 = value; + return C.#\u2118; + } + static ZW_\u200C_NJ(value) { + C.#ZW_\u200C_NJ = value; + return C.#ZW_\u200C_NJ; + } + static ZW_\u200D_J(value) { + C.#ZW_\u200D_J = value; + return C.#ZW_\u200D_J; + } +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +C.m().then(function(v) { + assert.sameValue(v, 42); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert.sameValue(C.$(1), 1); + assert.sameValue(C._(1), 1); + assert.sameValue(C.\u{6F}(1), 1); + assert.sameValue(C.\u2118(1), 1); + assert.sameValue(C.ZW_\u200C_NJ(1), 1); + assert.sameValue(C.ZW_\u200D_J(1), 1); + + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-rs-static-privatename-identifier-initializer-alt-by-classname.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-rs-static-privatename-identifier-initializer-alt-by-classname.js new file mode 100644 index 0000000000..ae1ee0eeab --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-rs-static-privatename-identifier-initializer-alt-by-classname.js @@ -0,0 +1,119 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-privatename-identifier-initializer-alt-by-classname.case +// - src/class-elements/productions/cls-decl-after-same-line-static-async-method.template +/*--- +description: Valid Static PrivateName (field definitions after a static async method in the same line) +esid: prod-FieldDefinition +features: [class-static-fields-private, class, class-fields-public, async-functions] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static async m() { return 42; } static #$ = 1; static #_ = 1; static #\u{6F} = 1; static #℘ = 1; static #ZW_‌_NJ = 1; static #ZW_‍_J = 1; + static $() { + return C.#$; + } + static _() { + return C.#_; + } + static \u{6F}() { + return C.#\u{6F}; + } + static ℘() { + return C.#℘; + } + static ZW_‌_NJ() { + return C.#ZW_‌_NJ; + } + static ZW_‍_J() { + return C.#ZW_‍_J; + } +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +C.m().then(function(v) { + assert.sameValue(v, 42); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert.sameValue(C.$(), 1); + assert.sameValue(C._(), 1); + assert.sameValue(C.\u{6F}(), 1); + assert.sameValue(C.℘(), 1); + assert.sameValue(C.ZW_‌_NJ(), 1); + assert.sameValue(C.ZW_‍_J(), 1); + + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-rs-static-privatename-identifier-initializer-alt.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-rs-static-privatename-identifier-initializer-alt.js new file mode 100644 index 0000000000..050cce6101 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-rs-static-privatename-identifier-initializer-alt.js @@ -0,0 +1,119 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-privatename-identifier-initializer-alt.case +// - src/class-elements/productions/cls-decl-after-same-line-static-async-method.template +/*--- +description: Valid Static PrivateName (field definitions after a static async method in the same line) +esid: prod-FieldDefinition +features: [class-static-fields-private, class, class-fields-public, async-functions] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static async m() { return 42; } static #$ = 1; static #_ = 1; static #\u{6F} = 1; static #℘ = 1; static #ZW_‌_NJ = 1; static #ZW_‍_J = 1; + static $() { + return this.#$; + } + static _() { + return this.#_; + } + static \u{6F}() { + return this.#\u{6F}; + } + static ℘() { + return this.#℘; + } + static ZW_‌_NJ() { + return this.#ZW_‌_NJ; + } + static ZW_‍_J() { + return this.#ZW_‍_J; + } +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +C.m().then(function(v) { + assert.sameValue(v, 42); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert.sameValue(C.$(), 1); + assert.sameValue(C._(), 1); + assert.sameValue(C.\u{6F}(), 1); + assert.sameValue(C.℘(), 1); + assert.sameValue(C.ZW_‌_NJ(), 1); + assert.sameValue(C.ZW_‍_J(), 1); + + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-rs-static-privatename-identifier-initializer.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-rs-static-privatename-identifier-initializer.js new file mode 100644 index 0000000000..868c5a6289 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-rs-static-privatename-identifier-initializer.js @@ -0,0 +1,119 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-privatename-identifier-initializer.case +// - src/class-elements/productions/cls-decl-after-same-line-static-async-method.template +/*--- +description: Valid Static PrivateName (field definitions after a static async method in the same line) +esid: prod-FieldDefinition +features: [class-static-fields-private, class, class-fields-public, async-functions] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static async m() { return 42; } static #$ = 1; static #_ = 1; static #\u{6F} = 1; static #\u2118 = 1; static #ZW_\u200C_NJ = 1; static #ZW_\u200D_J = 1; + static $() { + return this.#$; + } + static _() { + return this.#_; + } + static \u{6F}() { + return this.#\u{6F}; + } + static \u2118() { + return this.#\u2118; + } + static ZW_\u200C_NJ() { + return this.#ZW_\u200C_NJ; + } + static ZW_\u200D_J() { + return this.#ZW_\u200D_J; + } +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +C.m().then(function(v) { + assert.sameValue(v, 42); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert.sameValue(C.$(), 1); + assert.sameValue(C._(), 1); + assert.sameValue(C.\u{6F}(), 1); + assert.sameValue(C.\u2118(), 1); + assert.sameValue(C.ZW_\u200C_NJ(), 1); + assert.sameValue(C.ZW_\u200D_J(), 1); + + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-rs-static-privatename-identifier.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-rs-static-privatename-identifier.js new file mode 100644 index 0000000000..439531a775 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-rs-static-privatename-identifier.js @@ -0,0 +1,125 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-privatename-identifier.case +// - src/class-elements/productions/cls-decl-after-same-line-static-async-method.template +/*--- +description: Valid Static PrivateName (field definitions after a static async method in the same line) +esid: prod-FieldDefinition +features: [class-static-fields-private, class, class-fields-public, async-functions] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static async m() { return 42; } static #$; static #_; static #\u{6F}; static #\u2118; static #ZW_\u200C_NJ; static #ZW_\u200D_J; + static $(value) { + this.#$ = value; + return this.#$; + } + static _(value) { + this.#_ = value; + return this.#_; + } + static \u{6F}(value) { + this.#\u{6F} = value; + return this.#\u{6F}; + } + static \u2118(value) { + this.#\u2118 = value; + return this.#\u2118; + } + static ZW_\u200C_NJ(value) { + this.#ZW_\u200C_NJ = value; + return this.#ZW_\u200C_NJ; + } + static ZW_\u200D_J(value) { + this.#ZW_\u200D_J = value; + return this.#ZW_\u200D_J; + } +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +C.m().then(function(v) { + assert.sameValue(v, 42); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert.sameValue(C.$(1), 1); + assert.sameValue(C._(1), 1); + assert.sameValue(C.\u{6F}(1), 1); + assert.sameValue(C.\u2118(1), 1); + assert.sameValue(C.ZW_\u200C_NJ(1), 1); + assert.sameValue(C.ZW_\u200D_J(1), 1); + + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-static-private-fields.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-static-private-fields.js new file mode 100644 index 0000000000..8321179c85 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-static-private-fields.js @@ -0,0 +1,86 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/static-private-fields.case +// - src/class-elements/productions/cls-decl-after-same-line-static-async-method.template +/*--- +description: static private fields (field definitions after a static async method in the same line) +esid: prod-FieldDefinition +features: [class-static-fields-private, class, class-fields-public, async-functions] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + ... + static FieldDefinition ; + + FieldDefinition : + ClassElementName Initializer_opt + + ClassElementName : + PrivateName + + PrivateName : + # IdentifierName + +---*/ + + +class C { + static async m() { return 42; } static #x; static #y; + static x() { + this.#x = 42; + return this.#x; + } + static y() { + this.#y = 43; + return this.#y; + } +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +C.m().then(function(v) { + assert.sameValue(v, 42); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + // Test the private fields do not appear as properties before set to value + assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#x"), "test 1"); + assert(!Object.prototype.hasOwnProperty.call(C, "#x"), "test 2"); + assert(!Object.prototype.hasOwnProperty.call(c, "#x"), "test 3"); + + assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#y"), "test 4"); + assert(!Object.prototype.hasOwnProperty.call(C, "#y"), "test 5"); + assert(!Object.prototype.hasOwnProperty.call(c, "#y"), "test 6"); + + // Test if private fields can be sucessfully accessed and set to value + assert.sameValue(C.x(), 42, "test 7"); + assert.sameValue(C.y(), 43, "test 8"); + + // Test the private fields do not appear as properties before after set to value + assert(!Object.prototype.hasOwnProperty.call(C, "#x"), "test 9"); + assert(!Object.prototype.hasOwnProperty.call(C, "#y"), "test 10"); + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-static-private-methods-with-fields.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-static-private-methods-with-fields.js new file mode 100644 index 0000000000..451d1ff4e9 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-static-private-methods-with-fields.js @@ -0,0 +1,103 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/static-private-methods-with-fields.case +// - src/class-elements/productions/cls-decl-after-same-line-static-async-method.template +/*--- +description: static private methods with fields (field definitions after a static async method in the same line) +esid: prod-FieldDefinition +features: [class-static-methods-private, class-static-fields-private, class, class-fields-public, async-functions] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + ... + static FieldDefinition ; + + FieldDefinition : + ClassElementName Initializer_opt + + ClassElementName : + PrivateName + + PrivateName : + # IdentifierName + +---*/ + + +class C { + static async m() { return 42; } static #xVal; static #yVal; + static #x(value) { + this.#xVal = value; + return this.#xVal; + } + static #y(value) { + this.#yVal = value; + return this.#yVal; + } + static x() { + return this.#x(42); + } + static y() { + return this.#y(43); + } +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +C.m().then(function(v) { + assert.sameValue(v, 42); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + // Test the private methods do not appear as properties before set to value + assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#x"), "test 1"); + assert(!Object.prototype.hasOwnProperty.call(C, "#x"), "test 2"); + assert(!Object.prototype.hasOwnProperty.call(c, "#x"), "test 3"); + + assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#y"), "test 4"); + assert(!Object.prototype.hasOwnProperty.call(C, "#y"), "test 5"); + assert(!Object.prototype.hasOwnProperty.call(c, "#y"), "test 6"); + + assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#xVal"), "test 7"); + assert(!Object.prototype.hasOwnProperty.call(C, "#xVal"), "test 8"); + assert(!Object.prototype.hasOwnProperty.call(c, "#xVal"), "test 9"); + + assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#yVal"), "test 10"); + assert(!Object.prototype.hasOwnProperty.call(C, "#yVal"), "test 11"); + assert(!Object.prototype.hasOwnProperty.call(c, "#yVal"), "test 12"); + + // Test if private fields can be sucessfully accessed and set to value + assert.sameValue(C.x(), 42, "test 13"); + assert.sameValue(C.y(), 43, "test 14"); + + // Test the private fields do not appear as properties before after set to value + assert(!Object.prototype.hasOwnProperty.call(C, "#x"), "test 15"); + assert(!Object.prototype.hasOwnProperty.call(C, "#y"), "test 16"); + + assert(!Object.prototype.hasOwnProperty.call(C, "#xVal"), "test 17"); + assert(!Object.prototype.hasOwnProperty.call(C, "#yVal"), "test 18"); + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-static-private-methods.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-static-private-methods.js new file mode 100644 index 0000000000..212944715c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-static-private-methods.js @@ -0,0 +1,90 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/static-private-methods.case +// - src/class-elements/productions/cls-decl-after-same-line-static-async-method.template +/*--- +description: static private methods (field definitions after a static async method in the same line) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public, async-functions] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + ... + static FieldDefinition ; + + FieldDefinition : + ClassElementName Initializer_opt + + ClassElementName : + PrivateName + + PrivateName : + # IdentifierName + +---*/ + + +class C { + static async m() { return 42; } ; + static #x(value) { + return value / 2; + } + static #y(value) { + return value * 2; + } + static x() { + return this.#x(84); + } + static y() { + return this.#y(43); + } +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +C.m().then(function(v) { + assert.sameValue(v, 42); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + // Test the private methods do not appear as properties before set to value + assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#x"), "test 1"); + assert(!Object.prototype.hasOwnProperty.call(C, "#x"), "test 2"); + assert(!Object.prototype.hasOwnProperty.call(c, "#x"), "test 3"); + + assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#y"), "test 4"); + assert(!Object.prototype.hasOwnProperty.call(C, "#y"), "test 5"); + assert(!Object.prototype.hasOwnProperty.call(c, "#y"), "test 6"); + + // Test if private fields can be sucessfully accessed and set to value + assert.sameValue(C.x(), 42, "test 7"); + assert.sameValue(C.y(), 86, "test 8"); + + // Test the private fields do not appear as properties before after set to value + assert(!Object.prototype.hasOwnProperty.call(C, "#x"), "test 9"); + assert(!Object.prototype.hasOwnProperty.call(C, "#y"), "test 10"); + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-string-literal-names.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-string-literal-names.js new file mode 100644 index 0000000000..9f166c7de6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-method-string-literal-names.js @@ -0,0 +1,124 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/string-literal-names.case +// - src/class-elements/productions/cls-decl-after-same-line-static-async-method.template +/*--- +description: String literal names (field definitions after a static async method in the same line) +esid: prod-FieldDefinition +features: [class-fields-public, class, async-functions] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PropertyName + +---*/ + + +class C { + static async m() { return 42; } 'a'; "b"; 'c' = 39; + "d" = 42; + +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +C.m().then(function(v) { + assert.sameValue(v, 42); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "a"), + "a does not appear as an own property on C prototype" + ); + assert( + !Object.prototype.hasOwnProperty.call(C, "a"), + "a does not appear as an own property on C constructor" + ); + + verifyProperty(c, "a", { + value: undefined, + enumerable: true, + writable: true, + configurable: true + }); + + assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "b"), + "b does not appear as an own property on C prototype" + ); + assert( + !Object.prototype.hasOwnProperty.call(C, "b"), + "b does not appear as an own property on C constructor" + ); + + verifyProperty(c, "b", { + value: undefined, + enumerable: true, + writable: true, + configurable: true + }); + + assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "c"), + "c does not appear as an own property on C prototype" + ); + assert( + !Object.prototype.hasOwnProperty.call(C, "c"), + "c does not appear as an own property on C constructor" + ); + + verifyProperty(c, "c", { + value: 39, + enumerable: true, + writable: true, + configurable: true + }); + + assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "d"), + "d does not appear as an own property on C prototype" + ); + assert( + !Object.prototype.hasOwnProperty.call(C, "d"), + "d does not appear as an own property on C constructor" + ); + + verifyProperty(c, "d", { + value: 42, + enumerable: true, + writable: true, + configurable: true + }); + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-computed-names.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-computed-names.js new file mode 100644 index 0000000000..7a4af2835c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-computed-names.js @@ -0,0 +1,110 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/computed-names.case +// - src/class-elements/productions/cls-decl-after-same-line-static-gen.template +/*--- +description: Computed property names (field definitions after a static generator in the same line) +esid: prod-FieldDefinition +features: [class-fields-public, computed-property-names, generators, class] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PropertyName + +---*/ +var x = "b"; + + + +class C { + static *m() { return 42; } [x] = 42; [10] = "meep"; ["not initialized"]; + +} + +var c = new C(); + +assert.sameValue(C.m().next().value, 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "b"), + "b doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "b"), + "b doesn't appear as an own property on C constructor" +); + +verifyProperty(c, "b", { + value: 42, + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "x"), + "x doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "x"), + "x doesn't appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "x"), + "x doesn't appear as an own property on C instance" +); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "10"), + "10 doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "10"), + "10 doesn't appear as an own property on C constructor" +); + +verifyProperty(c, "10", { + value: "meep", + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "not initialized"), + "'not initialized' doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "not initialized"), + "'not initialized' doesn't appear as an own property on C constructor" +); + +verifyProperty(c, "not initialized", { + value: undefined, + enumerable: true, + writable: true, + configurable: true +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-computed-symbol-names.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-computed-symbol-names.js new file mode 100644 index 0000000000..9de02507a5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-computed-symbol-names.js @@ -0,0 +1,108 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/computed-symbol-names.case +// - src/class-elements/productions/cls-decl-after-same-line-static-gen.template +/*--- +description: Computed property symbol names (field definitions after a static generator in the same line) +esid: prod-FieldDefinition +features: [class-fields-public, Symbol, computed-property-names, generators, class] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PropertyName + +---*/ +var x = Symbol(); +var y = Symbol(); + + + +class C { + static *m() { return 42; } [x]; [y] = 42; + +} + +var c = new C(); + +assert.sameValue(C.m().next().value, 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, x), + "Symbol x doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, x), + "Symbol x doesn't appear as an own property on C constructor" +); + +verifyProperty(c, x, { + value: undefined, + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, y), + "Symbol y doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, y), + "Symbol y doesn't appear as an own property on C constructor" +); + +verifyProperty(c, y, { + value: 42, + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "x"), + "x doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "x"), + "x doesn't appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "x"), + "x doesn't appear as an own property on C instance" +); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "y"), + "y doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "y"), + "y doesn't appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "y"), + "y doesn't appear as an own property on C instance" +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-grammar-privatename-identifier-semantics-stringvalue.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-grammar-privatename-identifier-semantics-stringvalue.js new file mode 100644 index 0000000000..a7e4a814b1 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-grammar-privatename-identifier-semantics-stringvalue.js @@ -0,0 +1,112 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-privatename-identifier-semantics-stringvalue.case +// - src/class-elements/productions/cls-decl-after-same-line-static-gen.template +/*--- +description: PrivateName Static Semantics, StringValue (field definitions after a static generator in the same line) +esid: prod-FieldDefinition +features: [class-fields-private, generators, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + + + 1. Return the String value consisting of the sequence of code + units corresponding to PrivateName. In determining the sequence + any occurrences of \ UnicodeEscapeSequence are first replaced + with the code point represented by the UnicodeEscapeSequence + and then the code points of the entire PrivateName are converted + to code units by UTF16Encoding (10.1.1) each code point. + +---*/ + + +class C { + static *m() { return 42; } #\u{6F}; + #\u2118; + #ZW_\u200C_NJ; + #ZW_\u200D_J;; + o(value) { + this.#o = value; + return this.#o; + } + ℘(value) { + this.#℘ = value; + return this.#℘; + } + ZW_‌_NJ(value) { // DO NOT CHANGE THE NAME OF THIS METHOD + this.#ZW_‌_NJ = value; + return this.#ZW_‌_NJ; + } + ZW_‍_J(value) { // DO NOT CHANGE THE NAME OF THIS METHOD + this.#ZW_‍_J = value; + return this.#ZW_‍_J; + } +} + +var c = new C(); + +assert.sameValue(C.m().next().value, 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.o(1), 1); +assert.sameValue(c.℘(1), 1); +assert.sameValue(c.ZW_‌_NJ(1), 1); +assert.sameValue(c.ZW_‍_J(1), 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-literal-names-asi.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-literal-names-asi.js new file mode 100644 index 0000000000..573533abbd --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-literal-names-asi.js @@ -0,0 +1,80 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/literal-names-asi.case +// - src/class-elements/productions/cls-decl-after-same-line-static-gen.template +/*--- +description: Literal property names with ASI (field definitions after a static generator in the same line) +esid: prod-FieldDefinition +features: [class-fields-public, generators, class] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PropertyName + +---*/ + + +class C { + static *m() { return 42; } a + b = 42;; + +} + +var c = new C(); + +assert.sameValue(C.m().next().value, 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "a"), + "a doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "a"), + "a doesn't appear as an own property on C constructor" +); + +verifyProperty(c, "a", { + value: undefined, + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "b"), + "b doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "b"), + "b doesn't appear as an own property on C constructor" +); + +verifyProperty(c, "b", { + value: 42, + enumerable: true, + writable: true, + configurable: true +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-literal-names.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-literal-names.js new file mode 100644 index 0000000000..d2b667b977 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-literal-names.js @@ -0,0 +1,99 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/literal-names.case +// - src/class-elements/productions/cls-decl-after-same-line-static-gen.template +/*--- +description: Literal property names (field definitions after a static generator in the same line) +esid: prod-FieldDefinition +features: [class-fields-public, generators, class] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PropertyName + +---*/ +const fn = function() {} + + + +class C { + static *m() { return 42; } a; b = 42; + c = fn; + +} + +var c = new C(); + +assert.sameValue(C.m().next().value, 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "a"), + "a doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "a"), + "a doesn't appear as an own property on C constructor" +); + +verifyProperty(c, "a", { + value: undefined, + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "b"), + "b doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "b"), + "b doesn't appear as an own property on C constructor" +); + +verifyProperty(c, "b", { + value: 42, + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "c"), + "c doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "c"), + "c doesn't appear as an own property on C constructor" +); + +verifyProperty(c, "c", { + value: fn, + enumerable: true, + writable: true, + configurable: true +}); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-private-field-usage.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-private-field-usage.js new file mode 100644 index 0000000000..616b420dd1 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-private-field-usage.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/private-field-usage.case +// - src/class-elements/productions/cls-decl-after-same-line-static-gen.template +/*--- +description: PrivateName CallExpression usage (private field) (field definitions after a static generator in the same line) +esid: prod-FieldDefinition +features: [class-fields-private, generators, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + Updated Productions + + CallExpression[Yield, Await]: + CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await] + SuperCall[?Yield, ?Await] + CallExpression[?Yield, ?Await]Arguments[?Yield, ?Await] + CallExpression[?Yield, ?Await][Expression[+In, ?Yield, ?Await]] + CallExpression[?Yield, ?Await].IdentifierName + CallExpression[?Yield, ?Await]TemplateLiteral[?Yield, ?Await] + CallExpression[?Yield, ?Await].PrivateName + +---*/ + + +class C { + static *m() { return 42; } #m = 'test262';; + method() { + return this.#m; + } +} + +var c = new C(); + +assert.sameValue(C.m().next().value, 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.method(), 'test262'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-private-method-getter-usage.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-private-method-getter-usage.js new file mode 100644 index 0000000000..e66e791fc3 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-private-method-getter-usage.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/private-method-getter-usage.case +// - src/class-elements/productions/cls-decl-after-same-line-static-gen.template +/*--- +description: PrivateName CallExpression usage (Accesor get method) (field definitions after a static generator in the same line) +esid: prod-FieldDefinition +features: [class-methods-private, generators, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + Updated Productions + + CallExpression[Yield, Await]: + CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await] + SuperCall[?Yield, ?Await] + CallExpression[?Yield, ?Await]Arguments[?Yield, ?Await] + CallExpression[?Yield, ?Await][Expression[+In, ?Yield, ?Await]] + CallExpression[?Yield, ?Await].IdentifierName + CallExpression[?Yield, ?Await]TemplateLiteral[?Yield, ?Await] + CallExpression[?Yield, ?Await].PrivateName + +---*/ + + +class C { + static *m() { return 42; } get #m() { return 'test262'; }; + method() { + return this.#m; + } +} + +var c = new C(); + +assert.sameValue(C.m().next().value, 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.method(), 'test262'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-private-method-usage.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-private-method-usage.js new file mode 100644 index 0000000000..a79e11f931 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-private-method-usage.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/private-method-usage.case +// - src/class-elements/productions/cls-decl-after-same-line-static-gen.template +/*--- +description: PrivateName CallExpression usage (private method) (field definitions after a static generator in the same line) +esid: prod-FieldDefinition +features: [class-methods-private, generators, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + Updated Productions + + CallExpression[Yield, Await]: + CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await] + SuperCall[?Yield, ?Await] + CallExpression[?Yield, ?Await]Arguments[?Yield, ?Await] + CallExpression[?Yield, ?Await][Expression[+In, ?Yield, ?Await]] + CallExpression[?Yield, ?Await].IdentifierName + CallExpression[?Yield, ?Await]TemplateLiteral[?Yield, ?Await] + CallExpression[?Yield, ?Await].PrivateName + +---*/ + + +class C { + static *m() { return 42; } #m() { return 'test262'; }; + method() { + return this.#m(); + } +} + +var c = new C(); + +assert.sameValue(C.m().next().value, 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.method(), 'test262'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-private-names.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-private-names.js new file mode 100644 index 0000000000..77b88e5621 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-private-names.js @@ -0,0 +1,74 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/private-names.case +// - src/class-elements/productions/cls-decl-after-same-line-static-gen.template +/*--- +description: private names (field definitions after a static generator in the same line) +esid: prod-FieldDefinition +features: [class-fields-private, generators, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + ... + FieldDefinition ; + + FieldDefinition : + ClassElementName Initializer_opt + + ClassElementName : + PrivateName + + PrivateName : + # IdentifierName + +---*/ + + +class C { + static *m() { return 42; } #x; #y; + x() { + this.#x = 42; + return this.#x; + } + y() { + this.#y = 43; + return this.#y; + } +} + +var c = new C(); + +assert.sameValue(C.m().next().value, 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +// Test the private fields do not appear as properties before set to value +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#x"), "test 1"); +assert(!Object.prototype.hasOwnProperty.call(C, "#x"), "test 2"); +assert(!Object.prototype.hasOwnProperty.call(c, "#x"), "test 3"); + +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#y"), "test 4"); +assert(!Object.prototype.hasOwnProperty.call(C, "#y"), "test 5"); +assert(!Object.prototype.hasOwnProperty.call(c, "#y"), "test 6"); + +// Test if private fields can be sucessfully accessed and set to value +assert.sameValue(c.x(), 42, "test 7"); +assert.sameValue(c.y(), 43, "test 8"); + +// Test the private fields do not appear as properties before after set to value +assert(!Object.prototype.hasOwnProperty.call(c, "#x"), "test 9"); +assert(!Object.prototype.hasOwnProperty.call(c, "#y"), "test 10"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-rs-field-identifier-initializer.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-rs-field-identifier-initializer.js new file mode 100644 index 0000000000..b8a6287e9f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-rs-field-identifier-initializer.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-field-identifier-initializer.case +// - src/class-elements/productions/cls-decl-after-same-line-static-gen.template +/*--- +description: Valid FieldDefinition (field definitions after a static generator in the same line) +esid: prod-FieldDefinition +features: [class-fields-public, generators, class] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + ... + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + + PropertyName : + LiteralPropertyName + ComputedPropertyName + + LiteralPropertyName : + IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static *m() { return 42; } $ = 1; _ = 1; \u{6F} = 1; \u2118 = 1; ZW_\u200C_NJ = 1; ZW_\u200D_J = 1; + +} + +var c = new C(); + +assert.sameValue(C.m().next().value, 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.$, 1); +assert.sameValue(c._, 1); +assert.sameValue(c.\u{6F}, 1); +assert.sameValue(c.\u2118, 1); +assert.sameValue(c.ZW_\u200C_NJ, 1); +assert.sameValue(c.ZW_\u200D_J, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-rs-field-identifier.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-rs-field-identifier.js new file mode 100644 index 0000000000..697972b0df --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-rs-field-identifier.js @@ -0,0 +1,97 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-field-identifier.case +// - src/class-elements/productions/cls-decl-after-same-line-static-gen.template +/*--- +description: Valid FieldDefinition (field definitions after a static generator in the same line) +esid: prod-FieldDefinition +features: [class-fields-public, generators, class] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + ... + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + + PropertyName : + LiteralPropertyName + ComputedPropertyName + + LiteralPropertyName : + IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static *m() { return 42; } $; _; \u{6F}; \u2118; ZW_\u200C_NJ; ZW_\u200D_J; + +} + +var c = new C(); + +assert.sameValue(C.m().next().value, 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +c.$ = 1; +c._ = 1; +c.\u{6F} = 1; +c.\u2118 = 1; +c.ZW_\u200C_NJ = 1; +c.ZW_\u200D_J = 1; + +assert.sameValue(c.$, 1); +assert.sameValue(c._, 1); +assert.sameValue(c.\u{6F}, 1); +assert.sameValue(c.\u2118, 1); +assert.sameValue(c.ZW_\u200C_NJ, 1); +assert.sameValue(c.ZW_\u200D_J, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-rs-private-getter-alt.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-rs-private-getter-alt.js new file mode 100644 index 0000000000..ab50cf85b5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-rs-private-getter-alt.js @@ -0,0 +1,131 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-private-getter-alt.case +// - src/class-elements/productions/cls-decl-after-same-line-static-gen.template +/*--- +description: Valid PrivateName as private getter (field definitions after a static generator in the same line) +esid: prod-FieldDefinition +features: [class-methods-private, class-fields-private, generators, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + ... + ; + + MethodDefinition : + ... + get ClassElementName ( ){ FunctionBody } + ... + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static *m() { return 42; } #$_; #__; #\u{6F}_; #℘_; #ZW_‌_NJ_; #ZW_‍_J_; + get #$() { + return this.#$_; + } + get #_() { + return this.#__; + } + get #\u{6F}() { + return this.#\u{6F}_; + } + get #℘() { + return this.#℘_; + } + get #ZW_‌_NJ() { + return this.#ZW_‌_NJ_; + } + get #ZW_‍_J() { + return this.#ZW_‍_J_; + } +; + $(value) { + this.#$_ = value; + return this.#$; + } + _(value) { + this.#__ = value; + return this.#_; + } + \u{6F}(value) { + this.#\u{6F}_ = value; + return this.#\u{6F}; + } + ℘(value) { + this.#℘_ = value; + return this.#℘; + } + ZW_‌_NJ(value) { + this.#ZW_‌_NJ_ = value; + return this.#ZW_‌_NJ; + } + ZW_‍_J(value) { + this.#ZW_‍_J_ = value; + return this.#ZW_‍_J; + } + +} + +var c = new C(); + +assert.sameValue(C.m().next().value, 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.$(1), 1); +assert.sameValue(c._(1), 1); +assert.sameValue(c.\u{6F}(1), 1); +assert.sameValue(c.℘(1), 1); +assert.sameValue(c.ZW_‌_NJ(1), 1); +assert.sameValue(c.ZW_‍_J(1), 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-rs-private-getter.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-rs-private-getter.js new file mode 100644 index 0000000000..57f505cbd6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-rs-private-getter.js @@ -0,0 +1,131 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-private-getter.case +// - src/class-elements/productions/cls-decl-after-same-line-static-gen.template +/*--- +description: Valid PrivateName as private getter (field definitions after a static generator in the same line) +esid: prod-FieldDefinition +features: [class-methods-private, class-fields-private, generators, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + ... + ; + + MethodDefinition : + ... + get ClassElementName ( ){ FunctionBody } + ... + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static *m() { return 42; } #$_; #__; #\u{6F}_; #\u2118_; #ZW_\u200C_NJ_; #ZW_\u200D_J_; + get #$() { + return this.#$_; + } + get #_() { + return this.#__; + } + get #\u{6F}() { + return this.#\u{6F}_; + } + get #\u2118() { + return this.#\u2118_; + } + get #ZW_\u200C_NJ() { + return this.#ZW_\u200C_NJ_; + } + get #ZW_\u200D_J() { + return this.#ZW_\u200D_J_; + } +; + $(value) { + this.#$_ = value; + return this.#$; + } + _(value) { + this.#__ = value; + return this.#_; + } + \u{6F}(value) { + this.#\u{6F}_ = value; + return this.#\u{6F}; + } + \u2118(value) { + this.#\u2118_ = value; + return this.#\u2118; + } + ZW_\u200C_NJ(value) { + this.#ZW_\u200C_NJ_ = value; + return this.#ZW_\u200C_NJ; + } + ZW_\u200D_J(value) { + this.#ZW_\u200D_J_ = value; + return this.#ZW_\u200D_J; + } + +} + +var c = new C(); + +assert.sameValue(C.m().next().value, 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.$(1), 1); +assert.sameValue(c._(1), 1); +assert.sameValue(c.\u{6F}(1), 1); +assert.sameValue(c.\u2118(1), 1); +assert.sameValue(c.ZW_\u200C_NJ(1), 1); +assert.sameValue(c.ZW_\u200D_J(1), 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-rs-private-method-alt.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-rs-private-method-alt.js new file mode 100644 index 0000000000..89f5cf1ac1 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-rs-private-method-alt.js @@ -0,0 +1,130 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-private-method-alt.case +// - src/class-elements/productions/cls-decl-after-same-line-static-gen.template +/*--- +description: Valid PrivateName as private method (field definitions after a static generator in the same line) +esid: prod-FieldDefinition +features: [class-methods-private, class-fields-private, generators, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + ... + ; + + MethodDefinition : + ClassElementName ( UniqueFormalParameters ) { FunctionBody } + ... + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static *m() { return 42; } #$_; #__; #\u{6F}_; #℘_; #ZW_‌_NJ_; #ZW_‍_J_; + #$() { + return this.#$_; + } + #_() { + return this.#__; + } + #\u{6F}() { + return this.#\u{6F}_; + } + #℘() { + return this.#℘_; + } + #ZW_‌_NJ() { + return this.#ZW_‌_NJ_; + } + #ZW_‍_J() { + return this.#ZW_‍_J_; + } +; + $(value) { + this.#$_ = value; + return this.#$(); + } + _(value) { + this.#__ = value; + return this.#_(); + } + \u{6F}(value) { + this.#\u{6F}_ = value; + return this.#\u{6F}(); + } + ℘(value) { + this.#℘_ = value; + return this.#℘(); + } + ZW_‌_NJ(value) { + this.#ZW_‌_NJ_ = value; + return this.#ZW_‌_NJ(); + } + ZW_‍_J(value) { + this.#ZW_‍_J_ = value; + return this.#ZW_‍_J(); + } + +} + +var c = new C(); + +assert.sameValue(C.m().next().value, 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.$(1), 1); +assert.sameValue(c._(1), 1); +assert.sameValue(c.\u{6F}(1), 1); +assert.sameValue(c.℘(1), 1); +assert.sameValue(c.ZW_‌_NJ(1), 1); +assert.sameValue(c.ZW_‍_J(1), 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-rs-private-method.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-rs-private-method.js new file mode 100644 index 0000000000..1c5d73f675 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-rs-private-method.js @@ -0,0 +1,130 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-private-method.case +// - src/class-elements/productions/cls-decl-after-same-line-static-gen.template +/*--- +description: Valid PrivateName as private method (field definitions after a static generator in the same line) +esid: prod-FieldDefinition +features: [class-methods-private, class-fields-private, generators, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + ... + ; + + MethodDefinition : + ClassElementName ( UniqueFormalParameters ) { FunctionBody } + ... + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static *m() { return 42; } #$_; #__; #\u{6F}_; #\u2118_; #ZW_\u200C_NJ_; #ZW_\u200D_J_; + #$() { + return this.#$_; + } + #_() { + return this.#__; + } + #\u{6F}() { + return this.#\u{6F}_; + } + #\u2118() { + return this.#\u2118_; + } + #ZW_\u200C_NJ() { + return this.#ZW_\u200C_NJ_; + } + #ZW_\u200D_J() { + return this.#ZW_\u200D_J_; + } +; + $(value) { + this.#$_ = value; + return this.#$(); + } + _(value) { + this.#__ = value; + return this.#_(); + } + \u{6F}(value) { + this.#\u{6F}_ = value; + return this.#\u{6F}(); + } + \u2118(value) { + this.#\u2118_ = value; + return this.#\u2118(); + } + ZW_\u200C_NJ(value) { + this.#ZW_\u200C_NJ_ = value; + return this.#ZW_\u200C_NJ(); + } + ZW_\u200D_J(value) { + this.#ZW_\u200D_J_ = value; + return this.#ZW_\u200D_J(); + } + +} + +var c = new C(); + +assert.sameValue(C.m().next().value, 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.$(1), 1); +assert.sameValue(c._(1), 1); +assert.sameValue(c.\u{6F}(1), 1); +assert.sameValue(c.\u2118(1), 1); +assert.sameValue(c.ZW_\u200C_NJ(1), 1); +assert.sameValue(c.ZW_\u200D_J(1), 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-rs-private-setter-alt.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-rs-private-setter-alt.js new file mode 100644 index 0000000000..b382776e7d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-rs-private-setter-alt.js @@ -0,0 +1,130 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-private-setter-alt.case +// - src/class-elements/productions/cls-decl-after-same-line-static-gen.template +/*--- +description: Valid PrivateName as private setter (field definitions after a static generator in the same line) +esid: prod-FieldDefinition +features: [class-methods-private, class-fields-private, generators, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + ... + ; + + MethodDefinition : + ... + set ClassElementName ( PropertySetParameterList ) { FunctionBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static *m() { return 42; } #$_; #__; #\u{6F}_; #℘_; #ZW_‌_NJ_; #ZW_‍_J_; + set #$(value) { + this.#$_ = value; + } + set #_(value) { + this.#__ = value; + } + set #\u{6F}(value) { + this.#\u{6F}_ = value; + } + set #℘(value) { + this.#℘_ = value; + } + set #ZW_‌_NJ(value) { + this.#ZW_‌_NJ_ = value; + } + set #ZW_‍_J(value) { + this.#ZW_‍_J_ = value; + } +; + $(value) { + this.#$ = value; + return this.#$_; + } + _(value) { + this.#_ = value; + return this.#__; + } + \u{6F}(value) { + this.#\u{6F} = value; + return this.#\u{6F}_; + } + ℘(value) { + this.#℘ = value; + return this.#℘_; + } + ZW_‌_NJ(value) { + this.#ZW_‌_NJ = value; + return this.#ZW_‌_NJ_; + } + ZW_‍_J(value) { + this.#ZW_‍_J = value; + return this.#ZW_‍_J_; + } + +} + +var c = new C(); + +assert.sameValue(C.m().next().value, 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.$(1), 1); +assert.sameValue(c._(1), 1); +assert.sameValue(c.\u{6F}(1), 1); +assert.sameValue(c.℘(1), 1); +assert.sameValue(c.ZW_‌_NJ(1), 1); +assert.sameValue(c.ZW_‍_J(1), 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-rs-private-setter.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-rs-private-setter.js new file mode 100644 index 0000000000..0bb69a4311 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-rs-private-setter.js @@ -0,0 +1,130 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-private-setter.case +// - src/class-elements/productions/cls-decl-after-same-line-static-gen.template +/*--- +description: Valid PrivateName as private setter (field definitions after a static generator in the same line) +esid: prod-FieldDefinition +features: [class-methods-private, class-fields-private, generators, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + ... + ; + + MethodDefinition : + ... + set ClassElementName ( PropertySetParameterList ) { FunctionBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static *m() { return 42; } #$_; #__; #\u{6F}_; #\u2118_; #ZW_\u200C_NJ_; #ZW_\u200D_J_; + set #$(value) { + this.#$_ = value; + } + set #_(value) { + this.#__ = value; + } + set #\u{6F}(value) { + this.#\u{6F}_ = value; + } + set #\u2118(value) { + this.#\u2118_ = value; + } + set #ZW_\u200C_NJ(value) { + this.#ZW_\u200C_NJ_ = value; + } + set #ZW_\u200D_J(value) { + this.#ZW_\u200D_J_ = value; + } +; + $(value) { + this.#$ = value; + return this.#$_; + } + _(value) { + this.#_ = value; + return this.#__; + } + \u{6F}(value) { + this.#\u{6F} = value; + return this.#\u{6F}_; + } + \u2118(value) { + this.#\u2118 = value; + return this.#\u2118_; + } + ZW_\u200C_NJ(value) { + this.#ZW_\u200C_NJ = value; + return this.#ZW_\u200C_NJ_; + } + ZW_\u200D_J(value) { + this.#ZW_\u200D_J = value; + return this.#ZW_\u200D_J_; + } + +} + +var c = new C(); + +assert.sameValue(C.m().next().value, 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.$(1), 1); +assert.sameValue(c._(1), 1); +assert.sameValue(c.\u{6F}(1), 1); +assert.sameValue(c.\u2118(1), 1); +assert.sameValue(c.ZW_\u200C_NJ(1), 1); +assert.sameValue(c.ZW_\u200D_J(1), 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-rs-privatename-identifier-alt.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-rs-privatename-identifier-alt.js new file mode 100644 index 0000000000..2600dcfb6c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-rs-privatename-identifier-alt.js @@ -0,0 +1,112 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-privatename-identifier-alt.case +// - src/class-elements/productions/cls-decl-after-same-line-static-gen.template +/*--- +description: Valid PrivateName (field definitions after a static generator in the same line) +esid: prod-FieldDefinition +features: [class-fields-private, generators, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static *m() { return 42; } #$; #_; #\u{6F}; #℘; #ZW_‌_NJ; #ZW_‍_J; + $(value) { + this.#$ = value; + return this.#$; + } + _(value) { + this.#_ = value; + return this.#_; + } + \u{6F}(value) { + this.#\u{6F} = value; + return this.#\u{6F}; + } + ℘(value) { + this.#℘ = value; + return this.#℘; + } + ZW_‌_NJ(value) { + this.#ZW_‌_NJ = value; + return this.#ZW_‌_NJ; + } + ZW_‍_J(value) { + this.#ZW_‍_J = value; + return this.#ZW_‍_J; + } +} + +var c = new C(); + +assert.sameValue(C.m().next().value, 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.$(1), 1); +assert.sameValue(c._(1), 1); +assert.sameValue(c.\u{6F}(1), 1); +assert.sameValue(c.℘(1), 1); +assert.sameValue(c.ZW_‌_NJ(1), 1); +assert.sameValue(c.ZW_‍_J(1), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-rs-privatename-identifier-initializer-alt.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-rs-privatename-identifier-initializer-alt.js new file mode 100644 index 0000000000..d28198e687 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-rs-privatename-identifier-initializer-alt.js @@ -0,0 +1,106 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-privatename-identifier-initializer-alt.case +// - src/class-elements/productions/cls-decl-after-same-line-static-gen.template +/*--- +description: Valid PrivateName (field definitions after a static generator in the same line) +esid: prod-FieldDefinition +features: [class-fields-private, generators, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static *m() { return 42; } #$ = 1; #_ = 1; #\u{6F} = 1; #℘ = 1; #ZW_‌_NJ = 1; #ZW_‍_J = 1; + $() { + return this.#$; + } + _() { + return this.#_; + } + \u{6F}() { + return this.#\u{6F}; + } + ℘() { + return this.#℘; + } + ZW_‌_NJ() { + return this.#ZW_‌_NJ; + } + ZW_‍_J() { + return this.#ZW_‍_J; + } +} + +var c = new C(); + +assert.sameValue(C.m().next().value, 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.$(), 1); +assert.sameValue(c._(), 1); +assert.sameValue(c.\u{6F}(), 1); +assert.sameValue(c.℘(), 1); +assert.sameValue(c.ZW_‌_NJ(), 1); +assert.sameValue(c.ZW_‍_J(), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-rs-privatename-identifier-initializer.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-rs-privatename-identifier-initializer.js new file mode 100644 index 0000000000..507fb5ba2b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-rs-privatename-identifier-initializer.js @@ -0,0 +1,106 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-privatename-identifier-initializer.case +// - src/class-elements/productions/cls-decl-after-same-line-static-gen.template +/*--- +description: Valid PrivateName (field definitions after a static generator in the same line) +esid: prod-FieldDefinition +features: [class-fields-private, generators, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static *m() { return 42; } #$ = 1; #_ = 1; #\u{6F} = 1; #\u2118 = 1; #ZW_\u200C_NJ = 1; #ZW_\u200D_J = 1; + $() { + return this.#$; + } + _() { + return this.#_; + } + \u{6F}() { + return this.#\u{6F}; + } + \u2118() { + return this.#\u2118; + } + ZW_\u200C_NJ() { + return this.#ZW_\u200C_NJ; + } + ZW_\u200D_J() { + return this.#ZW_\u200D_J; + } +} + +var c = new C(); + +assert.sameValue(C.m().next().value, 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.$(), 1); +assert.sameValue(c._(), 1); +assert.sameValue(c.\u{6F}(), 1); +assert.sameValue(c.\u2118(), 1); +assert.sameValue(c.ZW_\u200C_NJ(), 1); +assert.sameValue(c.ZW_\u200D_J(), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-rs-privatename-identifier.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-rs-privatename-identifier.js new file mode 100644 index 0000000000..6be5e99862 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-rs-privatename-identifier.js @@ -0,0 +1,112 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-privatename-identifier.case +// - src/class-elements/productions/cls-decl-after-same-line-static-gen.template +/*--- +description: Valid PrivateName (field definitions after a static generator in the same line) +esid: prod-FieldDefinition +features: [class-fields-private, generators, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static *m() { return 42; } #$; #_; #\u{6F}; #\u2118; #ZW_\u200C_NJ; #ZW_\u200D_J; + $(value) { + this.#$ = value; + return this.#$; + } + _(value) { + this.#_ = value; + return this.#_; + } + \u{6F}(value) { + this.#\u{6F} = value; + return this.#\u{6F}; + } + \u2118(value) { + this.#\u2118 = value; + return this.#\u2118; + } + ZW_\u200C_NJ(value) { + this.#ZW_\u200C_NJ = value; + return this.#ZW_\u200C_NJ; + } + ZW_\u200D_J(value) { + this.#ZW_\u200D_J = value; + return this.#ZW_\u200D_J; + } +} + +var c = new C(); + +assert.sameValue(C.m().next().value, 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.$(1), 1); +assert.sameValue(c._(1), 1); +assert.sameValue(c.\u{6F}(1), 1); +assert.sameValue(c.\u2118(1), 1); +assert.sameValue(c.ZW_\u200C_NJ(1), 1); +assert.sameValue(c.ZW_\u200D_J(1), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-rs-static-async-generator-method-privatename-identifier-alt.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-rs-static-async-generator-method-privatename-identifier-alt.js new file mode 100644 index 0000000000..e591ba9030 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-rs-static-async-generator-method-privatename-identifier-alt.js @@ -0,0 +1,137 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-async-generator-method-privatename-identifier-alt.case +// - src/class-elements/productions/cls-decl-after-same-line-static-gen.template +/*--- +description: Valid Static AsyncGeneratorMethod PrivateName (field definitions after a static generator in the same line) +esid: prod-FieldDefinition +features: [class-static-methods-private, generators, class, class-fields-public] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + AsyncGeneratorMethod + + AsyncGeneratorMethod : + async [no LineTerminator here] * ClassElementName ( UniqueFormalParameters){ AsyncGeneratorBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static *m() { return 42; } static async * #$(value) { + yield * await value; + } + static async * #_(value) { + yield * await value; + } + static async * #o(value) { + yield * await value; + } + static async * #℘(value) { + yield * await value; + } + static async * #ZW_‌_NJ(value) { + yield * await value; + } + static async * #ZW_‍_J(value) { + yield * await value; + }; + static get $() { + return this.#$; + } + static get _() { + return this.#_; + } + static get o() { + return this.#o; + } + static get ℘() { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#℘; + } + static get ZW_‌_NJ() { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#ZW_‌_NJ; + } + static get ZW_‍_J() { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#ZW_‍_J; + } + +} + +var c = new C(); + +assert.sameValue(C.m().next().value, 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +Promise.all([ + C.$([1]).next(), + C._([1]).next(), + C.o([1]).next(), + C.℘([1]).next(), // DO NOT CHANGE THE NAME OF THIS FIELD + C.ZW_‌_NJ([1]).next(), // DO NOT CHANGE THE NAME OF THIS FIELD + C.ZW_‍_J([1]).next(), // DO NOT CHANGE THE NAME OF THIS FIELD +]).then(results => { + + assert.sameValue(results[0].value, 1); + assert.sameValue(results[1].value, 1); + assert.sameValue(results[2].value, 1); + assert.sameValue(results[3].value, 1); + assert.sameValue(results[4].value, 1); + assert.sameValue(results[5].value, 1); + +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-rs-static-async-generator-method-privatename-identifier.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-rs-static-async-generator-method-privatename-identifier.js new file mode 100644 index 0000000000..e984284638 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-rs-static-async-generator-method-privatename-identifier.js @@ -0,0 +1,138 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-async-generator-method-privatename-identifier.case +// - src/class-elements/productions/cls-decl-after-same-line-static-gen.template +/*--- +description: Valid Static AsyncGeneratorMethod PrivateName (field definitions after a static generator in the same line) +esid: prod-FieldDefinition +features: [class-static-methods-private, generators, class, class-fields-public] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + AsyncGeneratorMethod + + AsyncGeneratorMethod : + async [no LineTerminator here] * ClassElementName ( UniqueFormalParameters){ AsyncGeneratorBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static *m() { return 42; } static async * #$(value) { + yield * await value; + } + static async * #_(value) { + yield * await value; + } + static async * #\u{6F}(value) { + yield * await value; + } + static async * #\u2118(value) { + yield * await value; + } + static async * #ZW_\u200C_NJ(value) { + yield * await value; + } + static async * #ZW_\u200D_J(value) { + yield * await value; + }; + static get $() { + return this.#$; + } + static get _() { + return this.#_; + } + static get \u{6F}() { + return this.#\u{6F}; + } + static get \u2118() { + return this.#\u2118; + } + static get ZW_\u200C_NJ() { + return this.#ZW_\u200C_NJ; + } + static get ZW_\u200D_J() { + return this.#ZW_\u200D_J; + } + +} + +var c = new C(); + +assert.sameValue(C.m().next().value, 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +Promise.all([ + C.$([1]).next(), + C._([1]).next(), + C.\u{6F}([1]).next(), + C.\u2118([1]).next(), + C.ZW_\u200C_NJ([1]).next(), + C.ZW_\u200D_J([1]).next(), +]).then(results => { + + assert.sameValue(results[0].value, 1); + assert.sameValue(results[1].value, 1); + assert.sameValue(results[2].value, 1); + assert.sameValue(results[3].value, 1); + assert.sameValue(results[4].value, 1); + assert.sameValue(results[5].value, 1); + +}).then($DONE, $DONE); + diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-rs-static-async-method-privatename-identifier-alt.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-rs-static-async-method-privatename-identifier-alt.js new file mode 100644 index 0000000000..13aceacbbe --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-rs-static-async-method-privatename-identifier-alt.js @@ -0,0 +1,137 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-async-method-privatename-identifier-alt.case +// - src/class-elements/productions/cls-decl-after-same-line-static-gen.template +/*--- +description: Valid Static AsyncMethod PrivateName (field definitions after a static generator in the same line) +esid: prod-FieldDefinition +features: [class-static-methods-private, generators, class, class-fields-public] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + AsyncMethod + + AsyncMethod : + async [no LineTerminator here] ClassElementName ( UniqueFormalParameters ){ AsyncFunctionBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static *m() { return 42; } static async #$(value) { + return await value; + } + static async #_(value) { + return await value; + } + static async #o(value) { + return await value; + } + static async #℘(value) { + return await value; + } + static async #ZW_‌_NJ(value) { + return await value; + } + static async #ZW_‍_J(value) { + return await value; + }; + static async $(value) { + return await this.#$(value); + } + static async _(value) { + return await this.#_(value); + } + static async o(value) { + return await this.#o(value); + } + static async ℘(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + return await this.#℘(value); + } + static async ZW_‌_NJ(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + return await this.#ZW_‌_NJ(value); + } + static async ZW_‍_J(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + return await this.#ZW_‍_J(value); + } + +} + +var c = new C(); + +assert.sameValue(C.m().next().value, 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +Promise.all([ + C.$(1), + C._(1), + C.o(1), + C.℘(1), // DO NOT CHANGE THE NAME OF THIS FIELD + C.ZW_‌_NJ(1), // DO NOT CHANGE THE NAME OF THIS FIELD + C.ZW_‍_J(1), // DO NOT CHANGE THE NAME OF THIS FIELD +]).then(results => { + + assert.sameValue(results[0], 1); + assert.sameValue(results[1], 1); + assert.sameValue(results[2], 1); + assert.sameValue(results[3], 1); + assert.sameValue(results[4], 1); + assert.sameValue(results[5], 1); + +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-rs-static-async-method-privatename-identifier.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-rs-static-async-method-privatename-identifier.js new file mode 100644 index 0000000000..a4aef9d4bb --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-rs-static-async-method-privatename-identifier.js @@ -0,0 +1,138 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-async-method-privatename-identifier.case +// - src/class-elements/productions/cls-decl-after-same-line-static-gen.template +/*--- +description: Valid Static AsyncMethod PrivateName (field definitions after a static generator in the same line) +esid: prod-FieldDefinition +features: [class-static-methods-private, generators, class, class-fields-public] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + AsyncMethod + + AsyncMethod : + async [no LineTerminator here] ClassElementName ( UniqueFormalParameters ){ AsyncFunctionBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static *m() { return 42; } static async #$(value) { + return await value; + } + static async #_(value) { + return await value; + } + static async #\u{6F}(value) { + return await value; + } + static async #\u2118(value) { + return await value; + } + static async #ZW_\u200C_NJ(value) { + return await value; + } + static async #ZW_\u200D_J(value) { + return await value; + }; + static async $(value) { + return await this.#$(value); + } + static async _(value) { + return await this.#_(value); + } + static async \u{6F}(value) { + return await this.#\u{6F}(value); + } + static async \u2118(value) { + return await this.#\u2118(value); + } + static async ZW_\u200C_NJ(value) { + return await this.#ZW_\u200C_NJ(value); + } + static async ZW_\u200D_J(value) { + return await this.#ZW_\u200D_J(value); + } + +} + +var c = new C(); + +assert.sameValue(C.m().next().value, 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +Promise.all([ + C.$(1), + C._(1), + C.\u{6F}(1), + C.\u2118(1), + C.ZW_\u200C_NJ(1), + C.ZW_\u200D_J(1), +]).then(results => { + + assert.sameValue(results[0], 1); + assert.sameValue(results[1], 1); + assert.sameValue(results[2], 1); + assert.sameValue(results[3], 1); + assert.sameValue(results[4], 1); + assert.sameValue(results[5], 1); + +}).then($DONE, $DONE); + diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-rs-static-generator-method-privatename-identifier-alt.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-rs-static-generator-method-privatename-identifier-alt.js new file mode 100644 index 0000000000..92e3b3d66e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-rs-static-generator-method-privatename-identifier-alt.js @@ -0,0 +1,127 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-generator-method-privatename-identifier-alt.case +// - src/class-elements/productions/cls-decl-after-same-line-static-gen.template +/*--- +description: Valid Static GeneratorMethod PrivateName (field definitions after a static generator in the same line) +esid: prod-FieldDefinition +features: [class-static-methods-private, generators, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + GeneratorMethod + + GeneratorMethod : + * ClassElementName ( UniqueFormalParameters ){ GeneratorBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static *m() { return 42; } static * #$(value) { + yield * value; + } + static * #_(value) { + yield * value; + } + static * #o(value) { + yield * value; + } + static * #℘(value) { + yield * value; + } + static * #ZW_‌_NJ(value) { + yield * value; + } + static * #ZW_‍_J(value) { + yield * value; + }; + static get $() { + return this.#$; + } + static get _() { + return this.#_; + } + static get o() { + return this.#o; + } + static get ℘() { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#℘; + } + static get ZW_‌_NJ() { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#ZW_‌_NJ; + } + static get ZW_‍_J() { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#ZW_‍_J; + } + +} + +var c = new C(); + +assert.sameValue(C.m().next().value, 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(C.$([1]).next().value, 1); +assert.sameValue(C._([1]).next().value, 1); +assert.sameValue(C.o([1]).next().value, 1); +assert.sameValue(C.℘([1]).next().value, 1); +assert.sameValue(C.ZW_‌_NJ([1]).next().value, 1); +assert.sameValue(C.ZW_‍_J([1]).next().value, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-rs-static-generator-method-privatename-identifier.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-rs-static-generator-method-privatename-identifier.js new file mode 100644 index 0000000000..b84f84a43e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-rs-static-generator-method-privatename-identifier.js @@ -0,0 +1,128 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-generator-method-privatename-identifier.case +// - src/class-elements/productions/cls-decl-after-same-line-static-gen.template +/*--- +description: Valid Static GeneratorMethod PrivateName (field definitions after a static generator in the same line) +esid: prod-FieldDefinition +features: [class-static-methods-private, generators, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + GeneratorMethod + + GeneratorMethod : + * ClassElementName ( UniqueFormalParameters ){ GeneratorBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static *m() { return 42; } static * #$(value) { + yield * value; + } + static * #_(value) { + yield * value; + } + static * #\u{6F}(value) { + yield * value; + } + static * #\u2118(value) { + yield * value; + } + static * #ZW_\u200C_NJ(value) { + yield * value; + } + static * #ZW_\u200D_J(value) { + yield * value; + }; + static get $() { + return this.#$; + } + static get _() { + return this.#_; + } + static get \u{6F}() { + return this.#\u{6F}; + } + static get \u2118() { + return this.#\u2118; + } + static get ZW_\u200C_NJ() { + return this.#ZW_\u200C_NJ; + } + static get ZW_\u200D_J() { + return this.#ZW_\u200D_J; + } + +} + +var c = new C(); + +assert.sameValue(C.m().next().value, 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(C.$([1]).next().value, 1); +assert.sameValue(C._([1]).next().value, 1); +assert.sameValue(C.\u{6F}([1]).next().value, 1); +assert.sameValue(C.\u2118([1]).next().value, 1); +assert.sameValue(C.ZW_\u200C_NJ([1]).next().value, 1); +assert.sameValue(C.ZW_\u200D_J([1]).next().value, 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-rs-static-method-privatename-identifier-alt.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-rs-static-method-privatename-identifier-alt.js new file mode 100644 index 0000000000..cee0153caa --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-rs-static-method-privatename-identifier-alt.js @@ -0,0 +1,125 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-method-privatename-identifier-alt.case +// - src/class-elements/productions/cls-decl-after-same-line-static-gen.template +/*--- +description: Valid Static Method PrivateName (field definitions after a static generator in the same line) +esid: prod-FieldDefinition +features: [class-static-methods-private, generators, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + ClassElementName ( UniqueFormalParameters ){ FunctionBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static *m() { return 42; } static #$(value) { + return value; + } + static #_(value) { + return value; + } + static #o(value) { + return value; + } + static #℘(value) { + return value; + } + static #ZW_‌_NJ(value) { + return value; + } + static #ZW_‍_J(value) { + return value; + }; + static $(value) { + return this.#$(value); + } + static _(value) { + return this.#_(value); + } + static o(value) { + return this.#o(value); + } + static ℘(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#℘(value); + } + static ZW_‌_NJ(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#ZW_‌_NJ(value); + } + static ZW_‍_J(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#ZW_‍_J(value); + } + +} + +var c = new C(); + +assert.sameValue(C.m().next().value, 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(C.$(1), 1); +assert.sameValue(C._(1), 1); +assert.sameValue(C.o(1), 1); +assert.sameValue(C.℘(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD +assert.sameValue(C.ZW_‌_NJ(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD +assert.sameValue(C.ZW_‍_J(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-rs-static-method-privatename-identifier.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-rs-static-method-privatename-identifier.js new file mode 100644 index 0000000000..5b8e8822e7 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-rs-static-method-privatename-identifier.js @@ -0,0 +1,125 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-method-privatename-identifier.case +// - src/class-elements/productions/cls-decl-after-same-line-static-gen.template +/*--- +description: Valid Static Method PrivateName (field definitions after a static generator in the same line) +esid: prod-FieldDefinition +features: [class-static-methods-private, generators, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + ClassElementName ( UniqueFormalParameters ){ FunctionBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static *m() { return 42; } static #$(value) { + return value; + } + static #_(value) { + return value; + } + static #\u{6F}(value) { + return value; + } + static #\u2118(value) { + return value; + } + static #ZW_\u200C_NJ(value) { + return value; + } + static #ZW_\u200D_J(value) { + return value; + }; + static $(value) { + return this.#$(value); + } + static _(value) { + return this.#_(value); + } + static \u{6F}(value) { + return this.#\u{6F}(value); + } + static \u2118(value) { + return this.#\u2118(value); + } + static ZW_\u200C_NJ(value) { + return this.#ZW_\u200C_NJ(value); + } + static ZW_\u200D_J(value) { + return this.#ZW_\u200D_J(value); + } + +} + +var c = new C(); + +assert.sameValue(C.m().next().value, 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(C.$(1), 1); +assert.sameValue(C._(1), 1); +assert.sameValue(C.\u{6F}(1), 1); +assert.sameValue(C.\u2118(1), 1); +assert.sameValue(C.ZW_\u200C_NJ(1), 1); +assert.sameValue(C.ZW_\u200D_J(1), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-rs-static-privatename-identifier-alt-by-classname.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-rs-static-privatename-identifier-alt-by-classname.js new file mode 100644 index 0000000000..9713e63e6e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-rs-static-privatename-identifier-alt-by-classname.js @@ -0,0 +1,113 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-privatename-identifier-alt-by-classname.case +// - src/class-elements/productions/cls-decl-after-same-line-static-gen.template +/*--- +description: Valid Static PrivateName (field definitions after a static generator in the same line) +esid: prod-FieldDefinition +features: [class-static-fields-private, generators, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static *m() { return 42; } static #$; static #_; static #\u{6F}; static #℘; static #ZW_‌_NJ; static #ZW_‍_J; + static $(value) { + C.#$ = value; + return C.#$; + } + static _(value) { + C.#_ = value; + return C.#_; + } + static o(value) { + C.#\u{6F} = value; + return C.#\u{6F}; + } + static ℘(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + C.#℘ = value; + return C.#℘; + } + static ZW_‌_NJ(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + C.#ZW_‌_NJ = value; + return C.#ZW_‌_NJ; + } + static ZW_‍_J(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + C.#ZW_‍_J = value; + return C.#ZW_‍_J; + } +} + +var c = new C(); + +assert.sameValue(C.m().next().value, 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(C.$(1), 1); +assert.sameValue(C._(1), 1); +assert.sameValue(C.o(1), 1); +assert.sameValue(C.℘(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD +assert.sameValue(C.ZW_‌_NJ(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD +assert.sameValue(C.ZW_‍_J(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-rs-static-privatename-identifier-alt.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-rs-static-privatename-identifier-alt.js new file mode 100644 index 0000000000..7f1543380d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-rs-static-privatename-identifier-alt.js @@ -0,0 +1,113 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-privatename-identifier-alt.case +// - src/class-elements/productions/cls-decl-after-same-line-static-gen.template +/*--- +description: Valid Static PrivateName (field definitions after a static generator in the same line) +esid: prod-FieldDefinition +features: [class-static-fields-private, generators, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static *m() { return 42; } static #$; static #_; static #\u{6F}; static #℘; static #ZW_‌_NJ; static #ZW_‍_J; + static $(value) { + this.#$ = value; + return this.#$; + } + static _(value) { + this.#_ = value; + return this.#_; + } + static o(value) { + this.#\u{6F} = value; + return this.#\u{6F}; + } + static ℘(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + this.#℘ = value; + return this.#℘; + } + static ZW_‌_NJ(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + this.#ZW_‌_NJ = value; + return this.#ZW_‌_NJ; + } + static ZW_‍_J(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + this.#ZW_‍_J = value; + return this.#ZW_‍_J; + } +} + +var c = new C(); + +assert.sameValue(C.m().next().value, 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(C.$(1), 1); +assert.sameValue(C._(1), 1); +assert.sameValue(C.o(1), 1); +assert.sameValue(C.℘(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD +assert.sameValue(C.ZW_‌_NJ(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD +assert.sameValue(C.ZW_‍_J(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-rs-static-privatename-identifier-by-classname.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-rs-static-privatename-identifier-by-classname.js new file mode 100644 index 0000000000..c814f0615e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-rs-static-privatename-identifier-by-classname.js @@ -0,0 +1,113 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-privatename-identifier-by-classname.case +// - src/class-elements/productions/cls-decl-after-same-line-static-gen.template +/*--- +description: Valid Static PrivateName (field definitions after a static generator in the same line) +esid: prod-FieldDefinition +features: [class-static-fields-private, generators, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static *m() { return 42; } static #$; static #_; static #\u{6F}; static #\u2118; static #ZW_\u200C_NJ; static #ZW_\u200D_J; + static $(value) { + C.#$ = value; + return C.#$; + } + static _(value) { + C.#_ = value; + return C.#_; + } + static \u{6F}(value) { + C.#\u{6F} = value; + return C.#\u{6F}; + } + static \u2118(value) { + C.#\u2118 = value; + return C.#\u2118; + } + static ZW_\u200C_NJ(value) { + C.#ZW_\u200C_NJ = value; + return C.#ZW_\u200C_NJ; + } + static ZW_\u200D_J(value) { + C.#ZW_\u200D_J = value; + return C.#ZW_\u200D_J; + } +} + +var c = new C(); + +assert.sameValue(C.m().next().value, 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(C.$(1), 1); +assert.sameValue(C._(1), 1); +assert.sameValue(C.\u{6F}(1), 1); +assert.sameValue(C.\u2118(1), 1); +assert.sameValue(C.ZW_\u200C_NJ(1), 1); +assert.sameValue(C.ZW_\u200D_J(1), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-rs-static-privatename-identifier-initializer-alt-by-classname.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-rs-static-privatename-identifier-initializer-alt-by-classname.js new file mode 100644 index 0000000000..43888c6e25 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-rs-static-privatename-identifier-initializer-alt-by-classname.js @@ -0,0 +1,107 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-privatename-identifier-initializer-alt-by-classname.case +// - src/class-elements/productions/cls-decl-after-same-line-static-gen.template +/*--- +description: Valid Static PrivateName (field definitions after a static generator in the same line) +esid: prod-FieldDefinition +features: [class-static-fields-private, generators, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static *m() { return 42; } static #$ = 1; static #_ = 1; static #\u{6F} = 1; static #℘ = 1; static #ZW_‌_NJ = 1; static #ZW_‍_J = 1; + static $() { + return C.#$; + } + static _() { + return C.#_; + } + static \u{6F}() { + return C.#\u{6F}; + } + static ℘() { + return C.#℘; + } + static ZW_‌_NJ() { + return C.#ZW_‌_NJ; + } + static ZW_‍_J() { + return C.#ZW_‍_J; + } +} + +var c = new C(); + +assert.sameValue(C.m().next().value, 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(C.$(), 1); +assert.sameValue(C._(), 1); +assert.sameValue(C.\u{6F}(), 1); +assert.sameValue(C.℘(), 1); +assert.sameValue(C.ZW_‌_NJ(), 1); +assert.sameValue(C.ZW_‍_J(), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-rs-static-privatename-identifier-initializer-alt.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-rs-static-privatename-identifier-initializer-alt.js new file mode 100644 index 0000000000..3e0f9f7197 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-rs-static-privatename-identifier-initializer-alt.js @@ -0,0 +1,107 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-privatename-identifier-initializer-alt.case +// - src/class-elements/productions/cls-decl-after-same-line-static-gen.template +/*--- +description: Valid Static PrivateName (field definitions after a static generator in the same line) +esid: prod-FieldDefinition +features: [class-static-fields-private, generators, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static *m() { return 42; } static #$ = 1; static #_ = 1; static #\u{6F} = 1; static #℘ = 1; static #ZW_‌_NJ = 1; static #ZW_‍_J = 1; + static $() { + return this.#$; + } + static _() { + return this.#_; + } + static \u{6F}() { + return this.#\u{6F}; + } + static ℘() { + return this.#℘; + } + static ZW_‌_NJ() { + return this.#ZW_‌_NJ; + } + static ZW_‍_J() { + return this.#ZW_‍_J; + } +} + +var c = new C(); + +assert.sameValue(C.m().next().value, 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(C.$(), 1); +assert.sameValue(C._(), 1); +assert.sameValue(C.\u{6F}(), 1); +assert.sameValue(C.℘(), 1); +assert.sameValue(C.ZW_‌_NJ(), 1); +assert.sameValue(C.ZW_‍_J(), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-rs-static-privatename-identifier-initializer.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-rs-static-privatename-identifier-initializer.js new file mode 100644 index 0000000000..22059bc30a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-rs-static-privatename-identifier-initializer.js @@ -0,0 +1,107 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-privatename-identifier-initializer.case +// - src/class-elements/productions/cls-decl-after-same-line-static-gen.template +/*--- +description: Valid Static PrivateName (field definitions after a static generator in the same line) +esid: prod-FieldDefinition +features: [class-static-fields-private, generators, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static *m() { return 42; } static #$ = 1; static #_ = 1; static #\u{6F} = 1; static #\u2118 = 1; static #ZW_\u200C_NJ = 1; static #ZW_\u200D_J = 1; + static $() { + return this.#$; + } + static _() { + return this.#_; + } + static \u{6F}() { + return this.#\u{6F}; + } + static \u2118() { + return this.#\u2118; + } + static ZW_\u200C_NJ() { + return this.#ZW_\u200C_NJ; + } + static ZW_\u200D_J() { + return this.#ZW_\u200D_J; + } +} + +var c = new C(); + +assert.sameValue(C.m().next().value, 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(C.$(), 1); +assert.sameValue(C._(), 1); +assert.sameValue(C.\u{6F}(), 1); +assert.sameValue(C.\u2118(), 1); +assert.sameValue(C.ZW_\u200C_NJ(), 1); +assert.sameValue(C.ZW_\u200D_J(), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-rs-static-privatename-identifier.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-rs-static-privatename-identifier.js new file mode 100644 index 0000000000..2d39dafc78 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-rs-static-privatename-identifier.js @@ -0,0 +1,113 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-privatename-identifier.case +// - src/class-elements/productions/cls-decl-after-same-line-static-gen.template +/*--- +description: Valid Static PrivateName (field definitions after a static generator in the same line) +esid: prod-FieldDefinition +features: [class-static-fields-private, generators, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static *m() { return 42; } static #$; static #_; static #\u{6F}; static #\u2118; static #ZW_\u200C_NJ; static #ZW_\u200D_J; + static $(value) { + this.#$ = value; + return this.#$; + } + static _(value) { + this.#_ = value; + return this.#_; + } + static \u{6F}(value) { + this.#\u{6F} = value; + return this.#\u{6F}; + } + static \u2118(value) { + this.#\u2118 = value; + return this.#\u2118; + } + static ZW_\u200C_NJ(value) { + this.#ZW_\u200C_NJ = value; + return this.#ZW_\u200C_NJ; + } + static ZW_\u200D_J(value) { + this.#ZW_\u200D_J = value; + return this.#ZW_\u200D_J; + } +} + +var c = new C(); + +assert.sameValue(C.m().next().value, 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(C.$(1), 1); +assert.sameValue(C._(1), 1); +assert.sameValue(C.\u{6F}(1), 1); +assert.sameValue(C.\u2118(1), 1); +assert.sameValue(C.ZW_\u200C_NJ(1), 1); +assert.sameValue(C.ZW_\u200D_J(1), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-static-private-fields.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-static-private-fields.js new file mode 100644 index 0000000000..13d9a43d2a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-static-private-fields.js @@ -0,0 +1,74 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/static-private-fields.case +// - src/class-elements/productions/cls-decl-after-same-line-static-gen.template +/*--- +description: static private fields (field definitions after a static generator in the same line) +esid: prod-FieldDefinition +features: [class-static-fields-private, generators, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + ... + static FieldDefinition ; + + FieldDefinition : + ClassElementName Initializer_opt + + ClassElementName : + PrivateName + + PrivateName : + # IdentifierName + +---*/ + + +class C { + static *m() { return 42; } static #x; static #y; + static x() { + this.#x = 42; + return this.#x; + } + static y() { + this.#y = 43; + return this.#y; + } +} + +var c = new C(); + +assert.sameValue(C.m().next().value, 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +// Test the private fields do not appear as properties before set to value +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#x"), "test 1"); +assert(!Object.prototype.hasOwnProperty.call(C, "#x"), "test 2"); +assert(!Object.prototype.hasOwnProperty.call(c, "#x"), "test 3"); + +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#y"), "test 4"); +assert(!Object.prototype.hasOwnProperty.call(C, "#y"), "test 5"); +assert(!Object.prototype.hasOwnProperty.call(c, "#y"), "test 6"); + +// Test if private fields can be sucessfully accessed and set to value +assert.sameValue(C.x(), 42, "test 7"); +assert.sameValue(C.y(), 43, "test 8"); + +// Test the private fields do not appear as properties before after set to value +assert(!Object.prototype.hasOwnProperty.call(C, "#x"), "test 9"); +assert(!Object.prototype.hasOwnProperty.call(C, "#y"), "test 10"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-static-private-methods-with-fields.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-static-private-methods-with-fields.js new file mode 100644 index 0000000000..73d35265c5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-static-private-methods-with-fields.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/static-private-methods-with-fields.case +// - src/class-elements/productions/cls-decl-after-same-line-static-gen.template +/*--- +description: static private methods with fields (field definitions after a static generator in the same line) +esid: prod-FieldDefinition +features: [class-static-methods-private, class-static-fields-private, generators, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + ... + static FieldDefinition ; + + FieldDefinition : + ClassElementName Initializer_opt + + ClassElementName : + PrivateName + + PrivateName : + # IdentifierName + +---*/ + + +class C { + static *m() { return 42; } static #xVal; static #yVal; + static #x(value) { + this.#xVal = value; + return this.#xVal; + } + static #y(value) { + this.#yVal = value; + return this.#yVal; + } + static x() { + return this.#x(42); + } + static y() { + return this.#y(43); + } +} + +var c = new C(); + +assert.sameValue(C.m().next().value, 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +// Test the private methods do not appear as properties before set to value +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#x"), "test 1"); +assert(!Object.prototype.hasOwnProperty.call(C, "#x"), "test 2"); +assert(!Object.prototype.hasOwnProperty.call(c, "#x"), "test 3"); + +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#y"), "test 4"); +assert(!Object.prototype.hasOwnProperty.call(C, "#y"), "test 5"); +assert(!Object.prototype.hasOwnProperty.call(c, "#y"), "test 6"); + +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#xVal"), "test 7"); +assert(!Object.prototype.hasOwnProperty.call(C, "#xVal"), "test 8"); +assert(!Object.prototype.hasOwnProperty.call(c, "#xVal"), "test 9"); + +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#yVal"), "test 10"); +assert(!Object.prototype.hasOwnProperty.call(C, "#yVal"), "test 11"); +assert(!Object.prototype.hasOwnProperty.call(c, "#yVal"), "test 12"); + +// Test if private fields can be sucessfully accessed and set to value +assert.sameValue(C.x(), 42, "test 13"); +assert.sameValue(C.y(), 43, "test 14"); + +// Test the private fields do not appear as properties before after set to value +assert(!Object.prototype.hasOwnProperty.call(C, "#x"), "test 15"); +assert(!Object.prototype.hasOwnProperty.call(C, "#y"), "test 16"); + +assert(!Object.prototype.hasOwnProperty.call(C, "#xVal"), "test 17"); +assert(!Object.prototype.hasOwnProperty.call(C, "#yVal"), "test 18"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-static-private-methods.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-static-private-methods.js new file mode 100644 index 0000000000..214c71221e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-static-private-methods.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/static-private-methods.case +// - src/class-elements/productions/cls-decl-after-same-line-static-gen.template +/*--- +description: static private methods (field definitions after a static generator in the same line) +esid: prod-FieldDefinition +features: [class-static-methods-private, generators, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + ... + static FieldDefinition ; + + FieldDefinition : + ClassElementName Initializer_opt + + ClassElementName : + PrivateName + + PrivateName : + # IdentifierName + +---*/ + + +class C { + static *m() { return 42; } ; + static #x(value) { + return value / 2; + } + static #y(value) { + return value * 2; + } + static x() { + return this.#x(84); + } + static y() { + return this.#y(43); + } +} + +var c = new C(); + +assert.sameValue(C.m().next().value, 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +// Test the private methods do not appear as properties before set to value +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#x"), "test 1"); +assert(!Object.prototype.hasOwnProperty.call(C, "#x"), "test 2"); +assert(!Object.prototype.hasOwnProperty.call(c, "#x"), "test 3"); + +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#y"), "test 4"); +assert(!Object.prototype.hasOwnProperty.call(C, "#y"), "test 5"); +assert(!Object.prototype.hasOwnProperty.call(c, "#y"), "test 6"); + +// Test if private fields can be sucessfully accessed and set to value +assert.sameValue(C.x(), 42, "test 7"); +assert.sameValue(C.y(), 86, "test 8"); + +// Test the private fields do not appear as properties before after set to value +assert(!Object.prototype.hasOwnProperty.call(C, "#x"), "test 9"); +assert(!Object.prototype.hasOwnProperty.call(C, "#y"), "test 10"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-string-literal-names.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-string-literal-names.js new file mode 100644 index 0000000000..15a6f0219c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-gen-string-literal-names.js @@ -0,0 +1,112 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/string-literal-names.case +// - src/class-elements/productions/cls-decl-after-same-line-static-gen.template +/*--- +description: String literal names (field definitions after a static generator in the same line) +esid: prod-FieldDefinition +features: [class-fields-public, generators, class] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PropertyName + +---*/ + + +class C { + static *m() { return 42; } 'a'; "b"; 'c' = 39; + "d" = 42; + +} + +var c = new C(); + +assert.sameValue(C.m().next().value, 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "a"), + "a does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "a"), + "a does not appear as an own property on C constructor" +); + +verifyProperty(c, "a", { + value: undefined, + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "b"), + "b does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "b"), + "b does not appear as an own property on C constructor" +); + +verifyProperty(c, "b", { + value: undefined, + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "c"), + "c does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "c"), + "c does not appear as an own property on C constructor" +); + +verifyProperty(c, "c", { + value: 39, + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "d"), + "d does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "d"), + "d does not appear as an own property on C constructor" +); + +verifyProperty(c, "d", { + value: 42, + enumerable: true, + writable: true, + configurable: true +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-computed-names.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-computed-names.js new file mode 100644 index 0000000000..cb60bd378a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-computed-names.js @@ -0,0 +1,110 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/computed-names.case +// - src/class-elements/productions/cls-decl-after-same-line-static-method.template +/*--- +description: Computed property names (field definitions after a static method in the same line) +esid: prod-FieldDefinition +features: [class-fields-public, computed-property-names, class] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PropertyName + +---*/ +var x = "b"; + + + +class C { + static m() { return 42; } [x] = 42; [10] = "meep"; ["not initialized"]; + +} + +var c = new C(); + +assert.sameValue(C.m(), 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "b"), + "b doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "b"), + "b doesn't appear as an own property on C constructor" +); + +verifyProperty(c, "b", { + value: 42, + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "x"), + "x doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "x"), + "x doesn't appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "x"), + "x doesn't appear as an own property on C instance" +); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "10"), + "10 doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "10"), + "10 doesn't appear as an own property on C constructor" +); + +verifyProperty(c, "10", { + value: "meep", + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "not initialized"), + "'not initialized' doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "not initialized"), + "'not initialized' doesn't appear as an own property on C constructor" +); + +verifyProperty(c, "not initialized", { + value: undefined, + enumerable: true, + writable: true, + configurable: true +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-computed-symbol-names.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-computed-symbol-names.js new file mode 100644 index 0000000000..a6f74e7c7b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-computed-symbol-names.js @@ -0,0 +1,108 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/computed-symbol-names.case +// - src/class-elements/productions/cls-decl-after-same-line-static-method.template +/*--- +description: Computed property symbol names (field definitions after a static method in the same line) +esid: prod-FieldDefinition +features: [class-fields-public, Symbol, computed-property-names, class] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PropertyName + +---*/ +var x = Symbol(); +var y = Symbol(); + + + +class C { + static m() { return 42; } [x]; [y] = 42; + +} + +var c = new C(); + +assert.sameValue(C.m(), 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, x), + "Symbol x doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, x), + "Symbol x doesn't appear as an own property on C constructor" +); + +verifyProperty(c, x, { + value: undefined, + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, y), + "Symbol y doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, y), + "Symbol y doesn't appear as an own property on C constructor" +); + +verifyProperty(c, y, { + value: 42, + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "x"), + "x doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "x"), + "x doesn't appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "x"), + "x doesn't appear as an own property on C instance" +); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "y"), + "y doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "y"), + "y doesn't appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "y"), + "y doesn't appear as an own property on C instance" +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-grammar-privatename-identifier-semantics-stringvalue.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-grammar-privatename-identifier-semantics-stringvalue.js new file mode 100644 index 0000000000..820183bea5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-grammar-privatename-identifier-semantics-stringvalue.js @@ -0,0 +1,112 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-privatename-identifier-semantics-stringvalue.case +// - src/class-elements/productions/cls-decl-after-same-line-static-method.template +/*--- +description: PrivateName Static Semantics, StringValue (field definitions after a static method in the same line) +esid: prod-FieldDefinition +features: [class-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + + + 1. Return the String value consisting of the sequence of code + units corresponding to PrivateName. In determining the sequence + any occurrences of \ UnicodeEscapeSequence are first replaced + with the code point represented by the UnicodeEscapeSequence + and then the code points of the entire PrivateName are converted + to code units by UTF16Encoding (10.1.1) each code point. + +---*/ + + +class C { + static m() { return 42; } #\u{6F}; + #\u2118; + #ZW_\u200C_NJ; + #ZW_\u200D_J;; + o(value) { + this.#o = value; + return this.#o; + } + ℘(value) { + this.#℘ = value; + return this.#℘; + } + ZW_‌_NJ(value) { // DO NOT CHANGE THE NAME OF THIS METHOD + this.#ZW_‌_NJ = value; + return this.#ZW_‌_NJ; + } + ZW_‍_J(value) { // DO NOT CHANGE THE NAME OF THIS METHOD + this.#ZW_‍_J = value; + return this.#ZW_‍_J; + } +} + +var c = new C(); + +assert.sameValue(C.m(), 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.o(1), 1); +assert.sameValue(c.℘(1), 1); +assert.sameValue(c.ZW_‌_NJ(1), 1); +assert.sameValue(c.ZW_‍_J(1), 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-literal-names-asi.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-literal-names-asi.js new file mode 100644 index 0000000000..9e97c4a255 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-literal-names-asi.js @@ -0,0 +1,80 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/literal-names-asi.case +// - src/class-elements/productions/cls-decl-after-same-line-static-method.template +/*--- +description: Literal property names with ASI (field definitions after a static method in the same line) +esid: prod-FieldDefinition +features: [class-fields-public, class] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PropertyName + +---*/ + + +class C { + static m() { return 42; } a + b = 42;; + +} + +var c = new C(); + +assert.sameValue(C.m(), 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "a"), + "a doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "a"), + "a doesn't appear as an own property on C constructor" +); + +verifyProperty(c, "a", { + value: undefined, + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "b"), + "b doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "b"), + "b doesn't appear as an own property on C constructor" +); + +verifyProperty(c, "b", { + value: 42, + enumerable: true, + writable: true, + configurable: true +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-literal-names.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-literal-names.js new file mode 100644 index 0000000000..3cc1c1be04 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-literal-names.js @@ -0,0 +1,99 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/literal-names.case +// - src/class-elements/productions/cls-decl-after-same-line-static-method.template +/*--- +description: Literal property names (field definitions after a static method in the same line) +esid: prod-FieldDefinition +features: [class-fields-public, class] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PropertyName + +---*/ +const fn = function() {} + + + +class C { + static m() { return 42; } a; b = 42; + c = fn; + +} + +var c = new C(); + +assert.sameValue(C.m(), 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "a"), + "a doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "a"), + "a doesn't appear as an own property on C constructor" +); + +verifyProperty(c, "a", { + value: undefined, + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "b"), + "b doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "b"), + "b doesn't appear as an own property on C constructor" +); + +verifyProperty(c, "b", { + value: 42, + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "c"), + "c doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "c"), + "c doesn't appear as an own property on C constructor" +); + +verifyProperty(c, "c", { + value: fn, + enumerable: true, + writable: true, + configurable: true +}); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-private-field-usage.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-private-field-usage.js new file mode 100644 index 0000000000..1fd4217704 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-private-field-usage.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/private-field-usage.case +// - src/class-elements/productions/cls-decl-after-same-line-static-method.template +/*--- +description: PrivateName CallExpression usage (private field) (field definitions after a static method in the same line) +esid: prod-FieldDefinition +features: [class-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + Updated Productions + + CallExpression[Yield, Await]: + CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await] + SuperCall[?Yield, ?Await] + CallExpression[?Yield, ?Await]Arguments[?Yield, ?Await] + CallExpression[?Yield, ?Await][Expression[+In, ?Yield, ?Await]] + CallExpression[?Yield, ?Await].IdentifierName + CallExpression[?Yield, ?Await]TemplateLiteral[?Yield, ?Await] + CallExpression[?Yield, ?Await].PrivateName + +---*/ + + +class C { + static m() { return 42; } #m = 'test262';; + method() { + return this.#m; + } +} + +var c = new C(); + +assert.sameValue(C.m(), 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.method(), 'test262'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-private-method-getter-usage.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-private-method-getter-usage.js new file mode 100644 index 0000000000..35563b45d0 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-private-method-getter-usage.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/private-method-getter-usage.case +// - src/class-elements/productions/cls-decl-after-same-line-static-method.template +/*--- +description: PrivateName CallExpression usage (Accesor get method) (field definitions after a static method in the same line) +esid: prod-FieldDefinition +features: [class-methods-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + Updated Productions + + CallExpression[Yield, Await]: + CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await] + SuperCall[?Yield, ?Await] + CallExpression[?Yield, ?Await]Arguments[?Yield, ?Await] + CallExpression[?Yield, ?Await][Expression[+In, ?Yield, ?Await]] + CallExpression[?Yield, ?Await].IdentifierName + CallExpression[?Yield, ?Await]TemplateLiteral[?Yield, ?Await] + CallExpression[?Yield, ?Await].PrivateName + +---*/ + + +class C { + static m() { return 42; } get #m() { return 'test262'; }; + method() { + return this.#m; + } +} + +var c = new C(); + +assert.sameValue(C.m(), 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.method(), 'test262'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-private-method-usage.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-private-method-usage.js new file mode 100644 index 0000000000..375648c02c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-private-method-usage.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/private-method-usage.case +// - src/class-elements/productions/cls-decl-after-same-line-static-method.template +/*--- +description: PrivateName CallExpression usage (private method) (field definitions after a static method in the same line) +esid: prod-FieldDefinition +features: [class-methods-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + Updated Productions + + CallExpression[Yield, Await]: + CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await] + SuperCall[?Yield, ?Await] + CallExpression[?Yield, ?Await]Arguments[?Yield, ?Await] + CallExpression[?Yield, ?Await][Expression[+In, ?Yield, ?Await]] + CallExpression[?Yield, ?Await].IdentifierName + CallExpression[?Yield, ?Await]TemplateLiteral[?Yield, ?Await] + CallExpression[?Yield, ?Await].PrivateName + +---*/ + + +class C { + static m() { return 42; } #m() { return 'test262'; }; + method() { + return this.#m(); + } +} + +var c = new C(); + +assert.sameValue(C.m(), 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.method(), 'test262'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-private-names.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-private-names.js new file mode 100644 index 0000000000..1f1891cd9f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-private-names.js @@ -0,0 +1,74 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/private-names.case +// - src/class-elements/productions/cls-decl-after-same-line-static-method.template +/*--- +description: private names (field definitions after a static method in the same line) +esid: prod-FieldDefinition +features: [class-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + ... + FieldDefinition ; + + FieldDefinition : + ClassElementName Initializer_opt + + ClassElementName : + PrivateName + + PrivateName : + # IdentifierName + +---*/ + + +class C { + static m() { return 42; } #x; #y; + x() { + this.#x = 42; + return this.#x; + } + y() { + this.#y = 43; + return this.#y; + } +} + +var c = new C(); + +assert.sameValue(C.m(), 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +// Test the private fields do not appear as properties before set to value +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#x"), "test 1"); +assert(!Object.prototype.hasOwnProperty.call(C, "#x"), "test 2"); +assert(!Object.prototype.hasOwnProperty.call(c, "#x"), "test 3"); + +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#y"), "test 4"); +assert(!Object.prototype.hasOwnProperty.call(C, "#y"), "test 5"); +assert(!Object.prototype.hasOwnProperty.call(c, "#y"), "test 6"); + +// Test if private fields can be sucessfully accessed and set to value +assert.sameValue(c.x(), 42, "test 7"); +assert.sameValue(c.y(), 43, "test 8"); + +// Test the private fields do not appear as properties before after set to value +assert(!Object.prototype.hasOwnProperty.call(c, "#x"), "test 9"); +assert(!Object.prototype.hasOwnProperty.call(c, "#y"), "test 10"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-rs-field-identifier-initializer.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-rs-field-identifier-initializer.js new file mode 100644 index 0000000000..0bbf608b42 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-rs-field-identifier-initializer.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-field-identifier-initializer.case +// - src/class-elements/productions/cls-decl-after-same-line-static-method.template +/*--- +description: Valid FieldDefinition (field definitions after a static method in the same line) +esid: prod-FieldDefinition +features: [class-fields-public, class] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + ... + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + + PropertyName : + LiteralPropertyName + ComputedPropertyName + + LiteralPropertyName : + IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static m() { return 42; } $ = 1; _ = 1; \u{6F} = 1; \u2118 = 1; ZW_\u200C_NJ = 1; ZW_\u200D_J = 1; + +} + +var c = new C(); + +assert.sameValue(C.m(), 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.$, 1); +assert.sameValue(c._, 1); +assert.sameValue(c.\u{6F}, 1); +assert.sameValue(c.\u2118, 1); +assert.sameValue(c.ZW_\u200C_NJ, 1); +assert.sameValue(c.ZW_\u200D_J, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-rs-field-identifier.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-rs-field-identifier.js new file mode 100644 index 0000000000..18ae1d46b4 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-rs-field-identifier.js @@ -0,0 +1,97 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-field-identifier.case +// - src/class-elements/productions/cls-decl-after-same-line-static-method.template +/*--- +description: Valid FieldDefinition (field definitions after a static method in the same line) +esid: prod-FieldDefinition +features: [class-fields-public, class] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + ... + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + + PropertyName : + LiteralPropertyName + ComputedPropertyName + + LiteralPropertyName : + IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static m() { return 42; } $; _; \u{6F}; \u2118; ZW_\u200C_NJ; ZW_\u200D_J; + +} + +var c = new C(); + +assert.sameValue(C.m(), 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +c.$ = 1; +c._ = 1; +c.\u{6F} = 1; +c.\u2118 = 1; +c.ZW_\u200C_NJ = 1; +c.ZW_\u200D_J = 1; + +assert.sameValue(c.$, 1); +assert.sameValue(c._, 1); +assert.sameValue(c.\u{6F}, 1); +assert.sameValue(c.\u2118, 1); +assert.sameValue(c.ZW_\u200C_NJ, 1); +assert.sameValue(c.ZW_\u200D_J, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-rs-private-getter-alt.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-rs-private-getter-alt.js new file mode 100644 index 0000000000..f3432246aa --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-rs-private-getter-alt.js @@ -0,0 +1,131 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-private-getter-alt.case +// - src/class-elements/productions/cls-decl-after-same-line-static-method.template +/*--- +description: Valid PrivateName as private getter (field definitions after a static method in the same line) +esid: prod-FieldDefinition +features: [class-methods-private, class-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + ... + ; + + MethodDefinition : + ... + get ClassElementName ( ){ FunctionBody } + ... + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static m() { return 42; } #$_; #__; #\u{6F}_; #℘_; #ZW_‌_NJ_; #ZW_‍_J_; + get #$() { + return this.#$_; + } + get #_() { + return this.#__; + } + get #\u{6F}() { + return this.#\u{6F}_; + } + get #℘() { + return this.#℘_; + } + get #ZW_‌_NJ() { + return this.#ZW_‌_NJ_; + } + get #ZW_‍_J() { + return this.#ZW_‍_J_; + } +; + $(value) { + this.#$_ = value; + return this.#$; + } + _(value) { + this.#__ = value; + return this.#_; + } + \u{6F}(value) { + this.#\u{6F}_ = value; + return this.#\u{6F}; + } + ℘(value) { + this.#℘_ = value; + return this.#℘; + } + ZW_‌_NJ(value) { + this.#ZW_‌_NJ_ = value; + return this.#ZW_‌_NJ; + } + ZW_‍_J(value) { + this.#ZW_‍_J_ = value; + return this.#ZW_‍_J; + } + +} + +var c = new C(); + +assert.sameValue(C.m(), 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.$(1), 1); +assert.sameValue(c._(1), 1); +assert.sameValue(c.\u{6F}(1), 1); +assert.sameValue(c.℘(1), 1); +assert.sameValue(c.ZW_‌_NJ(1), 1); +assert.sameValue(c.ZW_‍_J(1), 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-rs-private-getter.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-rs-private-getter.js new file mode 100644 index 0000000000..0731610a19 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-rs-private-getter.js @@ -0,0 +1,131 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-private-getter.case +// - src/class-elements/productions/cls-decl-after-same-line-static-method.template +/*--- +description: Valid PrivateName as private getter (field definitions after a static method in the same line) +esid: prod-FieldDefinition +features: [class-methods-private, class-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + ... + ; + + MethodDefinition : + ... + get ClassElementName ( ){ FunctionBody } + ... + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static m() { return 42; } #$_; #__; #\u{6F}_; #\u2118_; #ZW_\u200C_NJ_; #ZW_\u200D_J_; + get #$() { + return this.#$_; + } + get #_() { + return this.#__; + } + get #\u{6F}() { + return this.#\u{6F}_; + } + get #\u2118() { + return this.#\u2118_; + } + get #ZW_\u200C_NJ() { + return this.#ZW_\u200C_NJ_; + } + get #ZW_\u200D_J() { + return this.#ZW_\u200D_J_; + } +; + $(value) { + this.#$_ = value; + return this.#$; + } + _(value) { + this.#__ = value; + return this.#_; + } + \u{6F}(value) { + this.#\u{6F}_ = value; + return this.#\u{6F}; + } + \u2118(value) { + this.#\u2118_ = value; + return this.#\u2118; + } + ZW_\u200C_NJ(value) { + this.#ZW_\u200C_NJ_ = value; + return this.#ZW_\u200C_NJ; + } + ZW_\u200D_J(value) { + this.#ZW_\u200D_J_ = value; + return this.#ZW_\u200D_J; + } + +} + +var c = new C(); + +assert.sameValue(C.m(), 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.$(1), 1); +assert.sameValue(c._(1), 1); +assert.sameValue(c.\u{6F}(1), 1); +assert.sameValue(c.\u2118(1), 1); +assert.sameValue(c.ZW_\u200C_NJ(1), 1); +assert.sameValue(c.ZW_\u200D_J(1), 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-rs-private-method-alt.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-rs-private-method-alt.js new file mode 100644 index 0000000000..d7a7a0e688 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-rs-private-method-alt.js @@ -0,0 +1,130 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-private-method-alt.case +// - src/class-elements/productions/cls-decl-after-same-line-static-method.template +/*--- +description: Valid PrivateName as private method (field definitions after a static method in the same line) +esid: prod-FieldDefinition +features: [class-methods-private, class-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + ... + ; + + MethodDefinition : + ClassElementName ( UniqueFormalParameters ) { FunctionBody } + ... + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static m() { return 42; } #$_; #__; #\u{6F}_; #℘_; #ZW_‌_NJ_; #ZW_‍_J_; + #$() { + return this.#$_; + } + #_() { + return this.#__; + } + #\u{6F}() { + return this.#\u{6F}_; + } + #℘() { + return this.#℘_; + } + #ZW_‌_NJ() { + return this.#ZW_‌_NJ_; + } + #ZW_‍_J() { + return this.#ZW_‍_J_; + } +; + $(value) { + this.#$_ = value; + return this.#$(); + } + _(value) { + this.#__ = value; + return this.#_(); + } + \u{6F}(value) { + this.#\u{6F}_ = value; + return this.#\u{6F}(); + } + ℘(value) { + this.#℘_ = value; + return this.#℘(); + } + ZW_‌_NJ(value) { + this.#ZW_‌_NJ_ = value; + return this.#ZW_‌_NJ(); + } + ZW_‍_J(value) { + this.#ZW_‍_J_ = value; + return this.#ZW_‍_J(); + } + +} + +var c = new C(); + +assert.sameValue(C.m(), 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.$(1), 1); +assert.sameValue(c._(1), 1); +assert.sameValue(c.\u{6F}(1), 1); +assert.sameValue(c.℘(1), 1); +assert.sameValue(c.ZW_‌_NJ(1), 1); +assert.sameValue(c.ZW_‍_J(1), 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-rs-private-method.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-rs-private-method.js new file mode 100644 index 0000000000..68a5e5e9e7 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-rs-private-method.js @@ -0,0 +1,130 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-private-method.case +// - src/class-elements/productions/cls-decl-after-same-line-static-method.template +/*--- +description: Valid PrivateName as private method (field definitions after a static method in the same line) +esid: prod-FieldDefinition +features: [class-methods-private, class-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + ... + ; + + MethodDefinition : + ClassElementName ( UniqueFormalParameters ) { FunctionBody } + ... + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static m() { return 42; } #$_; #__; #\u{6F}_; #\u2118_; #ZW_\u200C_NJ_; #ZW_\u200D_J_; + #$() { + return this.#$_; + } + #_() { + return this.#__; + } + #\u{6F}() { + return this.#\u{6F}_; + } + #\u2118() { + return this.#\u2118_; + } + #ZW_\u200C_NJ() { + return this.#ZW_\u200C_NJ_; + } + #ZW_\u200D_J() { + return this.#ZW_\u200D_J_; + } +; + $(value) { + this.#$_ = value; + return this.#$(); + } + _(value) { + this.#__ = value; + return this.#_(); + } + \u{6F}(value) { + this.#\u{6F}_ = value; + return this.#\u{6F}(); + } + \u2118(value) { + this.#\u2118_ = value; + return this.#\u2118(); + } + ZW_\u200C_NJ(value) { + this.#ZW_\u200C_NJ_ = value; + return this.#ZW_\u200C_NJ(); + } + ZW_\u200D_J(value) { + this.#ZW_\u200D_J_ = value; + return this.#ZW_\u200D_J(); + } + +} + +var c = new C(); + +assert.sameValue(C.m(), 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.$(1), 1); +assert.sameValue(c._(1), 1); +assert.sameValue(c.\u{6F}(1), 1); +assert.sameValue(c.\u2118(1), 1); +assert.sameValue(c.ZW_\u200C_NJ(1), 1); +assert.sameValue(c.ZW_\u200D_J(1), 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-rs-private-setter-alt.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-rs-private-setter-alt.js new file mode 100644 index 0000000000..5371131c0e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-rs-private-setter-alt.js @@ -0,0 +1,130 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-private-setter-alt.case +// - src/class-elements/productions/cls-decl-after-same-line-static-method.template +/*--- +description: Valid PrivateName as private setter (field definitions after a static method in the same line) +esid: prod-FieldDefinition +features: [class-methods-private, class-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + ... + ; + + MethodDefinition : + ... + set ClassElementName ( PropertySetParameterList ) { FunctionBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static m() { return 42; } #$_; #__; #\u{6F}_; #℘_; #ZW_‌_NJ_; #ZW_‍_J_; + set #$(value) { + this.#$_ = value; + } + set #_(value) { + this.#__ = value; + } + set #\u{6F}(value) { + this.#\u{6F}_ = value; + } + set #℘(value) { + this.#℘_ = value; + } + set #ZW_‌_NJ(value) { + this.#ZW_‌_NJ_ = value; + } + set #ZW_‍_J(value) { + this.#ZW_‍_J_ = value; + } +; + $(value) { + this.#$ = value; + return this.#$_; + } + _(value) { + this.#_ = value; + return this.#__; + } + \u{6F}(value) { + this.#\u{6F} = value; + return this.#\u{6F}_; + } + ℘(value) { + this.#℘ = value; + return this.#℘_; + } + ZW_‌_NJ(value) { + this.#ZW_‌_NJ = value; + return this.#ZW_‌_NJ_; + } + ZW_‍_J(value) { + this.#ZW_‍_J = value; + return this.#ZW_‍_J_; + } + +} + +var c = new C(); + +assert.sameValue(C.m(), 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.$(1), 1); +assert.sameValue(c._(1), 1); +assert.sameValue(c.\u{6F}(1), 1); +assert.sameValue(c.℘(1), 1); +assert.sameValue(c.ZW_‌_NJ(1), 1); +assert.sameValue(c.ZW_‍_J(1), 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-rs-private-setter.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-rs-private-setter.js new file mode 100644 index 0000000000..d15e7d36c4 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-rs-private-setter.js @@ -0,0 +1,130 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-private-setter.case +// - src/class-elements/productions/cls-decl-after-same-line-static-method.template +/*--- +description: Valid PrivateName as private setter (field definitions after a static method in the same line) +esid: prod-FieldDefinition +features: [class-methods-private, class-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + ... + ; + + MethodDefinition : + ... + set ClassElementName ( PropertySetParameterList ) { FunctionBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static m() { return 42; } #$_; #__; #\u{6F}_; #\u2118_; #ZW_\u200C_NJ_; #ZW_\u200D_J_; + set #$(value) { + this.#$_ = value; + } + set #_(value) { + this.#__ = value; + } + set #\u{6F}(value) { + this.#\u{6F}_ = value; + } + set #\u2118(value) { + this.#\u2118_ = value; + } + set #ZW_\u200C_NJ(value) { + this.#ZW_\u200C_NJ_ = value; + } + set #ZW_\u200D_J(value) { + this.#ZW_\u200D_J_ = value; + } +; + $(value) { + this.#$ = value; + return this.#$_; + } + _(value) { + this.#_ = value; + return this.#__; + } + \u{6F}(value) { + this.#\u{6F} = value; + return this.#\u{6F}_; + } + \u2118(value) { + this.#\u2118 = value; + return this.#\u2118_; + } + ZW_\u200C_NJ(value) { + this.#ZW_\u200C_NJ = value; + return this.#ZW_\u200C_NJ_; + } + ZW_\u200D_J(value) { + this.#ZW_\u200D_J = value; + return this.#ZW_\u200D_J_; + } + +} + +var c = new C(); + +assert.sameValue(C.m(), 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.$(1), 1); +assert.sameValue(c._(1), 1); +assert.sameValue(c.\u{6F}(1), 1); +assert.sameValue(c.\u2118(1), 1); +assert.sameValue(c.ZW_\u200C_NJ(1), 1); +assert.sameValue(c.ZW_\u200D_J(1), 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-rs-privatename-identifier-alt.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-rs-privatename-identifier-alt.js new file mode 100644 index 0000000000..d248e6ac16 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-rs-privatename-identifier-alt.js @@ -0,0 +1,112 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-privatename-identifier-alt.case +// - src/class-elements/productions/cls-decl-after-same-line-static-method.template +/*--- +description: Valid PrivateName (field definitions after a static method in the same line) +esid: prod-FieldDefinition +features: [class-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static m() { return 42; } #$; #_; #\u{6F}; #℘; #ZW_‌_NJ; #ZW_‍_J; + $(value) { + this.#$ = value; + return this.#$; + } + _(value) { + this.#_ = value; + return this.#_; + } + \u{6F}(value) { + this.#\u{6F} = value; + return this.#\u{6F}; + } + ℘(value) { + this.#℘ = value; + return this.#℘; + } + ZW_‌_NJ(value) { + this.#ZW_‌_NJ = value; + return this.#ZW_‌_NJ; + } + ZW_‍_J(value) { + this.#ZW_‍_J = value; + return this.#ZW_‍_J; + } +} + +var c = new C(); + +assert.sameValue(C.m(), 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.$(1), 1); +assert.sameValue(c._(1), 1); +assert.sameValue(c.\u{6F}(1), 1); +assert.sameValue(c.℘(1), 1); +assert.sameValue(c.ZW_‌_NJ(1), 1); +assert.sameValue(c.ZW_‍_J(1), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-rs-privatename-identifier-initializer-alt.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-rs-privatename-identifier-initializer-alt.js new file mode 100644 index 0000000000..aca2290a9d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-rs-privatename-identifier-initializer-alt.js @@ -0,0 +1,106 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-privatename-identifier-initializer-alt.case +// - src/class-elements/productions/cls-decl-after-same-line-static-method.template +/*--- +description: Valid PrivateName (field definitions after a static method in the same line) +esid: prod-FieldDefinition +features: [class-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static m() { return 42; } #$ = 1; #_ = 1; #\u{6F} = 1; #℘ = 1; #ZW_‌_NJ = 1; #ZW_‍_J = 1; + $() { + return this.#$; + } + _() { + return this.#_; + } + \u{6F}() { + return this.#\u{6F}; + } + ℘() { + return this.#℘; + } + ZW_‌_NJ() { + return this.#ZW_‌_NJ; + } + ZW_‍_J() { + return this.#ZW_‍_J; + } +} + +var c = new C(); + +assert.sameValue(C.m(), 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.$(), 1); +assert.sameValue(c._(), 1); +assert.sameValue(c.\u{6F}(), 1); +assert.sameValue(c.℘(), 1); +assert.sameValue(c.ZW_‌_NJ(), 1); +assert.sameValue(c.ZW_‍_J(), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-rs-privatename-identifier-initializer.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-rs-privatename-identifier-initializer.js new file mode 100644 index 0000000000..c2f6b16e75 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-rs-privatename-identifier-initializer.js @@ -0,0 +1,106 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-privatename-identifier-initializer.case +// - src/class-elements/productions/cls-decl-after-same-line-static-method.template +/*--- +description: Valid PrivateName (field definitions after a static method in the same line) +esid: prod-FieldDefinition +features: [class-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static m() { return 42; } #$ = 1; #_ = 1; #\u{6F} = 1; #\u2118 = 1; #ZW_\u200C_NJ = 1; #ZW_\u200D_J = 1; + $() { + return this.#$; + } + _() { + return this.#_; + } + \u{6F}() { + return this.#\u{6F}; + } + \u2118() { + return this.#\u2118; + } + ZW_\u200C_NJ() { + return this.#ZW_\u200C_NJ; + } + ZW_\u200D_J() { + return this.#ZW_\u200D_J; + } +} + +var c = new C(); + +assert.sameValue(C.m(), 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.$(), 1); +assert.sameValue(c._(), 1); +assert.sameValue(c.\u{6F}(), 1); +assert.sameValue(c.\u2118(), 1); +assert.sameValue(c.ZW_\u200C_NJ(), 1); +assert.sameValue(c.ZW_\u200D_J(), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-rs-privatename-identifier.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-rs-privatename-identifier.js new file mode 100644 index 0000000000..f5e5e271e9 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-rs-privatename-identifier.js @@ -0,0 +1,112 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-privatename-identifier.case +// - src/class-elements/productions/cls-decl-after-same-line-static-method.template +/*--- +description: Valid PrivateName (field definitions after a static method in the same line) +esid: prod-FieldDefinition +features: [class-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static m() { return 42; } #$; #_; #\u{6F}; #\u2118; #ZW_\u200C_NJ; #ZW_\u200D_J; + $(value) { + this.#$ = value; + return this.#$; + } + _(value) { + this.#_ = value; + return this.#_; + } + \u{6F}(value) { + this.#\u{6F} = value; + return this.#\u{6F}; + } + \u2118(value) { + this.#\u2118 = value; + return this.#\u2118; + } + ZW_\u200C_NJ(value) { + this.#ZW_\u200C_NJ = value; + return this.#ZW_\u200C_NJ; + } + ZW_\u200D_J(value) { + this.#ZW_\u200D_J = value; + return this.#ZW_\u200D_J; + } +} + +var c = new C(); + +assert.sameValue(C.m(), 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.$(1), 1); +assert.sameValue(c._(1), 1); +assert.sameValue(c.\u{6F}(1), 1); +assert.sameValue(c.\u2118(1), 1); +assert.sameValue(c.ZW_\u200C_NJ(1), 1); +assert.sameValue(c.ZW_\u200D_J(1), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-rs-static-async-generator-method-privatename-identifier-alt.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-rs-static-async-generator-method-privatename-identifier-alt.js new file mode 100644 index 0000000000..99ec2bf733 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-rs-static-async-generator-method-privatename-identifier-alt.js @@ -0,0 +1,137 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-async-generator-method-privatename-identifier-alt.case +// - src/class-elements/productions/cls-decl-after-same-line-static-method.template +/*--- +description: Valid Static AsyncGeneratorMethod PrivateName (field definitions after a static method in the same line) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + AsyncGeneratorMethod + + AsyncGeneratorMethod : + async [no LineTerminator here] * ClassElementName ( UniqueFormalParameters){ AsyncGeneratorBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static m() { return 42; } static async * #$(value) { + yield * await value; + } + static async * #_(value) { + yield * await value; + } + static async * #o(value) { + yield * await value; + } + static async * #℘(value) { + yield * await value; + } + static async * #ZW_‌_NJ(value) { + yield * await value; + } + static async * #ZW_‍_J(value) { + yield * await value; + }; + static get $() { + return this.#$; + } + static get _() { + return this.#_; + } + static get o() { + return this.#o; + } + static get ℘() { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#℘; + } + static get ZW_‌_NJ() { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#ZW_‌_NJ; + } + static get ZW_‍_J() { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#ZW_‍_J; + } + +} + +var c = new C(); + +assert.sameValue(C.m(), 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +Promise.all([ + C.$([1]).next(), + C._([1]).next(), + C.o([1]).next(), + C.℘([1]).next(), // DO NOT CHANGE THE NAME OF THIS FIELD + C.ZW_‌_NJ([1]).next(), // DO NOT CHANGE THE NAME OF THIS FIELD + C.ZW_‍_J([1]).next(), // DO NOT CHANGE THE NAME OF THIS FIELD +]).then(results => { + + assert.sameValue(results[0].value, 1); + assert.sameValue(results[1].value, 1); + assert.sameValue(results[2].value, 1); + assert.sameValue(results[3].value, 1); + assert.sameValue(results[4].value, 1); + assert.sameValue(results[5].value, 1); + +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-rs-static-async-generator-method-privatename-identifier.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-rs-static-async-generator-method-privatename-identifier.js new file mode 100644 index 0000000000..b33d56493a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-rs-static-async-generator-method-privatename-identifier.js @@ -0,0 +1,138 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-async-generator-method-privatename-identifier.case +// - src/class-elements/productions/cls-decl-after-same-line-static-method.template +/*--- +description: Valid Static AsyncGeneratorMethod PrivateName (field definitions after a static method in the same line) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + AsyncGeneratorMethod + + AsyncGeneratorMethod : + async [no LineTerminator here] * ClassElementName ( UniqueFormalParameters){ AsyncGeneratorBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static m() { return 42; } static async * #$(value) { + yield * await value; + } + static async * #_(value) { + yield * await value; + } + static async * #\u{6F}(value) { + yield * await value; + } + static async * #\u2118(value) { + yield * await value; + } + static async * #ZW_\u200C_NJ(value) { + yield * await value; + } + static async * #ZW_\u200D_J(value) { + yield * await value; + }; + static get $() { + return this.#$; + } + static get _() { + return this.#_; + } + static get \u{6F}() { + return this.#\u{6F}; + } + static get \u2118() { + return this.#\u2118; + } + static get ZW_\u200C_NJ() { + return this.#ZW_\u200C_NJ; + } + static get ZW_\u200D_J() { + return this.#ZW_\u200D_J; + } + +} + +var c = new C(); + +assert.sameValue(C.m(), 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +Promise.all([ + C.$([1]).next(), + C._([1]).next(), + C.\u{6F}([1]).next(), + C.\u2118([1]).next(), + C.ZW_\u200C_NJ([1]).next(), + C.ZW_\u200D_J([1]).next(), +]).then(results => { + + assert.sameValue(results[0].value, 1); + assert.sameValue(results[1].value, 1); + assert.sameValue(results[2].value, 1); + assert.sameValue(results[3].value, 1); + assert.sameValue(results[4].value, 1); + assert.sameValue(results[5].value, 1); + +}).then($DONE, $DONE); + diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-rs-static-async-method-privatename-identifier-alt.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-rs-static-async-method-privatename-identifier-alt.js new file mode 100644 index 0000000000..5a545abaea --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-rs-static-async-method-privatename-identifier-alt.js @@ -0,0 +1,137 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-async-method-privatename-identifier-alt.case +// - src/class-elements/productions/cls-decl-after-same-line-static-method.template +/*--- +description: Valid Static AsyncMethod PrivateName (field definitions after a static method in the same line) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + AsyncMethod + + AsyncMethod : + async [no LineTerminator here] ClassElementName ( UniqueFormalParameters ){ AsyncFunctionBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static m() { return 42; } static async #$(value) { + return await value; + } + static async #_(value) { + return await value; + } + static async #o(value) { + return await value; + } + static async #℘(value) { + return await value; + } + static async #ZW_‌_NJ(value) { + return await value; + } + static async #ZW_‍_J(value) { + return await value; + }; + static async $(value) { + return await this.#$(value); + } + static async _(value) { + return await this.#_(value); + } + static async o(value) { + return await this.#o(value); + } + static async ℘(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + return await this.#℘(value); + } + static async ZW_‌_NJ(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + return await this.#ZW_‌_NJ(value); + } + static async ZW_‍_J(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + return await this.#ZW_‍_J(value); + } + +} + +var c = new C(); + +assert.sameValue(C.m(), 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +Promise.all([ + C.$(1), + C._(1), + C.o(1), + C.℘(1), // DO NOT CHANGE THE NAME OF THIS FIELD + C.ZW_‌_NJ(1), // DO NOT CHANGE THE NAME OF THIS FIELD + C.ZW_‍_J(1), // DO NOT CHANGE THE NAME OF THIS FIELD +]).then(results => { + + assert.sameValue(results[0], 1); + assert.sameValue(results[1], 1); + assert.sameValue(results[2], 1); + assert.sameValue(results[3], 1); + assert.sameValue(results[4], 1); + assert.sameValue(results[5], 1); + +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-rs-static-async-method-privatename-identifier.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-rs-static-async-method-privatename-identifier.js new file mode 100644 index 0000000000..ea24834124 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-rs-static-async-method-privatename-identifier.js @@ -0,0 +1,138 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-async-method-privatename-identifier.case +// - src/class-elements/productions/cls-decl-after-same-line-static-method.template +/*--- +description: Valid Static AsyncMethod PrivateName (field definitions after a static method in the same line) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + AsyncMethod + + AsyncMethod : + async [no LineTerminator here] ClassElementName ( UniqueFormalParameters ){ AsyncFunctionBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static m() { return 42; } static async #$(value) { + return await value; + } + static async #_(value) { + return await value; + } + static async #\u{6F}(value) { + return await value; + } + static async #\u2118(value) { + return await value; + } + static async #ZW_\u200C_NJ(value) { + return await value; + } + static async #ZW_\u200D_J(value) { + return await value; + }; + static async $(value) { + return await this.#$(value); + } + static async _(value) { + return await this.#_(value); + } + static async \u{6F}(value) { + return await this.#\u{6F}(value); + } + static async \u2118(value) { + return await this.#\u2118(value); + } + static async ZW_\u200C_NJ(value) { + return await this.#ZW_\u200C_NJ(value); + } + static async ZW_\u200D_J(value) { + return await this.#ZW_\u200D_J(value); + } + +} + +var c = new C(); + +assert.sameValue(C.m(), 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +Promise.all([ + C.$(1), + C._(1), + C.\u{6F}(1), + C.\u2118(1), + C.ZW_\u200C_NJ(1), + C.ZW_\u200D_J(1), +]).then(results => { + + assert.sameValue(results[0], 1); + assert.sameValue(results[1], 1); + assert.sameValue(results[2], 1); + assert.sameValue(results[3], 1); + assert.sameValue(results[4], 1); + assert.sameValue(results[5], 1); + +}).then($DONE, $DONE); + diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-rs-static-generator-method-privatename-identifier-alt.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-rs-static-generator-method-privatename-identifier-alt.js new file mode 100644 index 0000000000..0c423cd562 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-rs-static-generator-method-privatename-identifier-alt.js @@ -0,0 +1,127 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-generator-method-privatename-identifier-alt.case +// - src/class-elements/productions/cls-decl-after-same-line-static-method.template +/*--- +description: Valid Static GeneratorMethod PrivateName (field definitions after a static method in the same line) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + GeneratorMethod + + GeneratorMethod : + * ClassElementName ( UniqueFormalParameters ){ GeneratorBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static m() { return 42; } static * #$(value) { + yield * value; + } + static * #_(value) { + yield * value; + } + static * #o(value) { + yield * value; + } + static * #℘(value) { + yield * value; + } + static * #ZW_‌_NJ(value) { + yield * value; + } + static * #ZW_‍_J(value) { + yield * value; + }; + static get $() { + return this.#$; + } + static get _() { + return this.#_; + } + static get o() { + return this.#o; + } + static get ℘() { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#℘; + } + static get ZW_‌_NJ() { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#ZW_‌_NJ; + } + static get ZW_‍_J() { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#ZW_‍_J; + } + +} + +var c = new C(); + +assert.sameValue(C.m(), 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(C.$([1]).next().value, 1); +assert.sameValue(C._([1]).next().value, 1); +assert.sameValue(C.o([1]).next().value, 1); +assert.sameValue(C.℘([1]).next().value, 1); +assert.sameValue(C.ZW_‌_NJ([1]).next().value, 1); +assert.sameValue(C.ZW_‍_J([1]).next().value, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-rs-static-generator-method-privatename-identifier.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-rs-static-generator-method-privatename-identifier.js new file mode 100644 index 0000000000..55f868c51e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-rs-static-generator-method-privatename-identifier.js @@ -0,0 +1,128 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-generator-method-privatename-identifier.case +// - src/class-elements/productions/cls-decl-after-same-line-static-method.template +/*--- +description: Valid Static GeneratorMethod PrivateName (field definitions after a static method in the same line) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + GeneratorMethod + + GeneratorMethod : + * ClassElementName ( UniqueFormalParameters ){ GeneratorBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static m() { return 42; } static * #$(value) { + yield * value; + } + static * #_(value) { + yield * value; + } + static * #\u{6F}(value) { + yield * value; + } + static * #\u2118(value) { + yield * value; + } + static * #ZW_\u200C_NJ(value) { + yield * value; + } + static * #ZW_\u200D_J(value) { + yield * value; + }; + static get $() { + return this.#$; + } + static get _() { + return this.#_; + } + static get \u{6F}() { + return this.#\u{6F}; + } + static get \u2118() { + return this.#\u2118; + } + static get ZW_\u200C_NJ() { + return this.#ZW_\u200C_NJ; + } + static get ZW_\u200D_J() { + return this.#ZW_\u200D_J; + } + +} + +var c = new C(); + +assert.sameValue(C.m(), 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(C.$([1]).next().value, 1); +assert.sameValue(C._([1]).next().value, 1); +assert.sameValue(C.\u{6F}([1]).next().value, 1); +assert.sameValue(C.\u2118([1]).next().value, 1); +assert.sameValue(C.ZW_\u200C_NJ([1]).next().value, 1); +assert.sameValue(C.ZW_\u200D_J([1]).next().value, 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-rs-static-method-privatename-identifier-alt.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-rs-static-method-privatename-identifier-alt.js new file mode 100644 index 0000000000..58462544d5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-rs-static-method-privatename-identifier-alt.js @@ -0,0 +1,125 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-method-privatename-identifier-alt.case +// - src/class-elements/productions/cls-decl-after-same-line-static-method.template +/*--- +description: Valid Static Method PrivateName (field definitions after a static method in the same line) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + ClassElementName ( UniqueFormalParameters ){ FunctionBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static m() { return 42; } static #$(value) { + return value; + } + static #_(value) { + return value; + } + static #o(value) { + return value; + } + static #℘(value) { + return value; + } + static #ZW_‌_NJ(value) { + return value; + } + static #ZW_‍_J(value) { + return value; + }; + static $(value) { + return this.#$(value); + } + static _(value) { + return this.#_(value); + } + static o(value) { + return this.#o(value); + } + static ℘(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#℘(value); + } + static ZW_‌_NJ(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#ZW_‌_NJ(value); + } + static ZW_‍_J(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#ZW_‍_J(value); + } + +} + +var c = new C(); + +assert.sameValue(C.m(), 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(C.$(1), 1); +assert.sameValue(C._(1), 1); +assert.sameValue(C.o(1), 1); +assert.sameValue(C.℘(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD +assert.sameValue(C.ZW_‌_NJ(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD +assert.sameValue(C.ZW_‍_J(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-rs-static-method-privatename-identifier.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-rs-static-method-privatename-identifier.js new file mode 100644 index 0000000000..a4995abb53 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-rs-static-method-privatename-identifier.js @@ -0,0 +1,125 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-method-privatename-identifier.case +// - src/class-elements/productions/cls-decl-after-same-line-static-method.template +/*--- +description: Valid Static Method PrivateName (field definitions after a static method in the same line) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + ClassElementName ( UniqueFormalParameters ){ FunctionBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static m() { return 42; } static #$(value) { + return value; + } + static #_(value) { + return value; + } + static #\u{6F}(value) { + return value; + } + static #\u2118(value) { + return value; + } + static #ZW_\u200C_NJ(value) { + return value; + } + static #ZW_\u200D_J(value) { + return value; + }; + static $(value) { + return this.#$(value); + } + static _(value) { + return this.#_(value); + } + static \u{6F}(value) { + return this.#\u{6F}(value); + } + static \u2118(value) { + return this.#\u2118(value); + } + static ZW_\u200C_NJ(value) { + return this.#ZW_\u200C_NJ(value); + } + static ZW_\u200D_J(value) { + return this.#ZW_\u200D_J(value); + } + +} + +var c = new C(); + +assert.sameValue(C.m(), 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(C.$(1), 1); +assert.sameValue(C._(1), 1); +assert.sameValue(C.\u{6F}(1), 1); +assert.sameValue(C.\u2118(1), 1); +assert.sameValue(C.ZW_\u200C_NJ(1), 1); +assert.sameValue(C.ZW_\u200D_J(1), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-rs-static-privatename-identifier-alt-by-classname.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-rs-static-privatename-identifier-alt-by-classname.js new file mode 100644 index 0000000000..7d795f14a5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-rs-static-privatename-identifier-alt-by-classname.js @@ -0,0 +1,113 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-privatename-identifier-alt-by-classname.case +// - src/class-elements/productions/cls-decl-after-same-line-static-method.template +/*--- +description: Valid Static PrivateName (field definitions after a static method in the same line) +esid: prod-FieldDefinition +features: [class-static-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static m() { return 42; } static #$; static #_; static #\u{6F}; static #℘; static #ZW_‌_NJ; static #ZW_‍_J; + static $(value) { + C.#$ = value; + return C.#$; + } + static _(value) { + C.#_ = value; + return C.#_; + } + static o(value) { + C.#\u{6F} = value; + return C.#\u{6F}; + } + static ℘(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + C.#℘ = value; + return C.#℘; + } + static ZW_‌_NJ(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + C.#ZW_‌_NJ = value; + return C.#ZW_‌_NJ; + } + static ZW_‍_J(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + C.#ZW_‍_J = value; + return C.#ZW_‍_J; + } +} + +var c = new C(); + +assert.sameValue(C.m(), 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(C.$(1), 1); +assert.sameValue(C._(1), 1); +assert.sameValue(C.o(1), 1); +assert.sameValue(C.℘(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD +assert.sameValue(C.ZW_‌_NJ(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD +assert.sameValue(C.ZW_‍_J(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-rs-static-privatename-identifier-alt.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-rs-static-privatename-identifier-alt.js new file mode 100644 index 0000000000..387692ab67 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-rs-static-privatename-identifier-alt.js @@ -0,0 +1,113 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-privatename-identifier-alt.case +// - src/class-elements/productions/cls-decl-after-same-line-static-method.template +/*--- +description: Valid Static PrivateName (field definitions after a static method in the same line) +esid: prod-FieldDefinition +features: [class-static-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static m() { return 42; } static #$; static #_; static #\u{6F}; static #℘; static #ZW_‌_NJ; static #ZW_‍_J; + static $(value) { + this.#$ = value; + return this.#$; + } + static _(value) { + this.#_ = value; + return this.#_; + } + static o(value) { + this.#\u{6F} = value; + return this.#\u{6F}; + } + static ℘(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + this.#℘ = value; + return this.#℘; + } + static ZW_‌_NJ(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + this.#ZW_‌_NJ = value; + return this.#ZW_‌_NJ; + } + static ZW_‍_J(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + this.#ZW_‍_J = value; + return this.#ZW_‍_J; + } +} + +var c = new C(); + +assert.sameValue(C.m(), 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(C.$(1), 1); +assert.sameValue(C._(1), 1); +assert.sameValue(C.o(1), 1); +assert.sameValue(C.℘(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD +assert.sameValue(C.ZW_‌_NJ(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD +assert.sameValue(C.ZW_‍_J(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-rs-static-privatename-identifier-by-classname.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-rs-static-privatename-identifier-by-classname.js new file mode 100644 index 0000000000..3a5862090b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-rs-static-privatename-identifier-by-classname.js @@ -0,0 +1,113 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-privatename-identifier-by-classname.case +// - src/class-elements/productions/cls-decl-after-same-line-static-method.template +/*--- +description: Valid Static PrivateName (field definitions after a static method in the same line) +esid: prod-FieldDefinition +features: [class-static-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static m() { return 42; } static #$; static #_; static #\u{6F}; static #\u2118; static #ZW_\u200C_NJ; static #ZW_\u200D_J; + static $(value) { + C.#$ = value; + return C.#$; + } + static _(value) { + C.#_ = value; + return C.#_; + } + static \u{6F}(value) { + C.#\u{6F} = value; + return C.#\u{6F}; + } + static \u2118(value) { + C.#\u2118 = value; + return C.#\u2118; + } + static ZW_\u200C_NJ(value) { + C.#ZW_\u200C_NJ = value; + return C.#ZW_\u200C_NJ; + } + static ZW_\u200D_J(value) { + C.#ZW_\u200D_J = value; + return C.#ZW_\u200D_J; + } +} + +var c = new C(); + +assert.sameValue(C.m(), 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(C.$(1), 1); +assert.sameValue(C._(1), 1); +assert.sameValue(C.\u{6F}(1), 1); +assert.sameValue(C.\u2118(1), 1); +assert.sameValue(C.ZW_\u200C_NJ(1), 1); +assert.sameValue(C.ZW_\u200D_J(1), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-rs-static-privatename-identifier-initializer-alt-by-classname.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-rs-static-privatename-identifier-initializer-alt-by-classname.js new file mode 100644 index 0000000000..f028117c95 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-rs-static-privatename-identifier-initializer-alt-by-classname.js @@ -0,0 +1,107 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-privatename-identifier-initializer-alt-by-classname.case +// - src/class-elements/productions/cls-decl-after-same-line-static-method.template +/*--- +description: Valid Static PrivateName (field definitions after a static method in the same line) +esid: prod-FieldDefinition +features: [class-static-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static m() { return 42; } static #$ = 1; static #_ = 1; static #\u{6F} = 1; static #℘ = 1; static #ZW_‌_NJ = 1; static #ZW_‍_J = 1; + static $() { + return C.#$; + } + static _() { + return C.#_; + } + static \u{6F}() { + return C.#\u{6F}; + } + static ℘() { + return C.#℘; + } + static ZW_‌_NJ() { + return C.#ZW_‌_NJ; + } + static ZW_‍_J() { + return C.#ZW_‍_J; + } +} + +var c = new C(); + +assert.sameValue(C.m(), 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(C.$(), 1); +assert.sameValue(C._(), 1); +assert.sameValue(C.\u{6F}(), 1); +assert.sameValue(C.℘(), 1); +assert.sameValue(C.ZW_‌_NJ(), 1); +assert.sameValue(C.ZW_‍_J(), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-rs-static-privatename-identifier-initializer-alt.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-rs-static-privatename-identifier-initializer-alt.js new file mode 100644 index 0000000000..ac7380a810 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-rs-static-privatename-identifier-initializer-alt.js @@ -0,0 +1,107 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-privatename-identifier-initializer-alt.case +// - src/class-elements/productions/cls-decl-after-same-line-static-method.template +/*--- +description: Valid Static PrivateName (field definitions after a static method in the same line) +esid: prod-FieldDefinition +features: [class-static-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static m() { return 42; } static #$ = 1; static #_ = 1; static #\u{6F} = 1; static #℘ = 1; static #ZW_‌_NJ = 1; static #ZW_‍_J = 1; + static $() { + return this.#$; + } + static _() { + return this.#_; + } + static \u{6F}() { + return this.#\u{6F}; + } + static ℘() { + return this.#℘; + } + static ZW_‌_NJ() { + return this.#ZW_‌_NJ; + } + static ZW_‍_J() { + return this.#ZW_‍_J; + } +} + +var c = new C(); + +assert.sameValue(C.m(), 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(C.$(), 1); +assert.sameValue(C._(), 1); +assert.sameValue(C.\u{6F}(), 1); +assert.sameValue(C.℘(), 1); +assert.sameValue(C.ZW_‌_NJ(), 1); +assert.sameValue(C.ZW_‍_J(), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-rs-static-privatename-identifier-initializer.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-rs-static-privatename-identifier-initializer.js new file mode 100644 index 0000000000..ad3e002644 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-rs-static-privatename-identifier-initializer.js @@ -0,0 +1,107 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-privatename-identifier-initializer.case +// - src/class-elements/productions/cls-decl-after-same-line-static-method.template +/*--- +description: Valid Static PrivateName (field definitions after a static method in the same line) +esid: prod-FieldDefinition +features: [class-static-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static m() { return 42; } static #$ = 1; static #_ = 1; static #\u{6F} = 1; static #\u2118 = 1; static #ZW_\u200C_NJ = 1; static #ZW_\u200D_J = 1; + static $() { + return this.#$; + } + static _() { + return this.#_; + } + static \u{6F}() { + return this.#\u{6F}; + } + static \u2118() { + return this.#\u2118; + } + static ZW_\u200C_NJ() { + return this.#ZW_\u200C_NJ; + } + static ZW_\u200D_J() { + return this.#ZW_\u200D_J; + } +} + +var c = new C(); + +assert.sameValue(C.m(), 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(C.$(), 1); +assert.sameValue(C._(), 1); +assert.sameValue(C.\u{6F}(), 1); +assert.sameValue(C.\u2118(), 1); +assert.sameValue(C.ZW_\u200C_NJ(), 1); +assert.sameValue(C.ZW_\u200D_J(), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-rs-static-privatename-identifier.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-rs-static-privatename-identifier.js new file mode 100644 index 0000000000..86a3bbe364 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-rs-static-privatename-identifier.js @@ -0,0 +1,113 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-privatename-identifier.case +// - src/class-elements/productions/cls-decl-after-same-line-static-method.template +/*--- +description: Valid Static PrivateName (field definitions after a static method in the same line) +esid: prod-FieldDefinition +features: [class-static-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static m() { return 42; } static #$; static #_; static #\u{6F}; static #\u2118; static #ZW_\u200C_NJ; static #ZW_\u200D_J; + static $(value) { + this.#$ = value; + return this.#$; + } + static _(value) { + this.#_ = value; + return this.#_; + } + static \u{6F}(value) { + this.#\u{6F} = value; + return this.#\u{6F}; + } + static \u2118(value) { + this.#\u2118 = value; + return this.#\u2118; + } + static ZW_\u200C_NJ(value) { + this.#ZW_\u200C_NJ = value; + return this.#ZW_\u200C_NJ; + } + static ZW_\u200D_J(value) { + this.#ZW_\u200D_J = value; + return this.#ZW_\u200D_J; + } +} + +var c = new C(); + +assert.sameValue(C.m(), 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(C.$(1), 1); +assert.sameValue(C._(1), 1); +assert.sameValue(C.\u{6F}(1), 1); +assert.sameValue(C.\u2118(1), 1); +assert.sameValue(C.ZW_\u200C_NJ(1), 1); +assert.sameValue(C.ZW_\u200D_J(1), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-static-private-fields.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-static-private-fields.js new file mode 100644 index 0000000000..e20e5ac17e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-static-private-fields.js @@ -0,0 +1,74 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/static-private-fields.case +// - src/class-elements/productions/cls-decl-after-same-line-static-method.template +/*--- +description: static private fields (field definitions after a static method in the same line) +esid: prod-FieldDefinition +features: [class-static-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + ... + static FieldDefinition ; + + FieldDefinition : + ClassElementName Initializer_opt + + ClassElementName : + PrivateName + + PrivateName : + # IdentifierName + +---*/ + + +class C { + static m() { return 42; } static #x; static #y; + static x() { + this.#x = 42; + return this.#x; + } + static y() { + this.#y = 43; + return this.#y; + } +} + +var c = new C(); + +assert.sameValue(C.m(), 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +// Test the private fields do not appear as properties before set to value +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#x"), "test 1"); +assert(!Object.prototype.hasOwnProperty.call(C, "#x"), "test 2"); +assert(!Object.prototype.hasOwnProperty.call(c, "#x"), "test 3"); + +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#y"), "test 4"); +assert(!Object.prototype.hasOwnProperty.call(C, "#y"), "test 5"); +assert(!Object.prototype.hasOwnProperty.call(c, "#y"), "test 6"); + +// Test if private fields can be sucessfully accessed and set to value +assert.sameValue(C.x(), 42, "test 7"); +assert.sameValue(C.y(), 43, "test 8"); + +// Test the private fields do not appear as properties before after set to value +assert(!Object.prototype.hasOwnProperty.call(C, "#x"), "test 9"); +assert(!Object.prototype.hasOwnProperty.call(C, "#y"), "test 10"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-static-private-methods-with-fields.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-static-private-methods-with-fields.js new file mode 100644 index 0000000000..aa6489c492 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-static-private-methods-with-fields.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/static-private-methods-with-fields.case +// - src/class-elements/productions/cls-decl-after-same-line-static-method.template +/*--- +description: static private methods with fields (field definitions after a static method in the same line) +esid: prod-FieldDefinition +features: [class-static-methods-private, class-static-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + ... + static FieldDefinition ; + + FieldDefinition : + ClassElementName Initializer_opt + + ClassElementName : + PrivateName + + PrivateName : + # IdentifierName + +---*/ + + +class C { + static m() { return 42; } static #xVal; static #yVal; + static #x(value) { + this.#xVal = value; + return this.#xVal; + } + static #y(value) { + this.#yVal = value; + return this.#yVal; + } + static x() { + return this.#x(42); + } + static y() { + return this.#y(43); + } +} + +var c = new C(); + +assert.sameValue(C.m(), 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +// Test the private methods do not appear as properties before set to value +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#x"), "test 1"); +assert(!Object.prototype.hasOwnProperty.call(C, "#x"), "test 2"); +assert(!Object.prototype.hasOwnProperty.call(c, "#x"), "test 3"); + +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#y"), "test 4"); +assert(!Object.prototype.hasOwnProperty.call(C, "#y"), "test 5"); +assert(!Object.prototype.hasOwnProperty.call(c, "#y"), "test 6"); + +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#xVal"), "test 7"); +assert(!Object.prototype.hasOwnProperty.call(C, "#xVal"), "test 8"); +assert(!Object.prototype.hasOwnProperty.call(c, "#xVal"), "test 9"); + +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#yVal"), "test 10"); +assert(!Object.prototype.hasOwnProperty.call(C, "#yVal"), "test 11"); +assert(!Object.prototype.hasOwnProperty.call(c, "#yVal"), "test 12"); + +// Test if private fields can be sucessfully accessed and set to value +assert.sameValue(C.x(), 42, "test 13"); +assert.sameValue(C.y(), 43, "test 14"); + +// Test the private fields do not appear as properties before after set to value +assert(!Object.prototype.hasOwnProperty.call(C, "#x"), "test 15"); +assert(!Object.prototype.hasOwnProperty.call(C, "#y"), "test 16"); + +assert(!Object.prototype.hasOwnProperty.call(C, "#xVal"), "test 17"); +assert(!Object.prototype.hasOwnProperty.call(C, "#yVal"), "test 18"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-static-private-methods.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-static-private-methods.js new file mode 100644 index 0000000000..8ab59dab0c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-static-private-methods.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/static-private-methods.case +// - src/class-elements/productions/cls-decl-after-same-line-static-method.template +/*--- +description: static private methods (field definitions after a static method in the same line) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + ... + static FieldDefinition ; + + FieldDefinition : + ClassElementName Initializer_opt + + ClassElementName : + PrivateName + + PrivateName : + # IdentifierName + +---*/ + + +class C { + static m() { return 42; } ; + static #x(value) { + return value / 2; + } + static #y(value) { + return value * 2; + } + static x() { + return this.#x(84); + } + static y() { + return this.#y(43); + } +} + +var c = new C(); + +assert.sameValue(C.m(), 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +// Test the private methods do not appear as properties before set to value +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#x"), "test 1"); +assert(!Object.prototype.hasOwnProperty.call(C, "#x"), "test 2"); +assert(!Object.prototype.hasOwnProperty.call(c, "#x"), "test 3"); + +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#y"), "test 4"); +assert(!Object.prototype.hasOwnProperty.call(C, "#y"), "test 5"); +assert(!Object.prototype.hasOwnProperty.call(c, "#y"), "test 6"); + +// Test if private fields can be sucessfully accessed and set to value +assert.sameValue(C.x(), 42, "test 7"); +assert.sameValue(C.y(), 86, "test 8"); + +// Test the private fields do not appear as properties before after set to value +assert(!Object.prototype.hasOwnProperty.call(C, "#x"), "test 9"); +assert(!Object.prototype.hasOwnProperty.call(C, "#y"), "test 10"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-string-literal-names.js b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-string-literal-names.js new file mode 100644 index 0000000000..a022473b03 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/after-same-line-static-method-string-literal-names.js @@ -0,0 +1,112 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/string-literal-names.case +// - src/class-elements/productions/cls-decl-after-same-line-static-method.template +/*--- +description: String literal names (field definitions after a static method in the same line) +esid: prod-FieldDefinition +features: [class-fields-public, class] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PropertyName + +---*/ + + +class C { + static m() { return 42; } 'a'; "b"; 'c' = 39; + "d" = 42; + +} + +var c = new C(); + +assert.sameValue(C.m(), 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "m"), + "m doesn't appear as an own property on the C prototype" +); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "a"), + "a does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "a"), + "a does not appear as an own property on C constructor" +); + +verifyProperty(c, "a", { + value: undefined, + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "b"), + "b does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "b"), + "b does not appear as an own property on C constructor" +); + +verifyProperty(c, "b", { + value: undefined, + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "c"), + "c does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "c"), + "c does not appear as an own property on C constructor" +); + +verifyProperty(c, "c", { + value: 39, + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "d"), + "d does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "d"), + "d does not appear as an own property on C constructor" +); + +verifyProperty(c, "d", { + value: 42, + enumerable: true, + writable: true, + configurable: true +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/arrow-body-derived-cls-direct-eval-contains-superproperty-1.js b/js/src/tests/test262/language/statements/class/elements/arrow-body-derived-cls-direct-eval-contains-superproperty-1.js new file mode 100644 index 0000000000..93c84e4144 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/arrow-body-derived-cls-direct-eval-contains-superproperty-1.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/eval-contains-superproperty-1.case +// - src/class-elements/initializer-eval-super-property/cls-decl-fields-eval-arrow-body.template +/*--- +description: super.x in StatementList of eval (direct eval) +esid: sec-performeval-rules-in-initializer +features: [class, class-fields-public] +flags: [generated] +info: | + Additional Early Error Rules for Eval Inside Initializer + These static semantics are applied by PerformEval when a direct eval call occurs inside a class field initializer. + ScriptBody : StatementList + + ... + The remaining eval rules apply as outside a constructor, inside a method, and inside a function. + + Additional Early Error Rules for Eval Outside Methods + These static semantics are applied by PerformEval when a direct eval call occurs outside of a MethodDefinition. + ScriptBody : StatementList + + It is a Syntax Error if StatementList Contains SuperProperty. + +---*/ + + +var executed = false; +class A {} +class C extends A { + x = eval('executed = true; () => super.x;'); +} + +new C().x(); + +assert.sameValue(executed, true); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/arrow-body-derived-cls-direct-eval-contains-superproperty-2.js b/js/src/tests/test262/language/statements/class/elements/arrow-body-derived-cls-direct-eval-contains-superproperty-2.js new file mode 100644 index 0000000000..a228bda128 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/arrow-body-derived-cls-direct-eval-contains-superproperty-2.js @@ -0,0 +1,33 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/eval-contains-superproperty-2.case +// - src/class-elements/initializer-eval-super-property/cls-decl-fields-eval-arrow-body.template +/*--- +description: super['x'] in StatementList of eval (direct eval) +esid: sec-performeval-rules-in-initializer +features: [class, class-fields-public] +flags: [generated] +info: | + The remaining eval rules apply as outside a constructor, inside a method, and inside a function. + + Additional Early Error Rules for Eval Outside Methods + + These static semantics are applied by PerformEval when a direct eval call occurs outside of a MethodDefinition. + + ScriptBody : StatementList + + It is a Syntax Error if StatementList Contains SuperProperty. + +---*/ + + +var executed = false; +class A {} +class C extends A { + x = eval('executed = true; () => super["x"];'); +} + +new C().x(); + +assert.sameValue(executed, true); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/arrow-body-derived-cls-direct-eval-err-contains-supercall-1.js b/js/src/tests/test262/language/statements/class/elements/arrow-body-derived-cls-direct-eval-err-contains-supercall-1.js new file mode 100644 index 0000000000..1cc1113d38 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/arrow-body-derived-cls-direct-eval-err-contains-supercall-1.js @@ -0,0 +1,38 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/eval-err-contains-supercall-1.case +// - src/class-elements/initializer-eval-super-call/cls-decl-fields-eval-arrow-body.template +/*--- +description: error if `super()['x']` in StatementList of eval (direct eval) +esid: sec-performeval-rules-in-initializer +features: [class, class-fields-public] +flags: [generated] +info: | + Additional Early Error Rules for Eval Inside Initializer + These static semantics are applied by PerformEval when a direct eval call occurs inside a class field initializer. + ScriptBody : StatementList + + ... + The remaining eval rules apply as outside a constructor, inside a method, and inside a function. + + Additional Early Error Rules for Eval Outside Constructor Methods + These static semantics are applied by PerformEval when a direct eval call occurs outside of the constructor method of a ClassDeclaration or ClassExpression. + ScriptBody : StatementList + + It is a Syntax Error if StatementList Contains SuperCall. + +---*/ + + +var executed = false; +class A {} +class C extends A { + x = eval('executed = true; () => super()["x"];'); +} + +assert.throws(SyntaxError, function() { + new C().x(); +}); + +assert.sameValue(executed, false); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/arrow-body-derived-cls-direct-eval-err-contains-supercall-2.js b/js/src/tests/test262/language/statements/class/elements/arrow-body-derived-cls-direct-eval-err-contains-supercall-2.js new file mode 100644 index 0000000000..a43bf96f7a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/arrow-body-derived-cls-direct-eval-err-contains-supercall-2.js @@ -0,0 +1,31 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/eval-err-contains-supercall-2.case +// - src/class-elements/initializer-eval-super-call/cls-decl-fields-eval-arrow-body.template +/*--- +description: error if `super().x` in StatementList of eval (direct eval) +esid: sec-performeval-rules-in-initializer +features: [class, class-fields-public] +flags: [generated] +info: | + Additional Early Error Rules for Eval Outside Constructor Methods + These static semantics are applied by PerformEval when a direct eval call occurs outside of the constructor method of a ClassDeclaration or ClassExpression. + ScriptBody : StatementList + + It is a Syntax Error if StatementList Contains SuperCall. + +---*/ + + +var executed = false; +class A {} +class C extends A { + x = eval('executed = true; () => super().x;'); +} + +assert.throws(SyntaxError, function() { + new C().x(); +}); + +assert.sameValue(executed, false); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/arrow-body-derived-cls-direct-eval-err-contains-supercall.js b/js/src/tests/test262/language/statements/class/elements/arrow-body-derived-cls-direct-eval-err-contains-supercall.js new file mode 100644 index 0000000000..d0eba15d3f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/arrow-body-derived-cls-direct-eval-err-contains-supercall.js @@ -0,0 +1,38 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/eval-err-contains-supercall.case +// - src/class-elements/initializer-eval-super-call/cls-decl-fields-eval-arrow-body.template +/*--- +description: error if `super()` in StatementList of eval (direct eval) +esid: sec-performeval-rules-in-initializer +features: [class, class-fields-public] +flags: [generated] +info: | + Additional Early Error Rules for Eval Inside Initializer + These static semantics are applied by PerformEval when a direct eval call occurs inside a class field initializer. + ScriptBody : StatementList + + ... + The remaining eval rules apply as outside a constructor, inside a method, and inside a function. + + Additional Early Error Rules for Eval Outside Constructor Methods + These static semantics are applied by PerformEval when a direct eval call occurs outside of the constructor method of a ClassDeclaration or ClassExpression. + ScriptBody : StatementList + + It is a Syntax Error if StatementList Contains SuperCall. + +---*/ + + +var executed = false; +class A {} +class C extends A { + x = eval('executed = true; () => super();'); +} + +assert.throws(SyntaxError, function() { + new C().x(); +}); + +assert.sameValue(executed, false); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/arrow-body-derived-cls-indirect-eval-contains-superproperty-1.js b/js/src/tests/test262/language/statements/class/elements/arrow-body-derived-cls-indirect-eval-contains-superproperty-1.js new file mode 100644 index 0000000000..76e3354f61 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/arrow-body-derived-cls-indirect-eval-contains-superproperty-1.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/eval-contains-superproperty-1.case +// - src/class-elements/initializer-eval-super-property/cls-decl-fields-indirect-eval-arrow-body.template +/*--- +description: super.x in StatementList of eval (indirect eval) +esid: sec-performeval-rules-in-initializer +features: [class, class-fields-public] +flags: [generated] +info: | + Additional Early Error Rules for Eval Inside Initializer + These static semantics are applied by PerformEval when a direct eval call occurs inside a class field initializer. + ScriptBody : StatementList + + ... + The remaining eval rules apply as outside a constructor, inside a method, and inside a function. + + Additional Early Error Rules for Eval Outside Methods + These static semantics are applied by PerformEval when a direct eval call occurs outside of a MethodDefinition. + ScriptBody : StatementList + + It is a Syntax Error if StatementList Contains SuperProperty. + +---*/ + + +class A {} +class C extends A { + x = (0, eval)('() => super.x;'); +} + +assert.throws(SyntaxError, function() { + new C().x(); +}); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/arrow-body-derived-cls-indirect-eval-contains-superproperty-2.js b/js/src/tests/test262/language/statements/class/elements/arrow-body-derived-cls-indirect-eval-contains-superproperty-2.js new file mode 100644 index 0000000000..4c636fac01 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/arrow-body-derived-cls-indirect-eval-contains-superproperty-2.js @@ -0,0 +1,33 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/eval-contains-superproperty-2.case +// - src/class-elements/initializer-eval-super-property/cls-decl-fields-indirect-eval-arrow-body.template +/*--- +description: super['x'] in StatementList of eval (indirect eval) +esid: sec-performeval-rules-in-initializer +features: [class, class-fields-public] +flags: [generated] +info: | + The remaining eval rules apply as outside a constructor, inside a method, and inside a function. + + Additional Early Error Rules for Eval Outside Methods + + These static semantics are applied by PerformEval when a direct eval call occurs outside of a MethodDefinition. + + ScriptBody : StatementList + + It is a Syntax Error if StatementList Contains SuperProperty. + +---*/ + + +class A {} +class C extends A { + x = (0, eval)('() => super["x"];'); +} + +assert.throws(SyntaxError, function() { + new C().x(); +}); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/arrow-body-derived-cls-indirect-eval-err-contains-supercall-1.js b/js/src/tests/test262/language/statements/class/elements/arrow-body-derived-cls-indirect-eval-err-contains-supercall-1.js new file mode 100644 index 0000000000..d18d96841d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/arrow-body-derived-cls-indirect-eval-err-contains-supercall-1.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/eval-err-contains-supercall-1.case +// - src/class-elements/initializer-eval-super-call/cls-decl-fields-indirect-eval-arrow-body.template +/*--- +description: error if `super()['x']` in StatementList of eval (indirect eval) +esid: sec-performeval-rules-in-initializer +features: [class, class-fields-public] +flags: [generated] +info: | + Additional Early Error Rules for Eval Inside Initializer + These static semantics are applied by PerformEval when a direct eval call occurs inside a class field initializer. + ScriptBody : StatementList + + ... + The remaining eval rules apply as outside a constructor, inside a method, and inside a function. + + Additional Early Error Rules for Eval Outside Constructor Methods + These static semantics are applied by PerformEval when a direct eval call occurs outside of the constructor method of a ClassDeclaration or ClassExpression. + ScriptBody : StatementList + + It is a Syntax Error if StatementList Contains SuperCall. + +---*/ + + +class A {} +class C extends A { + x = (0, eval)('() => super()["x"];'); +} + +assert.throws(SyntaxError, function() { + new C().x(); +}); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/arrow-body-derived-cls-indirect-eval-err-contains-supercall-2.js b/js/src/tests/test262/language/statements/class/elements/arrow-body-derived-cls-indirect-eval-err-contains-supercall-2.js new file mode 100644 index 0000000000..a8e100c4f3 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/arrow-body-derived-cls-indirect-eval-err-contains-supercall-2.js @@ -0,0 +1,29 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/eval-err-contains-supercall-2.case +// - src/class-elements/initializer-eval-super-call/cls-decl-fields-indirect-eval-arrow-body.template +/*--- +description: error if `super().x` in StatementList of eval (indirect eval) +esid: sec-performeval-rules-in-initializer +features: [class, class-fields-public] +flags: [generated] +info: | + Additional Early Error Rules for Eval Outside Constructor Methods + These static semantics are applied by PerformEval when a direct eval call occurs outside of the constructor method of a ClassDeclaration or ClassExpression. + ScriptBody : StatementList + + It is a Syntax Error if StatementList Contains SuperCall. + +---*/ + + +class A {} +class C extends A { + x = (0, eval)('() => super().x;'); +} + +assert.throws(SyntaxError, function() { + new C().x(); +}); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/arrow-body-derived-cls-indirect-eval-err-contains-supercall.js b/js/src/tests/test262/language/statements/class/elements/arrow-body-derived-cls-indirect-eval-err-contains-supercall.js new file mode 100644 index 0000000000..4c03c94360 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/arrow-body-derived-cls-indirect-eval-err-contains-supercall.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/eval-err-contains-supercall.case +// - src/class-elements/initializer-eval-super-call/cls-decl-fields-indirect-eval-arrow-body.template +/*--- +description: error if `super()` in StatementList of eval (indirect eval) +esid: sec-performeval-rules-in-initializer +features: [class, class-fields-public] +flags: [generated] +info: | + Additional Early Error Rules for Eval Inside Initializer + These static semantics are applied by PerformEval when a direct eval call occurs inside a class field initializer. + ScriptBody : StatementList + + ... + The remaining eval rules apply as outside a constructor, inside a method, and inside a function. + + Additional Early Error Rules for Eval Outside Constructor Methods + These static semantics are applied by PerformEval when a direct eval call occurs outside of the constructor method of a ClassDeclaration or ClassExpression. + ScriptBody : StatementList + + It is a Syntax Error if StatementList Contains SuperCall. + +---*/ + + +class A {} +class C extends A { + x = (0, eval)('() => super();'); +} + +assert.throws(SyntaxError, function() { + new C().x(); +}); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/arrow-body-direct-eval-err-contains-arguments.js b/js/src/tests/test262/language/statements/class/elements/arrow-body-direct-eval-err-contains-arguments.js new file mode 100644 index 0000000000..93e5ecfc53 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/arrow-body-direct-eval-err-contains-arguments.js @@ -0,0 +1,38 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/eval-err-contains-arguments.case +// - src/class-elements/initializer-direct-eval-arguments/cls-decl-fields-eval-arrow-body.template +/*--- +description: error if `arguments` in StatementList of eval (direct eval) +esid: sec-performeval-rules-in-initializer +features: [class, class-fields-public] +flags: [generated] +info: | + Additional Early Error Rules for Eval Inside Initializer + These static semantics are applied by PerformEval when a direct eval call occurs inside a class field initializer. + ScriptBody : StatementList + + It is a Syntax Error if ContainsArguments of StatementList is true. + ... + + Static Semantics: ContainsArguments + IdentifierReference : Identifier + + 1. If the StringValue of Identifier is "arguments", return true. + ... + For all other grammatical productions, recurse on all nonterminals. If any piece returns true, then return true. Otherwise return false. + +---*/ + + +var executed = false; +class C { + x = eval('executed = true; () => arguments;'); +} + +assert.throws(SyntaxError, function() { + new C().x(); +}); + +assert.sameValue(executed, false); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/arrow-body-direct-eval-err-contains-newtarget.js b/js/src/tests/test262/language/statements/class/elements/arrow-body-direct-eval-err-contains-newtarget.js new file mode 100644 index 0000000000..f8195d0139 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/arrow-body-direct-eval-err-contains-newtarget.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/eval-err-contains-newtarget.case +// - src/class-elements/initializer-eval-newtarget/cls-decl-fields-eval-arrow-body.template +/*--- +description: error if `new.target` in StatementList of eval (direct eval) +esid: sec-performeval-rules-in-initializer +features: [class, new.target, class-fields-public] +flags: [generated] +info: | + Additional Early Error Rules for Eval Inside Initializer + These static semantics are applied by PerformEval when a direct eval call occurs inside a class field initializer. + ScriptBody : StatementList + + ... + The remaining eval rules apply as outside a constructor, inside a method, and inside a function. + + Additional Early Error Rules for Eval Outside Functions + These static semantics are applied by PerformEval when a direct eval call occurs outside of any function. + ScriptBody : StatementList + + It is a Syntax Error if StatementList Contains NewTarget. + +---*/ + + +var executed = false; +class C { + x = eval('executed = true; () => new.target;'); +} + +var c = new C(); + +assert.sameValue(executed, true); +assert.sameValue(c.x(), undefined); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/arrow-body-indirect-eval-err-contains-newtarget.js b/js/src/tests/test262/language/statements/class/elements/arrow-body-indirect-eval-err-contains-newtarget.js new file mode 100644 index 0000000000..c41a3ac458 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/arrow-body-indirect-eval-err-contains-newtarget.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/eval-err-contains-newtarget.case +// - src/class-elements/initializer-eval-newtarget/cls-decl-fields-indirect-eval-arrow-body.template +/*--- +description: error if `new.target` in StatementList of eval (indirect eval) +esid: sec-performeval-rules-in-initializer +features: [class, new.target, class-fields-public] +flags: [generated] +info: | + Additional Early Error Rules for Eval Inside Initializer + These static semantics are applied by PerformEval when a direct eval call occurs inside a class field initializer. + ScriptBody : StatementList + + ... + The remaining eval rules apply as outside a constructor, inside a method, and inside a function. + + Additional Early Error Rules for Eval Outside Functions + These static semantics are applied by PerformEval when a direct eval call occurs outside of any function. + ScriptBody : StatementList + + It is a Syntax Error if StatementList Contains NewTarget. + +---*/ + + +class C { + x = (0, eval)('() => new.target;'); +} + +assert.throws(SyntaxError, function() { + new C().x(); +}); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/arrow-body-private-derived-cls-direct-eval-contains-superproperty-1.js b/js/src/tests/test262/language/statements/class/elements/arrow-body-private-derived-cls-direct-eval-contains-superproperty-1.js new file mode 100644 index 0000000000..aafbecc24a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/arrow-body-private-derived-cls-direct-eval-contains-superproperty-1.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/eval-contains-superproperty-1.case +// - src/class-elements/initializer-eval-super-property/cls-decl-private-fields-eval-arrow-body.template +/*--- +description: super.x in StatementList of eval (direct eval) +esid: sec-performeval-rules-in-initializer +features: [class, class-fields-public, class-fields-private] +flags: [generated] +info: | + Additional Early Error Rules for Eval Inside Initializer + These static semantics are applied by PerformEval when a direct eval call occurs inside a class field initializer. + ScriptBody : StatementList + + ... + The remaining eval rules apply as outside a constructor, inside a method, and inside a function. + + Additional Early Error Rules for Eval Outside Methods + These static semantics are applied by PerformEval when a direct eval call occurs outside of a MethodDefinition. + ScriptBody : StatementList + + It is a Syntax Error if StatementList Contains SuperProperty. + +---*/ + + +var executed = false; +class A {} +class C extends A { + #x = eval('executed = true; () => super.x;'); + x() { + this.#x(); + } +} + +new C().x(); + +assert.sameValue(executed, true); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/arrow-body-private-derived-cls-direct-eval-contains-superproperty-2.js b/js/src/tests/test262/language/statements/class/elements/arrow-body-private-derived-cls-direct-eval-contains-superproperty-2.js new file mode 100644 index 0000000000..7973af8125 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/arrow-body-private-derived-cls-direct-eval-contains-superproperty-2.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/eval-contains-superproperty-2.case +// - src/class-elements/initializer-eval-super-property/cls-decl-private-fields-eval-arrow-body.template +/*--- +description: super['x'] in StatementList of eval (direct eval) +esid: sec-performeval-rules-in-initializer +features: [class, class-fields-public, class-fields-private] +flags: [generated] +info: | + The remaining eval rules apply as outside a constructor, inside a method, and inside a function. + + Additional Early Error Rules for Eval Outside Methods + + These static semantics are applied by PerformEval when a direct eval call occurs outside of a MethodDefinition. + + ScriptBody : StatementList + + It is a Syntax Error if StatementList Contains SuperProperty. + +---*/ + + +var executed = false; +class A {} +class C extends A { + #x = eval('executed = true; () => super["x"];'); + x() { + this.#x(); + } +} + +new C().x(); + +assert.sameValue(executed, true); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/arrow-body-private-derived-cls-direct-eval-err-contains-supercall-1.js b/js/src/tests/test262/language/statements/class/elements/arrow-body-private-derived-cls-direct-eval-err-contains-supercall-1.js new file mode 100644 index 0000000000..21281940b3 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/arrow-body-private-derived-cls-direct-eval-err-contains-supercall-1.js @@ -0,0 +1,38 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/eval-err-contains-supercall-1.case +// - src/class-elements/initializer-eval-super-call/cls-decl-private-fields-eval-arrow-body.template +/*--- +description: error if `super()['x']` in StatementList of eval (direct eval) +esid: sec-performeval-rules-in-initializer +features: [class, class-fields-public, class-fields-private] +flags: [generated] +info: | + Additional Early Error Rules for Eval Inside Initializer + These static semantics are applied by PerformEval when a direct eval call occurs inside a class field initializer. + ScriptBody : StatementList + + ... + The remaining eval rules apply as outside a constructor, inside a method, and inside a function. + + Additional Early Error Rules for Eval Outside Constructor Methods + These static semantics are applied by PerformEval when a direct eval call occurs outside of the constructor method of a ClassDeclaration or ClassExpression. + ScriptBody : StatementList + + It is a Syntax Error if StatementList Contains SuperCall. + +---*/ + + +var executed = false; +class A {} +class C extends A { + #x = eval('executed = true; () => super()["x"];'); +} + +assert.throws(SyntaxError, function() { + new C().x(); +}); + +assert.sameValue(executed, false); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/arrow-body-private-derived-cls-direct-eval-err-contains-supercall-2.js b/js/src/tests/test262/language/statements/class/elements/arrow-body-private-derived-cls-direct-eval-err-contains-supercall-2.js new file mode 100644 index 0000000000..154041c503 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/arrow-body-private-derived-cls-direct-eval-err-contains-supercall-2.js @@ -0,0 +1,31 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/eval-err-contains-supercall-2.case +// - src/class-elements/initializer-eval-super-call/cls-decl-private-fields-eval-arrow-body.template +/*--- +description: error if `super().x` in StatementList of eval (direct eval) +esid: sec-performeval-rules-in-initializer +features: [class, class-fields-public, class-fields-private] +flags: [generated] +info: | + Additional Early Error Rules for Eval Outside Constructor Methods + These static semantics are applied by PerformEval when a direct eval call occurs outside of the constructor method of a ClassDeclaration or ClassExpression. + ScriptBody : StatementList + + It is a Syntax Error if StatementList Contains SuperCall. + +---*/ + + +var executed = false; +class A {} +class C extends A { + #x = eval('executed = true; () => super().x;'); +} + +assert.throws(SyntaxError, function() { + new C().x(); +}); + +assert.sameValue(executed, false); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/arrow-body-private-derived-cls-direct-eval-err-contains-supercall.js b/js/src/tests/test262/language/statements/class/elements/arrow-body-private-derived-cls-direct-eval-err-contains-supercall.js new file mode 100644 index 0000000000..df7a681804 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/arrow-body-private-derived-cls-direct-eval-err-contains-supercall.js @@ -0,0 +1,38 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/eval-err-contains-supercall.case +// - src/class-elements/initializer-eval-super-call/cls-decl-private-fields-eval-arrow-body.template +/*--- +description: error if `super()` in StatementList of eval (direct eval) +esid: sec-performeval-rules-in-initializer +features: [class, class-fields-public, class-fields-private] +flags: [generated] +info: | + Additional Early Error Rules for Eval Inside Initializer + These static semantics are applied by PerformEval when a direct eval call occurs inside a class field initializer. + ScriptBody : StatementList + + ... + The remaining eval rules apply as outside a constructor, inside a method, and inside a function. + + Additional Early Error Rules for Eval Outside Constructor Methods + These static semantics are applied by PerformEval when a direct eval call occurs outside of the constructor method of a ClassDeclaration or ClassExpression. + ScriptBody : StatementList + + It is a Syntax Error if StatementList Contains SuperCall. + +---*/ + + +var executed = false; +class A {} +class C extends A { + #x = eval('executed = true; () => super();'); +} + +assert.throws(SyntaxError, function() { + new C().x(); +}); + +assert.sameValue(executed, false); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/arrow-body-private-derived-cls-indirect-eval-contains-superproperty-1.js b/js/src/tests/test262/language/statements/class/elements/arrow-body-private-derived-cls-indirect-eval-contains-superproperty-1.js new file mode 100644 index 0000000000..407e470762 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/arrow-body-private-derived-cls-indirect-eval-contains-superproperty-1.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/eval-contains-superproperty-1.case +// - src/class-elements/initializer-eval-super-property/cls-decl-private-fields-indirect-eval-arrow-body.template +/*--- +description: super.x in StatementList of eval (indirect eval) +esid: sec-performeval-rules-in-initializer +features: [class, class-fields-public, class-fields-private] +flags: [generated] +info: | + Additional Early Error Rules for Eval Inside Initializer + These static semantics are applied by PerformEval when a direct eval call occurs inside a class field initializer. + ScriptBody : StatementList + + ... + The remaining eval rules apply as outside a constructor, inside a method, and inside a function. + + Additional Early Error Rules for Eval Outside Methods + These static semantics are applied by PerformEval when a direct eval call occurs outside of a MethodDefinition. + ScriptBody : StatementList + + It is a Syntax Error if StatementList Contains SuperProperty. + +---*/ + + +class A {} +class C extends A { + #x = (0, eval)('() => super.x;'); +} + +assert.throws(SyntaxError, function() { + new C().x(); +}); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/arrow-body-private-derived-cls-indirect-eval-contains-superproperty-2.js b/js/src/tests/test262/language/statements/class/elements/arrow-body-private-derived-cls-indirect-eval-contains-superproperty-2.js new file mode 100644 index 0000000000..19ace0c9d3 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/arrow-body-private-derived-cls-indirect-eval-contains-superproperty-2.js @@ -0,0 +1,33 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/eval-contains-superproperty-2.case +// - src/class-elements/initializer-eval-super-property/cls-decl-private-fields-indirect-eval-arrow-body.template +/*--- +description: super['x'] in StatementList of eval (indirect eval) +esid: sec-performeval-rules-in-initializer +features: [class, class-fields-public, class-fields-private] +flags: [generated] +info: | + The remaining eval rules apply as outside a constructor, inside a method, and inside a function. + + Additional Early Error Rules for Eval Outside Methods + + These static semantics are applied by PerformEval when a direct eval call occurs outside of a MethodDefinition. + + ScriptBody : StatementList + + It is a Syntax Error if StatementList Contains SuperProperty. + +---*/ + + +class A {} +class C extends A { + #x = (0, eval)('() => super["x"];'); +} + +assert.throws(SyntaxError, function() { + new C().x(); +}); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/arrow-body-private-derived-cls-indirect-eval-err-contains-supercall-1.js b/js/src/tests/test262/language/statements/class/elements/arrow-body-private-derived-cls-indirect-eval-err-contains-supercall-1.js new file mode 100644 index 0000000000..c36853216f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/arrow-body-private-derived-cls-indirect-eval-err-contains-supercall-1.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/eval-err-contains-supercall-1.case +// - src/class-elements/initializer-eval-super-call/cls-decl-private-fields-indirect-eval-arrow-body.template +/*--- +description: error if `super()['x']` in StatementList of eval (indirect eval) +esid: sec-performeval-rules-in-initializer +features: [class, class-fields-public, class-fields-private] +flags: [generated] +info: | + Additional Early Error Rules for Eval Inside Initializer + These static semantics are applied by PerformEval when a direct eval call occurs inside a class field initializer. + ScriptBody : StatementList + + ... + The remaining eval rules apply as outside a constructor, inside a method, and inside a function. + + Additional Early Error Rules for Eval Outside Constructor Methods + These static semantics are applied by PerformEval when a direct eval call occurs outside of the constructor method of a ClassDeclaration or ClassExpression. + ScriptBody : StatementList + + It is a Syntax Error if StatementList Contains SuperCall. + +---*/ + + +class A {} +class C extends A { + #x = (0, eval)('() => super()["x"];'); +} + +assert.throws(SyntaxError, function() { + new C().x(); +}); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/arrow-body-private-derived-cls-indirect-eval-err-contains-supercall-2.js b/js/src/tests/test262/language/statements/class/elements/arrow-body-private-derived-cls-indirect-eval-err-contains-supercall-2.js new file mode 100644 index 0000000000..dcbaf799a0 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/arrow-body-private-derived-cls-indirect-eval-err-contains-supercall-2.js @@ -0,0 +1,29 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/eval-err-contains-supercall-2.case +// - src/class-elements/initializer-eval-super-call/cls-decl-private-fields-indirect-eval-arrow-body.template +/*--- +description: error if `super().x` in StatementList of eval (indirect eval) +esid: sec-performeval-rules-in-initializer +features: [class, class-fields-public, class-fields-private] +flags: [generated] +info: | + Additional Early Error Rules for Eval Outside Constructor Methods + These static semantics are applied by PerformEval when a direct eval call occurs outside of the constructor method of a ClassDeclaration or ClassExpression. + ScriptBody : StatementList + + It is a Syntax Error if StatementList Contains SuperCall. + +---*/ + + +class A {} +class C extends A { + #x = (0, eval)('() => super().x;'); +} + +assert.throws(SyntaxError, function() { + new C().x(); +}); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/arrow-body-private-derived-cls-indirect-eval-err-contains-supercall.js b/js/src/tests/test262/language/statements/class/elements/arrow-body-private-derived-cls-indirect-eval-err-contains-supercall.js new file mode 100644 index 0000000000..637904527e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/arrow-body-private-derived-cls-indirect-eval-err-contains-supercall.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/eval-err-contains-supercall.case +// - src/class-elements/initializer-eval-super-call/cls-decl-private-fields-indirect-eval-arrow-body.template +/*--- +description: error if `super()` in StatementList of eval (indirect eval) +esid: sec-performeval-rules-in-initializer +features: [class, class-fields-public, class-fields-private] +flags: [generated] +info: | + Additional Early Error Rules for Eval Inside Initializer + These static semantics are applied by PerformEval when a direct eval call occurs inside a class field initializer. + ScriptBody : StatementList + + ... + The remaining eval rules apply as outside a constructor, inside a method, and inside a function. + + Additional Early Error Rules for Eval Outside Constructor Methods + These static semantics are applied by PerformEval when a direct eval call occurs outside of the constructor method of a ClassDeclaration or ClassExpression. + ScriptBody : StatementList + + It is a Syntax Error if StatementList Contains SuperCall. + +---*/ + + +class A {} +class C extends A { + #x = (0, eval)('() => super();'); +} + +assert.throws(SyntaxError, function() { + new C().x(); +}); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/arrow-body-private-direct-eval-err-contains-arguments.js b/js/src/tests/test262/language/statements/class/elements/arrow-body-private-direct-eval-err-contains-arguments.js new file mode 100644 index 0000000000..f8639d98b6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/arrow-body-private-direct-eval-err-contains-arguments.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/eval-err-contains-arguments.case +// - src/class-elements/initializer-direct-eval-arguments/cls-decl-private-fields-eval-arrow-body.template +/*--- +description: error if `arguments` in StatementList of eval (direct eval) +esid: sec-performeval-rules-in-initializer +features: [class, class-fields-public, class-fields-private] +flags: [generated] +info: | + Additional Early Error Rules for Eval Inside Initializer + These static semantics are applied by PerformEval when a direct eval call occurs inside a class field initializer. + ScriptBody : StatementList + + It is a Syntax Error if ContainsArguments of StatementList is true. + ... + + Static Semantics: ContainsArguments + IdentifierReference : Identifier + + 1. If the StringValue of Identifier is "arguments", return true. + ... + For all other grammatical productions, recurse on all nonterminals. If any piece returns true, then return true. Otherwise return false. + +---*/ + + +var executed = false; +class C { + #x = eval('executed = true; () => arguments;'); + constructor() { + this.#x(); + } +} + +assert.throws(SyntaxError, function() { + new C(); +}); + +assert.sameValue(executed, false); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/arrow-body-private-direct-eval-err-contains-newtarget.js b/js/src/tests/test262/language/statements/class/elements/arrow-body-private-direct-eval-err-contains-newtarget.js new file mode 100644 index 0000000000..3689dc5744 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/arrow-body-private-direct-eval-err-contains-newtarget.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/eval-err-contains-newtarget.case +// - src/class-elements/initializer-eval-newtarget/cls-decl-private-fields-eval-arrow-body.template +/*--- +description: error if `new.target` in StatementList of eval (direct eval) +esid: sec-performeval-rules-in-initializer +features: [class, new.target, class-fields-private] +flags: [generated] +info: | + Additional Early Error Rules for Eval Inside Initializer + These static semantics are applied by PerformEval when a direct eval call occurs inside a class field initializer. + ScriptBody : StatementList + + ... + The remaining eval rules apply as outside a constructor, inside a method, and inside a function. + + Additional Early Error Rules for Eval Outside Functions + These static semantics are applied by PerformEval when a direct eval call occurs outside of any function. + ScriptBody : StatementList + + It is a Syntax Error if StatementList Contains NewTarget. + +---*/ + + +var executed = false; +class C { + #x = eval('executed = true; () => new.target;'); + x() { + this.#x(); + } +} + +var c = new C(); + +assert.sameValue(executed, true); +assert.sameValue(c.x(), undefined); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/arrow-body-private-indirect-eval-err-contains-newtarget.js b/js/src/tests/test262/language/statements/class/elements/arrow-body-private-indirect-eval-err-contains-newtarget.js new file mode 100644 index 0000000000..3e0afad630 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/arrow-body-private-indirect-eval-err-contains-newtarget.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/eval-err-contains-newtarget.case +// - src/class-elements/initializer-eval-newtarget/cls-decl-private-fields-indirect-eval-arrow-body.template +/*--- +description: error if `new.target` in StatementList of eval (indirect eval) +esid: sec-performeval-rules-in-initializer +features: [class, new.target, class-fields-private] +flags: [generated] +info: | + Additional Early Error Rules for Eval Inside Initializer + These static semantics are applied by PerformEval when a direct eval call occurs inside a class field initializer. + ScriptBody : StatementList + + ... + The remaining eval rules apply as outside a constructor, inside a method, and inside a function. + + Additional Early Error Rules for Eval Outside Functions + These static semantics are applied by PerformEval when a direct eval call occurs outside of any function. + ScriptBody : StatementList + + It is a Syntax Error if StatementList Contains NewTarget. + +---*/ + + +class C { + #x = (0, eval)('() => new.target;'); +} + +assert.throws(SyntaxError, function() { + new C().x(); +}); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/arrow-fnc-init-err-contains-arguments.js b/js/src/tests/test262/language/statements/class/elements/arrow-fnc-init-err-contains-arguments.js new file mode 100644 index 0000000000..04dfb47d0a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/arrow-fnc-init-err-contains-arguments.js @@ -0,0 +1,35 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/init-err-contains-arguments.case +// - src/class-elements/initializer-error/cls-decl-fields-arrow-fnc.template +/*--- +description: Syntax error if `arguments` used in class field (arrow function expression) +esid: sec-class-definitions-static-semantics-early-errors +features: [class, class-fields-public, arrow-function] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Static Semantics: Early Errors + + FieldDefinition: + PropertyNameInitializeropt + + - It is a Syntax Error if ContainsArguments of Initializer is true. + + Static Semantics: ContainsArguments + IdentifierReference : Identifier + + 1. If the StringValue of Identifier is "arguments", return true. + ... + For all other grammatical productions, recurse on all nonterminals. If any piece returns true, then return true. Otherwise return false. + +---*/ + + +$DONOTEVALUATE(); + +class C { + x = () => arguments; +} diff --git a/js/src/tests/test262/language/statements/class/elements/arrow-fnc-init-err-contains-super.js b/js/src/tests/test262/language/statements/class/elements/arrow-fnc-init-err-contains-super.js new file mode 100644 index 0000000000..14f8d6ce04 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/arrow-fnc-init-err-contains-super.js @@ -0,0 +1,28 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/init-err-contains-super.case +// - src/class-elements/initializer-error/cls-decl-fields-arrow-fnc.template +/*--- +description: Syntax error if `super()` used in class field (arrow function expression) +esid: sec-class-definitions-static-semantics-early-errors +features: [class, class-fields-public, arrow-function] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Static Semantics: Early Errors + + FieldDefinition: + PropertyNameInitializeropt + + - It is a Syntax Error if Initializer is present and Initializer Contains SuperCall is true. + +---*/ + + +$DONOTEVALUATE(); + +class C { + x = () => super(); +} diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/await-as-binding-identifier-escaped.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/await-as-binding-identifier-escaped.js new file mode 100644 index 0000000000..0e0615f565 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/await-as-binding-identifier-escaped.js @@ -0,0 +1,37 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/async-generators/await-as-binding-identifier-escaped.case +// - src/async-generators/syntax/async-class-decl-static-private-method.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as a binding identifier. (Static async generator private method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration, class-static-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * # PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + BindingIdentifier : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +$DONOTEVALUATE(); + + +class C { static async *#gen() { + var \u0061wait; +}} diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/await-as-binding-identifier.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/await-as-binding-identifier.js new file mode 100644 index 0000000000..503c9a6db4 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/await-as-binding-identifier.js @@ -0,0 +1,37 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/async-generators/await-as-binding-identifier.case +// - src/async-generators/syntax/async-class-decl-static-private-method.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as a binding identifier. (Static async generator private method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration, class-static-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * # PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + BindingIdentifier : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +$DONOTEVALUATE(); + + +class C { static async *#gen() { + var await; +}} diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/await-as-identifier-reference-escaped.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/await-as-identifier-reference-escaped.js new file mode 100644 index 0000000000..2ddc243efa --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/await-as-identifier-reference-escaped.js @@ -0,0 +1,37 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/async-generators/await-as-identifier-reference-escaped.case +// - src/async-generators/syntax/async-class-decl-static-private-method.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as an identifier reference. (Static async generator private method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration, class-static-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * # PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + IdentifierReference : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +$DONOTEVALUATE(); + + +class C { static async *#gen() { + void \u0061wait; +}} diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/await-as-identifier-reference.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/await-as-identifier-reference.js new file mode 100644 index 0000000000..309e88e2e3 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/await-as-identifier-reference.js @@ -0,0 +1,37 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/async-generators/await-as-identifier-reference.case +// - src/async-generators/syntax/async-class-decl-static-private-method.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as an identifier reference. (Static async generator private method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration, class-static-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * # PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + IdentifierReference : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +$DONOTEVALUATE(); + + +class C { static async *#gen() { + void await; +}} diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/await-as-label-identifier-escaped.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/await-as-label-identifier-escaped.js new file mode 100644 index 0000000000..3c29401caf --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/await-as-label-identifier-escaped.js @@ -0,0 +1,37 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/async-generators/await-as-label-identifier-escaped.case +// - src/async-generators/syntax/async-class-decl-static-private-method.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as a label identifier. (Static async generator private method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration, class-static-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * # PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + LabelIdentifier : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +$DONOTEVALUATE(); + + +class C { static async *#gen() { + \u0061wait: ; +}} diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/await-as-label-identifier.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/await-as-label-identifier.js new file mode 100644 index 0000000000..e99c06f91f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/await-as-label-identifier.js @@ -0,0 +1,37 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/async-generators/await-as-label-identifier.case +// - src/async-generators/syntax/async-class-decl-static-private-method.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as a label identifier. (Static async generator private method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration, class-static-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * # PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + LabelIdentifier : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +$DONOTEVALUATE(); + + +class C { static async *#gen() { + await: ; +}} diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/browser.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/shell.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-as-binding-identifier-escaped.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-as-binding-identifier-escaped.js new file mode 100644 index 0000000000..d219716f1f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-as-binding-identifier-escaped.js @@ -0,0 +1,37 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-as-binding-identifier-escaped.case +// - src/async-generators/syntax/async-class-decl-static-private-method.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as a binding identifier. (Static async generator private method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration, class-static-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * # PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + BindingIdentifier : Identifier + + It is a Syntax Error if this production has a [Yield] parameter and + StringValue of Identifier is "yield". + +---*/ +$DONOTEVALUATE(); + + +class C { static async *#gen() { + var yi\u0065ld; +}} diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-as-binding-identifier.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-as-binding-identifier.js new file mode 100644 index 0000000000..d27ae33299 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-as-binding-identifier.js @@ -0,0 +1,37 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-as-binding-identifier.case +// - src/async-generators/syntax/async-class-decl-static-private-method.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as a binding identifier. (Static async generator private method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration, class-static-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * # PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + BindingIdentifier : Identifier + + It is a Syntax Error if this production has a [Yield] parameter and + StringValue of Identifier is "yield". + +---*/ +$DONOTEVALUATE(); + + +class C { static async *#gen() { + var yield; +}} diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-as-identifier-reference-escaped.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-as-identifier-reference-escaped.js new file mode 100644 index 0000000000..51d2a2d866 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-as-identifier-reference-escaped.js @@ -0,0 +1,37 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-as-identifier-reference-escaped.case +// - src/async-generators/syntax/async-class-decl-static-private-method.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as an identifier reference. (Static async generator private method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration, class-static-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * # PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + IdentifierReference : Identifier + + It is a Syntax Error if this production has a [Yield] parameter and + StringValue of Identifier is "yield". + +---*/ +$DONOTEVALUATE(); + + +class C { static async *#gen() { + void yi\u0065ld; +}} diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-as-identifier-reference.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-as-identifier-reference.js new file mode 100644 index 0000000000..8c09fab99e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-as-identifier-reference.js @@ -0,0 +1,37 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-as-identifier-reference.case +// - src/async-generators/syntax/async-class-decl-static-private-method.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as an identifier reference. (Static async generator private method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration, class-static-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * # PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + IdentifierReference : Identifier + + It is a Syntax Error if this production has a [Yield] parameter and + StringValue of Identifier is "yield". + +---*/ +$DONOTEVALUATE(); + + +class C { static async *#gen() { + void yield; +}} diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-as-label-identifier-escaped.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-as-label-identifier-escaped.js new file mode 100644 index 0000000000..03401d007a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-as-label-identifier-escaped.js @@ -0,0 +1,37 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-as-label-identifier-escaped.case +// - src/async-generators/syntax/async-class-decl-static-private-method.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as a label identifier. (Static async generator private method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration, class-static-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * # PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + LabelIdentifier : Identifier + + It is a Syntax Error if this production has a [Yield] parameter and + StringValue of Identifier is "yield". + +---*/ +$DONOTEVALUATE(); + + +class C { static async *#gen() { + yi\u0065ld: ; +}} diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-as-label-identifier.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-as-label-identifier.js new file mode 100644 index 0000000000..dde2b25edc --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-as-label-identifier.js @@ -0,0 +1,37 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-as-label-identifier.case +// - src/async-generators/syntax/async-class-decl-static-private-method.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as a label identifier. (Static async generator private method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration, class-static-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * # PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + LabelIdentifier : Identifier + + It is a Syntax Error if this production has a [Yield] parameter and + StringValue of Identifier is "yield". + +---*/ +$DONOTEVALUATE(); + + +class C { static async *#gen() { + yield: ; +}} diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-identifier-spread-strict-strict.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-identifier-spread-strict-strict.js new file mode 100644 index 0000000000..30ca50da2d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-identifier-spread-strict-strict.js @@ -0,0 +1,76 @@ +// |reftest| error:SyntaxError +'use strict'; +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-identifier-spread-strict.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: It's an early error if the AssignmentExpression is a function body with yield as an identifier in strict mode. (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [object-spread, async-iteration, class-static-methods-private] +flags: [generated, onlyStrict] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + Spread Properties + + PropertyDefinition[Yield]: + (...) + ...AssignmentExpression[In, ?Yield] + +---*/ +$DONOTEVALUATE(); + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + return { + ...(function() { + var yield; + throw new Test262Error(); + }()), + } + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); + +var iter = C.gen(); + + + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-identifier-strict-strict.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-identifier-strict-strict.js new file mode 100644 index 0000000000..c942f0ba2c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-identifier-strict-strict.js @@ -0,0 +1,67 @@ +// |reftest| error:SyntaxError +'use strict'; +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-identifier-strict.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: It's an early error if the generator body has another function body with yield as an identifier in strict mode. (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [async-iteration, class-static-methods-private] +flags: [generated, onlyStrict] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + +---*/ +$DONOTEVALUATE(); + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + (function() { + var yield; + throw new Test262Error(); + }()) + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); + +var iter = C.gen(); + + + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-promise-reject-next-catch.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-promise-reject-next-catch.js new file mode 100644 index 0000000000..c2e2d7d1a2 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-promise-reject-next-catch.js @@ -0,0 +1,72 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-promise-reject-next-catch.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: yield Promise.reject(value) is treated as throw value (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + +---*/ +let error = new Error(); + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + yield Promise.reject(error); + yield "unreachable"; + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error("Promise incorrectly resolved."); +}).catch(rejectValue => { + // yield Promise.reject(error); + assert.sameValue(rejectValue, error); + + iter.next().then(({done, value}) => { + // iter is closed now. + assert.sameValue(done, true, "The value of IteratorResult.done is `true`"); + assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`"); + }).then($DONE, $DONE); +}); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-promise-reject-next-for-await-of-async-iterator.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-promise-reject-next-for-await-of-async-iterator.js new file mode 100644 index 0000000000..cc865c0f2f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-promise-reject-next-for-await-of-async-iterator.js @@ -0,0 +1,78 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-promise-reject-next-for-await-of-async-iterator.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: yield * [Promise.reject(value)] is treated as throw value (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + +---*/ +let error = new Error(); +async function * readFile() { + yield Promise.reject(error); + yield "unreachable"; +} + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + for await (let line of readFile()) { + yield line; + } + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error("Promise incorrectly resolved."); +}, rejectValue => { + + // yield Promise.reject(error); + assert.sameValue(rejectValue, error); + + iter.next().then(({done, value}) => { + // iter is closed now. + assert.sameValue(done, true, "The value of IteratorResult.done is `true`"); + assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`"); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-promise-reject-next-for-await-of-sync-iterator.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-promise-reject-next-for-await-of-sync-iterator.js new file mode 100644 index 0000000000..fb2ad34bf8 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-promise-reject-next-for-await-of-sync-iterator.js @@ -0,0 +1,77 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-promise-reject-next-for-await-of-sync-iterator.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: yield Promise.reject(value) in for-await-of is treated as throw value (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + +---*/ +let error = new Error(); +let iterable = [ + Promise.reject(error), + "unreachable" +]; + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + for await (let value of iterable) { + yield value; + } + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error("Promise incorrectly resolved."); +}, rejectValue => { + // yield Promise.reject(error); + assert.sameValue(rejectValue, error); + + iter.next().then(({done, value}) => { + // iter is closed now. + assert.sameValue(done, true, "The value of IteratorResult.done is `true`"); + assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`"); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-promise-reject-next-yield-star-async-iterator.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-promise-reject-next-yield-star-async-iterator.js new file mode 100644 index 0000000000..748159fe28 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-promise-reject-next-yield-star-async-iterator.js @@ -0,0 +1,76 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-promise-reject-next-yield-star-async-iterator.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: yield * (async iterator) is treated as throw value (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + +---*/ +let error = new Error(); +async function * readFile() { + yield Promise.reject(error); + yield "unreachable"; +} + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + yield * readFile(); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error("Promise incorrectly resolved."); +}, rejectValue => { + // yield Promise.reject(error); + assert.sameValue(rejectValue, error); + + iter.next().then(({done, value}) => { + // iter is closed now. + assert.sameValue(done, true, "The value of IteratorResult.done is `true`"); + assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`"); + }).then($DONE, $DONE); +}, $DONE).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-promise-reject-next-yield-star-sync-iterator.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-promise-reject-next-yield-star-sync-iterator.js new file mode 100644 index 0000000000..9982495eb7 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-promise-reject-next-yield-star-sync-iterator.js @@ -0,0 +1,75 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-promise-reject-next-yield-star-sync-iterator.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: yield * (async iterator) is treated as throw value (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + +---*/ +let error = new Error(); +let iterable = [ + Promise.reject(error), + "unreachable" +]; + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + yield * iterable; + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error("Promise incorrectly resolved."); +}, rejectValue => { + // yield Promise.reject(error); + assert.sameValue(rejectValue, error); + + iter.next().then(({done, value}) => { + // iter is closed now. + assert.sameValue(done, true, "The value of IteratorResult.done is `true`"); + assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`"); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-promise-reject-next.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-promise-reject-next.js new file mode 100644 index 0000000000..25f0f09a64 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-promise-reject-next.js @@ -0,0 +1,72 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-promise-reject-next.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: yield Promise.reject(value) is treated as throw value (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + +---*/ +let error = new Error(); + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + yield Promise.reject(error); + yield "unreachable"; + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error("Promise incorrectly resolved."); +}, rejectValue => { + // yield Promise.reject(error); + assert.sameValue(rejectValue, error); + + iter.next().then(({done, value}) => { + // iter is closed now. + assert.sameValue(done, true, "The value of IteratorResult.done is `true`"); + assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`"); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-spread-arr-multiple.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-spread-arr-multiple.js new file mode 100644 index 0000000000..65942b1931 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-spread-arr-multiple.js @@ -0,0 +1,78 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-spread-arr-multiple.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: Use yield value in a array spread position (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [async-iteration, class-static-methods-private] +flags: [generated, async] +includes: [compareArray.js] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + Array Initializer + + SpreadElement[Yield, Await]: + ...AssignmentExpression[+In, ?Yield, ?Await] + +---*/ +var arr = ['a', 'b', 'c']; +var item; + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + yield [...yield yield]; + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); + +var iter = C.gen(); + +iter.next(false); +item = iter.next(['a', 'b', 'c']); + +item.then(({ done, value }) => { + item = iter.next(value); + + item.then(({ done, value }) => { + assert.compareArray(value, arr); + assert.sameValue(done, false); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-spread-arr-single.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-spread-arr-single.js new file mode 100644 index 0000000000..67b22e88e7 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-spread-arr-single.js @@ -0,0 +1,77 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-spread-arr-single.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: Use yield value in a array spread position (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + Array Initializer + + SpreadElement[Yield, Await]: + ...AssignmentExpression[+In, ?Yield, ?Await] + +---*/ +var arr = ['a', 'b', 'c']; + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + yield [...yield]; + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); + +var iter = C.gen(); + +iter.next(false); +var item = iter.next(arr); + +item.then(({ done, value }) => { + assert.notSameValue(value, arr, 'value is a new array'); + assert(Array.isArray(value), 'value is an Array exotic object'); + assert.sameValue(value.length, 3) + assert.sameValue(value[0], 'a'); + assert.sameValue(value[1], 'b'); + assert.sameValue(value[2], 'c'); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-spread-obj.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-spread-obj.js new file mode 100644 index 0000000000..67812bf013 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-spread-obj.js @@ -0,0 +1,80 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-spread-obj.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: Use yield value in a object spread position (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [object-spread, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + Spread Properties + + PropertyDefinition[Yield]: + (...) + ...AssignmentExpression[In, ?Yield] + +---*/ + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + yield { + ...yield, + y: 1, + ...yield yield, + }; + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); + +var iter = C.gen(); + +iter.next(); +iter.next({ x: 42 }); +iter.next({ x: 'lol' }); +var item = iter.next({ y: 39 }); + +item.then(({ done, value }) => { + assert.sameValue(value.x, 42); + assert.sameValue(value.y, 39); + assert.sameValue(Object.keys(value).length, 2); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-async-next.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-async-next.js new file mode 100644 index 0000000000..ddac13eccf --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-async-next.js @@ -0,0 +1,247 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-async-next.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: Execution order for yield* with async iterator and next() (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, async-iteration, Symbol.asyncIterator, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + +---*/ +var log = []; +var obj = { + get [Symbol.iterator]() { + log.push({ name: "get [Symbol.iterator]" }); + }, + get [Symbol.asyncIterator]() { + log.push({ + name: "get [Symbol.asyncIterator]", + thisValue: this + }); + return function() { + log.push({ + name: "call [Symbol.asyncIterator]", + thisValue: this, + args: [...arguments] + }); + var nextCount = 0; + return { + name: "asyncIterator", + get next() { + log.push({ + name: "get next", + thisValue: this + }); + return function() { + log.push({ + name: "call next", + thisValue: this, + args: [...arguments] + }); + + nextCount++; + if (nextCount == 1) { + return { + name: "next-promise-1", + get then() { + log.push({ + name: "get next then (1)", + thisValue: this + }); + return function(resolve) { + log.push({ + name: "call next then (1)", + thisValue: this, + args: [...arguments] + }); + + resolve({ + name: "next-result-1", + get value() { + log.push({ + name: "get next value (1)", + thisValue: this + }); + return "next-value-1"; + }, + get done() { + log.push({ + name: "get next done (1)", + thisValue: this + }); + return false; + } + }); + }; + } + }; + } + + return { + name: "next-promise-2", + get then() { + log.push({ + name: "get next then (2)", + thisValue: this + }); + return function(resolve) { + log.push({ + name: "call next then (2)", + thisValue: this, + args: [...arguments] + }); + + resolve({ + name: "next-result-2", + get value() { + log.push({ + name: "get next value (2)", + thisValue: this + }); + return "next-value-2"; + }, + get done() { + log.push({ + name: "get next done (2)", + thisValue: this + }); + return true; + } + }); + }; + } + }; + }; + } + }; + }; + } +}; + + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + log.push({ name: "before yield*" }); + var v = yield* obj; + log.push({ + name: "after yield*", + value: v + }); + return "return-value"; + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); + +var iter = C.gen(); + +assert.sameValue(log.length, 0, "log.length"); + +iter.next("next-arg-1").then(v => { + assert.sameValue(log[0].name, "before yield*"); + + assert.sameValue(log[1].name, "get [Symbol.asyncIterator]"); + assert.sameValue(log[1].thisValue, obj, "get [Symbol.asyncIterator] thisValue"); + + assert.sameValue(log[2].name, "call [Symbol.asyncIterator]"); + assert.sameValue(log[2].thisValue, obj, "[Symbol.asyncIterator] thisValue"); + assert.sameValue(log[2].args.length, 0, "[Symbol.asyncIterator] args.length"); + + assert.sameValue(log[3].name, "get next"); + assert.sameValue(log[3].thisValue.name, "asyncIterator", "get next thisValue"); + + assert.sameValue(log[4].name, "call next"); + assert.sameValue(log[4].thisValue.name, "asyncIterator", "next thisValue"); + assert.sameValue(log[4].args.length, 1, "next args.length"); + assert.sameValue(log[4].args[0], undefined, "next args[0]"); + + assert.sameValue(log[5].name, "get next then (1)"); + assert.sameValue(log[5].thisValue.name, "next-promise-1", "get next then thisValue"); + + assert.sameValue(log[6].name, "call next then (1)"); + assert.sameValue(log[6].thisValue.name, "next-promise-1", "next then thisValue"); + assert.sameValue(log[6].args.length, 2, "next then args.length"); + assert.sameValue(typeof log[6].args[0], "function", "next then args[0]"); + assert.sameValue(typeof log[6].args[1], "function", "next then args[1]"); + + assert.sameValue(log[7].name, "get next done (1)"); + assert.sameValue(log[7].thisValue.name, "next-result-1", "get next done thisValue"); + + assert.sameValue(log[8].name, "get next value (1)"); + assert.sameValue(log[8].thisValue.name, "next-result-1", "get next value thisValue"); + + assert.sameValue(v.value, "next-value-1"); + assert.sameValue(v.done, false); + + assert.sameValue(log.length, 9, "log.length"); + + iter.next("next-arg-2").then(v => { + assert.sameValue(log[9].name, "call next"); + assert.sameValue(log[9].thisValue.name, "asyncIterator", "next thisValue"); + assert.sameValue(log[9].args.length, 1, "next args.length"); + assert.sameValue(log[9].args[0], "next-arg-2", "next args[0]"); + + assert.sameValue(log[10].name, "get next then (2)"); + assert.sameValue(log[10].thisValue.name, "next-promise-2", "get next then thisValue"); + + assert.sameValue(log[11].name, "call next then (2)"); + assert.sameValue(log[11].thisValue.name, "next-promise-2", "next then thisValue"); + assert.sameValue(log[11].args.length, 2, "next then args.length"); + assert.sameValue(typeof log[11].args[0], "function", "next then args[0]"); + assert.sameValue(typeof log[11].args[1], "function", "next then args[1]"); + + assert.sameValue(log[12].name, "get next done (2)"); + assert.sameValue(log[12].thisValue.name, "next-result-2", "get next done thisValue"); + + assert.sameValue(log[13].name, "get next value (2)"); + assert.sameValue(log[13].thisValue.name, "next-result-2", "get next value thisValue"); + + assert.sameValue(log[14].name, "after yield*"); + assert.sameValue(log[14].value, "next-value-2"); + + assert.sameValue(v.value, "return-value"); + assert.sameValue(v.done, true); + + assert.sameValue(log.length, 15, "log.length"); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-async-return.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-async-return.js new file mode 100644 index 0000000000..3c4a474b2b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-async-return.js @@ -0,0 +1,263 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-async-return.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: execution order for yield* with async iterator and return() (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [async-iteration, Symbol.asyncIterator, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + ... + 6. Repeat + ... + c. Else, + i. Assert: received.[[Type]] is return. + ii. Let return be ? GetMethod(iterator, "return"). + iii. If return is undefined, return Completion(received). + iv. Let innerReturnResult be ? Call(return, iterator, « received.[[Value]] »). + v. If generatorKind is async, then set innerReturnResult to ? Await(innerReturnResult). + ... + vii. Let done be ? IteratorComplete(innerReturnResult). + viii. If done is true, then + 1. Let value be ? IteratorValue(innerReturnResult). + 2. If generatorKind is async, then set value to ? Await(value). + 3. Return Completion{[[Type]]: return, [[Value]]: value, [[Target]]: empty}. + ix. If generatorKind is async, then let received be AsyncGeneratorYield(? IteratorValue(innerResult)). + ... + + AsyncGeneratorYield ( value ) + ... + 8. Return ! AsyncGeneratorResolve(generator, value, false). + ... + +---*/ +var log = []; +var obj = { + [Symbol.asyncIterator]() { + var returnCount = 0; + return { + name: 'asyncIterator', + get next() { + log.push({ name: "get next" }); + return function() { + return { + value: "next-value-1", + done: false + }; + }; + }, + get return() { + log.push({ + name: "get return", + thisValue: this + }); + return function() { + log.push({ + name: "call return", + thisValue: this, + args: [...arguments] + }); + + returnCount++; + if (returnCount == 1) { + return { + name: "return-promise-1", + get then() { + log.push({ + name: "get return then (1)", + thisValue: this + }); + return function(resolve) { + log.push({ + name: "call return then (1)", + thisValue: this, + args: [...arguments] + }); + + resolve({ + name: "return-result-1", + get value() { + log.push({ + name: "get return value (1)", + thisValue: this + }); + return "return-value-1"; + }, + get done() { + log.push({ + name: "get return done (1)", + thisValue: this + }); + return false; + } + }); + }; + } + }; + } + + return { + name: "return-promise-2", + get then() { + log.push({ + name: "get return then (2)", + thisValue: this + }); + return function(resolve) { + log.push({ + name: "call return then (2)", + thisValue: this, + args: [...arguments] + }); + + resolve({ + name: "return-result-2", + get value() { + log.push({ + name: "get return value (2)", + thisValue: this + }); + return "return-value-2"; + }, + get done() { + log.push({ + name: "get return done (2)", + thisValue: this + }); + return true; + } + }); + }; + } + }; + }; + } + }; + } +}; + + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + log.push({ name: "before yield*" }); + yield* obj; + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); + +var iter = C.gen(); + +assert.sameValue(log.length, 0, "log.length"); + +iter.next().then(v => { + assert.sameValue(log[0].name, "before yield*"); + + assert.sameValue(log[1].name, "get next"); + + assert.sameValue(v.value, "next-value-1"); + assert.sameValue(v.done, false); + + assert.sameValue(log.length, 2, "log.length"); + + iter.return("return-arg-1").then(v => { + assert.sameValue(log[2].name, "get return"); + assert.sameValue(log[2].thisValue.name, "asyncIterator", "get return thisValue"); + + assert.sameValue(log[3].name, "call return"); + assert.sameValue(log[3].thisValue.name, "asyncIterator", "return thisValue"); + assert.sameValue(log[3].args.length, 1, "return args.length"); + assert.sameValue(log[3].args[0], "return-arg-1", "return args[0]"); + + assert.sameValue(log[4].name, "get return then (1)"); + assert.sameValue(log[4].thisValue.name, "return-promise-1", "get return then thisValue"); + + assert.sameValue(log[5].name, "call return then (1)"); + assert.sameValue(log[5].thisValue.name, "return-promise-1", "return then thisValue"); + assert.sameValue(log[5].args.length, 2, "return then args.length"); + assert.sameValue(typeof log[5].args[0], "function", "return then args[0]"); + assert.sameValue(typeof log[5].args[1], "function", "return then args[1]"); + + assert.sameValue(log[6].name, "get return done (1)"); + assert.sameValue(log[6].thisValue.name, "return-result-1", "get return done thisValue"); + + assert.sameValue(log[7].name, "get return value (1)"); + assert.sameValue(log[7].thisValue.name, "return-result-1", "get return value thisValue"); + + assert.sameValue(v.value, "return-value-1"); + assert.sameValue(v.done, false); + + assert.sameValue(log.length, 8, "log.length"); + + iter.return("return-arg-2").then(v => { + assert.sameValue(log[8].name, "get return"); + assert.sameValue(log[8].thisValue.name, "asyncIterator", "get return thisValue"); + + assert.sameValue(log[9].name, "call return"); + assert.sameValue(log[9].thisValue.name, "asyncIterator", "return thisValue"); + assert.sameValue(log[9].args.length, 1, "return args.length"); + assert.sameValue(log[9].args[0], "return-arg-2", "return args[0]"); + + assert.sameValue(log[10].name, "get return then (2)"); + assert.sameValue(log[10].thisValue.name, "return-promise-2", "get return then thisValue"); + + assert.sameValue(log[11].name, "call return then (2)"); + assert.sameValue(log[11].thisValue.name, "return-promise-2", "return then thisValue"); + assert.sameValue(log[11].args.length, 2, "return then args.length"); + assert.sameValue(typeof log[11].args[0], "function", "return then args[0]"); + assert.sameValue(typeof log[11].args[1], "function", "return then args[1]"); + + assert.sameValue(log[12].name, "get return done (2)"); + assert.sameValue(log[12].thisValue.name, "return-result-2", "get return done thisValue"); + + assert.sameValue(log[13].name, "get return value (2)"); + assert.sameValue(log[13].thisValue.name, "return-result-2", "get return value thisValue"); + + assert.sameValue(v.value, "return-value-2"); + assert.sameValue(v.done, true); + + assert.sameValue(log.length, 14, "log.length"); + }).then($DONE, $DONE); + }).catch($DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-async-throw.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-async-throw.js new file mode 100644 index 0000000000..6627b10e60 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-async-throw.js @@ -0,0 +1,271 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-async-throw.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: execution order for yield* with async iterator and throw() (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [async-iteration, Symbol.asyncIterator, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + ... + 6. Repeat + ... + b. Else if received.[[Type]] is throw, then + i. Let throw be ? GetMethod(iterator, "throw"). + ii. If throw is not undefined, then + 1. Let innerResult be ? Call(throw, iterator, « received.[[Value]] »). + 2. If generatorKind is async, then set innerResult to ? Await(innerResult). + ... + 5. Let done be ? IteratorComplete(innerResult). + 6. If done is true, then + a. Let resultValue be Return ? IteratorValue(innerResult). + b. If generatorKind is async, then set resultValue to ? Await(resultValue). + c. Return resultValue. + 7. If generatorKind is async, then let received be AsyncGeneratorYield(? IteratorValue(innerResult)). + ... + + AsyncGeneratorYield ( value ) + + ... + 8. Return ! AsyncGeneratorResolve(generator, value, false). + ... + +---*/ +var log = []; +var obj = { + [Symbol.asyncIterator]() { + var throwCount = 0; + return { + name: "asyncIterator", + get next() { + log.push({ name: "get next" }); + return function() { + return { + value: "next-value-1", + done: false + }; + }; + }, + get throw() { + log.push({ + name: "get throw", + thisValue: this + }); + return function() { + log.push({ + name: "call throw", + thisValue: this, + args: [...arguments] + }); + + throwCount++; + if (throwCount == 1) { + return { + name: "throw-promise-1", + get then() { + log.push({ + name: "get throw then (1)", + thisValue: this + }); + return function(resolve) { + log.push({ + name: "call throw then (1)", + thisValue: this, + args: [...arguments] + }); + + resolve({ + name: "throw-result-1", + get value() { + log.push({ + name: "get throw value (1)", + thisValue: this + }); + return "throw-value-1"; + }, + get done() { + log.push({ + name: "get throw done (1)", + thisValue: this + }); + return false; + } + }); + }; + } + }; + } + + return { + name: "throw-promise-2", + get then() { + log.push({ + name: "get throw then (2)", + thisValue: this + }); + return function(resolve) { + log.push({ + name: "call throw then (2)", + thisValue: this, + args: [...arguments] + }); + + resolve({ + name: "throw-result-2", + get value() { + log.push({ + name: "get throw value (2)", + thisValue: this + }); + return "throw-value-2"; + }, + get done() { + log.push({ + name: "get throw done (2)", + thisValue: this + }); + return true; + } + }); + }; + } + }; + }; + } + }; + } +}; + + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + log.push({ name: "before yield*" }); + var v = yield* obj; + log.push({ + name: "after yield*", + value: v + }); + return "return-value"; + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); + +var iter = C.gen(); + +assert.sameValue(log.length, 0, "log.length"); + +iter.next().then(v => { + assert.sameValue(log[0].name, "before yield*"); + + assert.sameValue(log[1].name, "get next"); + + assert.sameValue(v.value, "next-value-1"); + assert.sameValue(v.done, false); + + assert.sameValue(log.length, 2, "log.length"); + + iter.throw("throw-arg-1").then(v => { + assert.sameValue(log[2].name, "get throw"); + assert.sameValue(log[2].thisValue.name, "asyncIterator", "get throw thisValue"); + + assert.sameValue(log[3].name, "call throw"); + assert.sameValue(log[3].thisValue.name, "asyncIterator", "throw thisValue"); + assert.sameValue(log[3].args.length, 1, "throw args.length"); + assert.sameValue(log[3].args[0], "throw-arg-1", "throw args[0]"); + + assert.sameValue(log[4].name, "get throw then (1)"); + assert.sameValue(log[4].thisValue.name, "throw-promise-1", "get throw thisValue"); + + assert.sameValue(log[5].name, "call throw then (1)"); + assert.sameValue(log[5].thisValue.name, "throw-promise-1", "throw thisValue"); + assert.sameValue(log[5].args.length, 2, "throw then args.length"); + assert.sameValue(typeof log[5].args[0], "function", "throw then args[0]"); + assert.sameValue(typeof log[5].args[1], "function", "throw then args[1]"); + + assert.sameValue(log[6].name, "get throw done (1)"); + assert.sameValue(log[6].thisValue.name, "throw-result-1", "get throw done thisValue"); + + assert.sameValue(log[7].name, "get throw value (1)"); + assert.sameValue(log[7].thisValue.name, "throw-result-1", "get throw value thisValue"); + + assert.sameValue(v.value, "throw-value-1"); + assert.sameValue(v.done, false); + + assert.sameValue(log.length, 8, "log.length"); + + iter.throw("throw-arg-2").then(v => { + assert.sameValue(log[8].name, "get throw"); + assert.sameValue(log[8].thisValue.name, "asyncIterator", "get throw thisValue"); + + assert.sameValue(log[9].name, "call throw"); + assert.sameValue(log[9].thisValue.name, "asyncIterator", "throw thisValue"); + assert.sameValue(log[9].args.length, 1, "throw args.length"); + assert.sameValue(log[9].args[0], "throw-arg-2", "throw args[0]"); + + assert.sameValue(log[10].name, "get throw then (2)"); + assert.sameValue(log[10].thisValue.name, "throw-promise-2", "get throw thisValue"); + + assert.sameValue(log[11].name, "call throw then (2)"); + assert.sameValue(log[11].thisValue.name, "throw-promise-2", "throw thisValue"); + assert.sameValue(log[11].args.length, 2, "throw then args.length"); + assert.sameValue(typeof log[11].args[0], "function", "throw then args[0]"); + assert.sameValue(typeof log[11].args[1], "function", "throw then args[1]"); + + assert.sameValue(log[12].name, "get throw done (2)"); + assert.sameValue(log[12].thisValue.name, "throw-result-2", "get throw done thisValue"); + + assert.sameValue(log[13].name, "get throw value (2)"); + assert.sameValue(log[13].thisValue.name, "throw-result-2", "get throw value thisValue"); + + assert.sameValue(log[14].name, "after yield*"); + assert.sameValue(log[14].value, "throw-value-2"); + + assert.sameValue(v.value, "return-value"); + assert.sameValue(v.done, true); + + assert.sameValue(log.length, 15, "log.length"); + }).then($DONE, $DONE); + }).catch($DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-expr-abrupt.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-expr-abrupt.js new file mode 100644 index 0000000000..8e47406b79 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-expr-abrupt.js @@ -0,0 +1,82 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-expr-abrupt.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: Abrupt completion while getting yield* operand (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + ... + +---*/ +var obj = {}; +var abrupt = function() { + throw obj; +}; + + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + yield* abrupt(); + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, obj, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-getiter-async-get-abrupt.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-getiter-async-get-abrupt.js new file mode 100644 index 0000000000..c97c341790 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-getiter-async-get-abrupt.js @@ -0,0 +1,102 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-get-abrupt.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: Abrupt completion while getting [Symbol.asyncIterator] (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + get [Symbol.asyncIterator]() { + throw reason; + } +}; + + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-getiter-async-not-callable-boolean-throw.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-getiter-async-not-callable-boolean-throw.js new file mode 100644 index 0000000000..55f538fe56 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-getiter-async-not-callable-boolean-throw.js @@ -0,0 +1,101 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-not-callable-boolean-throw.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: Throws a TypeError on a non-callable [Symbol.asyncIterator] (boolean) (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + 3. If func is either undefined or null, return undefined. + 4. If IsCallable(func) is false, throw a TypeError exception. + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]: false +}; + + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-getiter-async-not-callable-number-throw.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-getiter-async-not-callable-number-throw.js new file mode 100644 index 0000000000..1014533cbe --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-getiter-async-not-callable-number-throw.js @@ -0,0 +1,101 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-not-callable-number-throw.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: Throws a TypeError on a non-callable [Symbol.asyncIterator] (number) (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + 3. If func is either undefined or null, return undefined. + 4. If IsCallable(func) is false, throw a TypeError exception. + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]: 0 +}; + + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-getiter-async-not-callable-object-throw.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-getiter-async-not-callable-object-throw.js new file mode 100644 index 0000000000..d883087711 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-getiter-async-not-callable-object-throw.js @@ -0,0 +1,101 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-not-callable-object-throw.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: Throws a TypeError on a non-callable [Symbol.asyncIterator] (object) (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + 3. If func is either undefined or null, return undefined. + 4. If IsCallable(func) is false, throw a TypeError exception. + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]: {} +}; + + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-getiter-async-not-callable-string-throw.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-getiter-async-not-callable-string-throw.js new file mode 100644 index 0000000000..0c93ce30d0 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-getiter-async-not-callable-string-throw.js @@ -0,0 +1,101 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-not-callable-string-throw.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: Throws a TypeError on a non-callable [Symbol.asyncIterator] (string) (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + 3. If func is either undefined or null, return undefined. + 4. If IsCallable(func) is false, throw a TypeError exception. + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]: '' +}; + + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-getiter-async-not-callable-symbol-throw.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-getiter-async-not-callable-symbol-throw.js new file mode 100644 index 0000000000..671d88533b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-getiter-async-not-callable-symbol-throw.js @@ -0,0 +1,101 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-not-callable-symbol-throw.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: Throws a TypeError on a non-callable [Symbol.asyncIterator] (symbol) (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + 3. If func is either undefined or null, return undefined. + 4. If IsCallable(func) is false, throw a TypeError exception. + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]: Symbol.asyncIterator +}; + + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-getiter-async-null-sync-get-abrupt.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-getiter-async-null-sync-get-abrupt.js new file mode 100644 index 0000000000..6bfab44818 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-getiter-async-null-sync-get-abrupt.js @@ -0,0 +1,107 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-null-sync-get-abrupt.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: Abrupt completion while getting @@iterator after null @@asyncIterator (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + b. If method is undefined, + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + ... + +---*/ +var calls = 0; +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw reason; + }, + get [Symbol.asyncIterator]() { + calls += 1; + return null; + } +}; + + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, 'reject reason'); + assert.sameValue(calls, 1); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-getiter-async-returns-abrupt.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-getiter-async-returns-abrupt.js new file mode 100644 index 0000000000..59c737afa7 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-getiter-async-returns-abrupt.js @@ -0,0 +1,98 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-returns-abrupt.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: Abrupt completion while calling [Symbol.asyncIterator] (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + 6. Let iterator be ? Call(method, obj). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + throw reason; + } +}; + + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-getiter-async-returns-boolean-throw.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-getiter-async-returns-boolean-throw.js new file mode 100644 index 0000000000..bb47a63b8e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-getiter-async-returns-boolean-throw.js @@ -0,0 +1,98 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-returns-boolean-throw.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: Non object returned by [Symbol.asyncIterator]() - boolean (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + 6. Let iterator be ? Call(method, obj). + 7. If Type(iterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return true; + } +}; + + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-getiter-async-returns-null-throw.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-getiter-async-returns-null-throw.js new file mode 100644 index 0000000000..3d714358e0 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-getiter-async-returns-null-throw.js @@ -0,0 +1,98 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-returns-null-throw.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: Non object returned by [Symbol.asyncIterator]() - null (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + 6. Let iterator be ? Call(method, obj). + 7. If Type(iterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return null; + } +}; + + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-getiter-async-returns-number-throw.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-getiter-async-returns-number-throw.js new file mode 100644 index 0000000000..2ef5888a9c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-getiter-async-returns-number-throw.js @@ -0,0 +1,98 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-returns-number-throw.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: Non object returned by [Symbol.asyncIterator]() - number (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + 6. Let iterator be ? Call(method, obj). + 7. If Type(iterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return 42; + } +}; + + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-getiter-async-returns-string-throw.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-getiter-async-returns-string-throw.js new file mode 100644 index 0000000000..dca0dd2b18 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-getiter-async-returns-string-throw.js @@ -0,0 +1,98 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-returns-string-throw.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: Non object returned by [Symbol.asyncIterator]() - string (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + 6. Let iterator be ? Call(method, obj). + 7. If Type(iterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return '42'; + } +}; + + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-getiter-async-returns-symbol-throw.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-getiter-async-returns-symbol-throw.js new file mode 100644 index 0000000000..b1f79aad56 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-getiter-async-returns-symbol-throw.js @@ -0,0 +1,98 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-returns-symbol-throw.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: Non object returned by [Symbol.asyncIterator]() - symbol (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + 6. Let iterator be ? Call(method, obj). + 7. If Type(iterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return Symbol.asyncIterator; + } +}; + + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-getiter-async-returns-undefined-throw.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-getiter-async-returns-undefined-throw.js new file mode 100644 index 0000000000..d242e4b5af --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-getiter-async-returns-undefined-throw.js @@ -0,0 +1,98 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-returns-undefined-throw.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: Non object returned by [Symbol.asyncIterator]() - undefined (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + 6. Let iterator be ? Call(method, obj). + 7. If Type(iterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return undefined; + } +}; + + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-getiter-async-undefined-sync-get-abrupt.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-getiter-async-undefined-sync-get-abrupt.js new file mode 100644 index 0000000000..c4697dc91e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-getiter-async-undefined-sync-get-abrupt.js @@ -0,0 +1,107 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-undefined-sync-get-abrupt.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: Abrupt completion while getting @@iterator after undefined @@asyncIterator (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + b. If method is undefined, + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + ... + +---*/ +var calls = 0; +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw reason; + }, + get [Symbol.asyncIterator]() { + calls += 1; + return undefined; + } +}; + + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, 'reject reason'); + assert.sameValue(calls, 1); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-getiter-sync-get-abrupt.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-getiter-sync-get-abrupt.js new file mode 100644 index 0000000000..f2166f1822 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-getiter-sync-get-abrupt.js @@ -0,0 +1,101 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-get-abrupt.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: Abrupt completion while getting [Symbol.iterator] (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + b. If method is undefined, + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw reason; + } +}; + + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-getiter-sync-not-callable-boolean-throw.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-getiter-sync-not-callable-boolean-throw.js new file mode 100644 index 0000000000..a51bb1dc62 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-getiter-sync-not-callable-boolean-throw.js @@ -0,0 +1,100 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-not-callable-boolean-throw.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: Throws a TypeError on a non-callable [Symbol.iterator] (boolean) (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + b. If method is undefined, + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + ... + 4. If IsCallable(func) is false, throw a TypeError exception. + ... + +---*/ +var obj = { + [Symbol.iterator]: false +}; + + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-getiter-sync-not-callable-number-throw.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-getiter-sync-not-callable-number-throw.js new file mode 100644 index 0000000000..9ee061597c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-getiter-sync-not-callable-number-throw.js @@ -0,0 +1,100 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-not-callable-number-throw.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: Throws a TypeError on a non-callable [Symbol.iterator] (number) (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + b. If method is undefined, + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + ... + 4. If IsCallable(func) is false, throw a TypeError exception. + ... + +---*/ +var obj = { + [Symbol.iterator]: 0 +}; + + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-getiter-sync-not-callable-object-throw.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-getiter-sync-not-callable-object-throw.js new file mode 100644 index 0000000000..cdb8723bed --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-getiter-sync-not-callable-object-throw.js @@ -0,0 +1,100 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-not-callable-object-throw.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: Throws a TypeError on a non-callable [Symbol.iterator] (object) (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + b. If method is undefined, + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + ... + 4. If IsCallable(func) is false, throw a TypeError exception. + ... + +---*/ +var obj = { + [Symbol.iterator]: {} +}; + + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-getiter-sync-not-callable-string-throw.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-getiter-sync-not-callable-string-throw.js new file mode 100644 index 0000000000..21ea26481e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-getiter-sync-not-callable-string-throw.js @@ -0,0 +1,100 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-not-callable-string-throw.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: Throws a TypeError on a non-callable [Symbol.iterator] (string) (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + b. If method is undefined, + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + ... + 4. If IsCallable(func) is false, throw a TypeError exception. + ... + +---*/ +var obj = { + [Symbol.iterator]: '' +}; + + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-getiter-sync-not-callable-symbol-throw.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-getiter-sync-not-callable-symbol-throw.js new file mode 100644 index 0000000000..b43852feb2 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-getiter-sync-not-callable-symbol-throw.js @@ -0,0 +1,100 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-not-callable-symbol-throw.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: Throws a TypeError on a non-callable [Symbol.iterator] (symbol) (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + b. If method is undefined, + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + ... + 4. If IsCallable(func) is false, throw a TypeError exception. + ... + +---*/ +var obj = { + [Symbol.iterator]: Symbol.iterator +}; + + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-getiter-sync-returns-abrupt.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-getiter-sync-returns-abrupt.js new file mode 100644 index 0000000000..676d38e67d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-getiter-sync-returns-abrupt.js @@ -0,0 +1,95 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-returns-abrupt.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: Abrupt completion while calling [Symbol.iterator] (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ii. Let syncIterator be ? Call(syncMethod, obj). + ... + +---*/ +var reason = {}; +var obj = { + [Symbol.iterator]() { + throw reason; + } +}; + + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-getiter-sync-returns-boolean-throw.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-getiter-sync-returns-boolean-throw.js new file mode 100644 index 0000000000..ff94fc055e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-getiter-sync-returns-boolean-throw.js @@ -0,0 +1,100 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-returns-boolean-throw.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: Non object returned by [Symbol.iterator]() - boolean (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ii. Let syncIterator be ? Call(syncMethod, obj). + iii. Return ? CreateAsyncFromSyncIterator(syncIterator). + ... + + CreateAsyncFromSyncIterator(syncIterator) + + 1. If Type(syncIterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + [Symbol.iterator]() { + return true; + } +}; + + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-getiter-sync-returns-null-throw.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-getiter-sync-returns-null-throw.js new file mode 100644 index 0000000000..d6da5ff2fa --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-getiter-sync-returns-null-throw.js @@ -0,0 +1,100 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-returns-null-throw.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: Non object returned by [Symbol.iterator]() - null (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ii. Let syncIterator be ? Call(syncMethod, obj). + iii. Return ? CreateAsyncFromSyncIterator(syncIterator). + ... + + CreateAsyncFromSyncIterator(syncIterator) + + 1. If Type(syncIterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + [Symbol.iterator]() { + return null; + } +}; + + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-getiter-sync-returns-number-throw.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-getiter-sync-returns-number-throw.js new file mode 100644 index 0000000000..db0e8b7ef8 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-getiter-sync-returns-number-throw.js @@ -0,0 +1,100 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-returns-number-throw.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: Non object returned by [Symbol.iterator]() - number (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ii. Let syncIterator be ? Call(syncMethod, obj). + iii. Return ? CreateAsyncFromSyncIterator(syncIterator). + ... + + CreateAsyncFromSyncIterator(syncIterator) + + 1. If Type(syncIterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + [Symbol.iterator]() { + return 0; + } +}; + + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-getiter-sync-returns-string-throw.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-getiter-sync-returns-string-throw.js new file mode 100644 index 0000000000..906b3fb983 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-getiter-sync-returns-string-throw.js @@ -0,0 +1,100 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-returns-string-throw.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: Non object returned by [Symbol.iterator]() - string (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ii. Let syncIterator be ? Call(syncMethod, obj). + iii. Return ? CreateAsyncFromSyncIterator(syncIterator). + ... + + CreateAsyncFromSyncIterator(syncIterator) + + 1. If Type(syncIterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + [Symbol.iterator]() { + return ''; + } +}; + + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-getiter-sync-returns-symbol-throw.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-getiter-sync-returns-symbol-throw.js new file mode 100644 index 0000000000..b98f887f1d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-getiter-sync-returns-symbol-throw.js @@ -0,0 +1,100 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-returns-symbol-throw.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: Non object returned by [Symbol.iterator]() - symbol (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ii. Let syncIterator be ? Call(syncMethod, obj). + iii. Return ? CreateAsyncFromSyncIterator(syncIterator). + ... + + CreateAsyncFromSyncIterator(syncIterator) + + 1. If Type(syncIterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + [Symbol.iterator]() { + return Symbol.iterator; + } +}; + + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-getiter-sync-returns-undefined-throw.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-getiter-sync-returns-undefined-throw.js new file mode 100644 index 0000000000..df045b3506 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-getiter-sync-returns-undefined-throw.js @@ -0,0 +1,100 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-returns-undefined-throw.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: Non object returned by [Symbol.iterator]() - undefined (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ii. Let syncIterator be ? Call(syncMethod, obj). + iii. Return ? CreateAsyncFromSyncIterator(syncIterator). + ... + + CreateAsyncFromSyncIterator(syncIterator) + + 1. If Type(syncIterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + [Symbol.iterator]() { + return undefined; + } +}; + + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-next-call-done-get-abrupt.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-next-call-done-get-abrupt.js new file mode 100644 index 0000000000..f4f4bfcaa2 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-next-call-done-get-abrupt.js @@ -0,0 +1,101 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-call-done-get-abrupt.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: Abrupt completion while getting done (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + v. Let done be ? IteratorComplete(innerResult). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + get done() { + throw reason; + } + }; + } + }; + } +}; + + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-next-call-returns-abrupt.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-next-call-returns-abrupt.js new file mode 100644 index 0000000000..44d53c9aeb --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-next-call-returns-abrupt.js @@ -0,0 +1,93 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-call-returns-abrupt.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: Abrupt completion while calling next (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + throw reason; + } + }; + } +}; + + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-next-call-value-get-abrupt.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-next-call-value-get-abrupt.js new file mode 100644 index 0000000000..c67b429835 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-next-call-value-get-abrupt.js @@ -0,0 +1,103 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-call-value-get-abrupt.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: Abrupt completion while getting value (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + vi. If done is true, then + 1. Return ? IteratorValue(innerResult). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + done: true, + get value() { + throw reason; + } + }; + } + }; + } +}; + + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-next-get-abrupt.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-next-get-abrupt.js new file mode 100644 index 0000000000..08dffdc7f2 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-next-get-abrupt.js @@ -0,0 +1,93 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-get-abrupt.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: Abrupt completion while getting next (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + get next() { + throw reason; + } + }; + } +}; + + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-next-non-object-ignores-then.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-next-non-object-ignores-then.js new file mode 100644 index 0000000000..3f0aa165b1 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-next-non-object-ignores-then.js @@ -0,0 +1,113 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-non-object-ignores-then.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: If next() value is not-object, do not access respective then property (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + +---*/ +Number.prototype.then = function() { + throw new Test262Error('Number#then should not be used'); +}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return 42; + } + }; + } +}; + + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, 'TypeError'); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-next-not-callable-boolean-throw.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-next-not-callable-boolean-throw.js new file mode 100644 index 0000000000..3464f628ef --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-next-not-callable-boolean-throw.js @@ -0,0 +1,90 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-boolean-throw.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: Not-callable next value in a yield star position - boolean (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: true + }; + } +}; + + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-next-not-callable-null-throw.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-next-not-callable-null-throw.js new file mode 100644 index 0000000000..57da39aeca --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-next-not-callable-null-throw.js @@ -0,0 +1,90 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-null-throw.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: Not-callable next value in a yield star position - null (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: null + }; + } +}; + + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-next-not-callable-number-throw.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-next-not-callable-number-throw.js new file mode 100644 index 0000000000..8085cdc57a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-next-not-callable-number-throw.js @@ -0,0 +1,90 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-number-throw.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: Not-callable next value in a yield star position - number (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: 42 + }; + } +}; + + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-next-not-callable-object-throw.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-next-not-callable-object-throw.js new file mode 100644 index 0000000000..c6a88ebefe --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-next-not-callable-object-throw.js @@ -0,0 +1,90 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-object-throw.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: Not-callable next value in a yield star position - object (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: {} + }; + } +}; + + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-next-not-callable-string-throw.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-next-not-callable-string-throw.js new file mode 100644 index 0000000000..d4a7d99cbd --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-next-not-callable-string-throw.js @@ -0,0 +1,90 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-string-throw.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: Not-callable next value in a yield star position - string (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: '' + }; + } +}; + + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-next-not-callable-symbol-throw.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-next-not-callable-symbol-throw.js new file mode 100644 index 0000000000..c1af4d3e4a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-next-not-callable-symbol-throw.js @@ -0,0 +1,90 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-symbol-throw.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: Not-callable next value in a yield star position - symbol (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: Symbol('oi') + }; + } +}; + + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-next-not-callable-undefined-throw.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-next-not-callable-undefined-throw.js new file mode 100644 index 0000000000..642e08097b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-next-not-callable-undefined-throw.js @@ -0,0 +1,90 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-undefined-throw.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: Not-callable next value in a yield star position - undefined (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: undefined + }; + } +}; + + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-next-then-get-abrupt.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-next-then-get-abrupt.js new file mode 100644 index 0000000000..03d1fb048b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-next-then-get-abrupt.js @@ -0,0 +1,117 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-get-abrupt.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: Return abrupt after getting next().then (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 8. Let then be Get(resolution, "then"). + ... + 10. Get thenAction be then.[[Value]]. + ... + 12. Perform EnqueueJob("PromiseJobs", PromiseResolveThenableJob, « promise, + resolution, thenAction »). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + get then() { + throw reason; + } + }; + } + }; + } +}; + + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, 'reject reason'); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-next-then-non-callable-boolean-fulfillpromise.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-next-then-non-callable-boolean-fulfillpromise.js new file mode 100644 index 0000000000..25c210f1bf --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-next-then-non-callable-boolean-fulfillpromise.js @@ -0,0 +1,111 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-boolean-fulfillpromise.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: FulfillPromise if next().then is not-callable (boolean) (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: true, + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); + +var iter = C.gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-next-then-non-callable-null-fulfillpromise.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-next-then-non-callable-null-fulfillpromise.js new file mode 100644 index 0000000000..b3f296d63a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-next-then-non-callable-null-fulfillpromise.js @@ -0,0 +1,111 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-null-fulfillpromise.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: FulfillPromise if next().then is not-callable (null) (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: null, + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); + +var iter = C.gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-next-then-non-callable-number-fulfillpromise.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-next-then-non-callable-number-fulfillpromise.js new file mode 100644 index 0000000000..ba523fd14b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-next-then-non-callable-number-fulfillpromise.js @@ -0,0 +1,111 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-number-fulfillpromise.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: FulfillPromise if next().then is not-callable (number) (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: 39, + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); + +var iter = C.gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-next-then-non-callable-object-fulfillpromise.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-next-then-non-callable-object-fulfillpromise.js new file mode 100644 index 0000000000..d333662616 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-next-then-non-callable-object-fulfillpromise.js @@ -0,0 +1,111 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-object-fulfillpromise.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: FulfillPromise if next().then is not-callable (object) (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: {}, + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); + +var iter = C.gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-next-then-non-callable-string-fulfillpromise.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-next-then-non-callable-string-fulfillpromise.js new file mode 100644 index 0000000000..b5b2c43cfc --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-next-then-non-callable-string-fulfillpromise.js @@ -0,0 +1,111 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-string-fulfillpromise.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: FulfillPromise if next().then is not-callable (string) (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: '', + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); + +var iter = C.gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-next-then-non-callable-symbol-fulfillpromise.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-next-then-non-callable-symbol-fulfillpromise.js new file mode 100644 index 0000000000..3a79a2c162 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-next-then-non-callable-symbol-fulfillpromise.js @@ -0,0 +1,111 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-symbol-fulfillpromise.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: FulfillPromise if next().then is not-callable (symbol) (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: Symbol('oi'), + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); + +var iter = C.gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-next-then-non-callable-undefined-fulfillpromise.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-next-then-non-callable-undefined-fulfillpromise.js new file mode 100644 index 0000000000..dfbd1f5642 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-next-then-non-callable-undefined-fulfillpromise.js @@ -0,0 +1,111 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-undefined-fulfillpromise.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: FulfillPromise if next().then is not-callable (undefined) (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: undefined, + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); + +var iter = C.gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-next-then-returns-abrupt.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-next-then-returns-abrupt.js new file mode 100644 index 0000000000..5b23bd00c5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-next-then-returns-abrupt.js @@ -0,0 +1,117 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-returns-abrupt.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: Return abrupt after calling next().then (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 8. Let then be Get(resolution, "then"). + ... + 10. Get thenAction be then.[[Value]]. + ... + 12. Perform EnqueueJob("PromiseJobs", PromiseResolveThenableJob, « promise, + resolution, thenAction »). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then() { + throw reason; + } + }; + } + }; + } +}; + + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, 'reject reason'); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-sync-next.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-sync-next.js new file mode 100644 index 0000000000..b89eab149d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-sync-next.js @@ -0,0 +1,250 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-sync-next.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: execution order for yield* with sync iterator and next() (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, async-iteration, Symbol.asyncIterator, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + ... + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + 5. Let received be NormalCompletion(undefined). + 6. Repeat + a. If received.[[Type]] is normal, then + i. Let innerResult be ? IteratorNext(iterator, received.[[Value]]). + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + v. Let done be ? IteratorComplete(innerResult). + vi. If done is true, then + 1. Return ? IteratorValue(innerResult). + vii. Let received be GeneratorYield(innerResult). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + b. If method is undefined, + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ii. Let syncIterator be ? Call(syncMethod, obj). + iii. Return ? CreateAsyncFromSyncIterator(syncIterator). + ... + + %AsyncFromSyncIteratorPrototype%.next ( value ) + + ... + 5. Let nextResult be IteratorNext(syncIterator, value). + ... + 7. Let nextValue be IteratorValue(nextResult). + ... + 9. Let nextDone be IteratorComplete(nextResult). + ... + 12. Perform ! Call(valueWrapperCapability.[[Resolve]], undefined, + « nextValue »). + ... + 14. Set onFulfilled.[[Done]] to nextDone. + 15. Perform ! PerformPromiseThen(valueWrapperCapability.[[Promise]], + onFulfilled, undefined, promiseCapability). + ... + + Async Iterator Value Unwrap Functions + + 1. Return ! CreateIterResultObject(value, F.[[Done]]). + +---*/ +var log = []; +var obj = { + get [Symbol.iterator]() { + log.push({ + name: "get [Symbol.iterator]", + thisValue: this + }); + return function() { + log.push({ + name: "call [Symbol.iterator]", + thisValue: this, + args: [...arguments] + }); + var nextCount = 0; + return { + name: "syncIterator", + get next() { + log.push({ + name: "get next", + thisValue: this + }); + return function() { + log.push({ + name: "call next", + thisValue: this, + args: [...arguments] + }); + + nextCount++; + if (nextCount == 1) { + return { + name: "next-result-1", + get value() { + log.push({ + name: "get next value (1)", + thisValue: this + }); + return "next-value-1"; + }, + get done() { + log.push({ + name: "get next done (1)", + thisValue: this + }); + return false; + } + }; + } + + return { + name: "next-result-2", + get value() { + log.push({ + name: "get next value (2)", + thisValue: this + }); + return "next-value-2"; + }, + get done() { + log.push({ + name: "get next done (2)", + thisValue: this + }); + return true; + } + }; + }; + } + }; + }; + }, + get [Symbol.asyncIterator]() { + log.push({ name: "get [Symbol.asyncIterator]" }); + return null; + } +}; + + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + log.push({ name: "before yield*" }); + var v = yield* obj; + log.push({ + name: "after yield*", + value: v + }); + return "return-value"; + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); + +var iter = C.gen(); + +assert.sameValue(log.length, 0, "log.length"); + +iter.next("next-arg-1").then(v => { + assert.sameValue(log[0].name, "before yield*"); + + assert.sameValue(log[1].name, "get [Symbol.asyncIterator]"); + + assert.sameValue(log[2].name, "get [Symbol.iterator]"); + assert.sameValue(log[2].thisValue, obj, "get [Symbol.iterator] thisValue"); + + assert.sameValue(log[3].name, "call [Symbol.iterator]"); + assert.sameValue(log[3].thisValue, obj, "[Symbol.iterator] thisValue"); + assert.sameValue(log[3].args.length, 0, "[Symbol.iterator] args.length"); + + assert.sameValue(log[4].name, "get next"); + assert.sameValue(log[4].thisValue.name, "syncIterator", "get next thisValue"); + + assert.sameValue(log[5].name, "call next"); + assert.sameValue(log[5].thisValue.name, "syncIterator", "next thisValue"); + assert.sameValue(log[5].args.length, 1, "next args.length"); + assert.sameValue(log[5].args[0], undefined, "next args[0]"); + + assert.sameValue(log[6].name, "get next done (1)"); + assert.sameValue(log[6].thisValue.name, "next-result-1", "get next done thisValue"); + + assert.sameValue(log[7].name, "get next value (1)"); + assert.sameValue(log[7].thisValue.name, "next-result-1", "get next value thisValue"); + + assert.sameValue(v.value, "next-value-1"); + assert.sameValue(v.done, false); + + assert.sameValue(log.length, 8, "log.length"); + + iter.next("next-arg-2").then(v => { + assert.sameValue(log[8].name, "call next"); + assert.sameValue(log[8].thisValue.name, "syncIterator", "next thisValue"); + assert.sameValue(log[8].args.length, 1, "next args.length"); + assert.sameValue(log[8].args[0], "next-arg-2", "next args[0]"); + + assert.sameValue(log[9].name, "get next done (2)"); + assert.sameValue(log[9].thisValue.name, "next-result-2", "get next done thisValue"); + + assert.sameValue(log[10].name, "get next value (2)"); + assert.sameValue(log[10].thisValue.name, "next-result-2", "get next value thisValue"); + + assert.sameValue(log[11].name, "after yield*"); + assert.sameValue(log[11].value, "next-value-2"); + + assert.sameValue(v.value, "return-value"); + assert.sameValue(v.done, true); + + assert.sameValue(log.length, 12, "log.length"); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-sync-return.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-sync-return.js new file mode 100644 index 0000000000..77a9271528 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-sync-return.js @@ -0,0 +1,225 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-sync-return.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: execution order for yield* with sync iterator and return() (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, async-iteration, Symbol.asyncIterator, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + ... + 6. Repeat + ... + c. Else, + i. Assert: received.[[Type]] is return. + ii. Let return be ? GetMethod(iterator, "return"). + iii. If return is undefined, return Completion(received). + iv. Let innerReturnResult be ? Call(return, iterator, + « received.[[Value]] »). + v. If generatorKind is async, then set innerReturnResult to + ? Await(innerReturnResult). + ... + vii. Let done be ? IteratorComplete(innerReturnResult). + viii. If done is true, then + 1. Let value be ? IteratorValue(innerReturnResult). + 2. Return Completion{[[Type]]: return, [[Value]]: value, + [[Target]]: empty}. + ix. Let received be GeneratorYield(innerResult). + + %AsyncFromSyncIteratorPrototype%.return ( value ) + + 5. Let return be GetMethod(syncIterator, "return"). + ... + ... + 8. Let returnResult be Call(return, syncIterator, « value »). + ... + 11. Let returnValue be IteratorValue(returnResult). + .. + 13. Let returnDone be IteratorComplete(returnResult). + ... + 16. Perform ! Call(valueWrapperCapability.[[Resolve]], undefined, « returnValue »). + ... + 18. Set onFulfilled.[[Done]] to returnDone. + 19. Perform ! PerformPromiseThen(valueWrapperCapability.[[Promise]], + onFulfilled, undefined, promiseCapability). + ... + +---*/ +var log = []; +var obj = { + [Symbol.iterator]() { + var returnCount = 0; + return { + name: "syncIterator", + get next() { + log.push({ name: "get next" }); + return function() { + return { + value: "next-value-1", + done: false + }; + }; + }, + get return() { + log.push({ + name: "get return", + thisValue: this + }); + return function() { + log.push({ + name: "call return", + thisValue: this, + args: [...arguments] + }); + + returnCount++; + if (returnCount == 1) { + return { + name: "return-result-1", + get value() { + log.push({ + name: "get return value (1)", + thisValue: this + }); + return "return-value-1"; + }, + get done() { + log.push({ + name: "get return done (1)", + thisValue: this + }); + return false; + } + }; + } + + return { + name: "return-result-2", + get value() { + log.push({ + name: "get return value (2)", + thisValue: this + }); + return "return-value-2"; + }, + get done() { + log.push({ + name: "get return done (2)", + thisValue: this + }); + return true; + } + }; + }; + } + }; + } +}; + + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + log.push({ name: "before yield*" }); + yield* obj; + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); + +var iter = C.gen(); + +assert.sameValue(log.length, 0, "log.length"); + +iter.next().then(v => { + assert.sameValue(log[0].name, "before yield*"); + + assert.sameValue(log[1].name, "get next"); + + assert.sameValue(v.value, "next-value-1"); + assert.sameValue(v.done, false); + + assert.sameValue(log.length, 2, "log.length"); + + iter.return("return-arg-1").then(v => { + assert.sameValue(log[2].name, "get return"); + assert.sameValue(log[2].thisValue.name, "syncIterator", "get return thisValue"); + + assert.sameValue(log[3].name, "call return"); + assert.sameValue(log[3].thisValue.name, "syncIterator", "return thisValue"); + assert.sameValue(log[3].args.length, 1, "return args.length"); + assert.sameValue(log[3].args[0], "return-arg-1", "return args[0]"); + + assert.sameValue(log[4].name, "get return done (1)"); + assert.sameValue(log[4].thisValue.name, "return-result-1", "get return done thisValue"); + + assert.sameValue(log[5].name, "get return value (1)"); + assert.sameValue(log[5].thisValue.name, "return-result-1", "get return value thisValue"); + + assert.sameValue(v.value, "return-value-1"); + assert.sameValue(v.done, false); + + assert.sameValue(log.length, 6, "log.length"); + + iter.return().then(v => { + assert.sameValue(log[6].name, "get return"); + assert.sameValue(log[6].thisValue.name, "syncIterator", "get return thisValue"); + + assert.sameValue(log[7].name, "call return"); + assert.sameValue(log[7].thisValue.name, "syncIterator", "get return thisValue"); + assert.sameValue(log[7].args.length, 1, "return args.length"); + assert.sameValue(log[7].args[0], undefined, "return args[0]"); + + assert.sameValue(log[8].name, "get return done (2)"); + assert.sameValue(log[8].thisValue.name, "return-result-2", "get return done thisValue"); + + assert.sameValue(log[9].name, "get return value (2)"); + assert.sameValue(log[9].thisValue.name, "return-result-2", "get return value thisValue"); + + assert.sameValue(v.value, "return-value-2"); + assert.sameValue(v.done, true); + + assert.sameValue(log.length, 10, "log.length"); + }).then($DONE, $DONE); + }).catch($DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-sync-throw.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-sync-throw.js new file mode 100644 index 0000000000..dfb64cf844 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-star-sync-throw.js @@ -0,0 +1,231 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-sync-throw.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: execution order for yield* with sync iterator and throw() (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + ... + 6. Repeat + ... + b. Else if received.[[Type]] is throw, then + i. Let throw be ? GetMethod(iterator, "throw"). + ii. If throw is not undefined, then + 1. Let innerResult be ? Call(throw, iterator, « received.[[Value]] »). + 2. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + 5. Let done be ? IteratorComplete(innerResult). + 6. If done is true, then + a. Return ? IteratorValue(innerResult). + 7. Let received be GeneratorYield(innerResult). + ... + + %AsyncFromSyncIteratorPrototype%.throw ( value ) + + ... + 5. Let throw be GetMethod(syncIterator, "throw"). + ... + 8. Let throwResult be Call(throw, syncIterator, « value »). + ... + 11. Let throwValue be IteratorValue(throwResult). + ... + 13. Let throwDone be IteratorComplete(throwResult). + ... + 16. Perform ! Call(valueWrapperCapability.[[Resolve]], undefined, + « throwValue »). + ... + 18. Set onFulfilled.[[Done]] to throwDone. + 19. Perform ! PerformPromiseThen(valueWrapperCapability.[[Promise]], + onFulfilled, undefined, promiseCapability). + ... + +---*/ +var log = []; +var obj = { + [Symbol.iterator]() { + var throwCount = 0; + return { + name: "syncIterator", + get next() { + log.push({ name: "get next" }); + return function() { + return { + value: "next-value-1", + done: false + }; + }; + }, + get throw() { + log.push({ + name: "get throw", + thisValue: this + }); + return function() { + log.push({ + name: "call throw", + thisValue: this, + args: [...arguments] + }); + + throwCount++; + if (throwCount == 1) { + return { + name: "throw-result-1", + get value() { + log.push({ + name: "get throw value (1)", + thisValue: this + }); + return "throw-value-1"; + }, + get done() { + log.push({ + name: "get throw done (1)", + thisValue: this + }); + return false; + } + }; + } + + return { + name: "throw-result-2", + get value() { + log.push({ + name: "get throw value (2)", + thisValue: this + }); + return "throw-value-2"; + }, + get done() { + log.push({ + name: "get throw done (2)", + thisValue: this + }); + return true; + } + }; + }; + } + }; + } +}; + + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + log.push({ name: "before yield*" }); + var v = yield* obj; + log.push({ + name: "after yield*", + value: v + }); + return "return-value"; + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); + +var iter = C.gen(); + +assert.sameValue(log.length, 0, "log.length"); + +iter.next().then(v => { + assert.sameValue(log[0].name, "before yield*"); + + assert.sameValue(log[1].name, "get next"); + + assert.sameValue(v.value, "next-value-1"); + assert.sameValue(v.done, false); + + assert.sameValue(log.length, 2, "log.length"); + + iter.throw("throw-arg-1").then(v => { + assert.sameValue(log[2].name, "get throw"); + assert.sameValue(log[2].thisValue.name, "syncIterator", "get throw thisValue"); + + assert.sameValue(log[3].name, "call throw"); + assert.sameValue(log[3].thisValue.name, "syncIterator", "throw thisValue"); + assert.sameValue(log[3].args.length, 1, "throw args.length"); + assert.sameValue(log[3].args[0], "throw-arg-1", "throw args[0]"); + + assert.sameValue(log[4].name, "get throw done (1)"); + assert.sameValue(log[4].thisValue.name, "throw-result-1", "get throw done thisValue"); + + assert.sameValue(log[5].name, "get throw value (1)"); + assert.sameValue(log[5].thisValue.name, "throw-result-1", "get throw value thisValue"); + + assert.sameValue(v.value, "throw-value-1"); + assert.sameValue(v.done, false); + + assert.sameValue(log.length, 6, "log.length"); + + iter.throw().then(v => { + assert.sameValue(log[6].name, "get throw"); + assert.sameValue(log[6].thisValue.name, "syncIterator", "get throw thisValue"); + + assert.sameValue(log[7].name, "call throw"); + assert.sameValue(log[7].thisValue.name, "syncIterator", "throw thisValue"); + assert.sameValue(log[7].args.length, 1, "throw args.length"); + assert.sameValue(log[7].args[0], undefined, "throw args[0]"); + + assert.sameValue(log[8].name, "get throw done (2)"); + assert.sameValue(log[8].thisValue.name, "throw-result-2", "get throw done thisValue"); + + assert.sameValue(log[9].name, "get throw value (2)"); + assert.sameValue(log[9].thisValue.name, "throw-result-2", "get throw value thisValue"); + + assert.sameValue(log[10].name, "after yield*"); + assert.sameValue(log[10].value, "throw-value-2"); + + assert.sameValue(v.value, "return-value"); + assert.sameValue(v.done, true); + + assert.sameValue(log.length, 11, "log.length"); + }).then($DONE, $DONE); + }).catch($DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/await-as-binding-identifier-escaped.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/await-as-binding-identifier-escaped.js new file mode 100644 index 0000000000..9e78aaed3e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/await-as-binding-identifier-escaped.js @@ -0,0 +1,37 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/async-generators/await-as-binding-identifier-escaped.case +// - src/async-generators/syntax/async-class-decl-private-method.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as a binding identifier. (Async Generator private method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration, class-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * # PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + BindingIdentifier : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +$DONOTEVALUATE(); + + +class C { async *#gen() { + var \u0061wait; +}} diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/await-as-binding-identifier.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/await-as-binding-identifier.js new file mode 100644 index 0000000000..1e8be0a40c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/await-as-binding-identifier.js @@ -0,0 +1,37 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/async-generators/await-as-binding-identifier.case +// - src/async-generators/syntax/async-class-decl-private-method.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as a binding identifier. (Async Generator private method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration, class-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * # PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + BindingIdentifier : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +$DONOTEVALUATE(); + + +class C { async *#gen() { + var await; +}} diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/await-as-identifier-reference-escaped.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/await-as-identifier-reference-escaped.js new file mode 100644 index 0000000000..3946d6a560 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/await-as-identifier-reference-escaped.js @@ -0,0 +1,37 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/async-generators/await-as-identifier-reference-escaped.case +// - src/async-generators/syntax/async-class-decl-private-method.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as an identifier reference. (Async Generator private method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration, class-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * # PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + IdentifierReference : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +$DONOTEVALUATE(); + + +class C { async *#gen() { + void \u0061wait; +}} diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/await-as-identifier-reference.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/await-as-identifier-reference.js new file mode 100644 index 0000000000..7eab728df7 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/await-as-identifier-reference.js @@ -0,0 +1,37 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/async-generators/await-as-identifier-reference.case +// - src/async-generators/syntax/async-class-decl-private-method.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as an identifier reference. (Async Generator private method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration, class-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * # PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + IdentifierReference : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +$DONOTEVALUATE(); + + +class C { async *#gen() { + void await; +}} diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/await-as-label-identifier-escaped.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/await-as-label-identifier-escaped.js new file mode 100644 index 0000000000..94641fd63d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/await-as-label-identifier-escaped.js @@ -0,0 +1,37 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/async-generators/await-as-label-identifier-escaped.case +// - src/async-generators/syntax/async-class-decl-private-method.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as a label identifier. (Async Generator private method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration, class-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * # PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + LabelIdentifier : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +$DONOTEVALUATE(); + + +class C { async *#gen() { + \u0061wait: ; +}} diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/await-as-label-identifier.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/await-as-label-identifier.js new file mode 100644 index 0000000000..5af287c972 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/await-as-label-identifier.js @@ -0,0 +1,37 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/async-generators/await-as-label-identifier.case +// - src/async-generators/syntax/async-class-decl-private-method.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as a label identifier. (Async Generator private method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration, class-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * # PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + LabelIdentifier : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +$DONOTEVALUATE(); + + +class C { async *#gen() { + await: ; +}} diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/browser.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/shell.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-as-binding-identifier-escaped.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-as-binding-identifier-escaped.js new file mode 100644 index 0000000000..589fa48c4e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-as-binding-identifier-escaped.js @@ -0,0 +1,37 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-as-binding-identifier-escaped.case +// - src/async-generators/syntax/async-class-decl-private-method.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as a binding identifier. (Async Generator private method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration, class-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * # PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + BindingIdentifier : Identifier + + It is a Syntax Error if this production has a [Yield] parameter and + StringValue of Identifier is "yield". + +---*/ +$DONOTEVALUATE(); + + +class C { async *#gen() { + var yi\u0065ld; +}} diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-as-binding-identifier.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-as-binding-identifier.js new file mode 100644 index 0000000000..27697e049c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-as-binding-identifier.js @@ -0,0 +1,37 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-as-binding-identifier.case +// - src/async-generators/syntax/async-class-decl-private-method.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as a binding identifier. (Async Generator private method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration, class-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * # PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + BindingIdentifier : Identifier + + It is a Syntax Error if this production has a [Yield] parameter and + StringValue of Identifier is "yield". + +---*/ +$DONOTEVALUATE(); + + +class C { async *#gen() { + var yield; +}} diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-as-identifier-reference-escaped.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-as-identifier-reference-escaped.js new file mode 100644 index 0000000000..d67ee05eb5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-as-identifier-reference-escaped.js @@ -0,0 +1,37 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-as-identifier-reference-escaped.case +// - src/async-generators/syntax/async-class-decl-private-method.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as an identifier reference. (Async Generator private method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration, class-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * # PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + IdentifierReference : Identifier + + It is a Syntax Error if this production has a [Yield] parameter and + StringValue of Identifier is "yield". + +---*/ +$DONOTEVALUATE(); + + +class C { async *#gen() { + void yi\u0065ld; +}} diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-as-identifier-reference.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-as-identifier-reference.js new file mode 100644 index 0000000000..110db6d7e9 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-as-identifier-reference.js @@ -0,0 +1,37 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-as-identifier-reference.case +// - src/async-generators/syntax/async-class-decl-private-method.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as an identifier reference. (Async Generator private method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration, class-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * # PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + IdentifierReference : Identifier + + It is a Syntax Error if this production has a [Yield] parameter and + StringValue of Identifier is "yield". + +---*/ +$DONOTEVALUATE(); + + +class C { async *#gen() { + void yield; +}} diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-as-label-identifier-escaped.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-as-label-identifier-escaped.js new file mode 100644 index 0000000000..6f91bff379 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-as-label-identifier-escaped.js @@ -0,0 +1,37 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-as-label-identifier-escaped.case +// - src/async-generators/syntax/async-class-decl-private-method.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as a label identifier. (Async Generator private method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration, class-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * # PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + LabelIdentifier : Identifier + + It is a Syntax Error if this production has a [Yield] parameter and + StringValue of Identifier is "yield". + +---*/ +$DONOTEVALUATE(); + + +class C { async *#gen() { + yi\u0065ld: ; +}} diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-as-label-identifier.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-as-label-identifier.js new file mode 100644 index 0000000000..a35f903c9c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-as-label-identifier.js @@ -0,0 +1,37 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-as-label-identifier.case +// - src/async-generators/syntax/async-class-decl-private-method.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as a label identifier. (Async Generator private method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration, class-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * # PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + LabelIdentifier : Identifier + + It is a Syntax Error if this production has a [Yield] parameter and + StringValue of Identifier is "yield". + +---*/ +$DONOTEVALUATE(); + + +class C { async *#gen() { + yield: ; +}} diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-identifier-spread-strict-strict.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-identifier-spread-strict-strict.js new file mode 100644 index 0000000000..ae61f6aca5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-identifier-spread-strict-strict.js @@ -0,0 +1,86 @@ +// |reftest| error:SyntaxError +'use strict'; +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-identifier-spread-strict.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: It's an early error if the AssignmentExpression is a function body with yield as an identifier in strict mode. (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [object-spread, async-iteration, class-methods-private] +flags: [generated, onlyStrict] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + Spread Properties + + PropertyDefinition[Yield]: + (...) + ...AssignmentExpression[In, ?Yield] + +---*/ +$DONOTEVALUATE(); + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + return { + ...(function() { + var yield; + throw new Test262Error(); + }()), + } + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); + +var iter = c.gen(); + + + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-identifier-strict-strict.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-identifier-strict-strict.js new file mode 100644 index 0000000000..3f4c11a46a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-identifier-strict-strict.js @@ -0,0 +1,77 @@ +// |reftest| error:SyntaxError +'use strict'; +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-identifier-strict.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: It's an early error if the generator body has another function body with yield as an identifier in strict mode. (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [async-iteration, class-methods-private] +flags: [generated, onlyStrict] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + +---*/ +$DONOTEVALUATE(); + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + (function() { + var yield; + throw new Test262Error(); + }()) + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); + +var iter = c.gen(); + + + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-promise-reject-next-catch.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-promise-reject-next-catch.js new file mode 100644 index 0000000000..8d8733af64 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-promise-reject-next-catch.js @@ -0,0 +1,82 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-promise-reject-next-catch.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: yield Promise.reject(value) is treated as throw value (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + +---*/ +let error = new Error(); + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + yield Promise.reject(error); + yield "unreachable"; + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error("Promise incorrectly resolved."); +}).catch(rejectValue => { + // yield Promise.reject(error); + assert.sameValue(rejectValue, error); + + iter.next().then(({done, value}) => { + // iter is closed now. + assert.sameValue(done, true, "The value of IteratorResult.done is `true`"); + assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`"); + }).then($DONE, $DONE); +}); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-promise-reject-next-for-await-of-async-iterator.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-promise-reject-next-for-await-of-async-iterator.js new file mode 100644 index 0000000000..04582ff261 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-promise-reject-next-for-await-of-async-iterator.js @@ -0,0 +1,88 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-promise-reject-next-for-await-of-async-iterator.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: yield * [Promise.reject(value)] is treated as throw value (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + +---*/ +let error = new Error(); +async function * readFile() { + yield Promise.reject(error); + yield "unreachable"; +} + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + for await (let line of readFile()) { + yield line; + } + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error("Promise incorrectly resolved."); +}, rejectValue => { + + // yield Promise.reject(error); + assert.sameValue(rejectValue, error); + + iter.next().then(({done, value}) => { + // iter is closed now. + assert.sameValue(done, true, "The value of IteratorResult.done is `true`"); + assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`"); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-promise-reject-next-for-await-of-sync-iterator.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-promise-reject-next-for-await-of-sync-iterator.js new file mode 100644 index 0000000000..50f8910ce2 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-promise-reject-next-for-await-of-sync-iterator.js @@ -0,0 +1,87 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-promise-reject-next-for-await-of-sync-iterator.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: yield Promise.reject(value) in for-await-of is treated as throw value (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + +---*/ +let error = new Error(); +let iterable = [ + Promise.reject(error), + "unreachable" +]; + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + for await (let value of iterable) { + yield value; + } + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error("Promise incorrectly resolved."); +}, rejectValue => { + // yield Promise.reject(error); + assert.sameValue(rejectValue, error); + + iter.next().then(({done, value}) => { + // iter is closed now. + assert.sameValue(done, true, "The value of IteratorResult.done is `true`"); + assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`"); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-promise-reject-next-yield-star-async-iterator.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-promise-reject-next-yield-star-async-iterator.js new file mode 100644 index 0000000000..c169a9cfd1 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-promise-reject-next-yield-star-async-iterator.js @@ -0,0 +1,86 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-promise-reject-next-yield-star-async-iterator.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: yield * (async iterator) is treated as throw value (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + +---*/ +let error = new Error(); +async function * readFile() { + yield Promise.reject(error); + yield "unreachable"; +} + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + yield * readFile(); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error("Promise incorrectly resolved."); +}, rejectValue => { + // yield Promise.reject(error); + assert.sameValue(rejectValue, error); + + iter.next().then(({done, value}) => { + // iter is closed now. + assert.sameValue(done, true, "The value of IteratorResult.done is `true`"); + assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`"); + }).then($DONE, $DONE); +}, $DONE).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-promise-reject-next-yield-star-sync-iterator.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-promise-reject-next-yield-star-sync-iterator.js new file mode 100644 index 0000000000..dab0435550 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-promise-reject-next-yield-star-sync-iterator.js @@ -0,0 +1,85 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-promise-reject-next-yield-star-sync-iterator.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: yield * (async iterator) is treated as throw value (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + +---*/ +let error = new Error(); +let iterable = [ + Promise.reject(error), + "unreachable" +]; + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + yield * iterable; + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error("Promise incorrectly resolved."); +}, rejectValue => { + // yield Promise.reject(error); + assert.sameValue(rejectValue, error); + + iter.next().then(({done, value}) => { + // iter is closed now. + assert.sameValue(done, true, "The value of IteratorResult.done is `true`"); + assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`"); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-promise-reject-next.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-promise-reject-next.js new file mode 100644 index 0000000000..8501934ec7 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-promise-reject-next.js @@ -0,0 +1,82 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-promise-reject-next.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: yield Promise.reject(value) is treated as throw value (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + +---*/ +let error = new Error(); + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + yield Promise.reject(error); + yield "unreachable"; + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error("Promise incorrectly resolved."); +}, rejectValue => { + // yield Promise.reject(error); + assert.sameValue(rejectValue, error); + + iter.next().then(({done, value}) => { + // iter is closed now. + assert.sameValue(done, true, "The value of IteratorResult.done is `true`"); + assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`"); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-spread-arr-multiple.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-spread-arr-multiple.js new file mode 100644 index 0000000000..eaad1ac942 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-spread-arr-multiple.js @@ -0,0 +1,88 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-spread-arr-multiple.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: Use yield value in a array spread position (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [async-iteration, class-methods-private] +flags: [generated, async] +includes: [compareArray.js] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + Array Initializer + + SpreadElement[Yield, Await]: + ...AssignmentExpression[+In, ?Yield, ?Await] + +---*/ +var arr = ['a', 'b', 'c']; +var item; + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + yield [...yield yield]; + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); + +var iter = c.gen(); + +iter.next(false); +item = iter.next(['a', 'b', 'c']); + +item.then(({ done, value }) => { + item = iter.next(value); + + item.then(({ done, value }) => { + assert.compareArray(value, arr); + assert.sameValue(done, false); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-spread-arr-single.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-spread-arr-single.js new file mode 100644 index 0000000000..760230055e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-spread-arr-single.js @@ -0,0 +1,87 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-spread-arr-single.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: Use yield value in a array spread position (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + Array Initializer + + SpreadElement[Yield, Await]: + ...AssignmentExpression[+In, ?Yield, ?Await] + +---*/ +var arr = ['a', 'b', 'c']; + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + yield [...yield]; + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); + +var iter = c.gen(); + +iter.next(false); +var item = iter.next(arr); + +item.then(({ done, value }) => { + assert.notSameValue(value, arr, 'value is a new array'); + assert(Array.isArray(value), 'value is an Array exotic object'); + assert.sameValue(value.length, 3) + assert.sameValue(value[0], 'a'); + assert.sameValue(value[1], 'b'); + assert.sameValue(value[2], 'c'); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-spread-obj.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-spread-obj.js new file mode 100644 index 0000000000..bb1db84550 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-spread-obj.js @@ -0,0 +1,90 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-spread-obj.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: Use yield value in a object spread position (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [object-spread, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + Spread Properties + + PropertyDefinition[Yield]: + (...) + ...AssignmentExpression[In, ?Yield] + +---*/ + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + yield { + ...yield, + y: 1, + ...yield yield, + }; + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); + +var iter = c.gen(); + +iter.next(); +iter.next({ x: 42 }); +iter.next({ x: 'lol' }); +var item = iter.next({ y: 39 }); + +item.then(({ done, value }) => { + assert.sameValue(value.x, 42); + assert.sameValue(value.y, 39); + assert.sameValue(Object.keys(value).length, 2); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-async-next.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-async-next.js new file mode 100644 index 0000000000..fa862ba92d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-async-next.js @@ -0,0 +1,257 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-async-next.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: Execution order for yield* with async iterator and next() (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, async-iteration, Symbol.asyncIterator, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + +---*/ +var log = []; +var obj = { + get [Symbol.iterator]() { + log.push({ name: "get [Symbol.iterator]" }); + }, + get [Symbol.asyncIterator]() { + log.push({ + name: "get [Symbol.asyncIterator]", + thisValue: this + }); + return function() { + log.push({ + name: "call [Symbol.asyncIterator]", + thisValue: this, + args: [...arguments] + }); + var nextCount = 0; + return { + name: "asyncIterator", + get next() { + log.push({ + name: "get next", + thisValue: this + }); + return function() { + log.push({ + name: "call next", + thisValue: this, + args: [...arguments] + }); + + nextCount++; + if (nextCount == 1) { + return { + name: "next-promise-1", + get then() { + log.push({ + name: "get next then (1)", + thisValue: this + }); + return function(resolve) { + log.push({ + name: "call next then (1)", + thisValue: this, + args: [...arguments] + }); + + resolve({ + name: "next-result-1", + get value() { + log.push({ + name: "get next value (1)", + thisValue: this + }); + return "next-value-1"; + }, + get done() { + log.push({ + name: "get next done (1)", + thisValue: this + }); + return false; + } + }); + }; + } + }; + } + + return { + name: "next-promise-2", + get then() { + log.push({ + name: "get next then (2)", + thisValue: this + }); + return function(resolve) { + log.push({ + name: "call next then (2)", + thisValue: this, + args: [...arguments] + }); + + resolve({ + name: "next-result-2", + get value() { + log.push({ + name: "get next value (2)", + thisValue: this + }); + return "next-value-2"; + }, + get done() { + log.push({ + name: "get next done (2)", + thisValue: this + }); + return true; + } + }); + }; + } + }; + }; + } + }; + }; + } +}; + + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + log.push({ name: "before yield*" }); + var v = yield* obj; + log.push({ + name: "after yield*", + value: v + }); + return "return-value"; + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); + +var iter = c.gen(); + +assert.sameValue(log.length, 0, "log.length"); + +iter.next("next-arg-1").then(v => { + assert.sameValue(log[0].name, "before yield*"); + + assert.sameValue(log[1].name, "get [Symbol.asyncIterator]"); + assert.sameValue(log[1].thisValue, obj, "get [Symbol.asyncIterator] thisValue"); + + assert.sameValue(log[2].name, "call [Symbol.asyncIterator]"); + assert.sameValue(log[2].thisValue, obj, "[Symbol.asyncIterator] thisValue"); + assert.sameValue(log[2].args.length, 0, "[Symbol.asyncIterator] args.length"); + + assert.sameValue(log[3].name, "get next"); + assert.sameValue(log[3].thisValue.name, "asyncIterator", "get next thisValue"); + + assert.sameValue(log[4].name, "call next"); + assert.sameValue(log[4].thisValue.name, "asyncIterator", "next thisValue"); + assert.sameValue(log[4].args.length, 1, "next args.length"); + assert.sameValue(log[4].args[0], undefined, "next args[0]"); + + assert.sameValue(log[5].name, "get next then (1)"); + assert.sameValue(log[5].thisValue.name, "next-promise-1", "get next then thisValue"); + + assert.sameValue(log[6].name, "call next then (1)"); + assert.sameValue(log[6].thisValue.name, "next-promise-1", "next then thisValue"); + assert.sameValue(log[6].args.length, 2, "next then args.length"); + assert.sameValue(typeof log[6].args[0], "function", "next then args[0]"); + assert.sameValue(typeof log[6].args[1], "function", "next then args[1]"); + + assert.sameValue(log[7].name, "get next done (1)"); + assert.sameValue(log[7].thisValue.name, "next-result-1", "get next done thisValue"); + + assert.sameValue(log[8].name, "get next value (1)"); + assert.sameValue(log[8].thisValue.name, "next-result-1", "get next value thisValue"); + + assert.sameValue(v.value, "next-value-1"); + assert.sameValue(v.done, false); + + assert.sameValue(log.length, 9, "log.length"); + + iter.next("next-arg-2").then(v => { + assert.sameValue(log[9].name, "call next"); + assert.sameValue(log[9].thisValue.name, "asyncIterator", "next thisValue"); + assert.sameValue(log[9].args.length, 1, "next args.length"); + assert.sameValue(log[9].args[0], "next-arg-2", "next args[0]"); + + assert.sameValue(log[10].name, "get next then (2)"); + assert.sameValue(log[10].thisValue.name, "next-promise-2", "get next then thisValue"); + + assert.sameValue(log[11].name, "call next then (2)"); + assert.sameValue(log[11].thisValue.name, "next-promise-2", "next then thisValue"); + assert.sameValue(log[11].args.length, 2, "next then args.length"); + assert.sameValue(typeof log[11].args[0], "function", "next then args[0]"); + assert.sameValue(typeof log[11].args[1], "function", "next then args[1]"); + + assert.sameValue(log[12].name, "get next done (2)"); + assert.sameValue(log[12].thisValue.name, "next-result-2", "get next done thisValue"); + + assert.sameValue(log[13].name, "get next value (2)"); + assert.sameValue(log[13].thisValue.name, "next-result-2", "get next value thisValue"); + + assert.sameValue(log[14].name, "after yield*"); + assert.sameValue(log[14].value, "next-value-2"); + + assert.sameValue(v.value, "return-value"); + assert.sameValue(v.done, true); + + assert.sameValue(log.length, 15, "log.length"); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-async-return.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-async-return.js new file mode 100644 index 0000000000..eb160aa548 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-async-return.js @@ -0,0 +1,273 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-async-return.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: execution order for yield* with async iterator and return() (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [async-iteration, Symbol.asyncIterator, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + ... + 6. Repeat + ... + c. Else, + i. Assert: received.[[Type]] is return. + ii. Let return be ? GetMethod(iterator, "return"). + iii. If return is undefined, return Completion(received). + iv. Let innerReturnResult be ? Call(return, iterator, « received.[[Value]] »). + v. If generatorKind is async, then set innerReturnResult to ? Await(innerReturnResult). + ... + vii. Let done be ? IteratorComplete(innerReturnResult). + viii. If done is true, then + 1. Let value be ? IteratorValue(innerReturnResult). + 2. If generatorKind is async, then set value to ? Await(value). + 3. Return Completion{[[Type]]: return, [[Value]]: value, [[Target]]: empty}. + ix. If generatorKind is async, then let received be AsyncGeneratorYield(? IteratorValue(innerResult)). + ... + + AsyncGeneratorYield ( value ) + ... + 8. Return ! AsyncGeneratorResolve(generator, value, false). + ... + +---*/ +var log = []; +var obj = { + [Symbol.asyncIterator]() { + var returnCount = 0; + return { + name: 'asyncIterator', + get next() { + log.push({ name: "get next" }); + return function() { + return { + value: "next-value-1", + done: false + }; + }; + }, + get return() { + log.push({ + name: "get return", + thisValue: this + }); + return function() { + log.push({ + name: "call return", + thisValue: this, + args: [...arguments] + }); + + returnCount++; + if (returnCount == 1) { + return { + name: "return-promise-1", + get then() { + log.push({ + name: "get return then (1)", + thisValue: this + }); + return function(resolve) { + log.push({ + name: "call return then (1)", + thisValue: this, + args: [...arguments] + }); + + resolve({ + name: "return-result-1", + get value() { + log.push({ + name: "get return value (1)", + thisValue: this + }); + return "return-value-1"; + }, + get done() { + log.push({ + name: "get return done (1)", + thisValue: this + }); + return false; + } + }); + }; + } + }; + } + + return { + name: "return-promise-2", + get then() { + log.push({ + name: "get return then (2)", + thisValue: this + }); + return function(resolve) { + log.push({ + name: "call return then (2)", + thisValue: this, + args: [...arguments] + }); + + resolve({ + name: "return-result-2", + get value() { + log.push({ + name: "get return value (2)", + thisValue: this + }); + return "return-value-2"; + }, + get done() { + log.push({ + name: "get return done (2)", + thisValue: this + }); + return true; + } + }); + }; + } + }; + }; + } + }; + } +}; + + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + log.push({ name: "before yield*" }); + yield* obj; + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); + +var iter = c.gen(); + +assert.sameValue(log.length, 0, "log.length"); + +iter.next().then(v => { + assert.sameValue(log[0].name, "before yield*"); + + assert.sameValue(log[1].name, "get next"); + + assert.sameValue(v.value, "next-value-1"); + assert.sameValue(v.done, false); + + assert.sameValue(log.length, 2, "log.length"); + + iter.return("return-arg-1").then(v => { + assert.sameValue(log[2].name, "get return"); + assert.sameValue(log[2].thisValue.name, "asyncIterator", "get return thisValue"); + + assert.sameValue(log[3].name, "call return"); + assert.sameValue(log[3].thisValue.name, "asyncIterator", "return thisValue"); + assert.sameValue(log[3].args.length, 1, "return args.length"); + assert.sameValue(log[3].args[0], "return-arg-1", "return args[0]"); + + assert.sameValue(log[4].name, "get return then (1)"); + assert.sameValue(log[4].thisValue.name, "return-promise-1", "get return then thisValue"); + + assert.sameValue(log[5].name, "call return then (1)"); + assert.sameValue(log[5].thisValue.name, "return-promise-1", "return then thisValue"); + assert.sameValue(log[5].args.length, 2, "return then args.length"); + assert.sameValue(typeof log[5].args[0], "function", "return then args[0]"); + assert.sameValue(typeof log[5].args[1], "function", "return then args[1]"); + + assert.sameValue(log[6].name, "get return done (1)"); + assert.sameValue(log[6].thisValue.name, "return-result-1", "get return done thisValue"); + + assert.sameValue(log[7].name, "get return value (1)"); + assert.sameValue(log[7].thisValue.name, "return-result-1", "get return value thisValue"); + + assert.sameValue(v.value, "return-value-1"); + assert.sameValue(v.done, false); + + assert.sameValue(log.length, 8, "log.length"); + + iter.return("return-arg-2").then(v => { + assert.sameValue(log[8].name, "get return"); + assert.sameValue(log[8].thisValue.name, "asyncIterator", "get return thisValue"); + + assert.sameValue(log[9].name, "call return"); + assert.sameValue(log[9].thisValue.name, "asyncIterator", "return thisValue"); + assert.sameValue(log[9].args.length, 1, "return args.length"); + assert.sameValue(log[9].args[0], "return-arg-2", "return args[0]"); + + assert.sameValue(log[10].name, "get return then (2)"); + assert.sameValue(log[10].thisValue.name, "return-promise-2", "get return then thisValue"); + + assert.sameValue(log[11].name, "call return then (2)"); + assert.sameValue(log[11].thisValue.name, "return-promise-2", "return then thisValue"); + assert.sameValue(log[11].args.length, 2, "return then args.length"); + assert.sameValue(typeof log[11].args[0], "function", "return then args[0]"); + assert.sameValue(typeof log[11].args[1], "function", "return then args[1]"); + + assert.sameValue(log[12].name, "get return done (2)"); + assert.sameValue(log[12].thisValue.name, "return-result-2", "get return done thisValue"); + + assert.sameValue(log[13].name, "get return value (2)"); + assert.sameValue(log[13].thisValue.name, "return-result-2", "get return value thisValue"); + + assert.sameValue(v.value, "return-value-2"); + assert.sameValue(v.done, true); + + assert.sameValue(log.length, 14, "log.length"); + }).then($DONE, $DONE); + }).catch($DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-async-throw.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-async-throw.js new file mode 100644 index 0000000000..96ff255a2b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-async-throw.js @@ -0,0 +1,281 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-async-throw.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: execution order for yield* with async iterator and throw() (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [async-iteration, Symbol.asyncIterator, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + ... + 6. Repeat + ... + b. Else if received.[[Type]] is throw, then + i. Let throw be ? GetMethod(iterator, "throw"). + ii. If throw is not undefined, then + 1. Let innerResult be ? Call(throw, iterator, « received.[[Value]] »). + 2. If generatorKind is async, then set innerResult to ? Await(innerResult). + ... + 5. Let done be ? IteratorComplete(innerResult). + 6. If done is true, then + a. Let resultValue be Return ? IteratorValue(innerResult). + b. If generatorKind is async, then set resultValue to ? Await(resultValue). + c. Return resultValue. + 7. If generatorKind is async, then let received be AsyncGeneratorYield(? IteratorValue(innerResult)). + ... + + AsyncGeneratorYield ( value ) + + ... + 8. Return ! AsyncGeneratorResolve(generator, value, false). + ... + +---*/ +var log = []; +var obj = { + [Symbol.asyncIterator]() { + var throwCount = 0; + return { + name: "asyncIterator", + get next() { + log.push({ name: "get next" }); + return function() { + return { + value: "next-value-1", + done: false + }; + }; + }, + get throw() { + log.push({ + name: "get throw", + thisValue: this + }); + return function() { + log.push({ + name: "call throw", + thisValue: this, + args: [...arguments] + }); + + throwCount++; + if (throwCount == 1) { + return { + name: "throw-promise-1", + get then() { + log.push({ + name: "get throw then (1)", + thisValue: this + }); + return function(resolve) { + log.push({ + name: "call throw then (1)", + thisValue: this, + args: [...arguments] + }); + + resolve({ + name: "throw-result-1", + get value() { + log.push({ + name: "get throw value (1)", + thisValue: this + }); + return "throw-value-1"; + }, + get done() { + log.push({ + name: "get throw done (1)", + thisValue: this + }); + return false; + } + }); + }; + } + }; + } + + return { + name: "throw-promise-2", + get then() { + log.push({ + name: "get throw then (2)", + thisValue: this + }); + return function(resolve) { + log.push({ + name: "call throw then (2)", + thisValue: this, + args: [...arguments] + }); + + resolve({ + name: "throw-result-2", + get value() { + log.push({ + name: "get throw value (2)", + thisValue: this + }); + return "throw-value-2"; + }, + get done() { + log.push({ + name: "get throw done (2)", + thisValue: this + }); + return true; + } + }); + }; + } + }; + }; + } + }; + } +}; + + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + log.push({ name: "before yield*" }); + var v = yield* obj; + log.push({ + name: "after yield*", + value: v + }); + return "return-value"; + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); + +var iter = c.gen(); + +assert.sameValue(log.length, 0, "log.length"); + +iter.next().then(v => { + assert.sameValue(log[0].name, "before yield*"); + + assert.sameValue(log[1].name, "get next"); + + assert.sameValue(v.value, "next-value-1"); + assert.sameValue(v.done, false); + + assert.sameValue(log.length, 2, "log.length"); + + iter.throw("throw-arg-1").then(v => { + assert.sameValue(log[2].name, "get throw"); + assert.sameValue(log[2].thisValue.name, "asyncIterator", "get throw thisValue"); + + assert.sameValue(log[3].name, "call throw"); + assert.sameValue(log[3].thisValue.name, "asyncIterator", "throw thisValue"); + assert.sameValue(log[3].args.length, 1, "throw args.length"); + assert.sameValue(log[3].args[0], "throw-arg-1", "throw args[0]"); + + assert.sameValue(log[4].name, "get throw then (1)"); + assert.sameValue(log[4].thisValue.name, "throw-promise-1", "get throw thisValue"); + + assert.sameValue(log[5].name, "call throw then (1)"); + assert.sameValue(log[5].thisValue.name, "throw-promise-1", "throw thisValue"); + assert.sameValue(log[5].args.length, 2, "throw then args.length"); + assert.sameValue(typeof log[5].args[0], "function", "throw then args[0]"); + assert.sameValue(typeof log[5].args[1], "function", "throw then args[1]"); + + assert.sameValue(log[6].name, "get throw done (1)"); + assert.sameValue(log[6].thisValue.name, "throw-result-1", "get throw done thisValue"); + + assert.sameValue(log[7].name, "get throw value (1)"); + assert.sameValue(log[7].thisValue.name, "throw-result-1", "get throw value thisValue"); + + assert.sameValue(v.value, "throw-value-1"); + assert.sameValue(v.done, false); + + assert.sameValue(log.length, 8, "log.length"); + + iter.throw("throw-arg-2").then(v => { + assert.sameValue(log[8].name, "get throw"); + assert.sameValue(log[8].thisValue.name, "asyncIterator", "get throw thisValue"); + + assert.sameValue(log[9].name, "call throw"); + assert.sameValue(log[9].thisValue.name, "asyncIterator", "throw thisValue"); + assert.sameValue(log[9].args.length, 1, "throw args.length"); + assert.sameValue(log[9].args[0], "throw-arg-2", "throw args[0]"); + + assert.sameValue(log[10].name, "get throw then (2)"); + assert.sameValue(log[10].thisValue.name, "throw-promise-2", "get throw thisValue"); + + assert.sameValue(log[11].name, "call throw then (2)"); + assert.sameValue(log[11].thisValue.name, "throw-promise-2", "throw thisValue"); + assert.sameValue(log[11].args.length, 2, "throw then args.length"); + assert.sameValue(typeof log[11].args[0], "function", "throw then args[0]"); + assert.sameValue(typeof log[11].args[1], "function", "throw then args[1]"); + + assert.sameValue(log[12].name, "get throw done (2)"); + assert.sameValue(log[12].thisValue.name, "throw-result-2", "get throw done thisValue"); + + assert.sameValue(log[13].name, "get throw value (2)"); + assert.sameValue(log[13].thisValue.name, "throw-result-2", "get throw value thisValue"); + + assert.sameValue(log[14].name, "after yield*"); + assert.sameValue(log[14].value, "throw-value-2"); + + assert.sameValue(v.value, "return-value"); + assert.sameValue(v.done, true); + + assert.sameValue(log.length, 15, "log.length"); + }).then($DONE, $DONE); + }).catch($DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-expr-abrupt.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-expr-abrupt.js new file mode 100644 index 0000000000..91d08ffc93 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-expr-abrupt.js @@ -0,0 +1,92 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-expr-abrupt.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: Abrupt completion while getting yield* operand (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + ... + +---*/ +var obj = {}; +var abrupt = function() { + throw obj; +}; + + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + yield* abrupt(); + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, obj, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-getiter-async-get-abrupt.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-getiter-async-get-abrupt.js new file mode 100644 index 0000000000..2b0d311b2e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-getiter-async-get-abrupt.js @@ -0,0 +1,112 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-get-abrupt.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: Abrupt completion while getting [Symbol.asyncIterator] (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + get [Symbol.asyncIterator]() { + throw reason; + } +}; + + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-getiter-async-not-callable-boolean-throw.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-getiter-async-not-callable-boolean-throw.js new file mode 100644 index 0000000000..b5a7b2a394 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-getiter-async-not-callable-boolean-throw.js @@ -0,0 +1,111 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-not-callable-boolean-throw.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: Throws a TypeError on a non-callable [Symbol.asyncIterator] (boolean) (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + 3. If func is either undefined or null, return undefined. + 4. If IsCallable(func) is false, throw a TypeError exception. + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]: false +}; + + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-getiter-async-not-callable-number-throw.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-getiter-async-not-callable-number-throw.js new file mode 100644 index 0000000000..7bfc8e0dbf --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-getiter-async-not-callable-number-throw.js @@ -0,0 +1,111 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-not-callable-number-throw.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: Throws a TypeError on a non-callable [Symbol.asyncIterator] (number) (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + 3. If func is either undefined or null, return undefined. + 4. If IsCallable(func) is false, throw a TypeError exception. + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]: 0 +}; + + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-getiter-async-not-callable-object-throw.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-getiter-async-not-callable-object-throw.js new file mode 100644 index 0000000000..2bd00fd6a6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-getiter-async-not-callable-object-throw.js @@ -0,0 +1,111 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-not-callable-object-throw.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: Throws a TypeError on a non-callable [Symbol.asyncIterator] (object) (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + 3. If func is either undefined or null, return undefined. + 4. If IsCallable(func) is false, throw a TypeError exception. + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]: {} +}; + + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-getiter-async-not-callable-string-throw.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-getiter-async-not-callable-string-throw.js new file mode 100644 index 0000000000..077c8f6745 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-getiter-async-not-callable-string-throw.js @@ -0,0 +1,111 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-not-callable-string-throw.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: Throws a TypeError on a non-callable [Symbol.asyncIterator] (string) (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + 3. If func is either undefined or null, return undefined. + 4. If IsCallable(func) is false, throw a TypeError exception. + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]: '' +}; + + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-getiter-async-not-callable-symbol-throw.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-getiter-async-not-callable-symbol-throw.js new file mode 100644 index 0000000000..443ac26876 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-getiter-async-not-callable-symbol-throw.js @@ -0,0 +1,111 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-not-callable-symbol-throw.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: Throws a TypeError on a non-callable [Symbol.asyncIterator] (symbol) (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + 3. If func is either undefined or null, return undefined. + 4. If IsCallable(func) is false, throw a TypeError exception. + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]: Symbol.asyncIterator +}; + + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-getiter-async-null-sync-get-abrupt.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-getiter-async-null-sync-get-abrupt.js new file mode 100644 index 0000000000..e8b2f33c0e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-getiter-async-null-sync-get-abrupt.js @@ -0,0 +1,117 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-null-sync-get-abrupt.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: Abrupt completion while getting @@iterator after null @@asyncIterator (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + b. If method is undefined, + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + ... + +---*/ +var calls = 0; +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw reason; + }, + get [Symbol.asyncIterator]() { + calls += 1; + return null; + } +}; + + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, 'reject reason'); + assert.sameValue(calls, 1); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-getiter-async-returns-abrupt.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-getiter-async-returns-abrupt.js new file mode 100644 index 0000000000..33db1241b7 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-getiter-async-returns-abrupt.js @@ -0,0 +1,108 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-returns-abrupt.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: Abrupt completion while calling [Symbol.asyncIterator] (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + 6. Let iterator be ? Call(method, obj). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + throw reason; + } +}; + + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-getiter-async-returns-boolean-throw.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-getiter-async-returns-boolean-throw.js new file mode 100644 index 0000000000..4f38c21ac6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-getiter-async-returns-boolean-throw.js @@ -0,0 +1,108 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-returns-boolean-throw.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: Non object returned by [Symbol.asyncIterator]() - boolean (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + 6. Let iterator be ? Call(method, obj). + 7. If Type(iterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return true; + } +}; + + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-getiter-async-returns-null-throw.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-getiter-async-returns-null-throw.js new file mode 100644 index 0000000000..60af524617 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-getiter-async-returns-null-throw.js @@ -0,0 +1,108 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-returns-null-throw.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: Non object returned by [Symbol.asyncIterator]() - null (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + 6. Let iterator be ? Call(method, obj). + 7. If Type(iterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return null; + } +}; + + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-getiter-async-returns-number-throw.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-getiter-async-returns-number-throw.js new file mode 100644 index 0000000000..3d8016897d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-getiter-async-returns-number-throw.js @@ -0,0 +1,108 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-returns-number-throw.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: Non object returned by [Symbol.asyncIterator]() - number (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + 6. Let iterator be ? Call(method, obj). + 7. If Type(iterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return 42; + } +}; + + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-getiter-async-returns-string-throw.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-getiter-async-returns-string-throw.js new file mode 100644 index 0000000000..a30b5f666d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-getiter-async-returns-string-throw.js @@ -0,0 +1,108 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-returns-string-throw.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: Non object returned by [Symbol.asyncIterator]() - string (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + 6. Let iterator be ? Call(method, obj). + 7. If Type(iterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return '42'; + } +}; + + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-getiter-async-returns-symbol-throw.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-getiter-async-returns-symbol-throw.js new file mode 100644 index 0000000000..8f1f6b80f1 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-getiter-async-returns-symbol-throw.js @@ -0,0 +1,108 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-returns-symbol-throw.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: Non object returned by [Symbol.asyncIterator]() - symbol (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + 6. Let iterator be ? Call(method, obj). + 7. If Type(iterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return Symbol.asyncIterator; + } +}; + + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-getiter-async-returns-undefined-throw.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-getiter-async-returns-undefined-throw.js new file mode 100644 index 0000000000..e7bc047cdf --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-getiter-async-returns-undefined-throw.js @@ -0,0 +1,108 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-returns-undefined-throw.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: Non object returned by [Symbol.asyncIterator]() - undefined (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + 6. Let iterator be ? Call(method, obj). + 7. If Type(iterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return undefined; + } +}; + + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-getiter-async-undefined-sync-get-abrupt.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-getiter-async-undefined-sync-get-abrupt.js new file mode 100644 index 0000000000..4ac2e2c911 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-getiter-async-undefined-sync-get-abrupt.js @@ -0,0 +1,117 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-undefined-sync-get-abrupt.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: Abrupt completion while getting @@iterator after undefined @@asyncIterator (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + b. If method is undefined, + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + ... + +---*/ +var calls = 0; +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw reason; + }, + get [Symbol.asyncIterator]() { + calls += 1; + return undefined; + } +}; + + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, 'reject reason'); + assert.sameValue(calls, 1); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-getiter-sync-get-abrupt.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-getiter-sync-get-abrupt.js new file mode 100644 index 0000000000..741f3f3879 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-getiter-sync-get-abrupt.js @@ -0,0 +1,111 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-get-abrupt.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: Abrupt completion while getting [Symbol.iterator] (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + b. If method is undefined, + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw reason; + } +}; + + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-getiter-sync-not-callable-boolean-throw.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-getiter-sync-not-callable-boolean-throw.js new file mode 100644 index 0000000000..14ed0208c0 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-getiter-sync-not-callable-boolean-throw.js @@ -0,0 +1,110 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-not-callable-boolean-throw.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: Throws a TypeError on a non-callable [Symbol.iterator] (boolean) (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + b. If method is undefined, + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + ... + 4. If IsCallable(func) is false, throw a TypeError exception. + ... + +---*/ +var obj = { + [Symbol.iterator]: false +}; + + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-getiter-sync-not-callable-number-throw.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-getiter-sync-not-callable-number-throw.js new file mode 100644 index 0000000000..631ffec6b9 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-getiter-sync-not-callable-number-throw.js @@ -0,0 +1,110 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-not-callable-number-throw.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: Throws a TypeError on a non-callable [Symbol.iterator] (number) (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + b. If method is undefined, + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + ... + 4. If IsCallable(func) is false, throw a TypeError exception. + ... + +---*/ +var obj = { + [Symbol.iterator]: 0 +}; + + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-getiter-sync-not-callable-object-throw.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-getiter-sync-not-callable-object-throw.js new file mode 100644 index 0000000000..e9f554efbd --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-getiter-sync-not-callable-object-throw.js @@ -0,0 +1,110 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-not-callable-object-throw.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: Throws a TypeError on a non-callable [Symbol.iterator] (object) (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + b. If method is undefined, + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + ... + 4. If IsCallable(func) is false, throw a TypeError exception. + ... + +---*/ +var obj = { + [Symbol.iterator]: {} +}; + + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-getiter-sync-not-callable-string-throw.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-getiter-sync-not-callable-string-throw.js new file mode 100644 index 0000000000..aeb155bb63 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-getiter-sync-not-callable-string-throw.js @@ -0,0 +1,110 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-not-callable-string-throw.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: Throws a TypeError on a non-callable [Symbol.iterator] (string) (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + b. If method is undefined, + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + ... + 4. If IsCallable(func) is false, throw a TypeError exception. + ... + +---*/ +var obj = { + [Symbol.iterator]: '' +}; + + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-getiter-sync-not-callable-symbol-throw.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-getiter-sync-not-callable-symbol-throw.js new file mode 100644 index 0000000000..90515b351d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-getiter-sync-not-callable-symbol-throw.js @@ -0,0 +1,110 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-not-callable-symbol-throw.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: Throws a TypeError on a non-callable [Symbol.iterator] (symbol) (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + b. If method is undefined, + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + ... + 4. If IsCallable(func) is false, throw a TypeError exception. + ... + +---*/ +var obj = { + [Symbol.iterator]: Symbol.iterator +}; + + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-getiter-sync-returns-abrupt.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-getiter-sync-returns-abrupt.js new file mode 100644 index 0000000000..73f3e12790 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-getiter-sync-returns-abrupt.js @@ -0,0 +1,105 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-returns-abrupt.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: Abrupt completion while calling [Symbol.iterator] (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ii. Let syncIterator be ? Call(syncMethod, obj). + ... + +---*/ +var reason = {}; +var obj = { + [Symbol.iterator]() { + throw reason; + } +}; + + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-getiter-sync-returns-boolean-throw.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-getiter-sync-returns-boolean-throw.js new file mode 100644 index 0000000000..50015e0abd --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-getiter-sync-returns-boolean-throw.js @@ -0,0 +1,110 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-returns-boolean-throw.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: Non object returned by [Symbol.iterator]() - boolean (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ii. Let syncIterator be ? Call(syncMethod, obj). + iii. Return ? CreateAsyncFromSyncIterator(syncIterator). + ... + + CreateAsyncFromSyncIterator(syncIterator) + + 1. If Type(syncIterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + [Symbol.iterator]() { + return true; + } +}; + + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-getiter-sync-returns-null-throw.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-getiter-sync-returns-null-throw.js new file mode 100644 index 0000000000..63546450d6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-getiter-sync-returns-null-throw.js @@ -0,0 +1,110 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-returns-null-throw.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: Non object returned by [Symbol.iterator]() - null (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ii. Let syncIterator be ? Call(syncMethod, obj). + iii. Return ? CreateAsyncFromSyncIterator(syncIterator). + ... + + CreateAsyncFromSyncIterator(syncIterator) + + 1. If Type(syncIterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + [Symbol.iterator]() { + return null; + } +}; + + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-getiter-sync-returns-number-throw.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-getiter-sync-returns-number-throw.js new file mode 100644 index 0000000000..1f52d1a513 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-getiter-sync-returns-number-throw.js @@ -0,0 +1,110 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-returns-number-throw.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: Non object returned by [Symbol.iterator]() - number (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ii. Let syncIterator be ? Call(syncMethod, obj). + iii. Return ? CreateAsyncFromSyncIterator(syncIterator). + ... + + CreateAsyncFromSyncIterator(syncIterator) + + 1. If Type(syncIterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + [Symbol.iterator]() { + return 0; + } +}; + + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-getiter-sync-returns-string-throw.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-getiter-sync-returns-string-throw.js new file mode 100644 index 0000000000..1b0fdcb4a5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-getiter-sync-returns-string-throw.js @@ -0,0 +1,110 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-returns-string-throw.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: Non object returned by [Symbol.iterator]() - string (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ii. Let syncIterator be ? Call(syncMethod, obj). + iii. Return ? CreateAsyncFromSyncIterator(syncIterator). + ... + + CreateAsyncFromSyncIterator(syncIterator) + + 1. If Type(syncIterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + [Symbol.iterator]() { + return ''; + } +}; + + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-getiter-sync-returns-symbol-throw.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-getiter-sync-returns-symbol-throw.js new file mode 100644 index 0000000000..8e86c1bd75 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-getiter-sync-returns-symbol-throw.js @@ -0,0 +1,110 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-returns-symbol-throw.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: Non object returned by [Symbol.iterator]() - symbol (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ii. Let syncIterator be ? Call(syncMethod, obj). + iii. Return ? CreateAsyncFromSyncIterator(syncIterator). + ... + + CreateAsyncFromSyncIterator(syncIterator) + + 1. If Type(syncIterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + [Symbol.iterator]() { + return Symbol.iterator; + } +}; + + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-getiter-sync-returns-undefined-throw.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-getiter-sync-returns-undefined-throw.js new file mode 100644 index 0000000000..eaf82447ee --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-getiter-sync-returns-undefined-throw.js @@ -0,0 +1,110 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-returns-undefined-throw.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: Non object returned by [Symbol.iterator]() - undefined (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ii. Let syncIterator be ? Call(syncMethod, obj). + iii. Return ? CreateAsyncFromSyncIterator(syncIterator). + ... + + CreateAsyncFromSyncIterator(syncIterator) + + 1. If Type(syncIterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + [Symbol.iterator]() { + return undefined; + } +}; + + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-next-call-done-get-abrupt.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-next-call-done-get-abrupt.js new file mode 100644 index 0000000000..d5bb772855 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-next-call-done-get-abrupt.js @@ -0,0 +1,111 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-call-done-get-abrupt.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: Abrupt completion while getting done (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + v. Let done be ? IteratorComplete(innerResult). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + get done() { + throw reason; + } + }; + } + }; + } +}; + + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-next-call-returns-abrupt.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-next-call-returns-abrupt.js new file mode 100644 index 0000000000..a6f731dc94 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-next-call-returns-abrupt.js @@ -0,0 +1,103 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-call-returns-abrupt.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: Abrupt completion while calling next (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + throw reason; + } + }; + } +}; + + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-next-call-value-get-abrupt.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-next-call-value-get-abrupt.js new file mode 100644 index 0000000000..c44953c1c7 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-next-call-value-get-abrupt.js @@ -0,0 +1,113 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-call-value-get-abrupt.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: Abrupt completion while getting value (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + vi. If done is true, then + 1. Return ? IteratorValue(innerResult). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + done: true, + get value() { + throw reason; + } + }; + } + }; + } +}; + + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-next-get-abrupt.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-next-get-abrupt.js new file mode 100644 index 0000000000..abeada6161 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-next-get-abrupt.js @@ -0,0 +1,103 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-get-abrupt.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: Abrupt completion while getting next (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + get next() { + throw reason; + } + }; + } +}; + + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-next-non-object-ignores-then.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-next-non-object-ignores-then.js new file mode 100644 index 0000000000..ed897fb8c3 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-next-non-object-ignores-then.js @@ -0,0 +1,123 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-non-object-ignores-then.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: If next() value is not-object, do not access respective then property (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + +---*/ +Number.prototype.then = function() { + throw new Test262Error('Number#then should not be used'); +}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return 42; + } + }; + } +}; + + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, 'TypeError'); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-next-not-callable-boolean-throw.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-next-not-callable-boolean-throw.js new file mode 100644 index 0000000000..daa99c2779 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-next-not-callable-boolean-throw.js @@ -0,0 +1,100 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-boolean-throw.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: Not-callable next value in a yield star position - boolean (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: true + }; + } +}; + + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-next-not-callable-null-throw.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-next-not-callable-null-throw.js new file mode 100644 index 0000000000..525fe38596 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-next-not-callable-null-throw.js @@ -0,0 +1,100 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-null-throw.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: Not-callable next value in a yield star position - null (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: null + }; + } +}; + + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-next-not-callable-number-throw.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-next-not-callable-number-throw.js new file mode 100644 index 0000000000..9883a3cdd3 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-next-not-callable-number-throw.js @@ -0,0 +1,100 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-number-throw.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: Not-callable next value in a yield star position - number (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: 42 + }; + } +}; + + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-next-not-callable-object-throw.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-next-not-callable-object-throw.js new file mode 100644 index 0000000000..1b592d2d99 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-next-not-callable-object-throw.js @@ -0,0 +1,100 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-object-throw.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: Not-callable next value in a yield star position - object (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: {} + }; + } +}; + + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-next-not-callable-string-throw.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-next-not-callable-string-throw.js new file mode 100644 index 0000000000..93f1525f17 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-next-not-callable-string-throw.js @@ -0,0 +1,100 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-string-throw.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: Not-callable next value in a yield star position - string (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: '' + }; + } +}; + + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-next-not-callable-symbol-throw.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-next-not-callable-symbol-throw.js new file mode 100644 index 0000000000..113904c014 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-next-not-callable-symbol-throw.js @@ -0,0 +1,100 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-symbol-throw.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: Not-callable next value in a yield star position - symbol (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: Symbol('oi') + }; + } +}; + + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-next-not-callable-undefined-throw.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-next-not-callable-undefined-throw.js new file mode 100644 index 0000000000..bd66cf0493 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-next-not-callable-undefined-throw.js @@ -0,0 +1,100 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-undefined-throw.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: Not-callable next value in a yield star position - undefined (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: undefined + }; + } +}; + + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-next-then-get-abrupt.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-next-then-get-abrupt.js new file mode 100644 index 0000000000..ad8c9590e5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-next-then-get-abrupt.js @@ -0,0 +1,127 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-get-abrupt.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: Return abrupt after getting next().then (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 8. Let then be Get(resolution, "then"). + ... + 10. Get thenAction be then.[[Value]]. + ... + 12. Perform EnqueueJob("PromiseJobs", PromiseResolveThenableJob, « promise, + resolution, thenAction »). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + get then() { + throw reason; + } + }; + } + }; + } +}; + + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, 'reject reason'); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-next-then-non-callable-boolean-fulfillpromise.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-next-then-non-callable-boolean-fulfillpromise.js new file mode 100644 index 0000000000..e6b3723774 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-next-then-non-callable-boolean-fulfillpromise.js @@ -0,0 +1,121 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-boolean-fulfillpromise.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: FulfillPromise if next().then is not-callable (boolean) (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: true, + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); + +var iter = c.gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-next-then-non-callable-null-fulfillpromise.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-next-then-non-callable-null-fulfillpromise.js new file mode 100644 index 0000000000..03a65a9806 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-next-then-non-callable-null-fulfillpromise.js @@ -0,0 +1,121 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-null-fulfillpromise.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: FulfillPromise if next().then is not-callable (null) (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: null, + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); + +var iter = c.gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-next-then-non-callable-number-fulfillpromise.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-next-then-non-callable-number-fulfillpromise.js new file mode 100644 index 0000000000..612f73cafe --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-next-then-non-callable-number-fulfillpromise.js @@ -0,0 +1,121 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-number-fulfillpromise.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: FulfillPromise if next().then is not-callable (number) (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: 39, + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); + +var iter = c.gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-next-then-non-callable-object-fulfillpromise.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-next-then-non-callable-object-fulfillpromise.js new file mode 100644 index 0000000000..aa38dcfbe2 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-next-then-non-callable-object-fulfillpromise.js @@ -0,0 +1,121 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-object-fulfillpromise.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: FulfillPromise if next().then is not-callable (object) (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: {}, + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); + +var iter = c.gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-next-then-non-callable-string-fulfillpromise.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-next-then-non-callable-string-fulfillpromise.js new file mode 100644 index 0000000000..058b82d40a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-next-then-non-callable-string-fulfillpromise.js @@ -0,0 +1,121 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-string-fulfillpromise.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: FulfillPromise if next().then is not-callable (string) (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: '', + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); + +var iter = c.gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-next-then-non-callable-symbol-fulfillpromise.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-next-then-non-callable-symbol-fulfillpromise.js new file mode 100644 index 0000000000..121893b0ca --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-next-then-non-callable-symbol-fulfillpromise.js @@ -0,0 +1,121 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-symbol-fulfillpromise.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: FulfillPromise if next().then is not-callable (symbol) (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: Symbol('oi'), + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); + +var iter = c.gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-next-then-non-callable-undefined-fulfillpromise.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-next-then-non-callable-undefined-fulfillpromise.js new file mode 100644 index 0000000000..ac4111c2b6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-next-then-non-callable-undefined-fulfillpromise.js @@ -0,0 +1,121 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-undefined-fulfillpromise.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: FulfillPromise if next().then is not-callable (undefined) (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: undefined, + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); + +var iter = c.gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-next-then-returns-abrupt.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-next-then-returns-abrupt.js new file mode 100644 index 0000000000..16e6019abd --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-next-then-returns-abrupt.js @@ -0,0 +1,127 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-returns-abrupt.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: Return abrupt after calling next().then (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 8. Let then be Get(resolution, "then"). + ... + 10. Get thenAction be then.[[Value]]. + ... + 12. Perform EnqueueJob("PromiseJobs", PromiseResolveThenableJob, « promise, + resolution, thenAction »). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then() { + throw reason; + } + }; + } + }; + } +}; + + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, 'reject reason'); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-sync-next.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-sync-next.js new file mode 100644 index 0000000000..70ebbacca3 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-sync-next.js @@ -0,0 +1,260 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-sync-next.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: execution order for yield* with sync iterator and next() (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, async-iteration, Symbol.asyncIterator, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + ... + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + 5. Let received be NormalCompletion(undefined). + 6. Repeat + a. If received.[[Type]] is normal, then + i. Let innerResult be ? IteratorNext(iterator, received.[[Value]]). + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + v. Let done be ? IteratorComplete(innerResult). + vi. If done is true, then + 1. Return ? IteratorValue(innerResult). + vii. Let received be GeneratorYield(innerResult). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + b. If method is undefined, + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ii. Let syncIterator be ? Call(syncMethod, obj). + iii. Return ? CreateAsyncFromSyncIterator(syncIterator). + ... + + %AsyncFromSyncIteratorPrototype%.next ( value ) + + ... + 5. Let nextResult be IteratorNext(syncIterator, value). + ... + 7. Let nextValue be IteratorValue(nextResult). + ... + 9. Let nextDone be IteratorComplete(nextResult). + ... + 12. Perform ! Call(valueWrapperCapability.[[Resolve]], undefined, + « nextValue »). + ... + 14. Set onFulfilled.[[Done]] to nextDone. + 15. Perform ! PerformPromiseThen(valueWrapperCapability.[[Promise]], + onFulfilled, undefined, promiseCapability). + ... + + Async Iterator Value Unwrap Functions + + 1. Return ! CreateIterResultObject(value, F.[[Done]]). + +---*/ +var log = []; +var obj = { + get [Symbol.iterator]() { + log.push({ + name: "get [Symbol.iterator]", + thisValue: this + }); + return function() { + log.push({ + name: "call [Symbol.iterator]", + thisValue: this, + args: [...arguments] + }); + var nextCount = 0; + return { + name: "syncIterator", + get next() { + log.push({ + name: "get next", + thisValue: this + }); + return function() { + log.push({ + name: "call next", + thisValue: this, + args: [...arguments] + }); + + nextCount++; + if (nextCount == 1) { + return { + name: "next-result-1", + get value() { + log.push({ + name: "get next value (1)", + thisValue: this + }); + return "next-value-1"; + }, + get done() { + log.push({ + name: "get next done (1)", + thisValue: this + }); + return false; + } + }; + } + + return { + name: "next-result-2", + get value() { + log.push({ + name: "get next value (2)", + thisValue: this + }); + return "next-value-2"; + }, + get done() { + log.push({ + name: "get next done (2)", + thisValue: this + }); + return true; + } + }; + }; + } + }; + }; + }, + get [Symbol.asyncIterator]() { + log.push({ name: "get [Symbol.asyncIterator]" }); + return null; + } +}; + + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + log.push({ name: "before yield*" }); + var v = yield* obj; + log.push({ + name: "after yield*", + value: v + }); + return "return-value"; + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); + +var iter = c.gen(); + +assert.sameValue(log.length, 0, "log.length"); + +iter.next("next-arg-1").then(v => { + assert.sameValue(log[0].name, "before yield*"); + + assert.sameValue(log[1].name, "get [Symbol.asyncIterator]"); + + assert.sameValue(log[2].name, "get [Symbol.iterator]"); + assert.sameValue(log[2].thisValue, obj, "get [Symbol.iterator] thisValue"); + + assert.sameValue(log[3].name, "call [Symbol.iterator]"); + assert.sameValue(log[3].thisValue, obj, "[Symbol.iterator] thisValue"); + assert.sameValue(log[3].args.length, 0, "[Symbol.iterator] args.length"); + + assert.sameValue(log[4].name, "get next"); + assert.sameValue(log[4].thisValue.name, "syncIterator", "get next thisValue"); + + assert.sameValue(log[5].name, "call next"); + assert.sameValue(log[5].thisValue.name, "syncIterator", "next thisValue"); + assert.sameValue(log[5].args.length, 1, "next args.length"); + assert.sameValue(log[5].args[0], undefined, "next args[0]"); + + assert.sameValue(log[6].name, "get next done (1)"); + assert.sameValue(log[6].thisValue.name, "next-result-1", "get next done thisValue"); + + assert.sameValue(log[7].name, "get next value (1)"); + assert.sameValue(log[7].thisValue.name, "next-result-1", "get next value thisValue"); + + assert.sameValue(v.value, "next-value-1"); + assert.sameValue(v.done, false); + + assert.sameValue(log.length, 8, "log.length"); + + iter.next("next-arg-2").then(v => { + assert.sameValue(log[8].name, "call next"); + assert.sameValue(log[8].thisValue.name, "syncIterator", "next thisValue"); + assert.sameValue(log[8].args.length, 1, "next args.length"); + assert.sameValue(log[8].args[0], "next-arg-2", "next args[0]"); + + assert.sameValue(log[9].name, "get next done (2)"); + assert.sameValue(log[9].thisValue.name, "next-result-2", "get next done thisValue"); + + assert.sameValue(log[10].name, "get next value (2)"); + assert.sameValue(log[10].thisValue.name, "next-result-2", "get next value thisValue"); + + assert.sameValue(log[11].name, "after yield*"); + assert.sameValue(log[11].value, "next-value-2"); + + assert.sameValue(v.value, "return-value"); + assert.sameValue(v.done, true); + + assert.sameValue(log.length, 12, "log.length"); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-sync-return.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-sync-return.js new file mode 100644 index 0000000000..ea4577649c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-sync-return.js @@ -0,0 +1,235 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-sync-return.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: execution order for yield* with sync iterator and return() (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, async-iteration, Symbol.asyncIterator, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + ... + 6. Repeat + ... + c. Else, + i. Assert: received.[[Type]] is return. + ii. Let return be ? GetMethod(iterator, "return"). + iii. If return is undefined, return Completion(received). + iv. Let innerReturnResult be ? Call(return, iterator, + « received.[[Value]] »). + v. If generatorKind is async, then set innerReturnResult to + ? Await(innerReturnResult). + ... + vii. Let done be ? IteratorComplete(innerReturnResult). + viii. If done is true, then + 1. Let value be ? IteratorValue(innerReturnResult). + 2. Return Completion{[[Type]]: return, [[Value]]: value, + [[Target]]: empty}. + ix. Let received be GeneratorYield(innerResult). + + %AsyncFromSyncIteratorPrototype%.return ( value ) + + 5. Let return be GetMethod(syncIterator, "return"). + ... + ... + 8. Let returnResult be Call(return, syncIterator, « value »). + ... + 11. Let returnValue be IteratorValue(returnResult). + .. + 13. Let returnDone be IteratorComplete(returnResult). + ... + 16. Perform ! Call(valueWrapperCapability.[[Resolve]], undefined, « returnValue »). + ... + 18. Set onFulfilled.[[Done]] to returnDone. + 19. Perform ! PerformPromiseThen(valueWrapperCapability.[[Promise]], + onFulfilled, undefined, promiseCapability). + ... + +---*/ +var log = []; +var obj = { + [Symbol.iterator]() { + var returnCount = 0; + return { + name: "syncIterator", + get next() { + log.push({ name: "get next" }); + return function() { + return { + value: "next-value-1", + done: false + }; + }; + }, + get return() { + log.push({ + name: "get return", + thisValue: this + }); + return function() { + log.push({ + name: "call return", + thisValue: this, + args: [...arguments] + }); + + returnCount++; + if (returnCount == 1) { + return { + name: "return-result-1", + get value() { + log.push({ + name: "get return value (1)", + thisValue: this + }); + return "return-value-1"; + }, + get done() { + log.push({ + name: "get return done (1)", + thisValue: this + }); + return false; + } + }; + } + + return { + name: "return-result-2", + get value() { + log.push({ + name: "get return value (2)", + thisValue: this + }); + return "return-value-2"; + }, + get done() { + log.push({ + name: "get return done (2)", + thisValue: this + }); + return true; + } + }; + }; + } + }; + } +}; + + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + log.push({ name: "before yield*" }); + yield* obj; + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); + +var iter = c.gen(); + +assert.sameValue(log.length, 0, "log.length"); + +iter.next().then(v => { + assert.sameValue(log[0].name, "before yield*"); + + assert.sameValue(log[1].name, "get next"); + + assert.sameValue(v.value, "next-value-1"); + assert.sameValue(v.done, false); + + assert.sameValue(log.length, 2, "log.length"); + + iter.return("return-arg-1").then(v => { + assert.sameValue(log[2].name, "get return"); + assert.sameValue(log[2].thisValue.name, "syncIterator", "get return thisValue"); + + assert.sameValue(log[3].name, "call return"); + assert.sameValue(log[3].thisValue.name, "syncIterator", "return thisValue"); + assert.sameValue(log[3].args.length, 1, "return args.length"); + assert.sameValue(log[3].args[0], "return-arg-1", "return args[0]"); + + assert.sameValue(log[4].name, "get return done (1)"); + assert.sameValue(log[4].thisValue.name, "return-result-1", "get return done thisValue"); + + assert.sameValue(log[5].name, "get return value (1)"); + assert.sameValue(log[5].thisValue.name, "return-result-1", "get return value thisValue"); + + assert.sameValue(v.value, "return-value-1"); + assert.sameValue(v.done, false); + + assert.sameValue(log.length, 6, "log.length"); + + iter.return().then(v => { + assert.sameValue(log[6].name, "get return"); + assert.sameValue(log[6].thisValue.name, "syncIterator", "get return thisValue"); + + assert.sameValue(log[7].name, "call return"); + assert.sameValue(log[7].thisValue.name, "syncIterator", "get return thisValue"); + assert.sameValue(log[7].args.length, 1, "return args.length"); + assert.sameValue(log[7].args[0], undefined, "return args[0]"); + + assert.sameValue(log[8].name, "get return done (2)"); + assert.sameValue(log[8].thisValue.name, "return-result-2", "get return done thisValue"); + + assert.sameValue(log[9].name, "get return value (2)"); + assert.sameValue(log[9].thisValue.name, "return-result-2", "get return value thisValue"); + + assert.sameValue(v.value, "return-value-2"); + assert.sameValue(v.done, true); + + assert.sameValue(log.length, 10, "log.length"); + }).then($DONE, $DONE); + }).catch($DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-sync-throw.js b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-sync-throw.js new file mode 100644 index 0000000000..3579ace644 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-gen-private-method/yield-star-sync-throw.js @@ -0,0 +1,241 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-sync-throw.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: execution order for yield* with sync iterator and throw() (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + ... + 6. Repeat + ... + b. Else if received.[[Type]] is throw, then + i. Let throw be ? GetMethod(iterator, "throw"). + ii. If throw is not undefined, then + 1. Let innerResult be ? Call(throw, iterator, « received.[[Value]] »). + 2. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + 5. Let done be ? IteratorComplete(innerResult). + 6. If done is true, then + a. Return ? IteratorValue(innerResult). + 7. Let received be GeneratorYield(innerResult). + ... + + %AsyncFromSyncIteratorPrototype%.throw ( value ) + + ... + 5. Let throw be GetMethod(syncIterator, "throw"). + ... + 8. Let throwResult be Call(throw, syncIterator, « value »). + ... + 11. Let throwValue be IteratorValue(throwResult). + ... + 13. Let throwDone be IteratorComplete(throwResult). + ... + 16. Perform ! Call(valueWrapperCapability.[[Resolve]], undefined, + « throwValue »). + ... + 18. Set onFulfilled.[[Done]] to throwDone. + 19. Perform ! PerformPromiseThen(valueWrapperCapability.[[Promise]], + onFulfilled, undefined, promiseCapability). + ... + +---*/ +var log = []; +var obj = { + [Symbol.iterator]() { + var throwCount = 0; + return { + name: "syncIterator", + get next() { + log.push({ name: "get next" }); + return function() { + return { + value: "next-value-1", + done: false + }; + }; + }, + get throw() { + log.push({ + name: "get throw", + thisValue: this + }); + return function() { + log.push({ + name: "call throw", + thisValue: this, + args: [...arguments] + }); + + throwCount++; + if (throwCount == 1) { + return { + name: "throw-result-1", + get value() { + log.push({ + name: "get throw value (1)", + thisValue: this + }); + return "throw-value-1"; + }, + get done() { + log.push({ + name: "get throw done (1)", + thisValue: this + }); + return false; + } + }; + } + + return { + name: "throw-result-2", + get value() { + log.push({ + name: "get throw value (2)", + thisValue: this + }); + return "throw-value-2"; + }, + get done() { + log.push({ + name: "get throw done (2)", + thisValue: this + }); + return true; + } + }; + }; + } + }; + } +}; + + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + log.push({ name: "before yield*" }); + var v = yield* obj; + log.push({ + name: "after yield*", + value: v + }); + return "return-value"; + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); + +var iter = c.gen(); + +assert.sameValue(log.length, 0, "log.length"); + +iter.next().then(v => { + assert.sameValue(log[0].name, "before yield*"); + + assert.sameValue(log[1].name, "get next"); + + assert.sameValue(v.value, "next-value-1"); + assert.sameValue(v.done, false); + + assert.sameValue(log.length, 2, "log.length"); + + iter.throw("throw-arg-1").then(v => { + assert.sameValue(log[2].name, "get throw"); + assert.sameValue(log[2].thisValue.name, "syncIterator", "get throw thisValue"); + + assert.sameValue(log[3].name, "call throw"); + assert.sameValue(log[3].thisValue.name, "syncIterator", "throw thisValue"); + assert.sameValue(log[3].args.length, 1, "throw args.length"); + assert.sameValue(log[3].args[0], "throw-arg-1", "throw args[0]"); + + assert.sameValue(log[4].name, "get throw done (1)"); + assert.sameValue(log[4].thisValue.name, "throw-result-1", "get throw done thisValue"); + + assert.sameValue(log[5].name, "get throw value (1)"); + assert.sameValue(log[5].thisValue.name, "throw-result-1", "get throw value thisValue"); + + assert.sameValue(v.value, "throw-value-1"); + assert.sameValue(v.done, false); + + assert.sameValue(log.length, 6, "log.length"); + + iter.throw().then(v => { + assert.sameValue(log[6].name, "get throw"); + assert.sameValue(log[6].thisValue.name, "syncIterator", "get throw thisValue"); + + assert.sameValue(log[7].name, "call throw"); + assert.sameValue(log[7].thisValue.name, "syncIterator", "throw thisValue"); + assert.sameValue(log[7].args.length, 1, "throw args.length"); + assert.sameValue(log[7].args[0], undefined, "throw args[0]"); + + assert.sameValue(log[8].name, "get throw done (2)"); + assert.sameValue(log[8].thisValue.name, "throw-result-2", "get throw done thisValue"); + + assert.sameValue(log[9].name, "get throw value (2)"); + assert.sameValue(log[9].thisValue.name, "throw-result-2", "get throw value thisValue"); + + assert.sameValue(log[10].name, "after yield*"); + assert.sameValue(log[10].value, "throw-value-2"); + + assert.sameValue(v.value, "return-value"); + assert.sameValue(v.done, true); + + assert.sameValue(log.length, 11, "log.length"); + }).then($DONE, $DONE); + }).catch($DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "#gen does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "#gen does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "#gen does not appear as an own property on C instance" +); diff --git a/js/src/tests/test262/language/statements/class/elements/async-private-method-static/await-as-binding-identifier-escaped.js b/js/src/tests/test262/language/statements/class/elements/async-private-method-static/await-as-binding-identifier-escaped.js new file mode 100644 index 0000000000..65094a194e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-private-method-static/await-as-binding-identifier-escaped.js @@ -0,0 +1,41 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/async-functions/await-as-binding-identifier-escaped.case +// - src/async-functions/syntax/async-class-decl-static-private-method.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as a binding identifier. (Static async private method as a ClassDeclaration element) +esid: prod-AsyncMethod +features: [async-functions, class-static-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncMethod + + Async Function Definitions + + AsyncMethod : + async [no LineTerminator here] # PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + + BindingIdentifier : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +$DONOTEVALUATE(); + + +class C { + static async #method() { + var \u0061wait; + } +} + + diff --git a/js/src/tests/test262/language/statements/class/elements/async-private-method-static/await-as-binding-identifier.js b/js/src/tests/test262/language/statements/class/elements/async-private-method-static/await-as-binding-identifier.js new file mode 100644 index 0000000000..03633af3f5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-private-method-static/await-as-binding-identifier.js @@ -0,0 +1,41 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/async-functions/await-as-binding-identifier.case +// - src/async-functions/syntax/async-class-decl-static-private-method.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as a binding identifier. (Static async private method as a ClassDeclaration element) +esid: prod-AsyncMethod +features: [async-functions, class-static-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncMethod + + Async Function Definitions + + AsyncMethod : + async [no LineTerminator here] # PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + + BindingIdentifier : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +$DONOTEVALUATE(); + + +class C { + static async #method() { + var await; + } +} + + diff --git a/js/src/tests/test262/language/statements/class/elements/async-private-method-static/await-as-identifier-reference-escaped.js b/js/src/tests/test262/language/statements/class/elements/async-private-method-static/await-as-identifier-reference-escaped.js new file mode 100644 index 0000000000..9497de6af9 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-private-method-static/await-as-identifier-reference-escaped.js @@ -0,0 +1,41 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/async-functions/await-as-identifier-reference-escaped.case +// - src/async-functions/syntax/async-class-decl-static-private-method.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as an identifier reference. (Static async private method as a ClassDeclaration element) +esid: prod-AsyncMethod +features: [async-functions, class-static-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncMethod + + Async Function Definitions + + AsyncMethod : + async [no LineTerminator here] # PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + + IdentifierReference : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +$DONOTEVALUATE(); + + +class C { + static async #method() { + void \u0061wait; + } +} + + diff --git a/js/src/tests/test262/language/statements/class/elements/async-private-method-static/await-as-identifier-reference.js b/js/src/tests/test262/language/statements/class/elements/async-private-method-static/await-as-identifier-reference.js new file mode 100644 index 0000000000..186b301db2 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-private-method-static/await-as-identifier-reference.js @@ -0,0 +1,41 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/async-functions/await-as-identifier-reference.case +// - src/async-functions/syntax/async-class-decl-static-private-method.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as an identifier reference. (Static async private method as a ClassDeclaration element) +esid: prod-AsyncMethod +features: [async-functions, class-static-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncMethod + + Async Function Definitions + + AsyncMethod : + async [no LineTerminator here] # PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + + IdentifierReference : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +$DONOTEVALUATE(); + + +class C { + static async #method() { + void await; + } +} + + diff --git a/js/src/tests/test262/language/statements/class/elements/async-private-method-static/await-as-label-identifier-escaped.js b/js/src/tests/test262/language/statements/class/elements/async-private-method-static/await-as-label-identifier-escaped.js new file mode 100644 index 0000000000..79c9a46179 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-private-method-static/await-as-label-identifier-escaped.js @@ -0,0 +1,41 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/async-functions/await-as-label-identifier-escaped.case +// - src/async-functions/syntax/async-class-decl-static-private-method.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as a label identifier. (Static async private method as a ClassDeclaration element) +esid: prod-AsyncMethod +features: [async-functions, class-static-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncMethod + + Async Function Definitions + + AsyncMethod : + async [no LineTerminator here] # PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + + LabelIdentifier : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +$DONOTEVALUATE(); + + +class C { + static async #method() { + \u0061wait: ; + } +} + + diff --git a/js/src/tests/test262/language/statements/class/elements/async-private-method-static/await-as-label-identifier.js b/js/src/tests/test262/language/statements/class/elements/async-private-method-static/await-as-label-identifier.js new file mode 100644 index 0000000000..d0493a7bac --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-private-method-static/await-as-label-identifier.js @@ -0,0 +1,41 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/async-functions/await-as-label-identifier.case +// - src/async-functions/syntax/async-class-decl-static-private-method.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as a label identifier. (Static async private method as a ClassDeclaration element) +esid: prod-AsyncMethod +features: [async-functions, class-static-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncMethod + + Async Function Definitions + + AsyncMethod : + async [no LineTerminator here] # PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + + LabelIdentifier : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +$DONOTEVALUATE(); + + +class C { + static async #method() { + await: ; + } +} + + diff --git a/js/src/tests/test262/language/statements/class/elements/async-private-method-static/browser.js b/js/src/tests/test262/language/statements/class/elements/async-private-method-static/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/elements/async-private-method-static/returns-async-arrow-returns-arguments-from-parent-function.js b/js/src/tests/test262/language/statements/class/elements/async-private-method-static/returns-async-arrow-returns-arguments-from-parent-function.js new file mode 100644 index 0000000000..8fceeed5d1 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-private-method-static/returns-async-arrow-returns-arguments-from-parent-function.js @@ -0,0 +1,44 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-functions/returns-async-arrow-returns-arguments-from-parent-function.case +// - src/async-functions/evaluation/async-class-decl-static-private-method.template +/*--- +description: Async function returns an async function. (Static async private method as a ClassDeclaration element) +esid: prod-AsyncMethod +features: [async-functions, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncMethod + + Async Function Definitions + + AsyncMethod : + async [no LineTerminator here] # PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + +---*/ +let count = 0; + + +class C { + static async #method(x) { + let a = arguments; + return async () => a === arguments; + } + static async method(x) { + return this.#method(x); + } +} +// Stores a reference `asyncFn` for case evaluation +let asyncFn = C.method.bind(C); + +asyncFn().then(retFn => { + count++; + return retFn(); +}).then(result => { + assert.sameValue(result, true); + assert.sameValue(count, 1); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/async-private-method-static/returns-async-arrow-returns-newtarget.js b/js/src/tests/test262/language/statements/class/elements/async-private-method-static/returns-async-arrow-returns-newtarget.js new file mode 100644 index 0000000000..3946ffd23a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-private-method-static/returns-async-arrow-returns-newtarget.js @@ -0,0 +1,43 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-functions/returns-async-arrow-returns-newtarget.case +// - src/async-functions/evaluation/async-class-decl-static-private-method.template +/*--- +description: Async function returns an async function. (Static async private method as a ClassDeclaration element) +esid: prod-AsyncMethod +features: [async-functions, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncMethod + + Async Function Definitions + + AsyncMethod : + async [no LineTerminator here] # PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + +---*/ +let count = 0; + + +class C { + static async #method(x) { + return async () => new.target; + } + static async method(x) { + return this.#method(x); + } +} +// Stores a reference `asyncFn` for case evaluation +let asyncFn = C.method.bind(C); + +asyncFn().then(retFn => { + count++; + return retFn(); +}).then(result => { + assert.sameValue(result, undefined); + assert.sameValue(count, 1); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/async-private-method-static/returns-async-arrow.js b/js/src/tests/test262/language/statements/class/elements/async-private-method-static/returns-async-arrow.js new file mode 100644 index 0000000000..ae1ac57bf9 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-private-method-static/returns-async-arrow.js @@ -0,0 +1,43 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-functions/returns-async-arrow.case +// - src/async-functions/evaluation/async-class-decl-static-private-method.template +/*--- +description: Async function returns an async function. (Static async private method as a ClassDeclaration element) +esid: prod-AsyncMethod +features: [async-functions, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncMethod + + Async Function Definitions + + AsyncMethod : + async [no LineTerminator here] # PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + +---*/ +let count = 0; + + +class C { + static async #method(x) { + return async () => x; + } + static async method(x) { + return this.#method(x); + } +} +// Stores a reference `asyncFn` for case evaluation +let asyncFn = C.method.bind(C); + +asyncFn(1).then(retFn => { + count++; + return retFn(); +}).then(result => { + assert.sameValue(result, 1); + assert.sameValue(count, 1); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/async-private-method-static/returns-async-function-returns-arguments-from-own-function.js b/js/src/tests/test262/language/statements/class/elements/async-private-method-static/returns-async-function-returns-arguments-from-own-function.js new file mode 100644 index 0000000000..692da97eee --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-private-method-static/returns-async-function-returns-arguments-from-own-function.js @@ -0,0 +1,44 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-functions/returns-async-function-returns-arguments-from-own-function.case +// - src/async-functions/evaluation/async-class-decl-static-private-method.template +/*--- +description: Async function returns an async function. (Static async private method as a ClassDeclaration element) +esid: prod-AsyncMethod +features: [async-functions, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncMethod + + Async Function Definitions + + AsyncMethod : + async [no LineTerminator here] # PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + +---*/ +let count = 0; + + +class C { + static async #method(x) { + let a = arguments; + return async function() { return a === arguments; }; + } + static async method(x) { + return this.#method(x); + } +} +// Stores a reference `asyncFn` for case evaluation +let asyncFn = C.method.bind(C); + +asyncFn(1).then(retFn => { + count++; + return retFn(); +}).then(result => { + assert.sameValue(result, false); + assert.sameValue(count, 1); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/async-private-method-static/returns-async-function-returns-newtarget.js b/js/src/tests/test262/language/statements/class/elements/async-private-method-static/returns-async-function-returns-newtarget.js new file mode 100644 index 0000000000..0b2351911d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-private-method-static/returns-async-function-returns-newtarget.js @@ -0,0 +1,43 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-functions/returns-async-function-returns-newtarget.case +// - src/async-functions/evaluation/async-class-decl-static-private-method.template +/*--- +description: Async function returns an async function. (Static async private method as a ClassDeclaration element) +esid: prod-AsyncMethod +features: [async-functions, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncMethod + + Async Function Definitions + + AsyncMethod : + async [no LineTerminator here] # PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + +---*/ +let count = 0; + + +class C { + static async #method(x) { + return async function() { return new.target; }; + } + static async method(x) { + return this.#method(x); + } +} +// Stores a reference `asyncFn` for case evaluation +let asyncFn = C.method.bind(C); + +asyncFn(1).then(retFn => { + count++; + return retFn(); +}).then(result => { + assert.sameValue(result, undefined); + assert.sameValue(count, 1); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/async-private-method-static/returns-async-function.js b/js/src/tests/test262/language/statements/class/elements/async-private-method-static/returns-async-function.js new file mode 100644 index 0000000000..8bdec77ce3 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-private-method-static/returns-async-function.js @@ -0,0 +1,43 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-functions/returns-async-function.case +// - src/async-functions/evaluation/async-class-decl-static-private-method.template +/*--- +description: Async function returns an async function. (Static async private method as a ClassDeclaration element) +esid: prod-AsyncMethod +features: [async-functions, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncMethod + + Async Function Definitions + + AsyncMethod : + async [no LineTerminator here] # PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + +---*/ +let count = 0; + + +class C { + static async #method(x) { + return async function() { return x; }; + } + static async method(x) { + return this.#method(x); + } +} +// Stores a reference `asyncFn` for case evaluation +let asyncFn = C.method.bind(C); + +asyncFn(1).then(retFn => { + count++; + return retFn(); +}).then(result => { + assert.sameValue(result, 1); + assert.sameValue(count, 1); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/async-private-method-static/shell.js b/js/src/tests/test262/language/statements/class/elements/async-private-method-static/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/elements/async-private-method/await-as-binding-identifier-escaped.js b/js/src/tests/test262/language/statements/class/elements/async-private-method/await-as-binding-identifier-escaped.js new file mode 100644 index 0000000000..d40bf022b2 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-private-method/await-as-binding-identifier-escaped.js @@ -0,0 +1,39 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/async-functions/await-as-binding-identifier-escaped.case +// - src/async-functions/syntax/async-class-decl-private-method.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as a binding identifier. (Async private method as a ClassDeclaration element) +esid: prod-AsyncMethod +features: [async-functions, class-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncMethod + + Async Function Definitions + + AsyncMethod : + async [no LineTerminator here] # PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + + BindingIdentifier : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +$DONOTEVALUATE(); + + +class C { + async #method() { + var \u0061wait; + } +} diff --git a/js/src/tests/test262/language/statements/class/elements/async-private-method/await-as-binding-identifier.js b/js/src/tests/test262/language/statements/class/elements/async-private-method/await-as-binding-identifier.js new file mode 100644 index 0000000000..cf96ab3b04 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-private-method/await-as-binding-identifier.js @@ -0,0 +1,39 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/async-functions/await-as-binding-identifier.case +// - src/async-functions/syntax/async-class-decl-private-method.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as a binding identifier. (Async private method as a ClassDeclaration element) +esid: prod-AsyncMethod +features: [async-functions, class-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncMethod + + Async Function Definitions + + AsyncMethod : + async [no LineTerminator here] # PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + + BindingIdentifier : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +$DONOTEVALUATE(); + + +class C { + async #method() { + var await; + } +} diff --git a/js/src/tests/test262/language/statements/class/elements/async-private-method/await-as-identifier-reference-escaped.js b/js/src/tests/test262/language/statements/class/elements/async-private-method/await-as-identifier-reference-escaped.js new file mode 100644 index 0000000000..6a0207039f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-private-method/await-as-identifier-reference-escaped.js @@ -0,0 +1,39 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/async-functions/await-as-identifier-reference-escaped.case +// - src/async-functions/syntax/async-class-decl-private-method.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as an identifier reference. (Async private method as a ClassDeclaration element) +esid: prod-AsyncMethod +features: [async-functions, class-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncMethod + + Async Function Definitions + + AsyncMethod : + async [no LineTerminator here] # PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + + IdentifierReference : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +$DONOTEVALUATE(); + + +class C { + async #method() { + void \u0061wait; + } +} diff --git a/js/src/tests/test262/language/statements/class/elements/async-private-method/await-as-identifier-reference.js b/js/src/tests/test262/language/statements/class/elements/async-private-method/await-as-identifier-reference.js new file mode 100644 index 0000000000..7931167ccd --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-private-method/await-as-identifier-reference.js @@ -0,0 +1,39 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/async-functions/await-as-identifier-reference.case +// - src/async-functions/syntax/async-class-decl-private-method.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as an identifier reference. (Async private method as a ClassDeclaration element) +esid: prod-AsyncMethod +features: [async-functions, class-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncMethod + + Async Function Definitions + + AsyncMethod : + async [no LineTerminator here] # PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + + IdentifierReference : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +$DONOTEVALUATE(); + + +class C { + async #method() { + void await; + } +} diff --git a/js/src/tests/test262/language/statements/class/elements/async-private-method/await-as-label-identifier-escaped.js b/js/src/tests/test262/language/statements/class/elements/async-private-method/await-as-label-identifier-escaped.js new file mode 100644 index 0000000000..20905576ef --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-private-method/await-as-label-identifier-escaped.js @@ -0,0 +1,39 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/async-functions/await-as-label-identifier-escaped.case +// - src/async-functions/syntax/async-class-decl-private-method.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as a label identifier. (Async private method as a ClassDeclaration element) +esid: prod-AsyncMethod +features: [async-functions, class-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncMethod + + Async Function Definitions + + AsyncMethod : + async [no LineTerminator here] # PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + + LabelIdentifier : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +$DONOTEVALUATE(); + + +class C { + async #method() { + \u0061wait: ; + } +} diff --git a/js/src/tests/test262/language/statements/class/elements/async-private-method/await-as-label-identifier.js b/js/src/tests/test262/language/statements/class/elements/async-private-method/await-as-label-identifier.js new file mode 100644 index 0000000000..c6859c2ecc --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-private-method/await-as-label-identifier.js @@ -0,0 +1,39 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/async-functions/await-as-label-identifier.case +// - src/async-functions/syntax/async-class-decl-private-method.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as a label identifier. (Async private method as a ClassDeclaration element) +esid: prod-AsyncMethod +features: [async-functions, class-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncMethod + + Async Function Definitions + + AsyncMethod : + async [no LineTerminator here] # PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + + LabelIdentifier : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +$DONOTEVALUATE(); + + +class C { + async #method() { + await: ; + } +} diff --git a/js/src/tests/test262/language/statements/class/elements/async-private-method/browser.js b/js/src/tests/test262/language/statements/class/elements/async-private-method/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/elements/async-private-method/returns-async-arrow-returns-arguments-from-parent-function.js b/js/src/tests/test262/language/statements/class/elements/async-private-method/returns-async-arrow-returns-arguments-from-parent-function.js new file mode 100644 index 0000000000..a40fd874eb --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-private-method/returns-async-arrow-returns-arguments-from-parent-function.js @@ -0,0 +1,45 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-functions/returns-async-arrow-returns-arguments-from-parent-function.case +// - src/async-functions/evaluation/async-class-decl-private-method.template +/*--- +description: Async function returns an async function. (Async private method as a ClassDeclaration element) +esid: prod-AsyncMethod +features: [async-functions, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncMethod + + Async Function Definitions + + AsyncMethod : + async [no LineTerminator here] # PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + +---*/ +let count = 0; + + +class C { + async #method(x) { + let a = arguments; + return async () => a === arguments; + } + async method(x) { + return this.#method(x); + } +} +// Stores a reference `asyncFn` for case evaluation +let c = new C(); +let asyncFn = c.method.bind(c); + +asyncFn().then(retFn => { + count++; + return retFn(); +}).then(result => { + assert.sameValue(result, true); + assert.sameValue(count, 1); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/async-private-method/returns-async-arrow-returns-newtarget.js b/js/src/tests/test262/language/statements/class/elements/async-private-method/returns-async-arrow-returns-newtarget.js new file mode 100644 index 0000000000..f960ba8e6f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-private-method/returns-async-arrow-returns-newtarget.js @@ -0,0 +1,44 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-functions/returns-async-arrow-returns-newtarget.case +// - src/async-functions/evaluation/async-class-decl-private-method.template +/*--- +description: Async function returns an async function. (Async private method as a ClassDeclaration element) +esid: prod-AsyncMethod +features: [async-functions, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncMethod + + Async Function Definitions + + AsyncMethod : + async [no LineTerminator here] # PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + +---*/ +let count = 0; + + +class C { + async #method(x) { + return async () => new.target; + } + async method(x) { + return this.#method(x); + } +} +// Stores a reference `asyncFn` for case evaluation +let c = new C(); +let asyncFn = c.method.bind(c); + +asyncFn().then(retFn => { + count++; + return retFn(); +}).then(result => { + assert.sameValue(result, undefined); + assert.sameValue(count, 1); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/async-private-method/returns-async-arrow.js b/js/src/tests/test262/language/statements/class/elements/async-private-method/returns-async-arrow.js new file mode 100644 index 0000000000..ee8b999095 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-private-method/returns-async-arrow.js @@ -0,0 +1,44 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-functions/returns-async-arrow.case +// - src/async-functions/evaluation/async-class-decl-private-method.template +/*--- +description: Async function returns an async function. (Async private method as a ClassDeclaration element) +esid: prod-AsyncMethod +features: [async-functions, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncMethod + + Async Function Definitions + + AsyncMethod : + async [no LineTerminator here] # PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + +---*/ +let count = 0; + + +class C { + async #method(x) { + return async () => x; + } + async method(x) { + return this.#method(x); + } +} +// Stores a reference `asyncFn` for case evaluation +let c = new C(); +let asyncFn = c.method.bind(c); + +asyncFn(1).then(retFn => { + count++; + return retFn(); +}).then(result => { + assert.sameValue(result, 1); + assert.sameValue(count, 1); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/async-private-method/returns-async-function-returns-arguments-from-own-function.js b/js/src/tests/test262/language/statements/class/elements/async-private-method/returns-async-function-returns-arguments-from-own-function.js new file mode 100644 index 0000000000..462ae56bc6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-private-method/returns-async-function-returns-arguments-from-own-function.js @@ -0,0 +1,45 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-functions/returns-async-function-returns-arguments-from-own-function.case +// - src/async-functions/evaluation/async-class-decl-private-method.template +/*--- +description: Async function returns an async function. (Async private method as a ClassDeclaration element) +esid: prod-AsyncMethod +features: [async-functions, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncMethod + + Async Function Definitions + + AsyncMethod : + async [no LineTerminator here] # PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + +---*/ +let count = 0; + + +class C { + async #method(x) { + let a = arguments; + return async function() { return a === arguments; }; + } + async method(x) { + return this.#method(x); + } +} +// Stores a reference `asyncFn` for case evaluation +let c = new C(); +let asyncFn = c.method.bind(c); + +asyncFn(1).then(retFn => { + count++; + return retFn(); +}).then(result => { + assert.sameValue(result, false); + assert.sameValue(count, 1); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/async-private-method/returns-async-function-returns-newtarget.js b/js/src/tests/test262/language/statements/class/elements/async-private-method/returns-async-function-returns-newtarget.js new file mode 100644 index 0000000000..6046cef1b4 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-private-method/returns-async-function-returns-newtarget.js @@ -0,0 +1,44 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-functions/returns-async-function-returns-newtarget.case +// - src/async-functions/evaluation/async-class-decl-private-method.template +/*--- +description: Async function returns an async function. (Async private method as a ClassDeclaration element) +esid: prod-AsyncMethod +features: [async-functions, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncMethod + + Async Function Definitions + + AsyncMethod : + async [no LineTerminator here] # PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + +---*/ +let count = 0; + + +class C { + async #method(x) { + return async function() { return new.target; }; + } + async method(x) { + return this.#method(x); + } +} +// Stores a reference `asyncFn` for case evaluation +let c = new C(); +let asyncFn = c.method.bind(c); + +asyncFn(1).then(retFn => { + count++; + return retFn(); +}).then(result => { + assert.sameValue(result, undefined); + assert.sameValue(count, 1); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/async-private-method/returns-async-function.js b/js/src/tests/test262/language/statements/class/elements/async-private-method/returns-async-function.js new file mode 100644 index 0000000000..2dc6bce21a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/async-private-method/returns-async-function.js @@ -0,0 +1,44 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/async-functions/returns-async-function.case +// - src/async-functions/evaluation/async-class-decl-private-method.template +/*--- +description: Async function returns an async function. (Async private method as a ClassDeclaration element) +esid: prod-AsyncMethod +features: [async-functions, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncMethod + + Async Function Definitions + + AsyncMethod : + async [no LineTerminator here] # PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + +---*/ +let count = 0; + + +class C { + async #method(x) { + return async function() { return x; }; + } + async method(x) { + return this.#method(x); + } +} +// Stores a reference `asyncFn` for case evaluation +let c = new C(); +let asyncFn = c.method.bind(c); + +asyncFn(1).then(retFn => { + count++; + return retFn(); +}).then(result => { + assert.sameValue(result, 1); + assert.sameValue(count, 1); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/async-private-method/shell.js b/js/src/tests/test262/language/statements/class/elements/async-private-method/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/elements/browser.js b/js/src/tests/test262/language/statements/class/elements/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/elements/class-field-is-observable-by-proxy.js b/js/src/tests/test262/language/statements/class/elements/class-field-is-observable-by-proxy.js new file mode 100644 index 0000000000..9585324332 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/class-field-is-observable-by-proxy.js @@ -0,0 +1,48 @@ +// Copyright (C) 2019 Caio Lima. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Public class fields initialization calls [[DefineOwnProperty]] +esid: sec-define-field +info: | + DefineField(receiver, fieldRecord) + ... + 8. If fieldName is a Private Name, + a. Perform ? PrivateFieldAdd(fieldName, receiver, initValue). + 9. Else, + a. Assert: IsPropertyKey(fieldName) is true. + b. Perform ? CreateDataPropertyOrThrow(receiver, fieldName, initValue). + 10. Return. +includes: [compareArray.js] +features: [class, class-fields-public, Proxy] +---*/ + +let arr = []; +let expectedTarget = null; +function ProxyBase() { + expectedTarget = this; + return new Proxy(this, { + defineProperty: function (target, key, descriptor) { + arr.push(key); + arr.push(descriptor.value); + arr.push(target); + assert.sameValue(descriptor.enumerable, true); + assert.sameValue(descriptor.configurable, true); + assert.sameValue(descriptor.writable, true); + return Reflect.defineProperty(target, key, descriptor); + } + }); +} + +class Test extends ProxyBase { + f = 3; + g = "Test262"; +} + +let t = new Test(); +assert.sameValue(t.f, 3); +assert.sameValue(t.g, "Test262"); + +assert.compareArray(arr, ["f", 3, expectedTarget, "g", "Test262", expectedTarget]); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/class-field-on-frozen-objects-strict.js b/js/src/tests/test262/language/statements/class/elements/class-field-on-frozen-objects-strict.js new file mode 100644 index 0000000000..94a86d6694 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/class-field-on-frozen-objects-strict.js @@ -0,0 +1,30 @@ +'use strict'; +// Copyright (C) 2019 Caio Lima. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Public class field initialization fails on frozen object +esid: sec-define-field +info: | + DefineField(receiver, fieldRecord) + ... + 8. If fieldName is a Private Name, + a. Perform ? PrivateFieldAdd(fieldName, receiver, initValue). + 9. Else, + a. Assert: IsPropertyKey(fieldName) is true. + b. Perform ? CreateDataPropertyOrThrow(receiver, fieldName, initValue). + 10. Return. +features: [class, class-fields-public] +flags: [onlyStrict] +---*/ + +class Test { + f = Object.freeze(this); + g = "Test262"; +} + +assert.throws(TypeError, function() { + new Test(); +}, "Frozen objects can't be changed"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/comp-name-init-err-contains-arguments.js b/js/src/tests/test262/language/statements/class/elements/comp-name-init-err-contains-arguments.js new file mode 100644 index 0000000000..2b0b71942b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/comp-name-init-err-contains-arguments.js @@ -0,0 +1,36 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/init-err-contains-arguments.case +// - src/class-elements/initializer-error/cls-decl-fields-comp-name.template +/*--- +description: Syntax error if `arguments` used in class field (computed ClassElementName) +esid: sec-class-definitions-static-semantics-early-errors +features: [class, class-fields-public, computed-property-names] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Static Semantics: Early Errors + + FieldDefinition: + PropertyNameInitializeropt + + - It is a Syntax Error if ContainsArguments of Initializer is true. + + Static Semantics: ContainsArguments + IdentifierReference : Identifier + + 1. If the StringValue of Identifier is "arguments", return true. + ... + For all other grammatical productions, recurse on all nonterminals. If any piece returns true, then return true. Otherwise return false. + +---*/ + + +$DONOTEVALUATE(); + +var x = "string"; +class C { + [x] = arguments; +} diff --git a/js/src/tests/test262/language/statements/class/elements/comp-name-init-err-contains-super.js b/js/src/tests/test262/language/statements/class/elements/comp-name-init-err-contains-super.js new file mode 100644 index 0000000000..84a2c49a34 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/comp-name-init-err-contains-super.js @@ -0,0 +1,29 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/init-err-contains-super.case +// - src/class-elements/initializer-error/cls-decl-fields-comp-name.template +/*--- +description: Syntax error if `super()` used in class field (computed ClassElementName) +esid: sec-class-definitions-static-semantics-early-errors +features: [class, class-fields-public, computed-property-names] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Static Semantics: Early Errors + + FieldDefinition: + PropertyNameInitializeropt + + - It is a Syntax Error if Initializer is present and Initializer Contains SuperCall is true. + +---*/ + + +$DONOTEVALUATE(); + +var x = "string"; +class C { + [x] = super(); +} diff --git a/js/src/tests/test262/language/statements/class/elements/computed-name-toprimitive-symbol.js b/js/src/tests/test262/language/statements/class/elements/computed-name-toprimitive-symbol.js new file mode 100644 index 0000000000..ead50e26dd --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/computed-name-toprimitive-symbol.js @@ -0,0 +1,123 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/computed-name-toprimitive-symbol.case +// - src/class-elements/default/cls-decl.template +/*--- +description: ToPrimitive evaluation in the ComputedPropertyName (field definitions in a class declaration) +esid: prod-FieldDefinition +features: [class-fields-public, computed-property-names, Symbol.toPrimitive, Symbol, class] +flags: [generated] +includes: [propertyHelper.js] +info: | + Runtime Semantics: ClassDefinitionEvaluation + + ... + 27. For each ClassElement e in order from elements + a. If IsStatic of me is false, then + i. Let fields be the result of performing ClassElementEvaluation for e with arguments proto and false. + b. Else, + i. Let fields be the result of performing ClassElementEvaluation for e with arguments F and false. + c. If fields is an abrupt completion, then + i. Set the running execution context's LexicalEnvironment to lex. + ii. Set the running execution context's PrivateNameEnvironment to outerPrivateEnvironment. + iii. Return Completion(status). + ... + + Runtime Semantics: ClassElementEvaluation + + ClassElement: FieldDefinition; + Return ClassFieldDefinitionEvaluation of FieldDefinition with parameter false and object. + + Runtime Semantics: ClassFieldDefinitionEvaluation + With parameters isStatic and homeObject. + + 1. Let fieldName be the result of evaluating ClassElementName. + 2. ReturnIfAbrupt(fieldName). + ... + + Runtime Semantics: Evaluation + ComputedPropertyName: [ AssignmentExpression ] + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let propName be ? GetValue(exprValue). + 3. Return ? ToPropertyKey(propName). + +---*/ +var s1 = Symbol(); +var s2 = Symbol(); +var s3 = Symbol(); +var err = function() { throw new Test262Error(); }; +var obj1 = { + [Symbol.toPrimitive]: function() { return s1; }, + toString: err, + valueOf: err +}; + +var obj2 = { + toString: function() { return s2; }, + valueOf: err +}; + +var obj3 = { + toString: undefined, + valueOf: function() { return s3; } +}; + + + +class C { + [obj1] = 42; + [obj2] = 43; + [obj3] = 44; +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, s1), + "s1 doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, s1), + "s1 doesn't appear as an own property on C constructor" +); + +verifyProperty(c, s1, { + value: 42, + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, s2), + "s2 doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, s2), + "s2 doesn't appear as an own property on C constructor" +); + +verifyProperty(c, s2, { + value: 43, + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, s3), + "s3 doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, s3), + "s3 doesn't appear as an own property on C constructor" +); + +verifyProperty(c, s3, { + value: 44, + enumerable: true, + writable: true, + configurable: true +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/computed-name-toprimitive.js b/js/src/tests/test262/language/statements/class/elements/computed-name-toprimitive.js new file mode 100644 index 0000000000..684907a32d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/computed-name-toprimitive.js @@ -0,0 +1,120 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/computed-name-toprimitive.case +// - src/class-elements/default/cls-decl.template +/*--- +description: ToPrimitive evaluation in the ComputedPropertyName (field definitions in a class declaration) +esid: prod-FieldDefinition +features: [class-fields-public, computed-property-names, Symbol.toPrimitive, class] +flags: [generated] +includes: [propertyHelper.js] +info: | + Runtime Semantics: ClassDefinitionEvaluation + + ... + 27. For each ClassElement e in order from elements + a. If IsStatic of me is false, then + i. Let fields be the result of performing ClassElementEvaluation for e with arguments proto and false. + b. Else, + i. Let fields be the result of performing ClassElementEvaluation for e with arguments F and false. + c. If fields is an abrupt completion, then + i. Set the running execution context's LexicalEnvironment to lex. + ii. Set the running execution context's PrivateNameEnvironment to outerPrivateEnvironment. + iii. Return Completion(status). + ... + + Runtime Semantics: ClassElementEvaluation + + ClassElement: FieldDefinition; + Return ClassFieldDefinitionEvaluation of FieldDefinition with parameter false and object. + + Runtime Semantics: ClassFieldDefinitionEvaluation + With parameters isStatic and homeObject. + + 1. Let fieldName be the result of evaluating ClassElementName. + 2. ReturnIfAbrupt(fieldName). + ... + + Runtime Semantics: Evaluation + ComputedPropertyName: [ AssignmentExpression ] + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let propName be ? GetValue(exprValue). + 3. Return ? ToPropertyKey(propName). + +---*/ +var err = function() { throw new Test262Error(); }; +var obj1 = { + [Symbol.toPrimitive]: function() { return "d"; }, + toString: err, + valueOf: err +}; + +var obj2 = { + toString: function() { return "e"; }, + valueOf: err +}; + +var obj3 = { + toString: undefined, + valueOf: function() { return "f"; } +}; + + + +class C { + [obj1] = 42; + [obj2] = 43; + [obj3] = 44; +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "d"), + "d doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "d"), + "d doesn't appear as an own property on C constructor" +); + +verifyProperty(c, "d", { + value: 42, + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "e"), + "e doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "e"), + "e doesn't appear as an own property on C constructor" +); + +verifyProperty(c, "e", { + value: 43, + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "f"), + "f doesn't appear as an own property on C prototype" +); +assert(! + Object.prototype.hasOwnProperty.call(C, "f"), + "f doesn't appear as an own property on C constructor" +); + +verifyProperty(c, "f", { + value: 44, + enumerable: true, + writable: true, + configurable: true +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/computed-property-abrupt-completition.js b/js/src/tests/test262/language/statements/class/elements/computed-property-abrupt-completition.js new file mode 100644 index 0000000000..c07ed35e8a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/computed-property-abrupt-completition.js @@ -0,0 +1,45 @@ +// Copyright (C) 2019 Caio Lima (Igalia SL). All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: PrivateFieldGet should return with abrupt completion +esid: runtime-semantics-class-definition-evaluation +info: | + ClassTail : ClassHeritage { ClassBody } + ... + 28. For each ClassElement e in order from elements, + a. If IsStatic of e is false, then + i. Let field be the result of performing ClassElementEvaluation for e with arguments proto and false. + b. Else, + i. Let field be the result of performing PropertyDefinitionEvaluation for mClassElementEvaluation for e with arguments F and false. + c. If field is an abrupt completion, then + i. Set the running execution context's LexicalEnvironment to lex. + ii. Set the running execution context's PrivateEnvironment to outerPrivateEnvironment. + iii. Return Completion(field). + ... +features: [class-fields-public, class-static-fields-public, class] +---*/ + +function abruptCompletion() { + throw new Test262Error(); +} + +let neverExecuted = false; + +assert.throws(Test262Error, function() { + class C { + [abruptCompletion()]; + [neverExecuted = true]; + } +}, 'computed property should have abrupt completion'); +assert.sameValue(neverExecuted, false); + +assert.throws(Test262Error, function() { + class C { + static [abruptCompletion()]; + [neverExecuted = true]; + } +}, 'static computed property should have abrupt completion'); +assert.sameValue(neverExecuted, false); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/ctor-called-after-fields-init.js b/js/src/tests/test262/language/statements/class/elements/ctor-called-after-fields-init.js new file mode 100644 index 0000000000..77e483856d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/ctor-called-after-fields-init.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/ctor-called-after-fields-init.case +// - src/class-elements/default/cls-decl.template +/*--- +description: The constructor method is called after the fields are initalized (field definitions in a class declaration) +esid: prod-FieldDefinition +features: [class-fields-public, class] +flags: [generated] +info: | + [[Construct]] ( argumentsList, newTarget) + + 8. If kind is "base", then + a. Perform OrdinaryCallBindThis(F, calleeContext, thisArgument). + b. Let result be InitializeInstanceFields(thisArgument, F). + ... + ... + 11. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + ... + +---*/ +var ctor; + + +class C { + constructor() { + ctor = this.foo; + } + foo = 42; +} + +var c = new C(); + +assert.sameValue(ctor, 42); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/derived-cls-direct-eval-contains-superproperty-1.js b/js/src/tests/test262/language/statements/class/elements/derived-cls-direct-eval-contains-superproperty-1.js new file mode 100644 index 0000000000..ae4d849ba1 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/derived-cls-direct-eval-contains-superproperty-1.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/eval-contains-superproperty-1.case +// - src/class-elements/initializer-eval-super-property/cls-decl-fields-eval.template +/*--- +description: super.x in StatementList of eval (direct eval) +esid: sec-performeval-rules-in-initializer +features: [class, class-fields-public] +flags: [generated] +info: | + Additional Early Error Rules for Eval Inside Initializer + These static semantics are applied by PerformEval when a direct eval call occurs inside a class field initializer. + ScriptBody : StatementList + + ... + The remaining eval rules apply as outside a constructor, inside a method, and inside a function. + + Additional Early Error Rules for Eval Outside Methods + These static semantics are applied by PerformEval when a direct eval call occurs outside of a MethodDefinition. + ScriptBody : StatementList + + It is a Syntax Error if StatementList Contains SuperProperty. + +---*/ + + +var executed = false; +class A {} +class C extends A { + x = eval('executed = true; super.x;'); +} + +new C(); + +assert.sameValue(executed, true); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/derived-cls-direct-eval-contains-superproperty-2.js b/js/src/tests/test262/language/statements/class/elements/derived-cls-direct-eval-contains-superproperty-2.js new file mode 100644 index 0000000000..f070550b43 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/derived-cls-direct-eval-contains-superproperty-2.js @@ -0,0 +1,33 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/eval-contains-superproperty-2.case +// - src/class-elements/initializer-eval-super-property/cls-decl-fields-eval.template +/*--- +description: super['x'] in StatementList of eval (direct eval) +esid: sec-performeval-rules-in-initializer +features: [class, class-fields-public] +flags: [generated] +info: | + The remaining eval rules apply as outside a constructor, inside a method, and inside a function. + + Additional Early Error Rules for Eval Outside Methods + + These static semantics are applied by PerformEval when a direct eval call occurs outside of a MethodDefinition. + + ScriptBody : StatementList + + It is a Syntax Error if StatementList Contains SuperProperty. + +---*/ + + +var executed = false; +class A {} +class C extends A { + x = eval('executed = true; super["x"];'); +} + +new C(); + +assert.sameValue(executed, true); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/derived-cls-direct-eval-err-contains-supercall-1.js b/js/src/tests/test262/language/statements/class/elements/derived-cls-direct-eval-err-contains-supercall-1.js new file mode 100644 index 0000000000..3bee4474f2 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/derived-cls-direct-eval-err-contains-supercall-1.js @@ -0,0 +1,38 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/eval-err-contains-supercall-1.case +// - src/class-elements/initializer-eval-super-call/cls-decl-fields-eval.template +/*--- +description: error if `super()['x']` in StatementList of eval (direct eval) +esid: sec-performeval-rules-in-initializer +features: [class, class-fields-public] +flags: [generated] +info: | + Additional Early Error Rules for Eval Inside Initializer + These static semantics are applied by PerformEval when a direct eval call occurs inside a class field initializer. + ScriptBody : StatementList + + ... + The remaining eval rules apply as outside a constructor, inside a method, and inside a function. + + Additional Early Error Rules for Eval Outside Constructor Methods + These static semantics are applied by PerformEval when a direct eval call occurs outside of the constructor method of a ClassDeclaration or ClassExpression. + ScriptBody : StatementList + + It is a Syntax Error if StatementList Contains SuperCall. + +---*/ + + +var executed = false; +class A {} +class C extends A { + x = eval('executed = true; super()["x"];'); +} + +assert.throws(SyntaxError, function() { + new C(); +}); + +assert.sameValue(executed, false); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/derived-cls-direct-eval-err-contains-supercall-2.js b/js/src/tests/test262/language/statements/class/elements/derived-cls-direct-eval-err-contains-supercall-2.js new file mode 100644 index 0000000000..ce07927be2 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/derived-cls-direct-eval-err-contains-supercall-2.js @@ -0,0 +1,31 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/eval-err-contains-supercall-2.case +// - src/class-elements/initializer-eval-super-call/cls-decl-fields-eval.template +/*--- +description: error if `super().x` in StatementList of eval (direct eval) +esid: sec-performeval-rules-in-initializer +features: [class, class-fields-public] +flags: [generated] +info: | + Additional Early Error Rules for Eval Outside Constructor Methods + These static semantics are applied by PerformEval when a direct eval call occurs outside of the constructor method of a ClassDeclaration or ClassExpression. + ScriptBody : StatementList + + It is a Syntax Error if StatementList Contains SuperCall. + +---*/ + + +var executed = false; +class A {} +class C extends A { + x = eval('executed = true; super().x;'); +} + +assert.throws(SyntaxError, function() { + new C(); +}); + +assert.sameValue(executed, false); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/derived-cls-direct-eval-err-contains-supercall.js b/js/src/tests/test262/language/statements/class/elements/derived-cls-direct-eval-err-contains-supercall.js new file mode 100644 index 0000000000..cd2af53ae0 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/derived-cls-direct-eval-err-contains-supercall.js @@ -0,0 +1,38 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/eval-err-contains-supercall.case +// - src/class-elements/initializer-eval-super-call/cls-decl-fields-eval.template +/*--- +description: error if `super()` in StatementList of eval (direct eval) +esid: sec-performeval-rules-in-initializer +features: [class, class-fields-public] +flags: [generated] +info: | + Additional Early Error Rules for Eval Inside Initializer + These static semantics are applied by PerformEval when a direct eval call occurs inside a class field initializer. + ScriptBody : StatementList + + ... + The remaining eval rules apply as outside a constructor, inside a method, and inside a function. + + Additional Early Error Rules for Eval Outside Constructor Methods + These static semantics are applied by PerformEval when a direct eval call occurs outside of the constructor method of a ClassDeclaration or ClassExpression. + ScriptBody : StatementList + + It is a Syntax Error if StatementList Contains SuperCall. + +---*/ + + +var executed = false; +class A {} +class C extends A { + x = eval('executed = true; super();'); +} + +assert.throws(SyntaxError, function() { + new C(); +}); + +assert.sameValue(executed, false); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/derived-cls-indirect-eval-contains-superproperty-1.js b/js/src/tests/test262/language/statements/class/elements/derived-cls-indirect-eval-contains-superproperty-1.js new file mode 100644 index 0000000000..27895ab1a4 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/derived-cls-indirect-eval-contains-superproperty-1.js @@ -0,0 +1,38 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/eval-contains-superproperty-1.case +// - src/class-elements/initializer-eval-super-property/cls-decl-fields-indirect-eval.template +/*--- +description: super.x in StatementList of eval (indirect eval) +esid: sec-performeval-rules-in-initializer +features: [class, class-fields-public] +flags: [generated] +info: | + Additional Early Error Rules for Eval Inside Initializer + These static semantics are applied by PerformEval when a direct eval call occurs inside a class field initializer. + ScriptBody : StatementList + + ... + The remaining eval rules apply as outside a constructor, inside a method, and inside a function. + + Additional Early Error Rules for Eval Outside Methods + These static semantics are applied by PerformEval when a direct eval call occurs outside of a MethodDefinition. + ScriptBody : StatementList + + It is a Syntax Error if StatementList Contains SuperProperty. + +---*/ + + +var executed = false; +class A {} +class C extends A { + x = (0, eval)('executed = true; super.x;'); +} + +assert.throws(SyntaxError, function() { + new C(); +}); + +assert.sameValue(executed, false); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/derived-cls-indirect-eval-contains-superproperty-2.js b/js/src/tests/test262/language/statements/class/elements/derived-cls-indirect-eval-contains-superproperty-2.js new file mode 100644 index 0000000000..a6f86a2af5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/derived-cls-indirect-eval-contains-superproperty-2.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/eval-contains-superproperty-2.case +// - src/class-elements/initializer-eval-super-property/cls-decl-fields-indirect-eval.template +/*--- +description: super['x'] in StatementList of eval (indirect eval) +esid: sec-performeval-rules-in-initializer +features: [class, class-fields-public] +flags: [generated] +info: | + The remaining eval rules apply as outside a constructor, inside a method, and inside a function. + + Additional Early Error Rules for Eval Outside Methods + + These static semantics are applied by PerformEval when a direct eval call occurs outside of a MethodDefinition. + + ScriptBody : StatementList + + It is a Syntax Error if StatementList Contains SuperProperty. + +---*/ + + +var executed = false; +class A {} +class C extends A { + x = (0, eval)('executed = true; super["x"];'); +} + +assert.throws(SyntaxError, function() { + new C(); +}); + +assert.sameValue(executed, false); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/derived-cls-indirect-eval-err-contains-supercall-1.js b/js/src/tests/test262/language/statements/class/elements/derived-cls-indirect-eval-err-contains-supercall-1.js new file mode 100644 index 0000000000..6daeaa5d31 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/derived-cls-indirect-eval-err-contains-supercall-1.js @@ -0,0 +1,38 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/eval-err-contains-supercall-1.case +// - src/class-elements/initializer-eval-super-call/cls-decl-fields-indirect-eval.template +/*--- +description: error if `super()['x']` in StatementList of eval (indirect eval) +esid: sec-performeval-rules-in-initializer +features: [class, class-fields-public] +flags: [generated] +info: | + Additional Early Error Rules for Eval Inside Initializer + These static semantics are applied by PerformEval when a direct eval call occurs inside a class field initializer. + ScriptBody : StatementList + + ... + The remaining eval rules apply as outside a constructor, inside a method, and inside a function. + + Additional Early Error Rules for Eval Outside Constructor Methods + These static semantics are applied by PerformEval when a direct eval call occurs outside of the constructor method of a ClassDeclaration or ClassExpression. + ScriptBody : StatementList + + It is a Syntax Error if StatementList Contains SuperCall. + +---*/ + + +var executed = false; +class A {} +class C extends A { + x = (0, eval)('executed = true; super()["x"];'); +} + +assert.throws(SyntaxError, function() { + new C(); +}); + +assert.sameValue(executed, false); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/derived-cls-indirect-eval-err-contains-supercall-2.js b/js/src/tests/test262/language/statements/class/elements/derived-cls-indirect-eval-err-contains-supercall-2.js new file mode 100644 index 0000000000..ac275cc028 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/derived-cls-indirect-eval-err-contains-supercall-2.js @@ -0,0 +1,31 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/eval-err-contains-supercall-2.case +// - src/class-elements/initializer-eval-super-call/cls-decl-fields-indirect-eval.template +/*--- +description: error if `super().x` in StatementList of eval (indirect eval) +esid: sec-performeval-rules-in-initializer +features: [class, class-fields-public] +flags: [generated] +info: | + Additional Early Error Rules for Eval Outside Constructor Methods + These static semantics are applied by PerformEval when a direct eval call occurs outside of the constructor method of a ClassDeclaration or ClassExpression. + ScriptBody : StatementList + + It is a Syntax Error if StatementList Contains SuperCall. + +---*/ + + +var executed = false; +class A {} +class C extends A { + x = (0, eval)('executed = true; super().x;'); +} + +assert.throws(SyntaxError, function() { + new C(); +}); + +assert.sameValue(executed, false); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/derived-cls-indirect-eval-err-contains-supercall.js b/js/src/tests/test262/language/statements/class/elements/derived-cls-indirect-eval-err-contains-supercall.js new file mode 100644 index 0000000000..08f77e8118 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/derived-cls-indirect-eval-err-contains-supercall.js @@ -0,0 +1,38 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/eval-err-contains-supercall.case +// - src/class-elements/initializer-eval-super-call/cls-decl-fields-indirect-eval.template +/*--- +description: error if `super()` in StatementList of eval (indirect eval) +esid: sec-performeval-rules-in-initializer +features: [class, class-fields-public] +flags: [generated] +info: | + Additional Early Error Rules for Eval Inside Initializer + These static semantics are applied by PerformEval when a direct eval call occurs inside a class field initializer. + ScriptBody : StatementList + + ... + The remaining eval rules apply as outside a constructor, inside a method, and inside a function. + + Additional Early Error Rules for Eval Outside Constructor Methods + These static semantics are applied by PerformEval when a direct eval call occurs outside of the constructor method of a ClassDeclaration or ClassExpression. + ScriptBody : StatementList + + It is a Syntax Error if StatementList Contains SuperCall. + +---*/ + + +var executed = false; +class A {} +class C extends A { + x = (0, eval)('executed = true; super();'); +} + +assert.throws(SyntaxError, function() { + new C(); +}); + +assert.sameValue(executed, false); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/direct-eval-err-contains-arguments.js b/js/src/tests/test262/language/statements/class/elements/direct-eval-err-contains-arguments.js new file mode 100644 index 0000000000..32ef0e5489 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/direct-eval-err-contains-arguments.js @@ -0,0 +1,38 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/eval-err-contains-arguments.case +// - src/class-elements/initializer-direct-eval-arguments/cls-decl-fields-eval.template +/*--- +description: error if `arguments` in StatementList of eval (direct eval) +esid: sec-performeval-rules-in-initializer +features: [class, class-fields-public] +flags: [generated] +info: | + Additional Early Error Rules for Eval Inside Initializer + These static semantics are applied by PerformEval when a direct eval call occurs inside a class field initializer. + ScriptBody : StatementList + + It is a Syntax Error if ContainsArguments of StatementList is true. + ... + + Static Semantics: ContainsArguments + IdentifierReference : Identifier + + 1. If the StringValue of Identifier is "arguments", return true. + ... + For all other grammatical productions, recurse on all nonterminals. If any piece returns true, then return true. Otherwise return false. + +---*/ + + +var executed = false; +class C { + x = eval('executed = true; arguments;'); +} + +assert.throws(SyntaxError, function() { + new C(); +}); + +assert.sameValue(executed, false); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/direct-eval-err-contains-newtarget.js b/js/src/tests/test262/language/statements/class/elements/direct-eval-err-contains-newtarget.js new file mode 100644 index 0000000000..8097d57801 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/direct-eval-err-contains-newtarget.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/eval-err-contains-newtarget.case +// - src/class-elements/initializer-eval-newtarget/cls-decl-fields-eval.template +/*--- +description: error if `new.target` in StatementList of eval (direct eval) +esid: sec-performeval-rules-in-initializer +features: [class, new.target, class-fields-public] +flags: [generated] +info: | + Additional Early Error Rules for Eval Inside Initializer + These static semantics are applied by PerformEval when a direct eval call occurs inside a class field initializer. + ScriptBody : StatementList + + ... + The remaining eval rules apply as outside a constructor, inside a method, and inside a function. + + Additional Early Error Rules for Eval Outside Functions + These static semantics are applied by PerformEval when a direct eval call occurs outside of any function. + ScriptBody : StatementList + + It is a Syntax Error if StatementList Contains NewTarget. + +---*/ + + +var executed = false; +class C { + x = eval('executed = true; new.target;'); +} + +var c = new C(); + +assert.sameValue(executed, true); +assert.sameValue(c.x, undefined); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/equality-init-err-contains-arguments.js b/js/src/tests/test262/language/statements/class/elements/equality-init-err-contains-arguments.js new file mode 100644 index 0000000000..7d88fd26f8 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/equality-init-err-contains-arguments.js @@ -0,0 +1,35 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/init-err-contains-arguments.case +// - src/class-elements/initializer-error/cls-decl-fields-equality.template +/*--- +description: Syntax error if `arguments` used in class field (equality expression) +esid: sec-class-definitions-static-semantics-early-errors +features: [class, class-fields-public] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Static Semantics: Early Errors + + FieldDefinition: + PropertyNameInitializeropt + + - It is a Syntax Error if ContainsArguments of Initializer is true. + + Static Semantics: ContainsArguments + IdentifierReference : Identifier + + 1. If the StringValue of Identifier is "arguments", return true. + ... + For all other grammatical productions, recurse on all nonterminals. If any piece returns true, then return true. Otherwise return false. + +---*/ + + +$DONOTEVALUATE(); + +class C { + x = {} == arguments; +} diff --git a/js/src/tests/test262/language/statements/class/elements/equality-init-err-contains-super.js b/js/src/tests/test262/language/statements/class/elements/equality-init-err-contains-super.js new file mode 100644 index 0000000000..5eba280e2b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/equality-init-err-contains-super.js @@ -0,0 +1,28 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/init-err-contains-super.case +// - src/class-elements/initializer-error/cls-decl-fields-equality.template +/*--- +description: Syntax error if `super()` used in class field (equality expression) +esid: sec-class-definitions-static-semantics-early-errors +features: [class, class-fields-public] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Static Semantics: Early Errors + + FieldDefinition: + PropertyNameInitializeropt + + - It is a Syntax Error if Initializer is present and Initializer Contains SuperCall is true. + +---*/ + + +$DONOTEVALUATE(); + +class C { + x = {} == super(); +} diff --git a/js/src/tests/test262/language/statements/class/elements/evaluation-error/browser.js b/js/src/tests/test262/language/statements/class/elements/evaluation-error/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/elements/evaluation-error/computed-name-referenceerror.js b/js/src/tests/test262/language/statements/class/elements/evaluation-error/computed-name-referenceerror.js new file mode 100644 index 0000000000..4c59e16268 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/evaluation-error/computed-name-referenceerror.js @@ -0,0 +1,58 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/computed-name-referenceerror.case +// - src/class-elements/class-evaluation-error/cls-decl.template +/*--- +description: ReferenceError evaluating a computed property name (field definitions in a class declaration) +esid: sec-runtime-semantics-classdefinitionevaluation +features: [class-fields-public, computed-property-names, class] +flags: [generated] +info: | + Runtime Semantics: ClassDefinitionEvaluation + + ... + 27. For each ClassElement e in order from elements + a. If IsStatic of me is false, then + i. Let fields be the result of performing ClassElementEvaluation for e with arguments proto and false. + b. Else, + i. Let fields be the result of performing ClassElementEvaluation for e with arguments F and false. + c. If fields is an abrupt completion, then + i. Set the running execution context's LexicalEnvironment to lex. + ii. Set the running execution context's PrivateNameEnvironment to outerPrivateEnvironment. + iii. Return Completion(status). + ... + + Runtime Semantics: ClassElementEvaluation + + ClassElement: FieldDefinition; + Return ClassFieldDefinitionEvaluation of FieldDefinition with parameter false and object. + + Runtime Semantics: ClassFieldDefinitionEvaluation + With parameters isStatic and homeObject. + + 1. Let fieldName be the result of evaluating ClassElementName. + 2. ReturnIfAbrupt(fieldName). + ... + + Runtime Semantics: Evaluation + ComputedPropertyName: [ AssignmentExpression ] + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let propName be ? GetValue(exprValue). + 3. Return ? ToPropertyKey(propName). + +---*/ +function fn() { + throw new Test262Error(); +} + + + +function evaluate() { + class C { + [noRef] = fn(); + } +} + +assert.throws(ReferenceError, evaluate); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/evaluation-error/computed-name-toprimitive-err.js b/js/src/tests/test262/language/statements/class/elements/evaluation-error/computed-name-toprimitive-err.js new file mode 100644 index 0000000000..204d772fbe --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/evaluation-error/computed-name-toprimitive-err.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/computed-name-toprimitive-err.case +// - src/class-elements/class-evaluation-error/cls-decl.template +/*--- +description: Custom error evaluating a computed property name (field definitions in a class declaration) +esid: sec-runtime-semantics-classdefinitionevaluation +features: [class-fields-public, computed-property-names, Symbol.toPrimitive, class] +flags: [generated] +info: | + Runtime Semantics: ClassDefinitionEvaluation + + ... + 27. For each ClassElement e in order from elements + a. If IsStatic of me is false, then + i. Let fields be the result of performing ClassElementEvaluation for e with arguments proto and false. + b. Else, + i. Let fields be the result of performing ClassElementEvaluation for e with arguments F and false. + c. If fields is an abrupt completion, then + i. Set the running execution context's LexicalEnvironment to lex. + ii. Set the running execution context's PrivateNameEnvironment to outerPrivateEnvironment. + iii. Return Completion(status). + ... + + Runtime Semantics: ClassElementEvaluation + + ClassElement: FieldDefinition; + Return ClassFieldDefinitionEvaluation of FieldDefinition with parameter false and object. + + Runtime Semantics: ClassFieldDefinitionEvaluation + With parameters isStatic and homeObject. + + 1. Let fieldName be the result of evaluating ClassElementName. + 2. ReturnIfAbrupt(fieldName). + ... + + Runtime Semantics: Evaluation + ComputedPropertyName: [ AssignmentExpression ] + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let propName be ? GetValue(exprValue). + 3. Return ? ToPropertyKey(propName). + +---*/ +var obj = { + [Symbol.toPrimitive]: function() { + throw new Test262Error(); + } +}; + + + +function evaluate() { + class C { + [obj] + } +} + +assert.throws(Test262Error, evaluate); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/evaluation-error/computed-name-toprimitive-returns-noncallable.js b/js/src/tests/test262/language/statements/class/elements/evaluation-error/computed-name-toprimitive-returns-noncallable.js new file mode 100644 index 0000000000..f995fe93e0 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/evaluation-error/computed-name-toprimitive-returns-noncallable.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/computed-name-toprimitive-returns-noncallable.case +// - src/class-elements/class-evaluation-error/cls-decl.template +/*--- +description: Custom error evaluating a computed property name (field definitions in a class declaration) +esid: sec-runtime-semantics-classdefinitionevaluation +features: [class-fields-public, computed-property-names, Symbol.toPrimitive, class] +flags: [generated] +info: | + Runtime Semantics: ClassDefinitionEvaluation + + ... + 27. For each ClassElement e in order from elements + a. If IsStatic of me is false, then + i. Let fields be the result of performing ClassElementEvaluation for e with arguments proto and false. + b. Else, + i. Let fields be the result of performing ClassElementEvaluation for e with arguments F and false. + c. If fields is an abrupt completion, then + i. Set the running execution context's LexicalEnvironment to lex. + ii. Set the running execution context's PrivateNameEnvironment to outerPrivateEnvironment. + iii. Return Completion(status). + ... + + Runtime Semantics: ClassElementEvaluation + + ClassElement: FieldDefinition; + Return ClassFieldDefinitionEvaluation of FieldDefinition with parameter false and object. + + Runtime Semantics: ClassFieldDefinitionEvaluation + With parameters isStatic and homeObject. + + 1. Let fieldName be the result of evaluating ClassElementName. + 2. ReturnIfAbrupt(fieldName). + ... + + Runtime Semantics: Evaluation + ComputedPropertyName: [ AssignmentExpression ] + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let propName be ? GetValue(exprValue). + 3. Return ? ToPropertyKey(propName). + +---*/ +var obj = { + [Symbol.toPrimitive]: {} +}; + + + +function evaluate() { + class C { + [obj] = refErrorIfEvaluated; + } +} + +assert.throws(TypeError +, evaluate); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/evaluation-error/computed-name-toprimitive-returns-nonobject.js b/js/src/tests/test262/language/statements/class/elements/evaluation-error/computed-name-toprimitive-returns-nonobject.js new file mode 100644 index 0000000000..46d6d5f852 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/evaluation-error/computed-name-toprimitive-returns-nonobject.js @@ -0,0 +1,58 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/computed-name-toprimitive-returns-nonobject.case +// - src/class-elements/class-evaluation-error/cls-decl.template +/*--- +description: Custom error evaluating a computed property name (field definitions in a class declaration) +esid: sec-runtime-semantics-classdefinitionevaluation +features: [class-fields-public, computed-property-names, Symbol.toPrimitive, class] +flags: [generated] +info: | + Runtime Semantics: ClassDefinitionEvaluation + + ... + 27. For each ClassElement e in order from elements + a. If IsStatic of me is false, then + i. Let fields be the result of performing ClassElementEvaluation for e with arguments proto and false. + b. Else, + i. Let fields be the result of performing ClassElementEvaluation for e with arguments F and false. + c. If fields is an abrupt completion, then + i. Set the running execution context's LexicalEnvironment to lex. + ii. Set the running execution context's PrivateNameEnvironment to outerPrivateEnvironment. + iii. Return Completion(status). + ... + + Runtime Semantics: ClassElementEvaluation + + ClassElement: FieldDefinition; + Return ClassFieldDefinitionEvaluation of FieldDefinition with parameter false and object. + + Runtime Semantics: ClassFieldDefinitionEvaluation + With parameters isStatic and homeObject. + + 1. Let fieldName be the result of evaluating ClassElementName. + 2. ReturnIfAbrupt(fieldName). + ... + + Runtime Semantics: Evaluation + ComputedPropertyName: [ AssignmentExpression ] + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let propName be ? GetValue(exprValue). + 3. Return ? ToPropertyKey(propName). + +---*/ +var obj = { + [Symbol.toPrimitive]: 42 +}; + + + +function evaluate() { + class C { + [obj] = refErrorIfEvaluated; + } +} + +assert.throws(TypeError, evaluate); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/evaluation-error/computed-name-tostring-err.js b/js/src/tests/test262/language/statements/class/elements/evaluation-error/computed-name-tostring-err.js new file mode 100644 index 0000000000..3a43e1560d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/evaluation-error/computed-name-tostring-err.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/computed-name-tostring-err.case +// - src/class-elements/class-evaluation-error/cls-decl.template +/*--- +description: Custom error evaluating a computed property name (field definitions in a class declaration) +esid: sec-runtime-semantics-classdefinitionevaluation +features: [class-fields-public, computed-property-names, class] +flags: [generated] +info: | + Runtime Semantics: ClassDefinitionEvaluation + + ... + 27. For each ClassElement e in order from elements + a. If IsStatic of me is false, then + i. Let fields be the result of performing ClassElementEvaluation for e with arguments proto and false. + b. Else, + i. Let fields be the result of performing ClassElementEvaluation for e with arguments F and false. + c. If fields is an abrupt completion, then + i. Set the running execution context's LexicalEnvironment to lex. + ii. Set the running execution context's PrivateNameEnvironment to outerPrivateEnvironment. + iii. Return Completion(status). + ... + + Runtime Semantics: ClassElementEvaluation + + ClassElement: FieldDefinition; + Return ClassFieldDefinitionEvaluation of FieldDefinition with parameter false and object. + + Runtime Semantics: ClassFieldDefinitionEvaluation + With parameters isStatic and homeObject. + + 1. Let fieldName be the result of evaluating ClassElementName. + 2. ReturnIfAbrupt(fieldName). + ... + + Runtime Semantics: Evaluation + ComputedPropertyName: [ AssignmentExpression ] + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let propName be ? GetValue(exprValue). + 3. Return ? ToPropertyKey(propName). + +---*/ +var obj = { + toString: function() { + throw new Test262Error(); + } +}; + + + +function evaluate() { + class C { + [obj] + } +} + +assert.throws(Test262Error +, evaluate); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/evaluation-error/computed-name-valueof-err.js b/js/src/tests/test262/language/statements/class/elements/evaluation-error/computed-name-valueof-err.js new file mode 100644 index 0000000000..126a0e0a40 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/evaluation-error/computed-name-valueof-err.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/computed-name-valueof-err.case +// - src/class-elements/class-evaluation-error/cls-decl.template +/*--- +description: Custom error evaluating a computed property name (field definitions in a class declaration) +esid: sec-runtime-semantics-classdefinitionevaluation +features: [class-fields-public, computed-property-names, class] +flags: [generated] +info: | + Runtime Semantics: ClassDefinitionEvaluation + + ... + 27. For each ClassElement e in order from elements + a. If IsStatic of me is false, then + i. Let fields be the result of performing ClassElementEvaluation for e with arguments proto and false. + b. Else, + i. Let fields be the result of performing ClassElementEvaluation for e with arguments F and false. + c. If fields is an abrupt completion, then + i. Set the running execution context's LexicalEnvironment to lex. + ii. Set the running execution context's PrivateNameEnvironment to outerPrivateEnvironment. + iii. Return Completion(status). + ... + + Runtime Semantics: ClassElementEvaluation + + ClassElement: FieldDefinition; + Return ClassFieldDefinitionEvaluation of FieldDefinition with parameter false and object. + + Runtime Semantics: ClassFieldDefinitionEvaluation + With parameters isStatic and homeObject. + + 1. Let fieldName be the result of evaluating ClassElementName. + 2. ReturnIfAbrupt(fieldName). + ... + + Runtime Semantics: Evaluation + ComputedPropertyName: [ AssignmentExpression ] + + 1. Let exprValue be the result of evaluating AssignmentExpression. + 2. Let propName be ? GetValue(exprValue). + 3. Return ? ToPropertyKey(propName). + +---*/ +var obj = { + toString: undefined, + valueOf: function() { + throw new Test262Error(); + } +}; + + + +function evaluate() { + class C { + [obj] + } +} + +assert.throws(Test262Error, evaluate); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/evaluation-error/shell.js b/js/src/tests/test262/language/statements/class/elements/evaluation-error/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/elements/field-declaration.js b/js/src/tests/test262/language/statements/class/elements/field-declaration.js new file mode 100644 index 0000000000..b8c0fcc6c8 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/field-declaration.js @@ -0,0 +1,111 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/field-declaration.case +// - src/class-elements/default/cls-decl.template +/*--- +description: Fields are defined (field definitions in a class declaration) +esid: prod-FieldDefinition +features: [class-fields-public, class] +flags: [generated] +includes: [propertyHelper.js] +info: | + Updated Productions + + ClassElement : + ... + FieldDefinition ; + + FieldDefinition : + ClassElementName Initializer_opt + + ClassElementName : + PropertyName + + PropertyName : + LiteralPropertyName + ComputedPropertyName + + LiteralPropertyName : + IdentifierName + StringLiteral + NumericLiteral + + ClassDefinitionEvaluation: + ... + + 26. Let instanceFields be a new empty List. + 28. For each ClassElement e in order from elements, + a. If IsStatic of e is false, then + i. Let field be the result of performing ClassElementEvaluation for e with arguments proto and false. + b. ... + c. ... + d. If field is not empty, append field to instanceFields. + + ... + + 30. Set F.[[Fields]] to instanceFields. + ... + +---*/ +var computed = 'h'; + + +class C { + f = 'test262'; + 'g'; + 0 = 'bar'; + [computed]; +} + +let c = new C(); + +assert.sameValue(C.f, undefined); +assert.sameValue(C.g, undefined); +assert.sameValue(C.h, undefined); +assert.sameValue(C[0], undefined); + +assert( + !Object.prototype.hasOwnProperty.call(C, 'f'), + "f does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C, 'g'), + "g does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C, 'h'), + "h does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C, 0), + "0 does not appear as an own property on C constructor" +); + +verifyProperty(c, 'f', { + value: 'test262', + enumerable: true, + writable: true, + configurable: true +}); + +verifyProperty(c, 'g', { + value: undefined, + enumerable: true, + writable: true, + configurable: true +}); + +verifyProperty(c, 0, { + value: 'bar', + enumerable: true, + writable: true, + configurable: true +}); + +verifyProperty(c, 'h', { + value: undefined, + enumerable: true, + writable: true, + configurable: true +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/field-definition-accessor-no-line-terminator.js b/js/src/tests/test262/language/statements/class/elements/field-definition-accessor-no-line-terminator.js new file mode 100644 index 0000000000..bea195d730 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/field-definition-accessor-no-line-terminator.js @@ -0,0 +1,52 @@ +// |reftest| skip -- decorators is not supported +// This file was procedurally generated from the following sources: +// - src/class-elements/field-definition-accessor-no-line-terminator.case +// - src/class-elements/default/cls-decl.template +/*--- +description: Valid accessor FieldDefinition, ClassElementName, PropertyName Syntax (field definitions in a class declaration) +esid: prod-FieldDefinition +features: [decorators, class] +flags: [generated] +info: | + FieldDefinition[Yield, Await] : + accessor [no LineTerminator here] ClassElementName[?Yield, ?Await] Initializer[+In, ?Yield, ?Await]opt + +---*/ + + +class C { + accessor + $; + static accessor + $; + +} + +let c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, 'accessor'), + "accessor doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, '$'), + "$ doesn't appear as an own property on C prototype" +); +assert( + Object.prototype.hasOwnProperty.call(C, 'accessor'), + "C constructor has an own property accessor" +); +assert( + !Object.prototype.hasOwnProperty.call(C, '$'), + "$ doesn't appear as an own property on C constructor" +); +assert( + Object.prototype.hasOwnProperty.call(c, 'accessor'), + "C instance has an own property accessor" +); +assert( + Object.prototype.hasOwnProperty.call(c, '$'), + "C instance has an own property $" +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/fielddefinition-initializer-abrupt-completion.js b/js/src/tests/test262/language/statements/class/elements/fielddefinition-initializer-abrupt-completion.js new file mode 100644 index 0000000000..a29b1d94c9 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/fielddefinition-initializer-abrupt-completion.js @@ -0,0 +1,48 @@ +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Class construction should error if evaluation of field initializer errors +esid: sec-ecmascript-function-objects-construct-argumentslist-newtarget +info: | + [[Construct]] ( argumentsList, newTarget) + ... + 8. If kind is "base", then + a. Perform OrdinaryCallBindThis(F, calleeContext, thisArgument). + b. Let result be InitializeInstanceFields(thisArgument, F). + c. If result is an abrupt completion, then + i. Remove calleeContext from execution context stack and restore callerContext as the running execution context. + ii. Return Completion(result). + + InitializeInstanceFields ( O, constructor ) + 1. Assert: Type ( O ) is Object. + 2. Assert: Assert constructor is an ECMAScript function object. + 3. Let fieldRecords be the value of constructor's [[Fields]] internal slot. + 4. For each item fieldRecord in order from fieldRecords, + a. If fieldRecord.[[static]] is false, then + i. Perform ? DefineField(O, fieldRecord). + + DefineField(receiver, fieldRecord) + 1. Assert: Type(receiver) is Object. + 2. Assert: fieldRecord is a Record as created by ClassFieldDefinitionEvaluation. + 3. Let fieldName be fieldRecord.[[Name]]. + 4. Let initializer be fieldRecord.[[Initializer]]. + 5. If initializer is not empty, then + a.Let initValue be ? Call(initializer, receiver). + +features: [class, class-fields-public] +---*/ + +function f() { + throw new Test262Error(); +} + +class C { + x = f(); +} + +assert.throws(Test262Error, function() { + new C(); +}) + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/fields-anonymous-function-length.js b/js/src/tests/test262/language/statements/class/elements/fields-anonymous-function-length.js new file mode 100644 index 0000000000..38280bdfca --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/fields-anonymous-function-length.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/fields-anonymous-function-length.case +// - src/class-elements/default/cls-decl.template +/*--- +description: Anonymous functions in field initializer have length properly set (field definitions in a class declaration) +esid: prod-FieldDefinition +features: [class-fields-private, class-fields-public, class] +flags: [generated] +info: | + Updated Productions + + FieldDefinition : + ClassElementName Initializer_opt + + InitializeInstanceFields ( O, constructor ) + 1. Assert: Type ( O ) is Object. + 2. Assert: constructor is an ECMAScript function object. + 3. Let fields be the value of constructor.[[Fields]]. + 4. For each item fieldRecord in order from fields, + a. Perform ? DefineField(O, fieldRecord). + 5. Return. + + DefineField(receiver, fieldRecord) + 1. Assert: Type(receiver) is Object. + 2. Assert: fieldRecord is a Record as created by ClassFieldDefinitionEvaluation. + 3. Let name be fieldRecord.[[Name]]. + 4. Let initializer be fieldRecord.[[Initializer]]. + 5. If initializer is not empty, then + a. Let initValue be ? Call(initializer, receiver). + ... + +---*/ + + +class C { + field = function() {}; + #field = (a, b, c, d) => undefined; + + accessPrivateField() { + return this.#field; + } +} + +let c = new C(); +assert.sameValue(c.accessPrivateField().length, 4); +assert.sameValue(c.field.length, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/fields-asi-1.js b/js/src/tests/test262/language/statements/class/elements/fields-asi-1.js new file mode 100644 index 0000000000..440e30d93f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/fields-asi-1.js @@ -0,0 +1,21 @@ +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: ASI test in field declarations -- computed name interpreted as property +esid: sec-automatic-semicolon-insertion +features: [class, class-fields-public] +---*/ + +var obj = {} +class C { + x = obj + ['lol'] = 42 +} + +var c = new C(); + +assert.sameValue(c.x, 42); +assert.sameValue(obj['lol'], 42); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/fields-asi-2.js b/js/src/tests/test262/language/statements/class/elements/fields-asi-2.js new file mode 100644 index 0000000000..e7b2ce6a5c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/fields-asi-2.js @@ -0,0 +1,19 @@ +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: ASI test in field declarations -- computed name interpreted as string index +esid: sec-automatic-semicolon-insertion +features: [class, class-fields-public] +---*/ + +class C { + x = "lol" + [1] +} + +var c = new C(); + +assert.sameValue(c.x, 'o'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/fields-asi-3.js b/js/src/tests/test262/language/statements/class/elements/fields-asi-3.js new file mode 100644 index 0000000000..8bced9d0ba --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/fields-asi-3.js @@ -0,0 +1,19 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: ASI test in field declarations -- error when computed name interpreted as index +esid: sec-automatic-semicolon-insertion +features: [class, class-fields-public] +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +class C { + x = "string" + [0]() {} +} diff --git a/js/src/tests/test262/language/statements/class/elements/fields-asi-4.js b/js/src/tests/test262/language/statements/class/elements/fields-asi-4.js new file mode 100644 index 0000000000..b22cb71831 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/fields-asi-4.js @@ -0,0 +1,19 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: ASI test in field declarations -- error when generator interpreted as multiplication +esid: sec-automatic-semicolon-insertion +features: [class, class-fields-public, generators] +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +class C { + x = 42 + *gen() {} +} diff --git a/js/src/tests/test262/language/statements/class/elements/fields-asi-5.js b/js/src/tests/test262/language/statements/class/elements/fields-asi-5.js new file mode 100644 index 0000000000..55ab32690f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/fields-asi-5.js @@ -0,0 +1,30 @@ +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: ASI test in field declarations -- field with PropertyName "in" interpreted as index +esid: sec-automatic-semicolon-insertion +features: [class, class-fields-public] +---*/ + +var x = 0; +var y = 1; +var z = [42]; + +class C { + a = x + in + z + b = y + in + z +} + +var c = new C(); + +assert.sameValue(c.a, true, 'a = x in z'); +assert.sameValue(c.b, false, 'b = y in z'); +assert(!Object.prototype.hasOwnProperty.call(c, "in"), "'in' is not parsed as a field declaration"); +assert(!Object.prototype.hasOwnProperty.call(c, "z"), "'z' is not parsed as a field declaration"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/fields-asi-same-line-1.js b/js/src/tests/test262/language/statements/class/elements/fields-asi-same-line-1.js new file mode 100644 index 0000000000..f1badcbafb --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/fields-asi-same-line-1.js @@ -0,0 +1,18 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2019 Jason Orendorff. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: ASI test in field declarations -- error when method on same line +esid: sec-automatic-semicolon-insertion +features: [class, class-fields-public] +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +class C { + field /* no ASI here */ method(){} +} diff --git a/js/src/tests/test262/language/statements/class/elements/fields-asi-same-line-2.js b/js/src/tests/test262/language/statements/class/elements/fields-asi-same-line-2.js new file mode 100644 index 0000000000..8ee4caebd9 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/fields-asi-same-line-2.js @@ -0,0 +1,18 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2019 Jason Orendorff. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: ASI test in field declarations -- error when method on same line after initializer +esid: sec-automatic-semicolon-insertion +features: [class, class-fields-public] +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +class C { + field = 1 /* no ASI here */ method(){} +} diff --git a/js/src/tests/test262/language/statements/class/elements/fields-computed-name-propname-constructor.js b/js/src/tests/test262/language/statements/class/elements/fields-computed-name-propname-constructor.js new file mode 100644 index 0000000000..2eef946b50 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/fields-computed-name-propname-constructor.js @@ -0,0 +1,54 @@ +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: class fields forbid PropName 'constructor' (no early error -- PropName of ComputedPropertyName not forbidden value) +esid: sec-class-definitions-static-semantics-early-errors +features: [class, class-fields-public] +info: | + Static Semantics: PropName + ... + ComputedPropertyName : [ AssignmentExpression ] + Return empty. + + + // This test file tests the following early error: + Static Semantics: Early Errors + + ClassElement : FieldDefinition; + It is a Syntax Error if PropName of FieldDefinition is "constructor". + + DefineField(receiver, fieldRecord) + + ... + 8. If fieldName is a Private Name, + ... + 9. Else, + a. ... + b. Perform ? CreateDataPropertyOrThrow(receiver, fieldName, initValue). + + CreateDataPropertyOrThrow ( O, P, V ) + + ... + 3. Let success be ? CreateDataProperty(O, P, V). + 4. If success is false, throw a TypeError exception. + ... + + CreateDataProperty ( O, P, V ) + + ... + 3. Let newDesc be the PropertyDescriptor { [[Value]]: V, [[Writable]]: true, [[Enumerable]]: true, + [[Configurable]]: true }. + 4. Return ? O.[[DefineOwnProperty]](P, newDesc). +---*/ + +var x = "constructor"; +class C1 { + [x]; +} + +var c1 = new C1(); + +assert.sameValue(c1.hasOwnProperty("constructor"), true); +assert.sameValue(C1.hasOwnProperty("constructor"), false); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/fields-computed-name-static-computed-var-propname-constructor.js b/js/src/tests/test262/language/statements/class/elements/fields-computed-name-static-computed-var-propname-constructor.js new file mode 100644 index 0000000000..585dbac7de --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/fields-computed-name-static-computed-var-propname-constructor.js @@ -0,0 +1,82 @@ +// Copyright (C) 2017 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: static class fields forbid PropName 'constructor' (no early error -- PropName of ComputedPropertyName not forbidden value) +esid: sec-class-definitions-static-semantics-early-errors +features: [class, class-static-fields-public] +info: | + Static Semantics: PropName + ... + ComputedPropertyName : [ AssignmentExpression ] + Return empty. + + This test file tests the following early error is only valid for a matching PropName: + + Static Semantics: Early Errors + + ClassElement : static FieldDefinition; + It is a Syntax Error if PropName of FieldDefinition is "prototype" or "constructor". + + -- IDK what is calling InitializeClassElements but I guess it's supposed to be called to + -- set the fields + + InitializeClassElements(F, proto) + + ... + 6. For each item element in order from elements, + a. If element.[[Kind]] is "field" and element.[[Placement]] is "static" or "prototype", + ... + ii. Let receiver be F if element.[[Placement]] is "static", else let receiver be proto. + iii. Perform ? DefineClassElement(receiver, element). + + -- DefineClassElement is probably DefineField in the class fields proposal + + DefineField(receiver, fieldRecord) + + ... + 8. If fieldName is a Private Name, + ... + 9. Else, + a. ... + b. Perform ? CreateDataPropertyOrThrow(receiver, fieldName, initValue). + + CreateDataPropertyOrThrow ( O, P, V ) + + ... + 3. Let success be ? CreateDataProperty(O, P, V). + 4. If success is false, throw a TypeError exception. + ... + + CreateDataProperty ( O, P, V ) + + ... + 3. Let newDesc be the PropertyDescriptor { [[Value]]: V, [[Writable]]: true, [[Enumerable]]: true, + [[Configurable]]: true }. + 4. Return ? O.[[DefineOwnProperty]](P, newDesc). +includes: [propertyHelper.js] +---*/ + +var x = 'constructor'; +class C1 { + static [x]; +} + +verifyProperty(C1, 'constructor', { + value: undefined, + configurable: true, + writable: true, + enumerable: true, +}); + +class C2 { + static [x] = 42; +} + +verifyProperty(C2, 'constructor', { + value: 42, + configurable: true, + writable: true, + enumerable: true, +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/fields-computed-name-static-computed-var-propname-prototype.js b/js/src/tests/test262/language/statements/class/elements/fields-computed-name-static-computed-var-propname-prototype.js new file mode 100644 index 0000000000..7f4c43c8d3 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/fields-computed-name-static-computed-var-propname-prototype.js @@ -0,0 +1,34 @@ +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: static class fields forbid PropName 'prototype' (no early error -- PropName of ComputedPropertyName) +esid: sec-class-definitions-static-semantics-early-errors +features: [class, class-static-fields-public] +info: | + 14.6.13 Runtime Semantics: ClassDefinitionEvaluation + + ... + 16. Perform MakeConstructor(F, false, proto). + ... + + 9.2.10 MakeConstructor ( F [ , writablePrototype [ , prototype ] ] ) + + 6. Perform ! DefinePropertyOrThrow(F, "prototype", PropertyDescriptor { [[Value]]: prototype, + [[Writable]]: writablePrototype, [[Enumerable]]: false, [[Configurable]]: false }). +---*/ + +var x = "prototype"; + +assert.throws(TypeError, function() { + class C { + static [x] = 42; + } +}); + +assert.throws(TypeError, function() { + class C { + static [x]; + } +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/fields-computed-name-static-propname-constructor.js b/js/src/tests/test262/language/statements/class/elements/fields-computed-name-static-propname-constructor.js new file mode 100644 index 0000000000..b8bf0f8826 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/fields-computed-name-static-propname-constructor.js @@ -0,0 +1,81 @@ +// Copyright (C) 2017 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: static class fields forbid PropName 'constructor' (no early error -- PropName of ComputedPropertyName not forbidden value) +esid: sec-class-definitions-static-semantics-early-errors +features: [class, class-static-fields-public] +info: | + Static Semantics: PropName + ... + ComputedPropertyName : [ AssignmentExpression ] + Return empty. + + This test file tests the following early error is only valid for a matching PropName: + + Static Semantics: Early Errors + + ClassElement : static FieldDefinition; + It is a Syntax Error if PropName of FieldDefinition is "prototype" or "constructor". + + -- IDK what is calling InitializeClassElements but I guess it's supposed to be called to + -- set the fields + + InitializeClassElements(F, proto) + + ... + 6. For each item element in order from elements, + a. If element.[[Kind]] is "field" and element.[[Placement]] is "static" or "prototype", + ... + ii. Let receiver be F if element.[[Placement]] is "static", else let receiver be proto. + iii. Perform ? DefineClassElement(receiver, element). + + -- DefineClassElement is probably DefineField in the class fields proposal + + DefineField(receiver, fieldRecord) + + ... + 8. If fieldName is a Private Name, + ... + 9. Else, + a. ... + b. Perform ? CreateDataPropertyOrThrow(receiver, fieldName, initValue). + + CreateDataPropertyOrThrow ( O, P, V ) + + ... + 3. Let success be ? CreateDataProperty(O, P, V). + 4. If success is false, throw a TypeError exception. + ... + + CreateDataProperty ( O, P, V ) + + ... + 3. Let newDesc be the PropertyDescriptor { [[Value]]: V, [[Writable]]: true, [[Enumerable]]: true, + [[Configurable]]: true }. + 4. Return ? O.[[DefineOwnProperty]](P, newDesc). +includes: [propertyHelper.js] +---*/ + +class C1 { + static ['constructor']; +} + +verifyProperty(C1, 'constructor', { + value: undefined, + configurable: true, + writable: true, + enumerable: true, +}); + +class C2 { + static ['constructor'] = 42; +} + +verifyProperty(C2, 'constructor', { + value: 42, + configurable: true, + writable: true, + enumerable: true, +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/fields-computed-name-static-propname-prototype.js b/js/src/tests/test262/language/statements/class/elements/fields-computed-name-static-propname-prototype.js new file mode 100644 index 0000000000..5fba6d2d6c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/fields-computed-name-static-propname-prototype.js @@ -0,0 +1,32 @@ +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: static class fields forbid PropName 'prototype' (no early error -- PropName of ComputedPropertyName) +esid: sec-class-definitions-static-semantics-early-errors +features: [class, class-static-fields-public] +info: | + 14.6.13 Runtime Semantics: ClassDefinitionEvaluation + + ... + 16. Perform MakeConstructor(F, false, proto). + ... + + 9.2.10 MakeConstructor ( F [ , writablePrototype [ , prototype ] ] ) + + 6. Perform ! DefinePropertyOrThrow(F, "prototype", PropertyDescriptor { [[Value]]: prototype, + [[Writable]]: writablePrototype, [[Enumerable]]: false, [[Configurable]]: false }). +---*/ + +assert.throws(TypeError, function() { + class C { + static ['prototype'] = 42; + } +}); + +assert.throws(TypeError, function() { + class C { + static ['prototype']; + } +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/fields-duplicate-privatenames.js b/js/src/tests/test262/language/statements/class/elements/fields-duplicate-privatenames.js new file mode 100644 index 0000000000..da13cf7b43 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/fields-duplicate-privatenames.js @@ -0,0 +1,25 @@ +// |reftest| error:SyntaxError +// Copyright 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Syntax error if the same private field defined twice +esid: sec-class-definitions-static-semantics-early-errors +features: [class, class-fields-private] +negative: + phase: parse + type: SyntaxError +info: | + Static Semantics: Early Errors + + ClassBody : ClassElementList + It is a Syntax Error if PrivateBoundNames of ClassBody contains any duplicate entries. +---*/ + + +$DONOTEVALUATE(); + +class C { + #x; + #x; +} diff --git a/js/src/tests/test262/language/statements/class/elements/fields-hash-constructor-is-a-valid-name.js b/js/src/tests/test262/language/statements/class/elements/fields-hash-constructor-is-a-valid-name.js new file mode 100644 index 0000000000..0372cfa317 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/fields-hash-constructor-is-a-valid-name.js @@ -0,0 +1,42 @@ +// Copyright (C) 2018 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: "#constructor is a valid property name for a public field" +esid: sec-class-definitions-static-semantics-early-errors +features: [class, class-fields-public] +info: | + ClassElementName : PrivateName; + + It is a Syntax Error if StringValue of PrivateName is "#constructor". +includes: [propertyHelper.js] +---*/ + +class C1 { + ["#constructor"]; +} + +var c1 = new C1(); + +assert.sameValue(Object.prototype.hasOwnProperty.call(C1, '#constructor'), false); +verifyProperty(c1, '#constructor', { + value: undefined, + configurable: true, + enumerable: true, + writable: true, +}); + +class C2 { + ["#constructor"] = 42; +} + +var c2 = new C2(); + +assert.sameValue(Object.prototype.hasOwnProperty.call(C2, '#constructor'), false); +verifyProperty(c2, '#constructor', { + value: 42, + configurable: true, + enumerable: true, + writable: true, +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/fields-literal-name-propname-constructor.js b/js/src/tests/test262/language/statements/class/elements/fields-literal-name-propname-constructor.js new file mode 100644 index 0000000000..3bb17a4524 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/fields-literal-name-propname-constructor.js @@ -0,0 +1,30 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: class fields forbid PropName 'constructor' (early error -- PropName of IdentifierName is forbidden value) +esid: sec-class-definitions-static-semantics-early-errors +features: [class, class-fields-public] +negative: + phase: parse + type: SyntaxError +info: | + Static Semantics: PropName + LiteralPropertyName : IdentifierName + Return StringValue of IdentifierName. + + + // This test file tests the following early error: + Static Semantics: Early Errors + + ClassElement : FieldDefinition; + It is a Syntax Error if PropName of FieldDefinition is "constructor". + +---*/ + + +$DONOTEVALUATE(); + +class C { + constructor; +} diff --git a/js/src/tests/test262/language/statements/class/elements/fields-literal-name-static-propname-constructor.js b/js/src/tests/test262/language/statements/class/elements/fields-literal-name-static-propname-constructor.js new file mode 100644 index 0000000000..27b3ed35d4 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/fields-literal-name-static-propname-constructor.js @@ -0,0 +1,30 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: static class field forbid PropName 'constructor' (early error -- PropName of IdentifierName is forbidden value) +esid: sec-class-definitions-static-semantics-early-errors +features: [class, class-static-fields-public] +negative: + phase: parse + type: SyntaxError +info: | + Static Semantics: PropName + LiteralPropertyName : IdentifierName + Return StringValue of IdentifierName. + + + // This test file tests the following early error: + Static Semantics: Early Errors + + ClassElement : staticFieldDefinition; + It is a Syntax Error if PropName of FieldDefinition is "prototype" or "constructor". + +---*/ + + +$DONOTEVALUATE(); + +class C { + static constructor; +} diff --git a/js/src/tests/test262/language/statements/class/elements/fields-literal-name-static-propname-prototype.js b/js/src/tests/test262/language/statements/class/elements/fields-literal-name-static-propname-prototype.js new file mode 100644 index 0000000000..032744bc63 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/fields-literal-name-static-propname-prototype.js @@ -0,0 +1,30 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: static class fields forbid PropName 'prototype' (early error -- PropName of IdentifierName is forbidden value) +esid: sec-class-definitions-static-semantics-early-errors +features: [class, class-static-fields-public] +negative: + phase: parse + type: SyntaxError +info: | + Static Semantics: PropName + LiteralPropertyName : IdentifierName + Return StringValue of IdentifierName. + + + // This test file tests the following early error: + Static Semantics: Early Errors + + ClassElement : staticFieldDefinition; + It is a Syntax Error if PropName of FieldDefinition is "prototype" or "constructor". + +---*/ + + +$DONOTEVALUATE(); + +class C { + static prototype; +} diff --git a/js/src/tests/test262/language/statements/class/elements/fields-string-name-propname-constructor.js b/js/src/tests/test262/language/statements/class/elements/fields-string-name-propname-constructor.js new file mode 100644 index 0000000000..f81ce20424 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/fields-string-name-propname-constructor.js @@ -0,0 +1,31 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: class fields forbid PropName 'constructor' (early error -- PropName of StringLiteral is forbidden value) +esid: sec-class-definitions-static-semantics-early-errors +features: [class, class-fields-public] +negative: + phase: parse + type: SyntaxError +info: | + Static Semantics: PropName + ... + LiteralPropertyName : StringLiteral + Return the String value whose code units are the SV of the StringLiteral. + + + // This test file tests the following early error: + Static Semantics: Early Errors + + ClassElement : FieldDefinition; + It is a Syntax Error if PropName of FieldDefinition is "constructor". + +---*/ + + +$DONOTEVALUATE(); + +class C { + 'constructor'; +} diff --git a/js/src/tests/test262/language/statements/class/elements/fields-string-name-static-propname-constructor.js b/js/src/tests/test262/language/statements/class/elements/fields-string-name-static-propname-constructor.js new file mode 100644 index 0000000000..fe1a8bdbd3 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/fields-string-name-static-propname-constructor.js @@ -0,0 +1,31 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: static class field forbid PropName 'constructor' (early error -- PropName of StringLiteral is forbidden value) +esid: sec-class-definitions-static-semantics-early-errors +features: [class, class-static-fields-public] +negative: + phase: parse + type: SyntaxError +info: | + Static Semantics: PropName + ... + LiteralPropertyName : StringLiteral + Return the String value whose code units are the SV of the StringLiteral. + + + // This test file tests the following early error: + Static Semantics: Early Errors + + ClassElement : staticFieldDefinition; + It is a Syntax Error if PropName of FieldDefinition is "prototype" or "constructor". + +---*/ + + +$DONOTEVALUATE(); + +class C { + static 'constructor'; +} diff --git a/js/src/tests/test262/language/statements/class/elements/fields-string-name-static-propname-prototype.js b/js/src/tests/test262/language/statements/class/elements/fields-string-name-static-propname-prototype.js new file mode 100644 index 0000000000..3a8b62d3c0 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/fields-string-name-static-propname-prototype.js @@ -0,0 +1,31 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: static class fields forbid PropName 'prototype' (early error -- PropName of StringLiteral is forbidden value) +esid: sec-class-definitions-static-semantics-early-errors +features: [class, class-static-fields-public] +negative: + phase: parse + type: SyntaxError +info: | + Static Semantics: PropName + ... + LiteralPropertyName : StringLiteral + Return the String value whose code units are the SV of the StringLiteral. + + + // This test file tests the following early error: + Static Semantics: Early Errors + + ClassElement : staticFieldDefinition; + It is a Syntax Error if PropName of FieldDefinition is "prototype" or "constructor". + +---*/ + + +$DONOTEVALUATE(); + +class C { + static 'prototype'; +} diff --git a/js/src/tests/test262/language/statements/class/elements/gen-private-method-static/browser.js b/js/src/tests/test262/language/statements/class/elements/gen-private-method-static/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/elements/gen-private-method-static/shell.js b/js/src/tests/test262/language/statements/class/elements/gen-private-method-static/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/elements/gen-private-method-static/yield-as-binding-identifier-escaped.js b/js/src/tests/test262/language/statements/class/elements/gen-private-method-static/yield-as-binding-identifier-escaped.js new file mode 100644 index 0000000000..0e43f77456 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/gen-private-method-static/yield-as-binding-identifier-escaped.js @@ -0,0 +1,36 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/generators/yield-as-binding-identifier-escaped.case +// - src/generators/syntax/class-decl-static-private-method.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as a binding identifier. (Static generator method as a ClassDeclaration element) +esid: prod-GeneratorMethod +features: [generators, class-static-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + GeneratorMethod + + 14.4 Generator Function Definitions + + GeneratorMethod : + * # PropertyName ( UniqueFormalParameters ) { GeneratorBody } + + + BindingIdentifier : Identifier + + It is a Syntax Error if this production has a [Yield] parameter and + StringValue of Identifier is "yield". + +---*/ +$DONOTEVALUATE(); + +class C {static *#gen() { + var yi\u0065ld; +}} diff --git a/js/src/tests/test262/language/statements/class/elements/gen-private-method-static/yield-as-binding-identifier.js b/js/src/tests/test262/language/statements/class/elements/gen-private-method-static/yield-as-binding-identifier.js new file mode 100644 index 0000000000..b33a4d456b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/gen-private-method-static/yield-as-binding-identifier.js @@ -0,0 +1,36 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/generators/yield-as-binding-identifier.case +// - src/generators/syntax/class-decl-static-private-method.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as a binding identifier. (Static generator method as a ClassDeclaration element) +esid: prod-GeneratorMethod +features: [generators, class-static-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + GeneratorMethod + + 14.4 Generator Function Definitions + + GeneratorMethod : + * # PropertyName ( UniqueFormalParameters ) { GeneratorBody } + + + BindingIdentifier : Identifier + + It is a Syntax Error if this production has a [Yield] parameter and + StringValue of Identifier is "yield". + +---*/ +$DONOTEVALUATE(); + +class C {static *#gen() { + var yield; +}} diff --git a/js/src/tests/test262/language/statements/class/elements/gen-private-method-static/yield-as-identifier-reference-escaped.js b/js/src/tests/test262/language/statements/class/elements/gen-private-method-static/yield-as-identifier-reference-escaped.js new file mode 100644 index 0000000000..04677528e4 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/gen-private-method-static/yield-as-identifier-reference-escaped.js @@ -0,0 +1,36 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/generators/yield-as-identifier-reference-escaped.case +// - src/generators/syntax/class-decl-static-private-method.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as an identifier reference. (Static generator method as a ClassDeclaration element) +esid: prod-GeneratorMethod +features: [generators, class-static-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + GeneratorMethod + + 14.4 Generator Function Definitions + + GeneratorMethod : + * # PropertyName ( UniqueFormalParameters ) { GeneratorBody } + + + IdentifierReference : Identifier + + It is a Syntax Error if this production has a [Yield] parameter and + StringValue of Identifier is "yield". + +---*/ +$DONOTEVALUATE(); + +class C {static *#gen() { + void yi\u0065ld; +}} diff --git a/js/src/tests/test262/language/statements/class/elements/gen-private-method-static/yield-as-identifier-reference.js b/js/src/tests/test262/language/statements/class/elements/gen-private-method-static/yield-as-identifier-reference.js new file mode 100644 index 0000000000..be6cfcd5bf --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/gen-private-method-static/yield-as-identifier-reference.js @@ -0,0 +1,36 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/generators/yield-as-identifier-reference.case +// - src/generators/syntax/class-decl-static-private-method.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as an identifier reference. (Static generator method as a ClassDeclaration element) +esid: prod-GeneratorMethod +features: [generators, class-static-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + GeneratorMethod + + 14.4 Generator Function Definitions + + GeneratorMethod : + * # PropertyName ( UniqueFormalParameters ) { GeneratorBody } + + + IdentifierReference : Identifier + + It is a Syntax Error if this production has a [Yield] parameter and + StringValue of Identifier is "yield". + +---*/ +$DONOTEVALUATE(); + +class C {static *#gen() { + void yield; +}} diff --git a/js/src/tests/test262/language/statements/class/elements/gen-private-method-static/yield-as-label-identifier-escaped.js b/js/src/tests/test262/language/statements/class/elements/gen-private-method-static/yield-as-label-identifier-escaped.js new file mode 100644 index 0000000000..5dcb4df908 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/gen-private-method-static/yield-as-label-identifier-escaped.js @@ -0,0 +1,36 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/generators/yield-as-label-identifier-escaped.case +// - src/generators/syntax/class-decl-static-private-method.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as a label identifier. (Static generator method as a ClassDeclaration element) +esid: prod-GeneratorMethod +features: [generators, class-static-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + GeneratorMethod + + 14.4 Generator Function Definitions + + GeneratorMethod : + * # PropertyName ( UniqueFormalParameters ) { GeneratorBody } + + + LabelIdentifier : Identifier + + It is a Syntax Error if this production has a [Yield] parameter and + StringValue of Identifier is "yield". + +---*/ +$DONOTEVALUATE(); + +class C {static *#gen() { + yi\u0065ld: ; +}} diff --git a/js/src/tests/test262/language/statements/class/elements/gen-private-method-static/yield-as-label-identifier.js b/js/src/tests/test262/language/statements/class/elements/gen-private-method-static/yield-as-label-identifier.js new file mode 100644 index 0000000000..4371c8dba0 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/gen-private-method-static/yield-as-label-identifier.js @@ -0,0 +1,36 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/generators/yield-as-label-identifier.case +// - src/generators/syntax/class-decl-static-private-method.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as a label identifier. (Static generator method as a ClassDeclaration element) +esid: prod-GeneratorMethod +features: [generators, class-static-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + GeneratorMethod + + 14.4 Generator Function Definitions + + GeneratorMethod : + * # PropertyName ( UniqueFormalParameters ) { GeneratorBody } + + + LabelIdentifier : Identifier + + It is a Syntax Error if this production has a [Yield] parameter and + StringValue of Identifier is "yield". + +---*/ +$DONOTEVALUATE(); + +class C {static *#gen() { + yield: ; +}} diff --git a/js/src/tests/test262/language/statements/class/elements/gen-private-method-static/yield-identifier-spread-strict-strict.js b/js/src/tests/test262/language/statements/class/elements/gen-private-method-static/yield-identifier-spread-strict-strict.js new file mode 100644 index 0000000000..258b126d5b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/gen-private-method-static/yield-identifier-spread-strict-strict.js @@ -0,0 +1,75 @@ +// |reftest| error:SyntaxError +'use strict'; +// This file was procedurally generated from the following sources: +// - src/generators/yield-identifier-spread-strict.case +// - src/generators/default/class-decl-static-private-method.template +/*--- +description: It's an early error if the AssignmentExpression is a function body with yield as an identifier in strict mode. (Static generator private method as a ClassDeclaration element) +esid: prod-GeneratorPrivateMethod +features: [object-spread, generators, class-static-methods-private] +flags: [generated, onlyStrict] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + GeneratorMethod + + 14.4 Generator Function Definitions + + GeneratorMethod : + * PropertyName ( UniqueFormalParameters ) { GeneratorBody } + + + Spread Properties + + PropertyDefinition[Yield]: + (...) + ...AssignmentExpression[In, ?Yield] + +---*/ +$DONOTEVALUATE(); + +var callCount = 0; + +class C { + static *#gen() { + callCount += 1; + return { + ...(function() { + var yield; + throw new Test262Error(); + }()), + } + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "Private field '#gen' does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "Private field '#gen' does not appear as an own property on C constructor" +); + +var iter = C.gen(); + + + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "Private field '#gen' does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "Private field '#gen' does not appear as an own property on C constructor" +); diff --git a/js/src/tests/test262/language/statements/class/elements/gen-private-method-static/yield-identifier-strict-strict.js b/js/src/tests/test262/language/statements/class/elements/gen-private-method-static/yield-identifier-strict-strict.js new file mode 100644 index 0000000000..38bd773506 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/gen-private-method-static/yield-identifier-strict-strict.js @@ -0,0 +1,66 @@ +// |reftest| error:SyntaxError +'use strict'; +// This file was procedurally generated from the following sources: +// - src/generators/yield-identifier-strict.case +// - src/generators/default/class-decl-static-private-method.template +/*--- +description: It's an early error if the generator body has another function body with yield as an identifier in strict mode. (Static generator private method as a ClassDeclaration element) +esid: prod-GeneratorPrivateMethod +features: [generators, class-static-methods-private] +flags: [generated, onlyStrict] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + GeneratorMethod + + 14.4 Generator Function Definitions + + GeneratorMethod : + * PropertyName ( UniqueFormalParameters ) { GeneratorBody } + +---*/ +$DONOTEVALUATE(); + +var callCount = 0; + +class C { + static *#gen() { + callCount += 1; + (function() { + var yield; + throw new Test262Error(); + }()) + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "Private field '#gen' does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "Private field '#gen' does not appear as an own property on C constructor" +); + +var iter = C.gen(); + + + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "Private field '#gen' does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "Private field '#gen' does not appear as an own property on C constructor" +); diff --git a/js/src/tests/test262/language/statements/class/elements/gen-private-method-static/yield-spread-arr-multiple.js b/js/src/tests/test262/language/statements/class/elements/gen-private-method-static/yield-spread-arr-multiple.js new file mode 100644 index 0000000000..c1ba1a5916 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/gen-private-method-static/yield-spread-arr-multiple.js @@ -0,0 +1,73 @@ +// This file was procedurally generated from the following sources: +// - src/generators/yield-spread-arr-multiple.case +// - src/generators/default/class-decl-static-private-method.template +/*--- +description: Use yield value in a array spread position (Static generator private method as a ClassDeclaration element) +esid: prod-GeneratorPrivateMethod +features: [generators, class-static-methods-private] +flags: [generated] +includes: [compareArray.js] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + GeneratorMethod + + 14.4 Generator Function Definitions + + GeneratorMethod : + * PropertyName ( UniqueFormalParameters ) { GeneratorBody } + + + Array Initializer + + SpreadElement[Yield, Await]: + ...AssignmentExpression[+In, ?Yield, ?Await] + +---*/ +var arr = ['a', 'b', 'c']; +var item; + +var callCount = 0; + +class C { + static *#gen() { + callCount += 1; + yield [...yield yield]; + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "Private field '#gen' does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "Private field '#gen' does not appear as an own property on C constructor" +); + +var iter = C.gen(); + +iter.next(false); +item = iter.next(['a', 'b', 'c']); +item = iter.next(item.value); + +assert.compareArray(item.value, arr); +assert.sameValue(item.done, false); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "Private field '#gen' does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "Private field '#gen' does not appear as an own property on C constructor" +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/gen-private-method-static/yield-spread-arr-single.js b/js/src/tests/test262/language/statements/class/elements/gen-private-method-static/yield-spread-arr-single.js new file mode 100644 index 0000000000..06b50e2a37 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/gen-private-method-static/yield-spread-arr-single.js @@ -0,0 +1,75 @@ +// This file was procedurally generated from the following sources: +// - src/generators/yield-spread-arr-single.case +// - src/generators/default/class-decl-static-private-method.template +/*--- +description: Use yield value in a array spread position (Static generator private method as a ClassDeclaration element) +esid: prod-GeneratorPrivateMethod +features: [generators, class-static-methods-private] +flags: [generated] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + GeneratorMethod + + 14.4 Generator Function Definitions + + GeneratorMethod : + * PropertyName ( UniqueFormalParameters ) { GeneratorBody } + + + Array Initializer + + SpreadElement[Yield, Await]: + ...AssignmentExpression[+In, ?Yield, ?Await] +---*/ +var arr = ['a', 'b', 'c']; + +var callCount = 0; + +class C { + static *#gen() { + callCount += 1; + yield [...yield]; + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "Private field '#gen' does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "Private field '#gen' does not appear as an own property on C constructor" +); + +var iter = C.gen(); + +iter.next(false); +var item = iter.next(arr); +var value = item.value; + +assert.notSameValue(value, arr, 'value is a new array'); +assert(Array.isArray(value), 'value is an Array exotic object'); +assert.sameValue(value.length, 3) +assert.sameValue(value[0], 'a'); +assert.sameValue(value[1], 'b'); +assert.sameValue(value[2], 'c'); +assert.sameValue(item.done, false); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "Private field '#gen' does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "Private field '#gen' does not appear as an own property on C constructor" +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/gen-private-method-static/yield-spread-obj.js b/js/src/tests/test262/language/statements/class/elements/gen-private-method-static/yield-spread-obj.js new file mode 100644 index 0000000000..a98fdf4aad --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/gen-private-method-static/yield-spread-obj.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/generators/yield-spread-obj.case +// - src/generators/default/class-decl-static-private-method.template +/*--- +description: Use yield value in a object spread position (Static generator private method as a ClassDeclaration element) +esid: prod-GeneratorPrivateMethod +features: [object-spread, generators, class-static-methods-private] +flags: [generated] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + GeneratorMethod + + 14.4 Generator Function Definitions + + GeneratorMethod : + * PropertyName ( UniqueFormalParameters ) { GeneratorBody } + + + Spread Properties + + PropertyDefinition[Yield]: + (...) + ...AssignmentExpression[In, ?Yield] + +---*/ + +var callCount = 0; + +class C { + static *#gen() { + callCount += 1; + yield { + ...yield, + y: 1, + ...yield yield, + }; + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "Private field '#gen' does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "Private field '#gen' does not appear as an own property on C constructor" +); + +var iter = C.gen(); + +iter.next(); +iter.next({ x: 42 }); +iter.next({ x: 'lol' }); +var item = iter.next({ y: 39 }); + +assert.sameValue(item.value.x, 42); +assert.sameValue(item.value.y, 39); +assert.sameValue(Object.keys(item.value).length, 2); +assert.sameValue(item.done, false); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "Private field '#gen' does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "Private field '#gen' does not appear as an own property on C constructor" +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/gen-private-method/browser.js b/js/src/tests/test262/language/statements/class/elements/gen-private-method/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/elements/gen-private-method/shell.js b/js/src/tests/test262/language/statements/class/elements/gen-private-method/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/elements/gen-private-method/yield-as-binding-identifier-escaped.js b/js/src/tests/test262/language/statements/class/elements/gen-private-method/yield-as-binding-identifier-escaped.js new file mode 100644 index 0000000000..385e2b978c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/gen-private-method/yield-as-binding-identifier-escaped.js @@ -0,0 +1,36 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/generators/yield-as-binding-identifier-escaped.case +// - src/generators/syntax/class-decl-private-method.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as a binding identifier. (Generator method as a ClassDeclaration element) +esid: prod-GeneratorMethod +features: [generators, class-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + GeneratorMethod + + 14.4 Generator Function Definitions + + GeneratorMethod : + * # PropertyName ( UniqueFormalParameters ) { GeneratorBody } + + + BindingIdentifier : Identifier + + It is a Syntax Error if this production has a [Yield] parameter and + StringValue of Identifier is "yield". + +---*/ +$DONOTEVALUATE(); + +class C { *#gen() { + var yi\u0065ld; +}} diff --git a/js/src/tests/test262/language/statements/class/elements/gen-private-method/yield-as-binding-identifier.js b/js/src/tests/test262/language/statements/class/elements/gen-private-method/yield-as-binding-identifier.js new file mode 100644 index 0000000000..22dbaab59b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/gen-private-method/yield-as-binding-identifier.js @@ -0,0 +1,36 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/generators/yield-as-binding-identifier.case +// - src/generators/syntax/class-decl-private-method.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as a binding identifier. (Generator method as a ClassDeclaration element) +esid: prod-GeneratorMethod +features: [generators, class-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + GeneratorMethod + + 14.4 Generator Function Definitions + + GeneratorMethod : + * # PropertyName ( UniqueFormalParameters ) { GeneratorBody } + + + BindingIdentifier : Identifier + + It is a Syntax Error if this production has a [Yield] parameter and + StringValue of Identifier is "yield". + +---*/ +$DONOTEVALUATE(); + +class C { *#gen() { + var yield; +}} diff --git a/js/src/tests/test262/language/statements/class/elements/gen-private-method/yield-as-identifier-reference-escaped.js b/js/src/tests/test262/language/statements/class/elements/gen-private-method/yield-as-identifier-reference-escaped.js new file mode 100644 index 0000000000..2795745d2c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/gen-private-method/yield-as-identifier-reference-escaped.js @@ -0,0 +1,36 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/generators/yield-as-identifier-reference-escaped.case +// - src/generators/syntax/class-decl-private-method.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as an identifier reference. (Generator method as a ClassDeclaration element) +esid: prod-GeneratorMethod +features: [generators, class-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + GeneratorMethod + + 14.4 Generator Function Definitions + + GeneratorMethod : + * # PropertyName ( UniqueFormalParameters ) { GeneratorBody } + + + IdentifierReference : Identifier + + It is a Syntax Error if this production has a [Yield] parameter and + StringValue of Identifier is "yield". + +---*/ +$DONOTEVALUATE(); + +class C { *#gen() { + void yi\u0065ld; +}} diff --git a/js/src/tests/test262/language/statements/class/elements/gen-private-method/yield-as-identifier-reference.js b/js/src/tests/test262/language/statements/class/elements/gen-private-method/yield-as-identifier-reference.js new file mode 100644 index 0000000000..b67e9655e0 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/gen-private-method/yield-as-identifier-reference.js @@ -0,0 +1,36 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/generators/yield-as-identifier-reference.case +// - src/generators/syntax/class-decl-private-method.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as an identifier reference. (Generator method as a ClassDeclaration element) +esid: prod-GeneratorMethod +features: [generators, class-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + GeneratorMethod + + 14.4 Generator Function Definitions + + GeneratorMethod : + * # PropertyName ( UniqueFormalParameters ) { GeneratorBody } + + + IdentifierReference : Identifier + + It is a Syntax Error if this production has a [Yield] parameter and + StringValue of Identifier is "yield". + +---*/ +$DONOTEVALUATE(); + +class C { *#gen() { + void yield; +}} diff --git a/js/src/tests/test262/language/statements/class/elements/gen-private-method/yield-as-label-identifier-escaped.js b/js/src/tests/test262/language/statements/class/elements/gen-private-method/yield-as-label-identifier-escaped.js new file mode 100644 index 0000000000..c08efad0c1 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/gen-private-method/yield-as-label-identifier-escaped.js @@ -0,0 +1,36 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/generators/yield-as-label-identifier-escaped.case +// - src/generators/syntax/class-decl-private-method.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as a label identifier. (Generator method as a ClassDeclaration element) +esid: prod-GeneratorMethod +features: [generators, class-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + GeneratorMethod + + 14.4 Generator Function Definitions + + GeneratorMethod : + * # PropertyName ( UniqueFormalParameters ) { GeneratorBody } + + + LabelIdentifier : Identifier + + It is a Syntax Error if this production has a [Yield] parameter and + StringValue of Identifier is "yield". + +---*/ +$DONOTEVALUATE(); + +class C { *#gen() { + yi\u0065ld: ; +}} diff --git a/js/src/tests/test262/language/statements/class/elements/gen-private-method/yield-as-label-identifier.js b/js/src/tests/test262/language/statements/class/elements/gen-private-method/yield-as-label-identifier.js new file mode 100644 index 0000000000..3137bbb7dd --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/gen-private-method/yield-as-label-identifier.js @@ -0,0 +1,36 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/generators/yield-as-label-identifier.case +// - src/generators/syntax/class-decl-private-method.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as a label identifier. (Generator method as a ClassDeclaration element) +esid: prod-GeneratorMethod +features: [generators, class-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + GeneratorMethod + + 14.4 Generator Function Definitions + + GeneratorMethod : + * # PropertyName ( UniqueFormalParameters ) { GeneratorBody } + + + LabelIdentifier : Identifier + + It is a Syntax Error if this production has a [Yield] parameter and + StringValue of Identifier is "yield". + +---*/ +$DONOTEVALUATE(); + +class C { *#gen() { + yield: ; +}} diff --git a/js/src/tests/test262/language/statements/class/elements/gen-private-method/yield-identifier-spread-strict-strict.js b/js/src/tests/test262/language/statements/class/elements/gen-private-method/yield-identifier-spread-strict-strict.js new file mode 100644 index 0000000000..d8ec3056cf --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/gen-private-method/yield-identifier-spread-strict-strict.js @@ -0,0 +1,85 @@ +// |reftest| error:SyntaxError +'use strict'; +// This file was procedurally generated from the following sources: +// - src/generators/yield-identifier-spread-strict.case +// - src/generators/default/class-decl-private-method.template +/*--- +description: It's an early error if the AssignmentExpression is a function body with yield as an identifier in strict mode. (Generator private method as a ClassDeclaration element) +esid: prod-GeneratorPrivateMethod +features: [object-spread, generators, class-methods-private] +flags: [generated, onlyStrict] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + GeneratorMethod + + 14.4 Generator Function Definitions + + GeneratorMethod : + * PropertyName ( UniqueFormalParameters ) { GeneratorBody } + + + Spread Properties + + PropertyDefinition[Yield]: + (...) + ...AssignmentExpression[In, ?Yield] + +---*/ +$DONOTEVALUATE(); + +var callCount = 0; + +class C { + *#gen() { + callCount += 1; + return { + ...(function() { + var yield; + throw new Test262Error(); + }()), + } + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "Private field '#gen' does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "Private field '#gen' does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "Private field '#gen' does not appear as an own property on C instance" +); + +var iter = c.gen(); + + + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "Private field '#gen' does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "Private field '#gen' does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "Private field '#gen' does not appear as an own property on C instance" +); diff --git a/js/src/tests/test262/language/statements/class/elements/gen-private-method/yield-identifier-strict-strict.js b/js/src/tests/test262/language/statements/class/elements/gen-private-method/yield-identifier-strict-strict.js new file mode 100644 index 0000000000..0d4ecfecc4 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/gen-private-method/yield-identifier-strict-strict.js @@ -0,0 +1,76 @@ +// |reftest| error:SyntaxError +'use strict'; +// This file was procedurally generated from the following sources: +// - src/generators/yield-identifier-strict.case +// - src/generators/default/class-decl-private-method.template +/*--- +description: It's an early error if the generator body has another function body with yield as an identifier in strict mode. (Generator private method as a ClassDeclaration element) +esid: prod-GeneratorPrivateMethod +features: [generators, class-methods-private] +flags: [generated, onlyStrict] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + GeneratorMethod + + 14.4 Generator Function Definitions + + GeneratorMethod : + * PropertyName ( UniqueFormalParameters ) { GeneratorBody } + +---*/ +$DONOTEVALUATE(); + +var callCount = 0; + +class C { + *#gen() { + callCount += 1; + (function() { + var yield; + throw new Test262Error(); + }()) + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "Private field '#gen' does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "Private field '#gen' does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "Private field '#gen' does not appear as an own property on C instance" +); + +var iter = c.gen(); + + + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "Private field '#gen' does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "Private field '#gen' does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "Private field '#gen' does not appear as an own property on C instance" +); diff --git a/js/src/tests/test262/language/statements/class/elements/gen-private-method/yield-spread-arr-multiple.js b/js/src/tests/test262/language/statements/class/elements/gen-private-method/yield-spread-arr-multiple.js new file mode 100644 index 0000000000..5f066c3b1d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/gen-private-method/yield-spread-arr-multiple.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/generators/yield-spread-arr-multiple.case +// - src/generators/default/class-decl-private-method.template +/*--- +description: Use yield value in a array spread position (Generator private method as a ClassDeclaration element) +esid: prod-GeneratorPrivateMethod +features: [generators, class-methods-private] +flags: [generated] +includes: [compareArray.js] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + GeneratorMethod + + 14.4 Generator Function Definitions + + GeneratorMethod : + * PropertyName ( UniqueFormalParameters ) { GeneratorBody } + + + Array Initializer + + SpreadElement[Yield, Await]: + ...AssignmentExpression[+In, ?Yield, ?Await] + +---*/ +var arr = ['a', 'b', 'c']; +var item; + +var callCount = 0; + +class C { + *#gen() { + callCount += 1; + yield [...yield yield]; + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "Private field '#gen' does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "Private field '#gen' does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "Private field '#gen' does not appear as an own property on C instance" +); + +var iter = c.gen(); + +iter.next(false); +item = iter.next(['a', 'b', 'c']); +item = iter.next(item.value); + +assert.compareArray(item.value, arr); +assert.sameValue(item.done, false); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "Private field '#gen' does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "Private field '#gen' does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "Private field '#gen' does not appear as an own property on C instance" +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/gen-private-method/yield-spread-arr-single.js b/js/src/tests/test262/language/statements/class/elements/gen-private-method/yield-spread-arr-single.js new file mode 100644 index 0000000000..e683264094 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/gen-private-method/yield-spread-arr-single.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/generators/yield-spread-arr-single.case +// - src/generators/default/class-decl-private-method.template +/*--- +description: Use yield value in a array spread position (Generator private method as a ClassDeclaration element) +esid: prod-GeneratorPrivateMethod +features: [generators, class-methods-private] +flags: [generated] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + GeneratorMethod + + 14.4 Generator Function Definitions + + GeneratorMethod : + * PropertyName ( UniqueFormalParameters ) { GeneratorBody } + + + Array Initializer + + SpreadElement[Yield, Await]: + ...AssignmentExpression[+In, ?Yield, ?Await] +---*/ +var arr = ['a', 'b', 'c']; + +var callCount = 0; + +class C { + *#gen() { + callCount += 1; + yield [...yield]; + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "Private field '#gen' does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "Private field '#gen' does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "Private field '#gen' does not appear as an own property on C instance" +); + +var iter = c.gen(); + +iter.next(false); +var item = iter.next(arr); +var value = item.value; + +assert.notSameValue(value, arr, 'value is a new array'); +assert(Array.isArray(value), 'value is an Array exotic object'); +assert.sameValue(value.length, 3) +assert.sameValue(value[0], 'a'); +assert.sameValue(value[1], 'b'); +assert.sameValue(value[2], 'c'); +assert.sameValue(item.done, false); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "Private field '#gen' does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "Private field '#gen' does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "Private field '#gen' does not appear as an own property on C instance" +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/gen-private-method/yield-spread-obj.js b/js/src/tests/test262/language/statements/class/elements/gen-private-method/yield-spread-obj.js new file mode 100644 index 0000000000..cf3eb131fd --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/gen-private-method/yield-spread-obj.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/generators/yield-spread-obj.case +// - src/generators/default/class-decl-private-method.template +/*--- +description: Use yield value in a object spread position (Generator private method as a ClassDeclaration element) +esid: prod-GeneratorPrivateMethod +features: [object-spread, generators, class-methods-private] +flags: [generated] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + GeneratorMethod + + 14.4 Generator Function Definitions + + GeneratorMethod : + * PropertyName ( UniqueFormalParameters ) { GeneratorBody } + + + Spread Properties + + PropertyDefinition[Yield]: + (...) + ...AssignmentExpression[In, ?Yield] + +---*/ + +var callCount = 0; + +class C { + *#gen() { + callCount += 1; + yield { + ...yield, + y: 1, + ...yield yield, + }; + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "Private field '#gen' does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "Private field '#gen' does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "Private field '#gen' does not appear as an own property on C instance" +); + +var iter = c.gen(); + +iter.next(); +iter.next({ x: 42 }); +iter.next({ x: 'lol' }); +var item = iter.next({ y: 39 }); + +assert.sameValue(item.value.x, 42); +assert.sameValue(item.value.y, 39); +assert.sameValue(Object.keys(item.value).length, 2); +assert.sameValue(item.done, false); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "Private field '#gen' does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "Private field '#gen' does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "Private field '#gen' does not appear as an own property on C instance" +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/get-access-of-missing-private-getter.js b/js/src/tests/test262/language/statements/class/elements/get-access-of-missing-private-getter.js new file mode 100644 index 0000000000..900bb55fe0 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/get-access-of-missing-private-getter.js @@ -0,0 +1,41 @@ +// Copyright (C) 2019 Caio Lima (Igalia SL). All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Trying to get a private member without getter throws TypeError +esid: sec-privatefieldget +info: | + PrivateFieldGet ( P, O ) + 1. Assert: P is a Private Name. + 2. If O is not an object, throw a TypeError exception. + 3. If P.[[Kind]] is "field", + a. Let entry be PrivateFieldFind(P, O). + b. If entry is empty, throw a TypeError exception. + c. Return entry.[[PrivateFieldValue]]. + 4. Perform ? PrivateBrandCheck(O, P). + 5. If P.[[Kind]] is "method", + a. Return P.[[Value]]. + 6. Else, + a. Assert: P.[[Kind]] is "accessor". + b. If P does not have a [[Get]] field, throw a TypeError exception. + c. Let getter be P.[[Get]]. + d. Return ? Call(getter, O). +features: [class-methods-private, class] +---*/ + +class C { + set #f(v) { + throw new Test262Error(); + } + + getAccess() { + return this.#f; + } +} + +let c = new C(); +assert.throws(TypeError, function() { + c.getAccess(); +}, 'get operation on private accessor without getter should throw TypeError'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/get-access-of-missing-private-static-getter.js b/js/src/tests/test262/language/statements/class/elements/get-access-of-missing-private-static-getter.js new file mode 100644 index 0000000000..9958b1e474 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/get-access-of-missing-private-static-getter.js @@ -0,0 +1,40 @@ +// Copyright (C) 2021 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Trying to get a private member without getter throws TypeError +esid: sec-privatefieldget +info: | + PrivateFieldGet ( P, O ) + 1. Assert: P is a Private Name. + 2. If O is not an object, throw a TypeError exception. + 3. If P.[[Kind]] is "field", + a. Let entry be PrivateFieldFind(P, O). + b. If entry is empty, throw a TypeError exception. + c. Return entry.[[PrivateFieldValue]]. + 4. Perform ? PrivateBrandCheck(O, P). + 5. If P.[[Kind]] is "method", + a. Return P.[[Value]]. + 6. Else, + a. Assert: P.[[Kind]] is "accessor". + b. If P does not have a [[Get]] field, throw a TypeError exception. + c. Let getter be P.[[Get]]. + d. Return ? Call(getter, O). +features: [class-static-methods-private, class] +---*/ + +class C { + static set #f(v) { + throw new Test262Error(); + } + + static getAccess() { + return this.#f; + } +} + +assert.throws(TypeError, function() { + C.getAccess(); +}, 'get operation on private accessor without getter should throw TypeError'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/get-access-of-missing-shadowed-private-getter.js b/js/src/tests/test262/language/statements/class/elements/get-access-of-missing-shadowed-private-getter.js new file mode 100644 index 0000000000..c35e339eef --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/get-access-of-missing-shadowed-private-getter.js @@ -0,0 +1,91 @@ +// Copyright (C) 2019 Caio Lima (Igalia SL). All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Trying to get from PrivateName without [[Get]] throws TypeError +esid: sec-privatefieldget +info: | + PrivateFieldGet (P, O ) + 1. Assert: P is a Private Name. + 2. If O is not an object, throw a TypeError exception. + 3. If P.[[Kind]] is "field", + a. Let entry be PrivateFieldFind(P, O). + b. If entry is empty, throw a TypeError exception. + c. Return entry.[[PrivateFieldValue]]. + 4. Perform ? PrivateBrandCheck(O, P). + 5. If P.[[Kind]] is "method", + a. Return P.[[Value]]. + 6. Else, + a. Assert: P.[[Kind]] is "accessor". + b. If P does not have a [[Get]] field, throw a TypeError exception. + c. Let getter be P.[[Get]]. + d. Return ? Call(getter, O). +features: [class-methods-private, class-fields-public, class] +---*/ + +class A { + get #f() { + throw new Test262Error(); + } +} + +class C extends A { + set #f(v) { + throw new Test262Error(); + } + + getAccess() { + return this.#f; + } +} + +let c = new C(); +assert.throws(TypeError, function() { + c.getAccess(); +}, 'subclass private accessor should shadow super class private accessor'); + +class B { + get #f() { + throw new Test262Error(); + } + + Inner = class { + set #f(v) { + throw new Test262Error(); + } + + getAccess() { + return this.#f; + } + } +} + +let b = new B(); +let innerB = new b.Inner(); +assert.throws(TypeError, function() { + innerB.getAccess(); +}, 'inner class private accessor should shadow outer class private accessor'); + +class D { + set #f(v) { + throw new Test262Error(); + } + + Inner = class { + get #f() { + throw new Test262Error(); + } + } + + getAccess() { + return this.#f; + } +} + +let d = new D(); +assert.throws(TypeError, function() { + d.getAccess(); +}, 'inner class private accessor should not be visible to outer class private accessor'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/grammar-private-field-optional-chaining.js b/js/src/tests/test262/language/statements/class/elements/grammar-private-field-optional-chaining.js new file mode 100644 index 0000000000..d0c3fc7cbe --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/grammar-private-field-optional-chaining.js @@ -0,0 +1,42 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-private-field-optional-chaining.case +// - src/class-elements/default/cls-decl.template +/*--- +description: PrivateName after '?.' is valid syntax (field definitions in a class declaration) +esid: prod-FieldDefinition +features: [class-fields-private, optional-chaining, class] +flags: [generated] +info: | + Updated Productions + + OptionalChain[Yield, Await]: + `?.` `[` Expression[+In, ?Yield, ?Await] `]` + `?.` IdentifierName + `?.` Arguments[?Yield, ?Await] + `?.` TemplateLiteral[?Yield, ?Await, +Tagged] + `?.` PrivateIdentifier + +---*/ + + +class C { + #m = 'test262'; + + static access(obj) { + return obj?.#m; + } +} + +let c = new C(); + +assert.sameValue(C.access(c), 'test262'); + +assert.sameValue(C.access(null), undefined); +assert.sameValue(C.access(undefined), undefined); + +assert.throws(TypeError, function() { + C.access({}); +}, 'accessed private field from an ordinary object'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/indirect-eval-contains-arguments.js b/js/src/tests/test262/language/statements/class/elements/indirect-eval-contains-arguments.js new file mode 100644 index 0000000000..5223d5dd2b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/indirect-eval-contains-arguments.js @@ -0,0 +1,23 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/eval-contains-arguments.case +// - src/class-elements/initializer-indirect-eval-arguments/cls-decl-fields-indirect-eval.template +/*--- +description: No error if `arguments` in StatementList of eval (indirect eval) +esid: sec-performeval-rules-in-initializer +features: [class, class-fields-public] +flags: [generated, noStrict] +info: | + For indirect eval, the "Additional Early Error Rules for Eval Inside Initializer" + (in #sec-performeval-rules-in-initializer) are NOT applicable. + +---*/ + + +var arguments = 1; +class C { + x = (0, eval)('arguments;'); +} + +assert.sameValue(new C().x, arguments); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/indirect-eval-err-contains-newtarget.js b/js/src/tests/test262/language/statements/class/elements/indirect-eval-err-contains-newtarget.js new file mode 100644 index 0000000000..23dfc171bb --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/indirect-eval-err-contains-newtarget.js @@ -0,0 +1,37 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/eval-err-contains-newtarget.case +// - src/class-elements/initializer-eval-newtarget/cls-decl-fields-indirect-eval.template +/*--- +description: error if `new.target` in StatementList of eval (indirect eval) +esid: sec-performeval-rules-in-initializer +features: [class, new.target, class-fields-public] +flags: [generated] +info: | + Additional Early Error Rules for Eval Inside Initializer + These static semantics are applied by PerformEval when a direct eval call occurs inside a class field initializer. + ScriptBody : StatementList + + ... + The remaining eval rules apply as outside a constructor, inside a method, and inside a function. + + Additional Early Error Rules for Eval Outside Functions + These static semantics are applied by PerformEval when a direct eval call occurs outside of any function. + ScriptBody : StatementList + + It is a Syntax Error if StatementList Contains NewTarget. + +---*/ + + +var executed = false; +class C { + x = (0, eval)('executed = true; new.target;'); +} + +assert.throws(SyntaxError, function() { + new C(); +}); + +assert.sameValue(executed, false); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/init-err-evaluation.js b/js/src/tests/test262/language/statements/class/elements/init-err-evaluation.js new file mode 100644 index 0000000000..d661a37ab6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/init-err-evaluation.js @@ -0,0 +1,38 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/init-err-evaluation.case +// - src/class-elements/default/cls-decl.template +/*--- +description: Return abrupt completion evaluating the field initializer (field definitions in a class declaration) +esid: prod-FieldDefinition +features: [class-fields-public, class] +flags: [generated] +info: | + [[Construct]] ( argumentsList, newTarget) + + 8. If kind is "base", then + a. Perform OrdinaryCallBindThis(F, calleeContext, thisArgument). + b. Let result be InitializeInstanceFields(thisArgument, F). + ... + ... + 11. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + ... + +---*/ +var x = 0; +function fn1() { x += 1; } +function fn2() { throw new Test262Error(); } + + +class C { + x = fn1(); + y = fn2(); + z = fn1(); +} + +assert.throws(Test262Error, function() { + new C(); +}); + +assert.sameValue(x, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/init-value-defined-after-class.js b/js/src/tests/test262/language/statements/class/elements/init-value-defined-after-class.js new file mode 100644 index 0000000000..d5e0029d15 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/init-value-defined-after-class.js @@ -0,0 +1,50 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/init-value-defined-after-class.case +// - src/class-elements/default/cls-decl.template +/*--- +description: The initializer value is defined after the class evaluation (field definitions in a class declaration) +esid: prod-FieldDefinition +features: [class-fields-public, computed-property-names, class] +flags: [generated] +includes: [propertyHelper.js] +info: | + [[Construct]] ( argumentsList, newTarget) + + 8. If kind is "base", then + a. Perform OrdinaryCallBindThis(F, calleeContext, thisArgument). + b. Let result be InitializeInstanceFields(thisArgument, F). + ... + ... + 11. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + ... + +---*/ +var x = false; + + +class C { + [x] = x; +} + +var c1 = new C(); + +x = true; +var c2 = new C(); + +verifyProperty(c1, "false", { + value: false, + enumerable: true, + configurable: true, + writable: true, +}); +verifyProperty(c2, "false", { + value: true, + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(c1.hasOwnProperty("true"), false); +assert.sameValue(c2.hasOwnProperty("true"), false); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/init-value-incremental.js b/js/src/tests/test262/language/statements/class/elements/init-value-incremental.js new file mode 100644 index 0000000000..6fd18c1f7a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/init-value-incremental.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/init-value-incremental.case +// - src/class-elements/default/cls-decl.template +/*--- +description: The initializer value is defined during the class instatiation (field definitions in a class declaration) +esid: prod-FieldDefinition +features: [class-fields-public, computed-property-names, class] +flags: [generated] +includes: [propertyHelper.js] +info: | + Runtime Semantics: ClassDefinitionEvaluation + + 27. For each ClassElement e in order from elements + ... + d. Append to fieldRecords the elements of fields. + ... + 33. Let result be InitializeStaticFields(F). + ... + + [[Construct]] ( argumentsList, newTarget) + + 8. If kind is "base", then + a. Perform OrdinaryCallBindThis(F, calleeContext, thisArgument). + b. Let result be InitializeInstanceFields(thisArgument, F). + ... + ... + 11. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + ... + +---*/ +var x = 1; + + +class C { + [x++] = x++; + [x++] = x++; +} + +var c1 = new C(); +var c2 = new C(); + +verifyProperty(c1, "1", { + value: 3, + enumerable: true, + configurable: true, + writable: true, +}); + +verifyProperty(c1, "2", { + value: 4, + enumerable: true, + configurable: true, + writable: true, +}); + +verifyProperty(c2, "1", { + value: 5, + enumerable: true, + configurable: true, + writable: true, +}); + +verifyProperty(c2, "2", { + value: 6, + enumerable: true, + configurable: true, + writable: true, +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/intercalated-static-non-static-computed-fields.js b/js/src/tests/test262/language/statements/class/elements/intercalated-static-non-static-computed-fields.js new file mode 100644 index 0000000000..5cd4ef79f2 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/intercalated-static-non-static-computed-fields.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/intercalated-static-non-static-computed-fields.case +// - src/class-elements/default/cls-decl.template +/*--- +description: Computed class fields are executed in the order they are delcared, regardless it is static or instance field (field definitions in a class declaration) +esid: prod-FieldDefinition +features: [class-static-fields-public, class-fields-public, class] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassTail : ClassHeritage { ClassBody } + ... + 28. For each ClassElement e in order from elements, + a. If IsStatic of e is false, then + i. Let field be the result of performing ClassElementEvaluation for e with arguments proto and false. + b. Else, + i. Let field be the result of performing PropertyDefinitionEvaluation for mClassElementEvaluation for e with arguments F and false. + c. If field is an abrupt completion, then + ... + d. If field is not empty, + i. If IsStatic of e is false, append field to instanceFields. + ii. Otherwise, append field to staticFields. + ... + 34. For each item fieldRecord in order from staticFields, + a. Perform ? DefineField(F, field). + ... + + [[Construct]] (argumentsList, newTarget) + ... + 8. If kind is "base", then + a. Perform OrdinaryCallBindThis(F, calleeContext, thisArgument). + b. Let result be InitializeInstanceFields(thisArgument, F). + c. If result is an abrupt completion, then + i. Remove calleeContext from execution context stack and restore callerContext as the running execution context. + ii. Return Completion(result). + +---*/ + +let i = 0; + + +class C { + [i++] = i++; + static [i++] = i++; + [i++] = i++; +} + +let c = new C(); + +// It is important to notice that static field initializer will run before any instance initializer +verifyProperty(c, "0", { + value: 4, + enumerable: true, + writable: true, + configurable: true +}); + +verifyProperty(c, "2", { + value: 5, + enumerable: true, + writable: true, + configurable: true +}); + +verifyProperty(C, "1", { + value: 3, + enumerable: true, + writable: true, + configurable: true +}); + +assert.sameValue(i, 6); +assert.sameValue(c.hasOwnProperty('1'), false); +assert.sameValue(C.hasOwnProperty('0'), false); +assert.sameValue(C.hasOwnProperty('2'), false); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/literal-name-init-err-contains-arguments.js b/js/src/tests/test262/language/statements/class/elements/literal-name-init-err-contains-arguments.js new file mode 100644 index 0000000000..39a2bd81fa --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/literal-name-init-err-contains-arguments.js @@ -0,0 +1,35 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/init-err-contains-arguments.case +// - src/class-elements/initializer-error/cls-decl-fields-literal-name.template +/*--- +description: Syntax error if `arguments` used in class field (literal ClassElementName) +esid: sec-class-definitions-static-semantics-early-errors +features: [class, class-fields-public] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Static Semantics: Early Errors + + FieldDefinition: + PropertyNameInitializeropt + + - It is a Syntax Error if ContainsArguments of Initializer is true. + + Static Semantics: ContainsArguments + IdentifierReference : Identifier + + 1. If the StringValue of Identifier is "arguments", return true. + ... + For all other grammatical productions, recurse on all nonterminals. If any piece returns true, then return true. Otherwise return false. + +---*/ + + +$DONOTEVALUATE(); + +class C { + x = arguments; +} diff --git a/js/src/tests/test262/language/statements/class/elements/literal-name-init-err-contains-super.js b/js/src/tests/test262/language/statements/class/elements/literal-name-init-err-contains-super.js new file mode 100644 index 0000000000..a44c5fbb79 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/literal-name-init-err-contains-super.js @@ -0,0 +1,28 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/init-err-contains-super.case +// - src/class-elements/initializer-error/cls-decl-fields-literal-name.template +/*--- +description: Syntax error if `super()` used in class field (literal ClassElementName) +esid: sec-class-definitions-static-semantics-early-errors +features: [class, class-fields-public] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Static Semantics: Early Errors + + FieldDefinition: + PropertyNameInitializeropt + + - It is a Syntax Error if Initializer is present and Initializer Contains SuperCall is true. + +---*/ + + +$DONOTEVALUATE(); + +class C { + x = super(); +} diff --git a/js/src/tests/test262/language/statements/class/elements/multiple-definitions-computed-names.js b/js/src/tests/test262/language/statements/class/elements/multiple-definitions-computed-names.js new file mode 100644 index 0000000000..860928b3e2 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/multiple-definitions-computed-names.js @@ -0,0 +1,158 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/computed-names.case +// - src/class-elements/productions/cls-decl-multiple-definitions.template +/*--- +description: Computed property names (multiple fields definitions) +esid: prod-FieldDefinition +features: [class-fields-public, computed-property-names, class] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PropertyName + +---*/ +var x = "b"; + + + +class C { + foo = "foobar"; + m() { return 42 } + [x] = 42; [10] = "meep"; ["not initialized"] + m2() { return 39 } + bar = "barbaz"; + +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.m2(), 39); +assert(! + Object.prototype.hasOwnProperty.call(c, "m2"), + "m2 doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m2, C.prototype.m2); + +verifyProperty(C.prototype, "m2", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.foo, "foobar"); +assert( + !Object.prototype.hasOwnProperty.call(C, "foo"), + "foo doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "foo"), + "foo doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "foo", { + value: "foobar", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(c.bar, "barbaz"); +assert( + !Object.prototype.hasOwnProperty.call(C, "bar"), + "bar doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "bar"), + "bar doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "bar", { + value: "barbaz", + enumerable: true, + configurable: true, + writable: true, +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "b"), + "b doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "b"), + "b doesn't appear as an own property on C constructor" +); + +verifyProperty(c, "b", { + value: 42, + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "x"), + "x doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "x"), + "x doesn't appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "x"), + "x doesn't appear as an own property on C instance" +); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "10"), + "10 doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "10"), + "10 doesn't appear as an own property on C constructor" +); + +verifyProperty(c, "10", { + value: "meep", + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "not initialized"), + "'not initialized' doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "not initialized"), + "'not initialized' doesn't appear as an own property on C constructor" +); + +verifyProperty(c, "not initialized", { + value: undefined, + enumerable: true, + writable: true, + configurable: true +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/multiple-definitions-computed-symbol-names.js b/js/src/tests/test262/language/statements/class/elements/multiple-definitions-computed-symbol-names.js new file mode 100644 index 0000000000..fe31aada9d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/multiple-definitions-computed-symbol-names.js @@ -0,0 +1,156 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/computed-symbol-names.case +// - src/class-elements/productions/cls-decl-multiple-definitions.template +/*--- +description: Computed property symbol names (multiple fields definitions) +esid: prod-FieldDefinition +features: [class-fields-public, Symbol, computed-property-names, class] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PropertyName + +---*/ +var x = Symbol(); +var y = Symbol(); + + + +class C { + foo = "foobar"; + m() { return 42 } + [x]; [y] = 42 + m2() { return 39 } + bar = "barbaz"; + +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.m2(), 39); +assert(! + Object.prototype.hasOwnProperty.call(c, "m2"), + "m2 doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m2, C.prototype.m2); + +verifyProperty(C.prototype, "m2", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.foo, "foobar"); +assert( + !Object.prototype.hasOwnProperty.call(C, "foo"), + "foo doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "foo"), + "foo doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "foo", { + value: "foobar", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(c.bar, "barbaz"); +assert( + !Object.prototype.hasOwnProperty.call(C, "bar"), + "bar doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "bar"), + "bar doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "bar", { + value: "barbaz", + enumerable: true, + configurable: true, + writable: true, +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, x), + "Symbol x doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, x), + "Symbol x doesn't appear as an own property on C constructor" +); + +verifyProperty(c, x, { + value: undefined, + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, y), + "Symbol y doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, y), + "Symbol y doesn't appear as an own property on C constructor" +); + +verifyProperty(c, y, { + value: 42, + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "x"), + "x doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "x"), + "x doesn't appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "x"), + "x doesn't appear as an own property on C instance" +); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "y"), + "y doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "y"), + "y doesn't appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "y"), + "y doesn't appear as an own property on C instance" +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/multiple-definitions-grammar-privatename-identifier-semantics-stringvalue.js b/js/src/tests/test262/language/statements/class/elements/multiple-definitions-grammar-privatename-identifier-semantics-stringvalue.js new file mode 100644 index 0000000000..d014f636f4 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/multiple-definitions-grammar-privatename-identifier-semantics-stringvalue.js @@ -0,0 +1,160 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-privatename-identifier-semantics-stringvalue.case +// - src/class-elements/productions/cls-decl-multiple-definitions.template +/*--- +description: PrivateName Static Semantics, StringValue (multiple fields definitions) +esid: prod-FieldDefinition +features: [class-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + + + 1. Return the String value consisting of the sequence of code + units corresponding to PrivateName. In determining the sequence + any occurrences of \ UnicodeEscapeSequence are first replaced + with the code point represented by the UnicodeEscapeSequence + and then the code points of the entire PrivateName are converted + to code units by UTF16Encoding (10.1.1) each code point. + +---*/ + + +class C { + foo = "foobar"; + m() { return 42 } + #\u{6F}; + #\u2118; + #ZW_\u200C_NJ; + #ZW_\u200D_J; + m2() { return 39 } + bar = "barbaz"; + o(value) { + this.#o = value; + return this.#o; + } + ℘(value) { + this.#℘ = value; + return this.#℘; + } + ZW_‌_NJ(value) { // DO NOT CHANGE THE NAME OF THIS METHOD + this.#ZW_‌_NJ = value; + return this.#ZW_‌_NJ; + } + ZW_‍_J(value) { // DO NOT CHANGE THE NAME OF THIS METHOD + this.#ZW_‍_J = value; + return this.#ZW_‍_J; + } +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.m2(), 39); +assert(! + Object.prototype.hasOwnProperty.call(c, "m2"), + "m2 doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m2, C.prototype.m2); + +verifyProperty(C.prototype, "m2", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.foo, "foobar"); +assert( + !Object.prototype.hasOwnProperty.call(C, "foo"), + "foo doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "foo"), + "foo doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "foo", { + value: "foobar", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(c.bar, "barbaz"); +assert( + !Object.prototype.hasOwnProperty.call(C, "bar"), + "bar doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "bar"), + "bar doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "bar", { + value: "barbaz", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(c.o(1), 1); +assert.sameValue(c.℘(1), 1); +assert.sameValue(c.ZW_‌_NJ(1), 1); +assert.sameValue(c.ZW_‍_J(1), 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/multiple-definitions-literal-names-asi.js b/js/src/tests/test262/language/statements/class/elements/multiple-definitions-literal-names-asi.js new file mode 100644 index 0000000000..8ed80fdd78 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/multiple-definitions-literal-names-asi.js @@ -0,0 +1,128 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/literal-names-asi.case +// - src/class-elements/productions/cls-decl-multiple-definitions.template +/*--- +description: Literal property names with ASI (multiple fields definitions) +esid: prod-FieldDefinition +features: [class-fields-public, class] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PropertyName + +---*/ + + +class C { + foo = "foobar"; + m() { return 42 } + a + b = 42; + m2() { return 39 } + bar = "barbaz"; + +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.m2(), 39); +assert(! + Object.prototype.hasOwnProperty.call(c, "m2"), + "m2 doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m2, C.prototype.m2); + +verifyProperty(C.prototype, "m2", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.foo, "foobar"); +assert( + !Object.prototype.hasOwnProperty.call(C, "foo"), + "foo doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "foo"), + "foo doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "foo", { + value: "foobar", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(c.bar, "barbaz"); +assert( + !Object.prototype.hasOwnProperty.call(C, "bar"), + "bar doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "bar"), + "bar doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "bar", { + value: "barbaz", + enumerable: true, + configurable: true, + writable: true, +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "a"), + "a doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "a"), + "a doesn't appear as an own property on C constructor" +); + +verifyProperty(c, "a", { + value: undefined, + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "b"), + "b doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "b"), + "b doesn't appear as an own property on C constructor" +); + +verifyProperty(c, "b", { + value: 42, + enumerable: true, + writable: true, + configurable: true +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/multiple-definitions-literal-names.js b/js/src/tests/test262/language/statements/class/elements/multiple-definitions-literal-names.js new file mode 100644 index 0000000000..052d34112d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/multiple-definitions-literal-names.js @@ -0,0 +1,147 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/literal-names.case +// - src/class-elements/productions/cls-decl-multiple-definitions.template +/*--- +description: Literal property names (multiple fields definitions) +esid: prod-FieldDefinition +features: [class-fields-public, class] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PropertyName + +---*/ +const fn = function() {} + + + +class C { + foo = "foobar"; + m() { return 42 } + a; b = 42; + c = fn + m2() { return 39 } + bar = "barbaz"; + +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.m2(), 39); +assert(! + Object.prototype.hasOwnProperty.call(c, "m2"), + "m2 doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m2, C.prototype.m2); + +verifyProperty(C.prototype, "m2", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.foo, "foobar"); +assert( + !Object.prototype.hasOwnProperty.call(C, "foo"), + "foo doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "foo"), + "foo doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "foo", { + value: "foobar", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(c.bar, "barbaz"); +assert( + !Object.prototype.hasOwnProperty.call(C, "bar"), + "bar doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "bar"), + "bar doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "bar", { + value: "barbaz", + enumerable: true, + configurable: true, + writable: true, +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "a"), + "a doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "a"), + "a doesn't appear as an own property on C constructor" +); + +verifyProperty(c, "a", { + value: undefined, + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "b"), + "b doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "b"), + "b doesn't appear as an own property on C constructor" +); + +verifyProperty(c, "b", { + value: 42, + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "c"), + "c doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "c"), + "c doesn't appear as an own property on C constructor" +); + +verifyProperty(c, "c", { + value: fn, + enumerable: true, + writable: true, + configurable: true +}); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/multiple-definitions-private-field-usage.js b/js/src/tests/test262/language/statements/class/elements/multiple-definitions-private-field-usage.js new file mode 100644 index 0000000000..66093b3c15 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/multiple-definitions-private-field-usage.js @@ -0,0 +1,100 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/private-field-usage.case +// - src/class-elements/productions/cls-decl-multiple-definitions.template +/*--- +description: PrivateName CallExpression usage (private field) (multiple fields definitions) +esid: prod-FieldDefinition +features: [class-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + Updated Productions + + CallExpression[Yield, Await]: + CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await] + SuperCall[?Yield, ?Await] + CallExpression[?Yield, ?Await]Arguments[?Yield, ?Await] + CallExpression[?Yield, ?Await][Expression[+In, ?Yield, ?Await]] + CallExpression[?Yield, ?Await].IdentifierName + CallExpression[?Yield, ?Await]TemplateLiteral[?Yield, ?Await] + CallExpression[?Yield, ?Await].PrivateName + +---*/ + + +class C { + foo = "foobar"; + m() { return 42 } + #m = 'test262'; + m2() { return 39 } + bar = "barbaz"; + method() { + return this.#m; + } +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.m2(), 39); +assert(! + Object.prototype.hasOwnProperty.call(c, "m2"), + "m2 doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m2, C.prototype.m2); + +verifyProperty(C.prototype, "m2", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.foo, "foobar"); +assert( + !Object.prototype.hasOwnProperty.call(C, "foo"), + "foo doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "foo"), + "foo doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "foo", { + value: "foobar", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(c.bar, "barbaz"); +assert( + !Object.prototype.hasOwnProperty.call(C, "bar"), + "bar doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "bar"), + "bar doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "bar", { + value: "barbaz", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(c.method(), 'test262'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/multiple-definitions-private-method-getter-usage.js b/js/src/tests/test262/language/statements/class/elements/multiple-definitions-private-method-getter-usage.js new file mode 100644 index 0000000000..b750b761cf --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/multiple-definitions-private-method-getter-usage.js @@ -0,0 +1,100 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/private-method-getter-usage.case +// - src/class-elements/productions/cls-decl-multiple-definitions.template +/*--- +description: PrivateName CallExpression usage (Accesor get method) (multiple fields definitions) +esid: prod-FieldDefinition +features: [class-methods-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + Updated Productions + + CallExpression[Yield, Await]: + CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await] + SuperCall[?Yield, ?Await] + CallExpression[?Yield, ?Await]Arguments[?Yield, ?Await] + CallExpression[?Yield, ?Await][Expression[+In, ?Yield, ?Await]] + CallExpression[?Yield, ?Await].IdentifierName + CallExpression[?Yield, ?Await]TemplateLiteral[?Yield, ?Await] + CallExpression[?Yield, ?Await].PrivateName + +---*/ + + +class C { + foo = "foobar"; + m() { return 42 } + get #m() { return 'test262'; } + m2() { return 39 } + bar = "barbaz"; + method() { + return this.#m; + } +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.m2(), 39); +assert(! + Object.prototype.hasOwnProperty.call(c, "m2"), + "m2 doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m2, C.prototype.m2); + +verifyProperty(C.prototype, "m2", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.foo, "foobar"); +assert( + !Object.prototype.hasOwnProperty.call(C, "foo"), + "foo doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "foo"), + "foo doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "foo", { + value: "foobar", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(c.bar, "barbaz"); +assert( + !Object.prototype.hasOwnProperty.call(C, "bar"), + "bar doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "bar"), + "bar doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "bar", { + value: "barbaz", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(c.method(), 'test262'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/multiple-definitions-private-method-usage.js b/js/src/tests/test262/language/statements/class/elements/multiple-definitions-private-method-usage.js new file mode 100644 index 0000000000..b4818b335d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/multiple-definitions-private-method-usage.js @@ -0,0 +1,100 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/private-method-usage.case +// - src/class-elements/productions/cls-decl-multiple-definitions.template +/*--- +description: PrivateName CallExpression usage (private method) (multiple fields definitions) +esid: prod-FieldDefinition +features: [class-methods-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + Updated Productions + + CallExpression[Yield, Await]: + CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await] + SuperCall[?Yield, ?Await] + CallExpression[?Yield, ?Await]Arguments[?Yield, ?Await] + CallExpression[?Yield, ?Await][Expression[+In, ?Yield, ?Await]] + CallExpression[?Yield, ?Await].IdentifierName + CallExpression[?Yield, ?Await]TemplateLiteral[?Yield, ?Await] + CallExpression[?Yield, ?Await].PrivateName + +---*/ + + +class C { + foo = "foobar"; + m() { return 42 } + #m() { return 'test262'; } + m2() { return 39 } + bar = "barbaz"; + method() { + return this.#m(); + } +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.m2(), 39); +assert(! + Object.prototype.hasOwnProperty.call(c, "m2"), + "m2 doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m2, C.prototype.m2); + +verifyProperty(C.prototype, "m2", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.foo, "foobar"); +assert( + !Object.prototype.hasOwnProperty.call(C, "foo"), + "foo doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "foo"), + "foo doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "foo", { + value: "foobar", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(c.bar, "barbaz"); +assert( + !Object.prototype.hasOwnProperty.call(C, "bar"), + "bar doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "bar"), + "bar doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "bar", { + value: "barbaz", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(c.method(), 'test262'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/multiple-definitions-private-names.js b/js/src/tests/test262/language/statements/class/elements/multiple-definitions-private-names.js new file mode 100644 index 0000000000..a369a26e8f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/multiple-definitions-private-names.js @@ -0,0 +1,122 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/private-names.case +// - src/class-elements/productions/cls-decl-multiple-definitions.template +/*--- +description: private names (multiple fields definitions) +esid: prod-FieldDefinition +features: [class-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + ... + FieldDefinition ; + + FieldDefinition : + ClassElementName Initializer_opt + + ClassElementName : + PrivateName + + PrivateName : + # IdentifierName + +---*/ + + +class C { + foo = "foobar"; + m() { return 42 } + #x; #y + m2() { return 39 } + bar = "barbaz"; + x() { + this.#x = 42; + return this.#x; + } + y() { + this.#y = 43; + return this.#y; + } +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.m2(), 39); +assert(! + Object.prototype.hasOwnProperty.call(c, "m2"), + "m2 doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m2, C.prototype.m2); + +verifyProperty(C.prototype, "m2", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.foo, "foobar"); +assert( + !Object.prototype.hasOwnProperty.call(C, "foo"), + "foo doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "foo"), + "foo doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "foo", { + value: "foobar", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(c.bar, "barbaz"); +assert( + !Object.prototype.hasOwnProperty.call(C, "bar"), + "bar doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "bar"), + "bar doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "bar", { + value: "barbaz", + enumerable: true, + configurable: true, + writable: true, +}); + +// Test the private fields do not appear as properties before set to value +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#x"), "test 1"); +assert(!Object.prototype.hasOwnProperty.call(C, "#x"), "test 2"); +assert(!Object.prototype.hasOwnProperty.call(c, "#x"), "test 3"); + +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#y"), "test 4"); +assert(!Object.prototype.hasOwnProperty.call(C, "#y"), "test 5"); +assert(!Object.prototype.hasOwnProperty.call(c, "#y"), "test 6"); + +// Test if private fields can be sucessfully accessed and set to value +assert.sameValue(c.x(), 42, "test 7"); +assert.sameValue(c.y(), 43, "test 8"); + +// Test the private fields do not appear as properties before after set to value +assert(!Object.prototype.hasOwnProperty.call(c, "#x"), "test 9"); +assert(!Object.prototype.hasOwnProperty.call(c, "#y"), "test 10"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/multiple-definitions-rs-field-identifier-initializer.js b/js/src/tests/test262/language/statements/class/elements/multiple-definitions-rs-field-identifier-initializer.js new file mode 100644 index 0000000000..6cb971c04a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/multiple-definitions-rs-field-identifier-initializer.js @@ -0,0 +1,138 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-field-identifier-initializer.case +// - src/class-elements/productions/cls-decl-multiple-definitions.template +/*--- +description: Valid FieldDefinition (multiple fields definitions) +esid: prod-FieldDefinition +features: [class-fields-public, class] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + ... + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + + PropertyName : + LiteralPropertyName + ComputedPropertyName + + LiteralPropertyName : + IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + foo = "foobar"; + m() { return 42 } + $ = 1; _ = 1; \u{6F} = 1; \u2118 = 1; ZW_\u200C_NJ = 1; ZW_\u200D_J = 1 + m2() { return 39 } + bar = "barbaz"; + +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.m2(), 39); +assert(! + Object.prototype.hasOwnProperty.call(c, "m2"), + "m2 doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m2, C.prototype.m2); + +verifyProperty(C.prototype, "m2", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.foo, "foobar"); +assert( + !Object.prototype.hasOwnProperty.call(C, "foo"), + "foo doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "foo"), + "foo doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "foo", { + value: "foobar", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(c.bar, "barbaz"); +assert( + !Object.prototype.hasOwnProperty.call(C, "bar"), + "bar doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "bar"), + "bar doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "bar", { + value: "barbaz", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(c.$, 1); +assert.sameValue(c._, 1); +assert.sameValue(c.\u{6F}, 1); +assert.sameValue(c.\u2118, 1); +assert.sameValue(c.ZW_\u200C_NJ, 1); +assert.sameValue(c.ZW_\u200D_J, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/multiple-definitions-rs-field-identifier.js b/js/src/tests/test262/language/statements/class/elements/multiple-definitions-rs-field-identifier.js new file mode 100644 index 0000000000..a239133820 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/multiple-definitions-rs-field-identifier.js @@ -0,0 +1,145 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-field-identifier.case +// - src/class-elements/productions/cls-decl-multiple-definitions.template +/*--- +description: Valid FieldDefinition (multiple fields definitions) +esid: prod-FieldDefinition +features: [class-fields-public, class] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + ... + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + + PropertyName : + LiteralPropertyName + ComputedPropertyName + + LiteralPropertyName : + IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + foo = "foobar"; + m() { return 42 } + $; _; \u{6F}; \u2118; ZW_\u200C_NJ; ZW_\u200D_J + m2() { return 39 } + bar = "barbaz"; + +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.m2(), 39); +assert(! + Object.prototype.hasOwnProperty.call(c, "m2"), + "m2 doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m2, C.prototype.m2); + +verifyProperty(C.prototype, "m2", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.foo, "foobar"); +assert( + !Object.prototype.hasOwnProperty.call(C, "foo"), + "foo doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "foo"), + "foo doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "foo", { + value: "foobar", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(c.bar, "barbaz"); +assert( + !Object.prototype.hasOwnProperty.call(C, "bar"), + "bar doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "bar"), + "bar doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "bar", { + value: "barbaz", + enumerable: true, + configurable: true, + writable: true, +}); + +c.$ = 1; +c._ = 1; +c.\u{6F} = 1; +c.\u2118 = 1; +c.ZW_\u200C_NJ = 1; +c.ZW_\u200D_J = 1; + +assert.sameValue(c.$, 1); +assert.sameValue(c._, 1); +assert.sameValue(c.\u{6F}, 1); +assert.sameValue(c.\u2118, 1); +assert.sameValue(c.ZW_\u200C_NJ, 1); +assert.sameValue(c.ZW_\u200D_J, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/multiple-definitions-rs-private-getter-alt.js b/js/src/tests/test262/language/statements/class/elements/multiple-definitions-rs-private-getter-alt.js new file mode 100644 index 0000000000..3a346bad69 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/multiple-definitions-rs-private-getter-alt.js @@ -0,0 +1,179 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-private-getter-alt.case +// - src/class-elements/productions/cls-decl-multiple-definitions.template +/*--- +description: Valid PrivateName as private getter (multiple fields definitions) +esid: prod-FieldDefinition +features: [class-methods-private, class-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + ... + ; + + MethodDefinition : + ... + get ClassElementName ( ){ FunctionBody } + ... + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + foo = "foobar"; + m() { return 42 } + #$_; #__; #\u{6F}_; #℘_; #ZW_‌_NJ_; #ZW_‍_J_; + get #$() { + return this.#$_; + } + get #_() { + return this.#__; + } + get #\u{6F}() { + return this.#\u{6F}_; + } + get #℘() { + return this.#℘_; + } + get #ZW_‌_NJ() { + return this.#ZW_‌_NJ_; + } + get #ZW_‍_J() { + return this.#ZW_‍_J_; + } + + m2() { return 39 } + bar = "barbaz"; + $(value) { + this.#$_ = value; + return this.#$; + } + _(value) { + this.#__ = value; + return this.#_; + } + \u{6F}(value) { + this.#\u{6F}_ = value; + return this.#\u{6F}; + } + ℘(value) { + this.#℘_ = value; + return this.#℘; + } + ZW_‌_NJ(value) { + this.#ZW_‌_NJ_ = value; + return this.#ZW_‌_NJ; + } + ZW_‍_J(value) { + this.#ZW_‍_J_ = value; + return this.#ZW_‍_J; + } + +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.m2(), 39); +assert(! + Object.prototype.hasOwnProperty.call(c, "m2"), + "m2 doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m2, C.prototype.m2); + +verifyProperty(C.prototype, "m2", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.foo, "foobar"); +assert( + !Object.prototype.hasOwnProperty.call(C, "foo"), + "foo doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "foo"), + "foo doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "foo", { + value: "foobar", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(c.bar, "barbaz"); +assert( + !Object.prototype.hasOwnProperty.call(C, "bar"), + "bar doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "bar"), + "bar doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "bar", { + value: "barbaz", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(c.$(1), 1); +assert.sameValue(c._(1), 1); +assert.sameValue(c.\u{6F}(1), 1); +assert.sameValue(c.℘(1), 1); +assert.sameValue(c.ZW_‌_NJ(1), 1); +assert.sameValue(c.ZW_‍_J(1), 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/multiple-definitions-rs-private-getter.js b/js/src/tests/test262/language/statements/class/elements/multiple-definitions-rs-private-getter.js new file mode 100644 index 0000000000..7825d5d35d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/multiple-definitions-rs-private-getter.js @@ -0,0 +1,179 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-private-getter.case +// - src/class-elements/productions/cls-decl-multiple-definitions.template +/*--- +description: Valid PrivateName as private getter (multiple fields definitions) +esid: prod-FieldDefinition +features: [class-methods-private, class-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + ... + ; + + MethodDefinition : + ... + get ClassElementName ( ){ FunctionBody } + ... + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + foo = "foobar"; + m() { return 42 } + #$_; #__; #\u{6F}_; #\u2118_; #ZW_\u200C_NJ_; #ZW_\u200D_J_; + get #$() { + return this.#$_; + } + get #_() { + return this.#__; + } + get #\u{6F}() { + return this.#\u{6F}_; + } + get #\u2118() { + return this.#\u2118_; + } + get #ZW_\u200C_NJ() { + return this.#ZW_\u200C_NJ_; + } + get #ZW_\u200D_J() { + return this.#ZW_\u200D_J_; + } + + m2() { return 39 } + bar = "barbaz"; + $(value) { + this.#$_ = value; + return this.#$; + } + _(value) { + this.#__ = value; + return this.#_; + } + \u{6F}(value) { + this.#\u{6F}_ = value; + return this.#\u{6F}; + } + \u2118(value) { + this.#\u2118_ = value; + return this.#\u2118; + } + ZW_\u200C_NJ(value) { + this.#ZW_\u200C_NJ_ = value; + return this.#ZW_\u200C_NJ; + } + ZW_\u200D_J(value) { + this.#ZW_\u200D_J_ = value; + return this.#ZW_\u200D_J; + } + +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.m2(), 39); +assert(! + Object.prototype.hasOwnProperty.call(c, "m2"), + "m2 doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m2, C.prototype.m2); + +verifyProperty(C.prototype, "m2", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.foo, "foobar"); +assert( + !Object.prototype.hasOwnProperty.call(C, "foo"), + "foo doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "foo"), + "foo doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "foo", { + value: "foobar", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(c.bar, "barbaz"); +assert( + !Object.prototype.hasOwnProperty.call(C, "bar"), + "bar doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "bar"), + "bar doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "bar", { + value: "barbaz", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(c.$(1), 1); +assert.sameValue(c._(1), 1); +assert.sameValue(c.\u{6F}(1), 1); +assert.sameValue(c.\u2118(1), 1); +assert.sameValue(c.ZW_\u200C_NJ(1), 1); +assert.sameValue(c.ZW_\u200D_J(1), 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/multiple-definitions-rs-private-method-alt.js b/js/src/tests/test262/language/statements/class/elements/multiple-definitions-rs-private-method-alt.js new file mode 100644 index 0000000000..424a19e2e1 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/multiple-definitions-rs-private-method-alt.js @@ -0,0 +1,178 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-private-method-alt.case +// - src/class-elements/productions/cls-decl-multiple-definitions.template +/*--- +description: Valid PrivateName as private method (multiple fields definitions) +esid: prod-FieldDefinition +features: [class-methods-private, class-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + ... + ; + + MethodDefinition : + ClassElementName ( UniqueFormalParameters ) { FunctionBody } + ... + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + foo = "foobar"; + m() { return 42 } + #$_; #__; #\u{6F}_; #℘_; #ZW_‌_NJ_; #ZW_‍_J_; + #$() { + return this.#$_; + } + #_() { + return this.#__; + } + #\u{6F}() { + return this.#\u{6F}_; + } + #℘() { + return this.#℘_; + } + #ZW_‌_NJ() { + return this.#ZW_‌_NJ_; + } + #ZW_‍_J() { + return this.#ZW_‍_J_; + } + + m2() { return 39 } + bar = "barbaz"; + $(value) { + this.#$_ = value; + return this.#$(); + } + _(value) { + this.#__ = value; + return this.#_(); + } + \u{6F}(value) { + this.#\u{6F}_ = value; + return this.#\u{6F}(); + } + ℘(value) { + this.#℘_ = value; + return this.#℘(); + } + ZW_‌_NJ(value) { + this.#ZW_‌_NJ_ = value; + return this.#ZW_‌_NJ(); + } + ZW_‍_J(value) { + this.#ZW_‍_J_ = value; + return this.#ZW_‍_J(); + } + +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.m2(), 39); +assert(! + Object.prototype.hasOwnProperty.call(c, "m2"), + "m2 doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m2, C.prototype.m2); + +verifyProperty(C.prototype, "m2", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.foo, "foobar"); +assert( + !Object.prototype.hasOwnProperty.call(C, "foo"), + "foo doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "foo"), + "foo doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "foo", { + value: "foobar", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(c.bar, "barbaz"); +assert( + !Object.prototype.hasOwnProperty.call(C, "bar"), + "bar doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "bar"), + "bar doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "bar", { + value: "barbaz", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(c.$(1), 1); +assert.sameValue(c._(1), 1); +assert.sameValue(c.\u{6F}(1), 1); +assert.sameValue(c.℘(1), 1); +assert.sameValue(c.ZW_‌_NJ(1), 1); +assert.sameValue(c.ZW_‍_J(1), 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/multiple-definitions-rs-private-method.js b/js/src/tests/test262/language/statements/class/elements/multiple-definitions-rs-private-method.js new file mode 100644 index 0000000000..e956a4dc94 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/multiple-definitions-rs-private-method.js @@ -0,0 +1,178 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-private-method.case +// - src/class-elements/productions/cls-decl-multiple-definitions.template +/*--- +description: Valid PrivateName as private method (multiple fields definitions) +esid: prod-FieldDefinition +features: [class-methods-private, class-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + ... + ; + + MethodDefinition : + ClassElementName ( UniqueFormalParameters ) { FunctionBody } + ... + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + foo = "foobar"; + m() { return 42 } + #$_; #__; #\u{6F}_; #\u2118_; #ZW_\u200C_NJ_; #ZW_\u200D_J_; + #$() { + return this.#$_; + } + #_() { + return this.#__; + } + #\u{6F}() { + return this.#\u{6F}_; + } + #\u2118() { + return this.#\u2118_; + } + #ZW_\u200C_NJ() { + return this.#ZW_\u200C_NJ_; + } + #ZW_\u200D_J() { + return this.#ZW_\u200D_J_; + } + + m2() { return 39 } + bar = "barbaz"; + $(value) { + this.#$_ = value; + return this.#$(); + } + _(value) { + this.#__ = value; + return this.#_(); + } + \u{6F}(value) { + this.#\u{6F}_ = value; + return this.#\u{6F}(); + } + \u2118(value) { + this.#\u2118_ = value; + return this.#\u2118(); + } + ZW_\u200C_NJ(value) { + this.#ZW_\u200C_NJ_ = value; + return this.#ZW_\u200C_NJ(); + } + ZW_\u200D_J(value) { + this.#ZW_\u200D_J_ = value; + return this.#ZW_\u200D_J(); + } + +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.m2(), 39); +assert(! + Object.prototype.hasOwnProperty.call(c, "m2"), + "m2 doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m2, C.prototype.m2); + +verifyProperty(C.prototype, "m2", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.foo, "foobar"); +assert( + !Object.prototype.hasOwnProperty.call(C, "foo"), + "foo doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "foo"), + "foo doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "foo", { + value: "foobar", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(c.bar, "barbaz"); +assert( + !Object.prototype.hasOwnProperty.call(C, "bar"), + "bar doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "bar"), + "bar doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "bar", { + value: "barbaz", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(c.$(1), 1); +assert.sameValue(c._(1), 1); +assert.sameValue(c.\u{6F}(1), 1); +assert.sameValue(c.\u2118(1), 1); +assert.sameValue(c.ZW_\u200C_NJ(1), 1); +assert.sameValue(c.ZW_\u200D_J(1), 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/multiple-definitions-rs-private-setter-alt.js b/js/src/tests/test262/language/statements/class/elements/multiple-definitions-rs-private-setter-alt.js new file mode 100644 index 0000000000..ec5b69c42d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/multiple-definitions-rs-private-setter-alt.js @@ -0,0 +1,178 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-private-setter-alt.case +// - src/class-elements/productions/cls-decl-multiple-definitions.template +/*--- +description: Valid PrivateName as private setter (multiple fields definitions) +esid: prod-FieldDefinition +features: [class-methods-private, class-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + ... + ; + + MethodDefinition : + ... + set ClassElementName ( PropertySetParameterList ) { FunctionBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + foo = "foobar"; + m() { return 42 } + #$_; #__; #\u{6F}_; #℘_; #ZW_‌_NJ_; #ZW_‍_J_; + set #$(value) { + this.#$_ = value; + } + set #_(value) { + this.#__ = value; + } + set #\u{6F}(value) { + this.#\u{6F}_ = value; + } + set #℘(value) { + this.#℘_ = value; + } + set #ZW_‌_NJ(value) { + this.#ZW_‌_NJ_ = value; + } + set #ZW_‍_J(value) { + this.#ZW_‍_J_ = value; + } + + m2() { return 39 } + bar = "barbaz"; + $(value) { + this.#$ = value; + return this.#$_; + } + _(value) { + this.#_ = value; + return this.#__; + } + \u{6F}(value) { + this.#\u{6F} = value; + return this.#\u{6F}_; + } + ℘(value) { + this.#℘ = value; + return this.#℘_; + } + ZW_‌_NJ(value) { + this.#ZW_‌_NJ = value; + return this.#ZW_‌_NJ_; + } + ZW_‍_J(value) { + this.#ZW_‍_J = value; + return this.#ZW_‍_J_; + } + +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.m2(), 39); +assert(! + Object.prototype.hasOwnProperty.call(c, "m2"), + "m2 doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m2, C.prototype.m2); + +verifyProperty(C.prototype, "m2", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.foo, "foobar"); +assert( + !Object.prototype.hasOwnProperty.call(C, "foo"), + "foo doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "foo"), + "foo doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "foo", { + value: "foobar", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(c.bar, "barbaz"); +assert( + !Object.prototype.hasOwnProperty.call(C, "bar"), + "bar doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "bar"), + "bar doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "bar", { + value: "barbaz", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(c.$(1), 1); +assert.sameValue(c._(1), 1); +assert.sameValue(c.\u{6F}(1), 1); +assert.sameValue(c.℘(1), 1); +assert.sameValue(c.ZW_‌_NJ(1), 1); +assert.sameValue(c.ZW_‍_J(1), 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/multiple-definitions-rs-private-setter.js b/js/src/tests/test262/language/statements/class/elements/multiple-definitions-rs-private-setter.js new file mode 100644 index 0000000000..7d8736bd41 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/multiple-definitions-rs-private-setter.js @@ -0,0 +1,178 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-private-setter.case +// - src/class-elements/productions/cls-decl-multiple-definitions.template +/*--- +description: Valid PrivateName as private setter (multiple fields definitions) +esid: prod-FieldDefinition +features: [class-methods-private, class-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + ... + ; + + MethodDefinition : + ... + set ClassElementName ( PropertySetParameterList ) { FunctionBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + foo = "foobar"; + m() { return 42 } + #$_; #__; #\u{6F}_; #\u2118_; #ZW_\u200C_NJ_; #ZW_\u200D_J_; + set #$(value) { + this.#$_ = value; + } + set #_(value) { + this.#__ = value; + } + set #\u{6F}(value) { + this.#\u{6F}_ = value; + } + set #\u2118(value) { + this.#\u2118_ = value; + } + set #ZW_\u200C_NJ(value) { + this.#ZW_\u200C_NJ_ = value; + } + set #ZW_\u200D_J(value) { + this.#ZW_\u200D_J_ = value; + } + + m2() { return 39 } + bar = "barbaz"; + $(value) { + this.#$ = value; + return this.#$_; + } + _(value) { + this.#_ = value; + return this.#__; + } + \u{6F}(value) { + this.#\u{6F} = value; + return this.#\u{6F}_; + } + \u2118(value) { + this.#\u2118 = value; + return this.#\u2118_; + } + ZW_\u200C_NJ(value) { + this.#ZW_\u200C_NJ = value; + return this.#ZW_\u200C_NJ_; + } + ZW_\u200D_J(value) { + this.#ZW_\u200D_J = value; + return this.#ZW_\u200D_J_; + } + +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.m2(), 39); +assert(! + Object.prototype.hasOwnProperty.call(c, "m2"), + "m2 doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m2, C.prototype.m2); + +verifyProperty(C.prototype, "m2", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.foo, "foobar"); +assert( + !Object.prototype.hasOwnProperty.call(C, "foo"), + "foo doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "foo"), + "foo doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "foo", { + value: "foobar", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(c.bar, "barbaz"); +assert( + !Object.prototype.hasOwnProperty.call(C, "bar"), + "bar doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "bar"), + "bar doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "bar", { + value: "barbaz", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(c.$(1), 1); +assert.sameValue(c._(1), 1); +assert.sameValue(c.\u{6F}(1), 1); +assert.sameValue(c.\u2118(1), 1); +assert.sameValue(c.ZW_\u200C_NJ(1), 1); +assert.sameValue(c.ZW_\u200D_J(1), 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/multiple-definitions-rs-privatename-identifier-alt.js b/js/src/tests/test262/language/statements/class/elements/multiple-definitions-rs-privatename-identifier-alt.js new file mode 100644 index 0000000000..62f2d55a44 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/multiple-definitions-rs-privatename-identifier-alt.js @@ -0,0 +1,160 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-privatename-identifier-alt.case +// - src/class-elements/productions/cls-decl-multiple-definitions.template +/*--- +description: Valid PrivateName (multiple fields definitions) +esid: prod-FieldDefinition +features: [class-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + foo = "foobar"; + m() { return 42 } + #$; #_; #\u{6F}; #℘; #ZW_‌_NJ; #ZW_‍_J + m2() { return 39 } + bar = "barbaz"; + $(value) { + this.#$ = value; + return this.#$; + } + _(value) { + this.#_ = value; + return this.#_; + } + \u{6F}(value) { + this.#\u{6F} = value; + return this.#\u{6F}; + } + ℘(value) { + this.#℘ = value; + return this.#℘; + } + ZW_‌_NJ(value) { + this.#ZW_‌_NJ = value; + return this.#ZW_‌_NJ; + } + ZW_‍_J(value) { + this.#ZW_‍_J = value; + return this.#ZW_‍_J; + } +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.m2(), 39); +assert(! + Object.prototype.hasOwnProperty.call(c, "m2"), + "m2 doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m2, C.prototype.m2); + +verifyProperty(C.prototype, "m2", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.foo, "foobar"); +assert( + !Object.prototype.hasOwnProperty.call(C, "foo"), + "foo doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "foo"), + "foo doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "foo", { + value: "foobar", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(c.bar, "barbaz"); +assert( + !Object.prototype.hasOwnProperty.call(C, "bar"), + "bar doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "bar"), + "bar doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "bar", { + value: "barbaz", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(c.$(1), 1); +assert.sameValue(c._(1), 1); +assert.sameValue(c.\u{6F}(1), 1); +assert.sameValue(c.℘(1), 1); +assert.sameValue(c.ZW_‌_NJ(1), 1); +assert.sameValue(c.ZW_‍_J(1), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/multiple-definitions-rs-privatename-identifier-initializer-alt.js b/js/src/tests/test262/language/statements/class/elements/multiple-definitions-rs-privatename-identifier-initializer-alt.js new file mode 100644 index 0000000000..984a087064 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/multiple-definitions-rs-privatename-identifier-initializer-alt.js @@ -0,0 +1,154 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-privatename-identifier-initializer-alt.case +// - src/class-elements/productions/cls-decl-multiple-definitions.template +/*--- +description: Valid PrivateName (multiple fields definitions) +esid: prod-FieldDefinition +features: [class-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + foo = "foobar"; + m() { return 42 } + #$ = 1; #_ = 1; #\u{6F} = 1; #℘ = 1; #ZW_‌_NJ = 1; #ZW_‍_J = 1 + m2() { return 39 } + bar = "barbaz"; + $() { + return this.#$; + } + _() { + return this.#_; + } + \u{6F}() { + return this.#\u{6F}; + } + ℘() { + return this.#℘; + } + ZW_‌_NJ() { + return this.#ZW_‌_NJ; + } + ZW_‍_J() { + return this.#ZW_‍_J; + } +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.m2(), 39); +assert(! + Object.prototype.hasOwnProperty.call(c, "m2"), + "m2 doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m2, C.prototype.m2); + +verifyProperty(C.prototype, "m2", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.foo, "foobar"); +assert( + !Object.prototype.hasOwnProperty.call(C, "foo"), + "foo doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "foo"), + "foo doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "foo", { + value: "foobar", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(c.bar, "barbaz"); +assert( + !Object.prototype.hasOwnProperty.call(C, "bar"), + "bar doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "bar"), + "bar doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "bar", { + value: "barbaz", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(c.$(), 1); +assert.sameValue(c._(), 1); +assert.sameValue(c.\u{6F}(), 1); +assert.sameValue(c.℘(), 1); +assert.sameValue(c.ZW_‌_NJ(), 1); +assert.sameValue(c.ZW_‍_J(), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/multiple-definitions-rs-privatename-identifier-initializer.js b/js/src/tests/test262/language/statements/class/elements/multiple-definitions-rs-privatename-identifier-initializer.js new file mode 100644 index 0000000000..ae13ceac12 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/multiple-definitions-rs-privatename-identifier-initializer.js @@ -0,0 +1,154 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-privatename-identifier-initializer.case +// - src/class-elements/productions/cls-decl-multiple-definitions.template +/*--- +description: Valid PrivateName (multiple fields definitions) +esid: prod-FieldDefinition +features: [class-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + foo = "foobar"; + m() { return 42 } + #$ = 1; #_ = 1; #\u{6F} = 1; #\u2118 = 1; #ZW_\u200C_NJ = 1; #ZW_\u200D_J = 1 + m2() { return 39 } + bar = "barbaz"; + $() { + return this.#$; + } + _() { + return this.#_; + } + \u{6F}() { + return this.#\u{6F}; + } + \u2118() { + return this.#\u2118; + } + ZW_\u200C_NJ() { + return this.#ZW_\u200C_NJ; + } + ZW_\u200D_J() { + return this.#ZW_\u200D_J; + } +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.m2(), 39); +assert(! + Object.prototype.hasOwnProperty.call(c, "m2"), + "m2 doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m2, C.prototype.m2); + +verifyProperty(C.prototype, "m2", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.foo, "foobar"); +assert( + !Object.prototype.hasOwnProperty.call(C, "foo"), + "foo doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "foo"), + "foo doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "foo", { + value: "foobar", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(c.bar, "barbaz"); +assert( + !Object.prototype.hasOwnProperty.call(C, "bar"), + "bar doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "bar"), + "bar doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "bar", { + value: "barbaz", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(c.$(), 1); +assert.sameValue(c._(), 1); +assert.sameValue(c.\u{6F}(), 1); +assert.sameValue(c.\u2118(), 1); +assert.sameValue(c.ZW_\u200C_NJ(), 1); +assert.sameValue(c.ZW_\u200D_J(), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/multiple-definitions-rs-privatename-identifier.js b/js/src/tests/test262/language/statements/class/elements/multiple-definitions-rs-privatename-identifier.js new file mode 100644 index 0000000000..745f56f68d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/multiple-definitions-rs-privatename-identifier.js @@ -0,0 +1,160 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-privatename-identifier.case +// - src/class-elements/productions/cls-decl-multiple-definitions.template +/*--- +description: Valid PrivateName (multiple fields definitions) +esid: prod-FieldDefinition +features: [class-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + foo = "foobar"; + m() { return 42 } + #$; #_; #\u{6F}; #\u2118; #ZW_\u200C_NJ; #ZW_\u200D_J + m2() { return 39 } + bar = "barbaz"; + $(value) { + this.#$ = value; + return this.#$; + } + _(value) { + this.#_ = value; + return this.#_; + } + \u{6F}(value) { + this.#\u{6F} = value; + return this.#\u{6F}; + } + \u2118(value) { + this.#\u2118 = value; + return this.#\u2118; + } + ZW_\u200C_NJ(value) { + this.#ZW_\u200C_NJ = value; + return this.#ZW_\u200C_NJ; + } + ZW_\u200D_J(value) { + this.#ZW_\u200D_J = value; + return this.#ZW_\u200D_J; + } +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.m2(), 39); +assert(! + Object.prototype.hasOwnProperty.call(c, "m2"), + "m2 doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m2, C.prototype.m2); + +verifyProperty(C.prototype, "m2", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.foo, "foobar"); +assert( + !Object.prototype.hasOwnProperty.call(C, "foo"), + "foo doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "foo"), + "foo doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "foo", { + value: "foobar", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(c.bar, "barbaz"); +assert( + !Object.prototype.hasOwnProperty.call(C, "bar"), + "bar doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "bar"), + "bar doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "bar", { + value: "barbaz", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(c.$(1), 1); +assert.sameValue(c._(1), 1); +assert.sameValue(c.\u{6F}(1), 1); +assert.sameValue(c.\u2118(1), 1); +assert.sameValue(c.ZW_\u200C_NJ(1), 1); +assert.sameValue(c.ZW_\u200D_J(1), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/multiple-definitions-rs-static-async-generator-method-privatename-identifier-alt.js b/js/src/tests/test262/language/statements/class/elements/multiple-definitions-rs-static-async-generator-method-privatename-identifier-alt.js new file mode 100644 index 0000000000..aa20ede391 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/multiple-definitions-rs-static-async-generator-method-privatename-identifier-alt.js @@ -0,0 +1,185 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-async-generator-method-privatename-identifier-alt.case +// - src/class-elements/productions/cls-decl-multiple-definitions.template +/*--- +description: Valid Static AsyncGeneratorMethod PrivateName (multiple fields definitions) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + AsyncGeneratorMethod + + AsyncGeneratorMethod : + async [no LineTerminator here] * ClassElementName ( UniqueFormalParameters){ AsyncGeneratorBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + foo = "foobar"; + m() { return 42 } + static async * #$(value) { + yield * await value; + } + static async * #_(value) { + yield * await value; + } + static async * #o(value) { + yield * await value; + } + static async * #℘(value) { + yield * await value; + } + static async * #ZW_‌_NJ(value) { + yield * await value; + } + static async * #ZW_‍_J(value) { + yield * await value; + } + m2() { return 39 } + bar = "barbaz"; + static get $() { + return this.#$; + } + static get _() { + return this.#_; + } + static get o() { + return this.#o; + } + static get ℘() { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#℘; + } + static get ZW_‌_NJ() { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#ZW_‌_NJ; + } + static get ZW_‍_J() { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#ZW_‍_J; + } + +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.m2(), 39); +assert(! + Object.prototype.hasOwnProperty.call(c, "m2"), + "m2 doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m2, C.prototype.m2); + +verifyProperty(C.prototype, "m2", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.foo, "foobar"); +assert( + !Object.prototype.hasOwnProperty.call(C, "foo"), + "foo doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "foo"), + "foo doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "foo", { + value: "foobar", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(c.bar, "barbaz"); +assert( + !Object.prototype.hasOwnProperty.call(C, "bar"), + "bar doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "bar"), + "bar doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "bar", { + value: "barbaz", + enumerable: true, + configurable: true, + writable: true, +}); + +Promise.all([ + C.$([1]).next(), + C._([1]).next(), + C.o([1]).next(), + C.℘([1]).next(), // DO NOT CHANGE THE NAME OF THIS FIELD + C.ZW_‌_NJ([1]).next(), // DO NOT CHANGE THE NAME OF THIS FIELD + C.ZW_‍_J([1]).next(), // DO NOT CHANGE THE NAME OF THIS FIELD +]).then(results => { + + assert.sameValue(results[0].value, 1); + assert.sameValue(results[1].value, 1); + assert.sameValue(results[2].value, 1); + assert.sameValue(results[3].value, 1); + assert.sameValue(results[4].value, 1); + assert.sameValue(results[5].value, 1); + +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/multiple-definitions-rs-static-async-generator-method-privatename-identifier.js b/js/src/tests/test262/language/statements/class/elements/multiple-definitions-rs-static-async-generator-method-privatename-identifier.js new file mode 100644 index 0000000000..b627bf9127 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/multiple-definitions-rs-static-async-generator-method-privatename-identifier.js @@ -0,0 +1,186 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-async-generator-method-privatename-identifier.case +// - src/class-elements/productions/cls-decl-multiple-definitions.template +/*--- +description: Valid Static AsyncGeneratorMethod PrivateName (multiple fields definitions) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + AsyncGeneratorMethod + + AsyncGeneratorMethod : + async [no LineTerminator here] * ClassElementName ( UniqueFormalParameters){ AsyncGeneratorBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + foo = "foobar"; + m() { return 42 } + static async * #$(value) { + yield * await value; + } + static async * #_(value) { + yield * await value; + } + static async * #\u{6F}(value) { + yield * await value; + } + static async * #\u2118(value) { + yield * await value; + } + static async * #ZW_\u200C_NJ(value) { + yield * await value; + } + static async * #ZW_\u200D_J(value) { + yield * await value; + } + m2() { return 39 } + bar = "barbaz"; + static get $() { + return this.#$; + } + static get _() { + return this.#_; + } + static get \u{6F}() { + return this.#\u{6F}; + } + static get \u2118() { + return this.#\u2118; + } + static get ZW_\u200C_NJ() { + return this.#ZW_\u200C_NJ; + } + static get ZW_\u200D_J() { + return this.#ZW_\u200D_J; + } + +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.m2(), 39); +assert(! + Object.prototype.hasOwnProperty.call(c, "m2"), + "m2 doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m2, C.prototype.m2); + +verifyProperty(C.prototype, "m2", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.foo, "foobar"); +assert( + !Object.prototype.hasOwnProperty.call(C, "foo"), + "foo doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "foo"), + "foo doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "foo", { + value: "foobar", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(c.bar, "barbaz"); +assert( + !Object.prototype.hasOwnProperty.call(C, "bar"), + "bar doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "bar"), + "bar doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "bar", { + value: "barbaz", + enumerable: true, + configurable: true, + writable: true, +}); + +Promise.all([ + C.$([1]).next(), + C._([1]).next(), + C.\u{6F}([1]).next(), + C.\u2118([1]).next(), + C.ZW_\u200C_NJ([1]).next(), + C.ZW_\u200D_J([1]).next(), +]).then(results => { + + assert.sameValue(results[0].value, 1); + assert.sameValue(results[1].value, 1); + assert.sameValue(results[2].value, 1); + assert.sameValue(results[3].value, 1); + assert.sameValue(results[4].value, 1); + assert.sameValue(results[5].value, 1); + +}).then($DONE, $DONE); + diff --git a/js/src/tests/test262/language/statements/class/elements/multiple-definitions-rs-static-async-method-privatename-identifier-alt.js b/js/src/tests/test262/language/statements/class/elements/multiple-definitions-rs-static-async-method-privatename-identifier-alt.js new file mode 100644 index 0000000000..ac5f408b1b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/multiple-definitions-rs-static-async-method-privatename-identifier-alt.js @@ -0,0 +1,185 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-async-method-privatename-identifier-alt.case +// - src/class-elements/productions/cls-decl-multiple-definitions.template +/*--- +description: Valid Static AsyncMethod PrivateName (multiple fields definitions) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + AsyncMethod + + AsyncMethod : + async [no LineTerminator here] ClassElementName ( UniqueFormalParameters ){ AsyncFunctionBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + foo = "foobar"; + m() { return 42 } + static async #$(value) { + return await value; + } + static async #_(value) { + return await value; + } + static async #o(value) { + return await value; + } + static async #℘(value) { + return await value; + } + static async #ZW_‌_NJ(value) { + return await value; + } + static async #ZW_‍_J(value) { + return await value; + } + m2() { return 39 } + bar = "barbaz"; + static async $(value) { + return await this.#$(value); + } + static async _(value) { + return await this.#_(value); + } + static async o(value) { + return await this.#o(value); + } + static async ℘(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + return await this.#℘(value); + } + static async ZW_‌_NJ(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + return await this.#ZW_‌_NJ(value); + } + static async ZW_‍_J(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + return await this.#ZW_‍_J(value); + } + +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.m2(), 39); +assert(! + Object.prototype.hasOwnProperty.call(c, "m2"), + "m2 doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m2, C.prototype.m2); + +verifyProperty(C.prototype, "m2", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.foo, "foobar"); +assert( + !Object.prototype.hasOwnProperty.call(C, "foo"), + "foo doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "foo"), + "foo doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "foo", { + value: "foobar", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(c.bar, "barbaz"); +assert( + !Object.prototype.hasOwnProperty.call(C, "bar"), + "bar doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "bar"), + "bar doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "bar", { + value: "barbaz", + enumerable: true, + configurable: true, + writable: true, +}); + +Promise.all([ + C.$(1), + C._(1), + C.o(1), + C.℘(1), // DO NOT CHANGE THE NAME OF THIS FIELD + C.ZW_‌_NJ(1), // DO NOT CHANGE THE NAME OF THIS FIELD + C.ZW_‍_J(1), // DO NOT CHANGE THE NAME OF THIS FIELD +]).then(results => { + + assert.sameValue(results[0], 1); + assert.sameValue(results[1], 1); + assert.sameValue(results[2], 1); + assert.sameValue(results[3], 1); + assert.sameValue(results[4], 1); + assert.sameValue(results[5], 1); + +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/multiple-definitions-rs-static-async-method-privatename-identifier.js b/js/src/tests/test262/language/statements/class/elements/multiple-definitions-rs-static-async-method-privatename-identifier.js new file mode 100644 index 0000000000..32a004095c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/multiple-definitions-rs-static-async-method-privatename-identifier.js @@ -0,0 +1,186 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-async-method-privatename-identifier.case +// - src/class-elements/productions/cls-decl-multiple-definitions.template +/*--- +description: Valid Static AsyncMethod PrivateName (multiple fields definitions) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + AsyncMethod + + AsyncMethod : + async [no LineTerminator here] ClassElementName ( UniqueFormalParameters ){ AsyncFunctionBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + foo = "foobar"; + m() { return 42 } + static async #$(value) { + return await value; + } + static async #_(value) { + return await value; + } + static async #\u{6F}(value) { + return await value; + } + static async #\u2118(value) { + return await value; + } + static async #ZW_\u200C_NJ(value) { + return await value; + } + static async #ZW_\u200D_J(value) { + return await value; + } + m2() { return 39 } + bar = "barbaz"; + static async $(value) { + return await this.#$(value); + } + static async _(value) { + return await this.#_(value); + } + static async \u{6F}(value) { + return await this.#\u{6F}(value); + } + static async \u2118(value) { + return await this.#\u2118(value); + } + static async ZW_\u200C_NJ(value) { + return await this.#ZW_\u200C_NJ(value); + } + static async ZW_\u200D_J(value) { + return await this.#ZW_\u200D_J(value); + } + +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.m2(), 39); +assert(! + Object.prototype.hasOwnProperty.call(c, "m2"), + "m2 doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m2, C.prototype.m2); + +verifyProperty(C.prototype, "m2", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.foo, "foobar"); +assert( + !Object.prototype.hasOwnProperty.call(C, "foo"), + "foo doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "foo"), + "foo doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "foo", { + value: "foobar", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(c.bar, "barbaz"); +assert( + !Object.prototype.hasOwnProperty.call(C, "bar"), + "bar doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "bar"), + "bar doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "bar", { + value: "barbaz", + enumerable: true, + configurable: true, + writable: true, +}); + +Promise.all([ + C.$(1), + C._(1), + C.\u{6F}(1), + C.\u2118(1), + C.ZW_\u200C_NJ(1), + C.ZW_\u200D_J(1), +]).then(results => { + + assert.sameValue(results[0], 1); + assert.sameValue(results[1], 1); + assert.sameValue(results[2], 1); + assert.sameValue(results[3], 1); + assert.sameValue(results[4], 1); + assert.sameValue(results[5], 1); + +}).then($DONE, $DONE); + diff --git a/js/src/tests/test262/language/statements/class/elements/multiple-definitions-rs-static-generator-method-privatename-identifier-alt.js b/js/src/tests/test262/language/statements/class/elements/multiple-definitions-rs-static-generator-method-privatename-identifier-alt.js new file mode 100644 index 0000000000..95ebc4013d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/multiple-definitions-rs-static-generator-method-privatename-identifier-alt.js @@ -0,0 +1,175 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-generator-method-privatename-identifier-alt.case +// - src/class-elements/productions/cls-decl-multiple-definitions.template +/*--- +description: Valid Static GeneratorMethod PrivateName (multiple fields definitions) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + GeneratorMethod + + GeneratorMethod : + * ClassElementName ( UniqueFormalParameters ){ GeneratorBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + foo = "foobar"; + m() { return 42 } + static * #$(value) { + yield * value; + } + static * #_(value) { + yield * value; + } + static * #o(value) { + yield * value; + } + static * #℘(value) { + yield * value; + } + static * #ZW_‌_NJ(value) { + yield * value; + } + static * #ZW_‍_J(value) { + yield * value; + } + m2() { return 39 } + bar = "barbaz"; + static get $() { + return this.#$; + } + static get _() { + return this.#_; + } + static get o() { + return this.#o; + } + static get ℘() { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#℘; + } + static get ZW_‌_NJ() { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#ZW_‌_NJ; + } + static get ZW_‍_J() { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#ZW_‍_J; + } + +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.m2(), 39); +assert(! + Object.prototype.hasOwnProperty.call(c, "m2"), + "m2 doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m2, C.prototype.m2); + +verifyProperty(C.prototype, "m2", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.foo, "foobar"); +assert( + !Object.prototype.hasOwnProperty.call(C, "foo"), + "foo doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "foo"), + "foo doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "foo", { + value: "foobar", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(c.bar, "barbaz"); +assert( + !Object.prototype.hasOwnProperty.call(C, "bar"), + "bar doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "bar"), + "bar doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "bar", { + value: "barbaz", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(C.$([1]).next().value, 1); +assert.sameValue(C._([1]).next().value, 1); +assert.sameValue(C.o([1]).next().value, 1); +assert.sameValue(C.℘([1]).next().value, 1); +assert.sameValue(C.ZW_‌_NJ([1]).next().value, 1); +assert.sameValue(C.ZW_‍_J([1]).next().value, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/multiple-definitions-rs-static-generator-method-privatename-identifier.js b/js/src/tests/test262/language/statements/class/elements/multiple-definitions-rs-static-generator-method-privatename-identifier.js new file mode 100644 index 0000000000..4829fb1886 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/multiple-definitions-rs-static-generator-method-privatename-identifier.js @@ -0,0 +1,176 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-generator-method-privatename-identifier.case +// - src/class-elements/productions/cls-decl-multiple-definitions.template +/*--- +description: Valid Static GeneratorMethod PrivateName (multiple fields definitions) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + GeneratorMethod + + GeneratorMethod : + * ClassElementName ( UniqueFormalParameters ){ GeneratorBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + foo = "foobar"; + m() { return 42 } + static * #$(value) { + yield * value; + } + static * #_(value) { + yield * value; + } + static * #\u{6F}(value) { + yield * value; + } + static * #\u2118(value) { + yield * value; + } + static * #ZW_\u200C_NJ(value) { + yield * value; + } + static * #ZW_\u200D_J(value) { + yield * value; + } + m2() { return 39 } + bar = "barbaz"; + static get $() { + return this.#$; + } + static get _() { + return this.#_; + } + static get \u{6F}() { + return this.#\u{6F}; + } + static get \u2118() { + return this.#\u2118; + } + static get ZW_\u200C_NJ() { + return this.#ZW_\u200C_NJ; + } + static get ZW_\u200D_J() { + return this.#ZW_\u200D_J; + } + +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.m2(), 39); +assert(! + Object.prototype.hasOwnProperty.call(c, "m2"), + "m2 doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m2, C.prototype.m2); + +verifyProperty(C.prototype, "m2", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.foo, "foobar"); +assert( + !Object.prototype.hasOwnProperty.call(C, "foo"), + "foo doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "foo"), + "foo doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "foo", { + value: "foobar", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(c.bar, "barbaz"); +assert( + !Object.prototype.hasOwnProperty.call(C, "bar"), + "bar doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "bar"), + "bar doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "bar", { + value: "barbaz", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(C.$([1]).next().value, 1); +assert.sameValue(C._([1]).next().value, 1); +assert.sameValue(C.\u{6F}([1]).next().value, 1); +assert.sameValue(C.\u2118([1]).next().value, 1); +assert.sameValue(C.ZW_\u200C_NJ([1]).next().value, 1); +assert.sameValue(C.ZW_\u200D_J([1]).next().value, 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/multiple-definitions-rs-static-method-privatename-identifier-alt.js b/js/src/tests/test262/language/statements/class/elements/multiple-definitions-rs-static-method-privatename-identifier-alt.js new file mode 100644 index 0000000000..81d12a9690 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/multiple-definitions-rs-static-method-privatename-identifier-alt.js @@ -0,0 +1,173 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-method-privatename-identifier-alt.case +// - src/class-elements/productions/cls-decl-multiple-definitions.template +/*--- +description: Valid Static Method PrivateName (multiple fields definitions) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + ClassElementName ( UniqueFormalParameters ){ FunctionBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + foo = "foobar"; + m() { return 42 } + static #$(value) { + return value; + } + static #_(value) { + return value; + } + static #o(value) { + return value; + } + static #℘(value) { + return value; + } + static #ZW_‌_NJ(value) { + return value; + } + static #ZW_‍_J(value) { + return value; + } + m2() { return 39 } + bar = "barbaz"; + static $(value) { + return this.#$(value); + } + static _(value) { + return this.#_(value); + } + static o(value) { + return this.#o(value); + } + static ℘(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#℘(value); + } + static ZW_‌_NJ(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#ZW_‌_NJ(value); + } + static ZW_‍_J(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#ZW_‍_J(value); + } + +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.m2(), 39); +assert(! + Object.prototype.hasOwnProperty.call(c, "m2"), + "m2 doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m2, C.prototype.m2); + +verifyProperty(C.prototype, "m2", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.foo, "foobar"); +assert( + !Object.prototype.hasOwnProperty.call(C, "foo"), + "foo doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "foo"), + "foo doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "foo", { + value: "foobar", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(c.bar, "barbaz"); +assert( + !Object.prototype.hasOwnProperty.call(C, "bar"), + "bar doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "bar"), + "bar doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "bar", { + value: "barbaz", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(C.$(1), 1); +assert.sameValue(C._(1), 1); +assert.sameValue(C.o(1), 1); +assert.sameValue(C.℘(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD +assert.sameValue(C.ZW_‌_NJ(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD +assert.sameValue(C.ZW_‍_J(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/multiple-definitions-rs-static-method-privatename-identifier.js b/js/src/tests/test262/language/statements/class/elements/multiple-definitions-rs-static-method-privatename-identifier.js new file mode 100644 index 0000000000..9605b7ee9e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/multiple-definitions-rs-static-method-privatename-identifier.js @@ -0,0 +1,173 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-method-privatename-identifier.case +// - src/class-elements/productions/cls-decl-multiple-definitions.template +/*--- +description: Valid Static Method PrivateName (multiple fields definitions) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + ClassElementName ( UniqueFormalParameters ){ FunctionBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + foo = "foobar"; + m() { return 42 } + static #$(value) { + return value; + } + static #_(value) { + return value; + } + static #\u{6F}(value) { + return value; + } + static #\u2118(value) { + return value; + } + static #ZW_\u200C_NJ(value) { + return value; + } + static #ZW_\u200D_J(value) { + return value; + } + m2() { return 39 } + bar = "barbaz"; + static $(value) { + return this.#$(value); + } + static _(value) { + return this.#_(value); + } + static \u{6F}(value) { + return this.#\u{6F}(value); + } + static \u2118(value) { + return this.#\u2118(value); + } + static ZW_\u200C_NJ(value) { + return this.#ZW_\u200C_NJ(value); + } + static ZW_\u200D_J(value) { + return this.#ZW_\u200D_J(value); + } + +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.m2(), 39); +assert(! + Object.prototype.hasOwnProperty.call(c, "m2"), + "m2 doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m2, C.prototype.m2); + +verifyProperty(C.prototype, "m2", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.foo, "foobar"); +assert( + !Object.prototype.hasOwnProperty.call(C, "foo"), + "foo doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "foo"), + "foo doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "foo", { + value: "foobar", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(c.bar, "barbaz"); +assert( + !Object.prototype.hasOwnProperty.call(C, "bar"), + "bar doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "bar"), + "bar doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "bar", { + value: "barbaz", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(C.$(1), 1); +assert.sameValue(C._(1), 1); +assert.sameValue(C.\u{6F}(1), 1); +assert.sameValue(C.\u2118(1), 1); +assert.sameValue(C.ZW_\u200C_NJ(1), 1); +assert.sameValue(C.ZW_\u200D_J(1), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/multiple-definitions-rs-static-privatename-identifier-alt-by-classname.js b/js/src/tests/test262/language/statements/class/elements/multiple-definitions-rs-static-privatename-identifier-alt-by-classname.js new file mode 100644 index 0000000000..86ab6e2259 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/multiple-definitions-rs-static-privatename-identifier-alt-by-classname.js @@ -0,0 +1,161 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-privatename-identifier-alt-by-classname.case +// - src/class-elements/productions/cls-decl-multiple-definitions.template +/*--- +description: Valid Static PrivateName (multiple fields definitions) +esid: prod-FieldDefinition +features: [class-static-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + foo = "foobar"; + m() { return 42 } + static #$; static #_; static #\u{6F}; static #℘; static #ZW_‌_NJ; static #ZW_‍_J + m2() { return 39 } + bar = "barbaz"; + static $(value) { + C.#$ = value; + return C.#$; + } + static _(value) { + C.#_ = value; + return C.#_; + } + static o(value) { + C.#\u{6F} = value; + return C.#\u{6F}; + } + static ℘(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + C.#℘ = value; + return C.#℘; + } + static ZW_‌_NJ(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + C.#ZW_‌_NJ = value; + return C.#ZW_‌_NJ; + } + static ZW_‍_J(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + C.#ZW_‍_J = value; + return C.#ZW_‍_J; + } +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.m2(), 39); +assert(! + Object.prototype.hasOwnProperty.call(c, "m2"), + "m2 doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m2, C.prototype.m2); + +verifyProperty(C.prototype, "m2", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.foo, "foobar"); +assert( + !Object.prototype.hasOwnProperty.call(C, "foo"), + "foo doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "foo"), + "foo doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "foo", { + value: "foobar", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(c.bar, "barbaz"); +assert( + !Object.prototype.hasOwnProperty.call(C, "bar"), + "bar doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "bar"), + "bar doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "bar", { + value: "barbaz", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(C.$(1), 1); +assert.sameValue(C._(1), 1); +assert.sameValue(C.o(1), 1); +assert.sameValue(C.℘(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD +assert.sameValue(C.ZW_‌_NJ(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD +assert.sameValue(C.ZW_‍_J(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/multiple-definitions-rs-static-privatename-identifier-alt.js b/js/src/tests/test262/language/statements/class/elements/multiple-definitions-rs-static-privatename-identifier-alt.js new file mode 100644 index 0000000000..06b667ddf4 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/multiple-definitions-rs-static-privatename-identifier-alt.js @@ -0,0 +1,161 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-privatename-identifier-alt.case +// - src/class-elements/productions/cls-decl-multiple-definitions.template +/*--- +description: Valid Static PrivateName (multiple fields definitions) +esid: prod-FieldDefinition +features: [class-static-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + foo = "foobar"; + m() { return 42 } + static #$; static #_; static #\u{6F}; static #℘; static #ZW_‌_NJ; static #ZW_‍_J + m2() { return 39 } + bar = "barbaz"; + static $(value) { + this.#$ = value; + return this.#$; + } + static _(value) { + this.#_ = value; + return this.#_; + } + static o(value) { + this.#\u{6F} = value; + return this.#\u{6F}; + } + static ℘(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + this.#℘ = value; + return this.#℘; + } + static ZW_‌_NJ(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + this.#ZW_‌_NJ = value; + return this.#ZW_‌_NJ; + } + static ZW_‍_J(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + this.#ZW_‍_J = value; + return this.#ZW_‍_J; + } +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.m2(), 39); +assert(! + Object.prototype.hasOwnProperty.call(c, "m2"), + "m2 doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m2, C.prototype.m2); + +verifyProperty(C.prototype, "m2", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.foo, "foobar"); +assert( + !Object.prototype.hasOwnProperty.call(C, "foo"), + "foo doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "foo"), + "foo doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "foo", { + value: "foobar", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(c.bar, "barbaz"); +assert( + !Object.prototype.hasOwnProperty.call(C, "bar"), + "bar doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "bar"), + "bar doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "bar", { + value: "barbaz", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(C.$(1), 1); +assert.sameValue(C._(1), 1); +assert.sameValue(C.o(1), 1); +assert.sameValue(C.℘(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD +assert.sameValue(C.ZW_‌_NJ(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD +assert.sameValue(C.ZW_‍_J(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/multiple-definitions-rs-static-privatename-identifier-by-classname.js b/js/src/tests/test262/language/statements/class/elements/multiple-definitions-rs-static-privatename-identifier-by-classname.js new file mode 100644 index 0000000000..c0ba4475a5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/multiple-definitions-rs-static-privatename-identifier-by-classname.js @@ -0,0 +1,161 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-privatename-identifier-by-classname.case +// - src/class-elements/productions/cls-decl-multiple-definitions.template +/*--- +description: Valid Static PrivateName (multiple fields definitions) +esid: prod-FieldDefinition +features: [class-static-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + foo = "foobar"; + m() { return 42 } + static #$; static #_; static #\u{6F}; static #\u2118; static #ZW_\u200C_NJ; static #ZW_\u200D_J + m2() { return 39 } + bar = "barbaz"; + static $(value) { + C.#$ = value; + return C.#$; + } + static _(value) { + C.#_ = value; + return C.#_; + } + static \u{6F}(value) { + C.#\u{6F} = value; + return C.#\u{6F}; + } + static \u2118(value) { + C.#\u2118 = value; + return C.#\u2118; + } + static ZW_\u200C_NJ(value) { + C.#ZW_\u200C_NJ = value; + return C.#ZW_\u200C_NJ; + } + static ZW_\u200D_J(value) { + C.#ZW_\u200D_J = value; + return C.#ZW_\u200D_J; + } +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.m2(), 39); +assert(! + Object.prototype.hasOwnProperty.call(c, "m2"), + "m2 doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m2, C.prototype.m2); + +verifyProperty(C.prototype, "m2", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.foo, "foobar"); +assert( + !Object.prototype.hasOwnProperty.call(C, "foo"), + "foo doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "foo"), + "foo doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "foo", { + value: "foobar", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(c.bar, "barbaz"); +assert( + !Object.prototype.hasOwnProperty.call(C, "bar"), + "bar doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "bar"), + "bar doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "bar", { + value: "barbaz", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(C.$(1), 1); +assert.sameValue(C._(1), 1); +assert.sameValue(C.\u{6F}(1), 1); +assert.sameValue(C.\u2118(1), 1); +assert.sameValue(C.ZW_\u200C_NJ(1), 1); +assert.sameValue(C.ZW_\u200D_J(1), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/multiple-definitions-rs-static-privatename-identifier-initializer-alt-by-classname.js b/js/src/tests/test262/language/statements/class/elements/multiple-definitions-rs-static-privatename-identifier-initializer-alt-by-classname.js new file mode 100644 index 0000000000..fde32f87d6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/multiple-definitions-rs-static-privatename-identifier-initializer-alt-by-classname.js @@ -0,0 +1,155 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-privatename-identifier-initializer-alt-by-classname.case +// - src/class-elements/productions/cls-decl-multiple-definitions.template +/*--- +description: Valid Static PrivateName (multiple fields definitions) +esid: prod-FieldDefinition +features: [class-static-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + foo = "foobar"; + m() { return 42 } + static #$ = 1; static #_ = 1; static #\u{6F} = 1; static #℘ = 1; static #ZW_‌_NJ = 1; static #ZW_‍_J = 1 + m2() { return 39 } + bar = "barbaz"; + static $() { + return C.#$; + } + static _() { + return C.#_; + } + static \u{6F}() { + return C.#\u{6F}; + } + static ℘() { + return C.#℘; + } + static ZW_‌_NJ() { + return C.#ZW_‌_NJ; + } + static ZW_‍_J() { + return C.#ZW_‍_J; + } +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.m2(), 39); +assert(! + Object.prototype.hasOwnProperty.call(c, "m2"), + "m2 doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m2, C.prototype.m2); + +verifyProperty(C.prototype, "m2", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.foo, "foobar"); +assert( + !Object.prototype.hasOwnProperty.call(C, "foo"), + "foo doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "foo"), + "foo doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "foo", { + value: "foobar", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(c.bar, "barbaz"); +assert( + !Object.prototype.hasOwnProperty.call(C, "bar"), + "bar doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "bar"), + "bar doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "bar", { + value: "barbaz", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(C.$(), 1); +assert.sameValue(C._(), 1); +assert.sameValue(C.\u{6F}(), 1); +assert.sameValue(C.℘(), 1); +assert.sameValue(C.ZW_‌_NJ(), 1); +assert.sameValue(C.ZW_‍_J(), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/multiple-definitions-rs-static-privatename-identifier-initializer-alt.js b/js/src/tests/test262/language/statements/class/elements/multiple-definitions-rs-static-privatename-identifier-initializer-alt.js new file mode 100644 index 0000000000..1800c41d03 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/multiple-definitions-rs-static-privatename-identifier-initializer-alt.js @@ -0,0 +1,155 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-privatename-identifier-initializer-alt.case +// - src/class-elements/productions/cls-decl-multiple-definitions.template +/*--- +description: Valid Static PrivateName (multiple fields definitions) +esid: prod-FieldDefinition +features: [class-static-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + foo = "foobar"; + m() { return 42 } + static #$ = 1; static #_ = 1; static #\u{6F} = 1; static #℘ = 1; static #ZW_‌_NJ = 1; static #ZW_‍_J = 1 + m2() { return 39 } + bar = "barbaz"; + static $() { + return this.#$; + } + static _() { + return this.#_; + } + static \u{6F}() { + return this.#\u{6F}; + } + static ℘() { + return this.#℘; + } + static ZW_‌_NJ() { + return this.#ZW_‌_NJ; + } + static ZW_‍_J() { + return this.#ZW_‍_J; + } +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.m2(), 39); +assert(! + Object.prototype.hasOwnProperty.call(c, "m2"), + "m2 doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m2, C.prototype.m2); + +verifyProperty(C.prototype, "m2", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.foo, "foobar"); +assert( + !Object.prototype.hasOwnProperty.call(C, "foo"), + "foo doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "foo"), + "foo doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "foo", { + value: "foobar", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(c.bar, "barbaz"); +assert( + !Object.prototype.hasOwnProperty.call(C, "bar"), + "bar doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "bar"), + "bar doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "bar", { + value: "barbaz", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(C.$(), 1); +assert.sameValue(C._(), 1); +assert.sameValue(C.\u{6F}(), 1); +assert.sameValue(C.℘(), 1); +assert.sameValue(C.ZW_‌_NJ(), 1); +assert.sameValue(C.ZW_‍_J(), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/multiple-definitions-rs-static-privatename-identifier-initializer.js b/js/src/tests/test262/language/statements/class/elements/multiple-definitions-rs-static-privatename-identifier-initializer.js new file mode 100644 index 0000000000..8da79d7865 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/multiple-definitions-rs-static-privatename-identifier-initializer.js @@ -0,0 +1,155 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-privatename-identifier-initializer.case +// - src/class-elements/productions/cls-decl-multiple-definitions.template +/*--- +description: Valid Static PrivateName (multiple fields definitions) +esid: prod-FieldDefinition +features: [class-static-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + foo = "foobar"; + m() { return 42 } + static #$ = 1; static #_ = 1; static #\u{6F} = 1; static #\u2118 = 1; static #ZW_\u200C_NJ = 1; static #ZW_\u200D_J = 1 + m2() { return 39 } + bar = "barbaz"; + static $() { + return this.#$; + } + static _() { + return this.#_; + } + static \u{6F}() { + return this.#\u{6F}; + } + static \u2118() { + return this.#\u2118; + } + static ZW_\u200C_NJ() { + return this.#ZW_\u200C_NJ; + } + static ZW_\u200D_J() { + return this.#ZW_\u200D_J; + } +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.m2(), 39); +assert(! + Object.prototype.hasOwnProperty.call(c, "m2"), + "m2 doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m2, C.prototype.m2); + +verifyProperty(C.prototype, "m2", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.foo, "foobar"); +assert( + !Object.prototype.hasOwnProperty.call(C, "foo"), + "foo doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "foo"), + "foo doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "foo", { + value: "foobar", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(c.bar, "barbaz"); +assert( + !Object.prototype.hasOwnProperty.call(C, "bar"), + "bar doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "bar"), + "bar doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "bar", { + value: "barbaz", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(C.$(), 1); +assert.sameValue(C._(), 1); +assert.sameValue(C.\u{6F}(), 1); +assert.sameValue(C.\u2118(), 1); +assert.sameValue(C.ZW_\u200C_NJ(), 1); +assert.sameValue(C.ZW_\u200D_J(), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/multiple-definitions-rs-static-privatename-identifier.js b/js/src/tests/test262/language/statements/class/elements/multiple-definitions-rs-static-privatename-identifier.js new file mode 100644 index 0000000000..6aa6f017c9 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/multiple-definitions-rs-static-privatename-identifier.js @@ -0,0 +1,161 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-privatename-identifier.case +// - src/class-elements/productions/cls-decl-multiple-definitions.template +/*--- +description: Valid Static PrivateName (multiple fields definitions) +esid: prod-FieldDefinition +features: [class-static-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + foo = "foobar"; + m() { return 42 } + static #$; static #_; static #\u{6F}; static #\u2118; static #ZW_\u200C_NJ; static #ZW_\u200D_J + m2() { return 39 } + bar = "barbaz"; + static $(value) { + this.#$ = value; + return this.#$; + } + static _(value) { + this.#_ = value; + return this.#_; + } + static \u{6F}(value) { + this.#\u{6F} = value; + return this.#\u{6F}; + } + static \u2118(value) { + this.#\u2118 = value; + return this.#\u2118; + } + static ZW_\u200C_NJ(value) { + this.#ZW_\u200C_NJ = value; + return this.#ZW_\u200C_NJ; + } + static ZW_\u200D_J(value) { + this.#ZW_\u200D_J = value; + return this.#ZW_\u200D_J; + } +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.m2(), 39); +assert(! + Object.prototype.hasOwnProperty.call(c, "m2"), + "m2 doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m2, C.prototype.m2); + +verifyProperty(C.prototype, "m2", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.foo, "foobar"); +assert( + !Object.prototype.hasOwnProperty.call(C, "foo"), + "foo doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "foo"), + "foo doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "foo", { + value: "foobar", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(c.bar, "barbaz"); +assert( + !Object.prototype.hasOwnProperty.call(C, "bar"), + "bar doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "bar"), + "bar doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "bar", { + value: "barbaz", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(C.$(1), 1); +assert.sameValue(C._(1), 1); +assert.sameValue(C.\u{6F}(1), 1); +assert.sameValue(C.\u2118(1), 1); +assert.sameValue(C.ZW_\u200C_NJ(1), 1); +assert.sameValue(C.ZW_\u200D_J(1), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/multiple-definitions-static-private-fields.js b/js/src/tests/test262/language/statements/class/elements/multiple-definitions-static-private-fields.js new file mode 100644 index 0000000000..2d79468c3c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/multiple-definitions-static-private-fields.js @@ -0,0 +1,122 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/static-private-fields.case +// - src/class-elements/productions/cls-decl-multiple-definitions.template +/*--- +description: static private fields (multiple fields definitions) +esid: prod-FieldDefinition +features: [class-static-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + ... + static FieldDefinition ; + + FieldDefinition : + ClassElementName Initializer_opt + + ClassElementName : + PrivateName + + PrivateName : + # IdentifierName + +---*/ + + +class C { + foo = "foobar"; + m() { return 42 } + static #x; static #y + m2() { return 39 } + bar = "barbaz"; + static x() { + this.#x = 42; + return this.#x; + } + static y() { + this.#y = 43; + return this.#y; + } +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.m2(), 39); +assert(! + Object.prototype.hasOwnProperty.call(c, "m2"), + "m2 doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m2, C.prototype.m2); + +verifyProperty(C.prototype, "m2", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.foo, "foobar"); +assert( + !Object.prototype.hasOwnProperty.call(C, "foo"), + "foo doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "foo"), + "foo doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "foo", { + value: "foobar", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(c.bar, "barbaz"); +assert( + !Object.prototype.hasOwnProperty.call(C, "bar"), + "bar doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "bar"), + "bar doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "bar", { + value: "barbaz", + enumerable: true, + configurable: true, + writable: true, +}); + +// Test the private fields do not appear as properties before set to value +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#x"), "test 1"); +assert(!Object.prototype.hasOwnProperty.call(C, "#x"), "test 2"); +assert(!Object.prototype.hasOwnProperty.call(c, "#x"), "test 3"); + +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#y"), "test 4"); +assert(!Object.prototype.hasOwnProperty.call(C, "#y"), "test 5"); +assert(!Object.prototype.hasOwnProperty.call(c, "#y"), "test 6"); + +// Test if private fields can be sucessfully accessed and set to value +assert.sameValue(C.x(), 42, "test 7"); +assert.sameValue(C.y(), 43, "test 8"); + +// Test the private fields do not appear as properties before after set to value +assert(!Object.prototype.hasOwnProperty.call(C, "#x"), "test 9"); +assert(!Object.prototype.hasOwnProperty.call(C, "#y"), "test 10"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/multiple-definitions-static-private-methods-with-fields.js b/js/src/tests/test262/language/statements/class/elements/multiple-definitions-static-private-methods-with-fields.js new file mode 100644 index 0000000000..ae07f13ca4 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/multiple-definitions-static-private-methods-with-fields.js @@ -0,0 +1,139 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/static-private-methods-with-fields.case +// - src/class-elements/productions/cls-decl-multiple-definitions.template +/*--- +description: static private methods with fields (multiple fields definitions) +esid: prod-FieldDefinition +features: [class-static-methods-private, class-static-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + ... + static FieldDefinition ; + + FieldDefinition : + ClassElementName Initializer_opt + + ClassElementName : + PrivateName + + PrivateName : + # IdentifierName + +---*/ + + +class C { + foo = "foobar"; + m() { return 42 } + static #xVal; static #yVal + m2() { return 39 } + bar = "barbaz"; + static #x(value) { + this.#xVal = value; + return this.#xVal; + } + static #y(value) { + this.#yVal = value; + return this.#yVal; + } + static x() { + return this.#x(42); + } + static y() { + return this.#y(43); + } +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.m2(), 39); +assert(! + Object.prototype.hasOwnProperty.call(c, "m2"), + "m2 doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m2, C.prototype.m2); + +verifyProperty(C.prototype, "m2", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.foo, "foobar"); +assert( + !Object.prototype.hasOwnProperty.call(C, "foo"), + "foo doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "foo"), + "foo doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "foo", { + value: "foobar", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(c.bar, "barbaz"); +assert( + !Object.prototype.hasOwnProperty.call(C, "bar"), + "bar doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "bar"), + "bar doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "bar", { + value: "barbaz", + enumerable: true, + configurable: true, + writable: true, +}); + +// Test the private methods do not appear as properties before set to value +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#x"), "test 1"); +assert(!Object.prototype.hasOwnProperty.call(C, "#x"), "test 2"); +assert(!Object.prototype.hasOwnProperty.call(c, "#x"), "test 3"); + +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#y"), "test 4"); +assert(!Object.prototype.hasOwnProperty.call(C, "#y"), "test 5"); +assert(!Object.prototype.hasOwnProperty.call(c, "#y"), "test 6"); + +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#xVal"), "test 7"); +assert(!Object.prototype.hasOwnProperty.call(C, "#xVal"), "test 8"); +assert(!Object.prototype.hasOwnProperty.call(c, "#xVal"), "test 9"); + +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#yVal"), "test 10"); +assert(!Object.prototype.hasOwnProperty.call(C, "#yVal"), "test 11"); +assert(!Object.prototype.hasOwnProperty.call(c, "#yVal"), "test 12"); + +// Test if private fields can be sucessfully accessed and set to value +assert.sameValue(C.x(), 42, "test 13"); +assert.sameValue(C.y(), 43, "test 14"); + +// Test the private fields do not appear as properties before after set to value +assert(!Object.prototype.hasOwnProperty.call(C, "#x"), "test 15"); +assert(!Object.prototype.hasOwnProperty.call(C, "#y"), "test 16"); + +assert(!Object.prototype.hasOwnProperty.call(C, "#xVal"), "test 17"); +assert(!Object.prototype.hasOwnProperty.call(C, "#yVal"), "test 18"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/multiple-definitions-static-private-methods.js b/js/src/tests/test262/language/statements/class/elements/multiple-definitions-static-private-methods.js new file mode 100644 index 0000000000..73afd18ea3 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/multiple-definitions-static-private-methods.js @@ -0,0 +1,126 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/static-private-methods.case +// - src/class-elements/productions/cls-decl-multiple-definitions.template +/*--- +description: static private methods (multiple fields definitions) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + ... + static FieldDefinition ; + + FieldDefinition : + ClassElementName Initializer_opt + + ClassElementName : + PrivateName + + PrivateName : + # IdentifierName + +---*/ + + +class C { + foo = "foobar"; + m() { return 42 } + + m2() { return 39 } + bar = "barbaz"; + static #x(value) { + return value / 2; + } + static #y(value) { + return value * 2; + } + static x() { + return this.#x(84); + } + static y() { + return this.#y(43); + } +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.m2(), 39); +assert(! + Object.prototype.hasOwnProperty.call(c, "m2"), + "m2 doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m2, C.prototype.m2); + +verifyProperty(C.prototype, "m2", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.foo, "foobar"); +assert( + !Object.prototype.hasOwnProperty.call(C, "foo"), + "foo doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "foo"), + "foo doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "foo", { + value: "foobar", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(c.bar, "barbaz"); +assert( + !Object.prototype.hasOwnProperty.call(C, "bar"), + "bar doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "bar"), + "bar doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "bar", { + value: "barbaz", + enumerable: true, + configurable: true, + writable: true, +}); + +// Test the private methods do not appear as properties before set to value +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#x"), "test 1"); +assert(!Object.prototype.hasOwnProperty.call(C, "#x"), "test 2"); +assert(!Object.prototype.hasOwnProperty.call(c, "#x"), "test 3"); + +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#y"), "test 4"); +assert(!Object.prototype.hasOwnProperty.call(C, "#y"), "test 5"); +assert(!Object.prototype.hasOwnProperty.call(c, "#y"), "test 6"); + +// Test if private fields can be sucessfully accessed and set to value +assert.sameValue(C.x(), 42, "test 7"); +assert.sameValue(C.y(), 86, "test 8"); + +// Test the private fields do not appear as properties before after set to value +assert(!Object.prototype.hasOwnProperty.call(C, "#x"), "test 9"); +assert(!Object.prototype.hasOwnProperty.call(C, "#y"), "test 10"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/multiple-definitions-string-literal-names.js b/js/src/tests/test262/language/statements/class/elements/multiple-definitions-string-literal-names.js new file mode 100644 index 0000000000..0c19e95ae7 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/multiple-definitions-string-literal-names.js @@ -0,0 +1,160 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/string-literal-names.case +// - src/class-elements/productions/cls-decl-multiple-definitions.template +/*--- +description: String literal names (multiple fields definitions) +esid: prod-FieldDefinition +features: [class-fields-public, class] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PropertyName + +---*/ + + +class C { + foo = "foobar"; + m() { return 42 } + 'a'; "b"; 'c' = 39; + "d" = 42 + m2() { return 39 } + bar = "barbaz"; + +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.m2(), 39); +assert(! + Object.prototype.hasOwnProperty.call(c, "m2"), + "m2 doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m2, C.prototype.m2); + +verifyProperty(C.prototype, "m2", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.foo, "foobar"); +assert( + !Object.prototype.hasOwnProperty.call(C, "foo"), + "foo doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "foo"), + "foo doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "foo", { + value: "foobar", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(c.bar, "barbaz"); +assert( + !Object.prototype.hasOwnProperty.call(C, "bar"), + "bar doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "bar"), + "bar doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "bar", { + value: "barbaz", + enumerable: true, + configurable: true, + writable: true, +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "a"), + "a does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "a"), + "a does not appear as an own property on C constructor" +); + +verifyProperty(c, "a", { + value: undefined, + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "b"), + "b does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "b"), + "b does not appear as an own property on C constructor" +); + +verifyProperty(c, "b", { + value: undefined, + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "c"), + "c does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "c"), + "c does not appear as an own property on C constructor" +); + +verifyProperty(c, "c", { + value: 39, + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "d"), + "d does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "d"), + "d does not appear as an own property on C constructor" +); + +verifyProperty(c, "d", { + value: 42, + enumerable: true, + writable: true, + configurable: true +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-computed-names.js b/js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-computed-names.js new file mode 100644 index 0000000000..33a3cd84b1 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-computed-names.js @@ -0,0 +1,130 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/computed-names.case +// - src/class-elements/productions/cls-decl-multiple-stacked-definitions.template +/*--- +description: Computed property names (multiple stacked fields definitions through ASI) +esid: prod-FieldDefinition +features: [class-fields-public, computed-property-names, class] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PropertyName + +---*/ +var x = "b"; + + + +class C { + [x] = 42; [10] = "meep"; ["not initialized"] + foo = "foobar" + bar = "barbaz"; + +} + +var c = new C(); + +assert.sameValue(c.foo, "foobar"); +assert( + !Object.prototype.hasOwnProperty.call(C, "foo"), + "foo doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "foo"), + "foo doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "foo", { + value: "foobar", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(c.bar, "barbaz"); +assert( + !Object.prototype.hasOwnProperty.call(C, "bar"), + "bar doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "bar"), + "bar doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "bar", { + value: "barbaz", + enumerable: true, + configurable: true, + writable: true, +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "b"), + "b doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "b"), + "b doesn't appear as an own property on C constructor" +); + +verifyProperty(c, "b", { + value: 42, + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "x"), + "x doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "x"), + "x doesn't appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "x"), + "x doesn't appear as an own property on C instance" +); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "10"), + "10 doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "10"), + "10 doesn't appear as an own property on C constructor" +); + +verifyProperty(c, "10", { + value: "meep", + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "not initialized"), + "'not initialized' doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "not initialized"), + "'not initialized' doesn't appear as an own property on C constructor" +); + +verifyProperty(c, "not initialized", { + value: undefined, + enumerable: true, + writable: true, + configurable: true +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-computed-symbol-names.js b/js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-computed-symbol-names.js new file mode 100644 index 0000000000..dcc67070a1 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-computed-symbol-names.js @@ -0,0 +1,128 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/computed-symbol-names.case +// - src/class-elements/productions/cls-decl-multiple-stacked-definitions.template +/*--- +description: Computed property symbol names (multiple stacked fields definitions through ASI) +esid: prod-FieldDefinition +features: [class-fields-public, Symbol, computed-property-names, class] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PropertyName + +---*/ +var x = Symbol(); +var y = Symbol(); + + + +class C { + [x]; [y] = 42 + foo = "foobar" + bar = "barbaz"; + +} + +var c = new C(); + +assert.sameValue(c.foo, "foobar"); +assert( + !Object.prototype.hasOwnProperty.call(C, "foo"), + "foo doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "foo"), + "foo doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "foo", { + value: "foobar", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(c.bar, "barbaz"); +assert( + !Object.prototype.hasOwnProperty.call(C, "bar"), + "bar doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "bar"), + "bar doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "bar", { + value: "barbaz", + enumerable: true, + configurable: true, + writable: true, +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, x), + "Symbol x doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, x), + "Symbol x doesn't appear as an own property on C constructor" +); + +verifyProperty(c, x, { + value: undefined, + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, y), + "Symbol y doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, y), + "Symbol y doesn't appear as an own property on C constructor" +); + +verifyProperty(c, y, { + value: 42, + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "x"), + "x doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "x"), + "x doesn't appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "x"), + "x doesn't appear as an own property on C instance" +); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "y"), + "y doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "y"), + "y doesn't appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "y"), + "y doesn't appear as an own property on C instance" +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-grammar-privatename-identifier-semantics-stringvalue.js b/js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-grammar-privatename-identifier-semantics-stringvalue.js new file mode 100644 index 0000000000..24576d030b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-grammar-privatename-identifier-semantics-stringvalue.js @@ -0,0 +1,132 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-privatename-identifier-semantics-stringvalue.case +// - src/class-elements/productions/cls-decl-multiple-stacked-definitions.template +/*--- +description: PrivateName Static Semantics, StringValue (multiple stacked fields definitions through ASI) +esid: prod-FieldDefinition +features: [class-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + + + 1. Return the String value consisting of the sequence of code + units corresponding to PrivateName. In determining the sequence + any occurrences of \ UnicodeEscapeSequence are first replaced + with the code point represented by the UnicodeEscapeSequence + and then the code points of the entire PrivateName are converted + to code units by UTF16Encoding (10.1.1) each code point. + +---*/ + + +class C { + #\u{6F}; + #\u2118; + #ZW_\u200C_NJ; + #ZW_\u200D_J; + foo = "foobar" + bar = "barbaz"; + o(value) { + this.#o = value; + return this.#o; + } + ℘(value) { + this.#℘ = value; + return this.#℘; + } + ZW_‌_NJ(value) { // DO NOT CHANGE THE NAME OF THIS METHOD + this.#ZW_‌_NJ = value; + return this.#ZW_‌_NJ; + } + ZW_‍_J(value) { // DO NOT CHANGE THE NAME OF THIS METHOD + this.#ZW_‍_J = value; + return this.#ZW_‍_J; + } +} + +var c = new C(); + +assert.sameValue(c.foo, "foobar"); +assert( + !Object.prototype.hasOwnProperty.call(C, "foo"), + "foo doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "foo"), + "foo doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "foo", { + value: "foobar", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(c.bar, "barbaz"); +assert( + !Object.prototype.hasOwnProperty.call(C, "bar"), + "bar doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "bar"), + "bar doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "bar", { + value: "barbaz", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(c.o(1), 1); +assert.sameValue(c.℘(1), 1); +assert.sameValue(c.ZW_‌_NJ(1), 1); +assert.sameValue(c.ZW_‍_J(1), 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-literal-names-asi.js b/js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-literal-names-asi.js new file mode 100644 index 0000000000..18a29a486f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-literal-names-asi.js @@ -0,0 +1,100 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/literal-names-asi.case +// - src/class-elements/productions/cls-decl-multiple-stacked-definitions.template +/*--- +description: Literal property names with ASI (multiple stacked fields definitions through ASI) +esid: prod-FieldDefinition +features: [class-fields-public, class] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PropertyName + +---*/ + + +class C { + a + b = 42; + foo = "foobar" + bar = "barbaz"; + +} + +var c = new C(); + +assert.sameValue(c.foo, "foobar"); +assert( + !Object.prototype.hasOwnProperty.call(C, "foo"), + "foo doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "foo"), + "foo doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "foo", { + value: "foobar", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(c.bar, "barbaz"); +assert( + !Object.prototype.hasOwnProperty.call(C, "bar"), + "bar doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "bar"), + "bar doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "bar", { + value: "barbaz", + enumerable: true, + configurable: true, + writable: true, +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "a"), + "a doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "a"), + "a doesn't appear as an own property on C constructor" +); + +verifyProperty(c, "a", { + value: undefined, + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "b"), + "b doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "b"), + "b doesn't appear as an own property on C constructor" +); + +verifyProperty(c, "b", { + value: 42, + enumerable: true, + writable: true, + configurable: true +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-literal-names.js b/js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-literal-names.js new file mode 100644 index 0000000000..24d02c0387 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-literal-names.js @@ -0,0 +1,119 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/literal-names.case +// - src/class-elements/productions/cls-decl-multiple-stacked-definitions.template +/*--- +description: Literal property names (multiple stacked fields definitions through ASI) +esid: prod-FieldDefinition +features: [class-fields-public, class] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PropertyName + +---*/ +const fn = function() {} + + + +class C { + a; b = 42; + c = fn + foo = "foobar" + bar = "barbaz"; + +} + +var c = new C(); + +assert.sameValue(c.foo, "foobar"); +assert( + !Object.prototype.hasOwnProperty.call(C, "foo"), + "foo doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "foo"), + "foo doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "foo", { + value: "foobar", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(c.bar, "barbaz"); +assert( + !Object.prototype.hasOwnProperty.call(C, "bar"), + "bar doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "bar"), + "bar doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "bar", { + value: "barbaz", + enumerable: true, + configurable: true, + writable: true, +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "a"), + "a doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "a"), + "a doesn't appear as an own property on C constructor" +); + +verifyProperty(c, "a", { + value: undefined, + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "b"), + "b doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "b"), + "b doesn't appear as an own property on C constructor" +); + +verifyProperty(c, "b", { + value: 42, + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "c"), + "c doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "c"), + "c doesn't appear as an own property on C constructor" +); + +verifyProperty(c, "c", { + value: fn, + enumerable: true, + writable: true, + configurable: true +}); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-private-field-usage.js b/js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-private-field-usage.js new file mode 100644 index 0000000000..924a3e50bc --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-private-field-usage.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/private-field-usage.case +// - src/class-elements/productions/cls-decl-multiple-stacked-definitions.template +/*--- +description: PrivateName CallExpression usage (private field) (multiple stacked fields definitions through ASI) +esid: prod-FieldDefinition +features: [class-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + Updated Productions + + CallExpression[Yield, Await]: + CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await] + SuperCall[?Yield, ?Await] + CallExpression[?Yield, ?Await]Arguments[?Yield, ?Await] + CallExpression[?Yield, ?Await][Expression[+In, ?Yield, ?Await]] + CallExpression[?Yield, ?Await].IdentifierName + CallExpression[?Yield, ?Await]TemplateLiteral[?Yield, ?Await] + CallExpression[?Yield, ?Await].PrivateName + +---*/ + + +class C { + #m = 'test262'; + foo = "foobar" + bar = "barbaz"; + method() { + return this.#m; + } +} + +var c = new C(); + +assert.sameValue(c.foo, "foobar"); +assert( + !Object.prototype.hasOwnProperty.call(C, "foo"), + "foo doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "foo"), + "foo doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "foo", { + value: "foobar", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(c.bar, "barbaz"); +assert( + !Object.prototype.hasOwnProperty.call(C, "bar"), + "bar doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "bar"), + "bar doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "bar", { + value: "barbaz", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(c.method(), 'test262'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-private-method-getter-usage.js b/js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-private-method-getter-usage.js new file mode 100644 index 0000000000..852b25356f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-private-method-getter-usage.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/private-method-getter-usage.case +// - src/class-elements/productions/cls-decl-multiple-stacked-definitions.template +/*--- +description: PrivateName CallExpression usage (Accesor get method) (multiple stacked fields definitions through ASI) +esid: prod-FieldDefinition +features: [class-methods-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + Updated Productions + + CallExpression[Yield, Await]: + CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await] + SuperCall[?Yield, ?Await] + CallExpression[?Yield, ?Await]Arguments[?Yield, ?Await] + CallExpression[?Yield, ?Await][Expression[+In, ?Yield, ?Await]] + CallExpression[?Yield, ?Await].IdentifierName + CallExpression[?Yield, ?Await]TemplateLiteral[?Yield, ?Await] + CallExpression[?Yield, ?Await].PrivateName + +---*/ + + +class C { + get #m() { return 'test262'; } + foo = "foobar" + bar = "barbaz"; + method() { + return this.#m; + } +} + +var c = new C(); + +assert.sameValue(c.foo, "foobar"); +assert( + !Object.prototype.hasOwnProperty.call(C, "foo"), + "foo doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "foo"), + "foo doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "foo", { + value: "foobar", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(c.bar, "barbaz"); +assert( + !Object.prototype.hasOwnProperty.call(C, "bar"), + "bar doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "bar"), + "bar doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "bar", { + value: "barbaz", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(c.method(), 'test262'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-private-method-usage.js b/js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-private-method-usage.js new file mode 100644 index 0000000000..5a14646ea9 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-private-method-usage.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/private-method-usage.case +// - src/class-elements/productions/cls-decl-multiple-stacked-definitions.template +/*--- +description: PrivateName CallExpression usage (private method) (multiple stacked fields definitions through ASI) +esid: prod-FieldDefinition +features: [class-methods-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + Updated Productions + + CallExpression[Yield, Await]: + CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await] + SuperCall[?Yield, ?Await] + CallExpression[?Yield, ?Await]Arguments[?Yield, ?Await] + CallExpression[?Yield, ?Await][Expression[+In, ?Yield, ?Await]] + CallExpression[?Yield, ?Await].IdentifierName + CallExpression[?Yield, ?Await]TemplateLiteral[?Yield, ?Await] + CallExpression[?Yield, ?Await].PrivateName + +---*/ + + +class C { + #m() { return 'test262'; } + foo = "foobar" + bar = "barbaz"; + method() { + return this.#m(); + } +} + +var c = new C(); + +assert.sameValue(c.foo, "foobar"); +assert( + !Object.prototype.hasOwnProperty.call(C, "foo"), + "foo doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "foo"), + "foo doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "foo", { + value: "foobar", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(c.bar, "barbaz"); +assert( + !Object.prototype.hasOwnProperty.call(C, "bar"), + "bar doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "bar"), + "bar doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "bar", { + value: "barbaz", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(c.method(), 'test262'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-private-names.js b/js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-private-names.js new file mode 100644 index 0000000000..84db117fb4 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-private-names.js @@ -0,0 +1,94 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/private-names.case +// - src/class-elements/productions/cls-decl-multiple-stacked-definitions.template +/*--- +description: private names (multiple stacked fields definitions through ASI) +esid: prod-FieldDefinition +features: [class-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + ... + FieldDefinition ; + + FieldDefinition : + ClassElementName Initializer_opt + + ClassElementName : + PrivateName + + PrivateName : + # IdentifierName + +---*/ + + +class C { + #x; #y + foo = "foobar" + bar = "barbaz"; + x() { + this.#x = 42; + return this.#x; + } + y() { + this.#y = 43; + return this.#y; + } +} + +var c = new C(); + +assert.sameValue(c.foo, "foobar"); +assert( + !Object.prototype.hasOwnProperty.call(C, "foo"), + "foo doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "foo"), + "foo doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "foo", { + value: "foobar", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(c.bar, "barbaz"); +assert( + !Object.prototype.hasOwnProperty.call(C, "bar"), + "bar doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "bar"), + "bar doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "bar", { + value: "barbaz", + enumerable: true, + configurable: true, + writable: true, +}); + +// Test the private fields do not appear as properties before set to value +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#x"), "test 1"); +assert(!Object.prototype.hasOwnProperty.call(C, "#x"), "test 2"); +assert(!Object.prototype.hasOwnProperty.call(c, "#x"), "test 3"); + +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#y"), "test 4"); +assert(!Object.prototype.hasOwnProperty.call(C, "#y"), "test 5"); +assert(!Object.prototype.hasOwnProperty.call(c, "#y"), "test 6"); + +// Test if private fields can be sucessfully accessed and set to value +assert.sameValue(c.x(), 42, "test 7"); +assert.sameValue(c.y(), 43, "test 8"); + +// Test the private fields do not appear as properties before after set to value +assert(!Object.prototype.hasOwnProperty.call(c, "#x"), "test 9"); +assert(!Object.prototype.hasOwnProperty.call(c, "#y"), "test 10"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-rs-field-identifier-initializer.js b/js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-rs-field-identifier-initializer.js new file mode 100644 index 0000000000..533d2babf1 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-rs-field-identifier-initializer.js @@ -0,0 +1,110 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-field-identifier-initializer.case +// - src/class-elements/productions/cls-decl-multiple-stacked-definitions.template +/*--- +description: Valid FieldDefinition (multiple stacked fields definitions through ASI) +esid: prod-FieldDefinition +features: [class-fields-public, class] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + ... + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + + PropertyName : + LiteralPropertyName + ComputedPropertyName + + LiteralPropertyName : + IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + $ = 1; _ = 1; \u{6F} = 1; \u2118 = 1; ZW_\u200C_NJ = 1; ZW_\u200D_J = 1 + foo = "foobar" + bar = "barbaz"; + +} + +var c = new C(); + +assert.sameValue(c.foo, "foobar"); +assert( + !Object.prototype.hasOwnProperty.call(C, "foo"), + "foo doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "foo"), + "foo doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "foo", { + value: "foobar", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(c.bar, "barbaz"); +assert( + !Object.prototype.hasOwnProperty.call(C, "bar"), + "bar doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "bar"), + "bar doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "bar", { + value: "barbaz", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(c.$, 1); +assert.sameValue(c._, 1); +assert.sameValue(c.\u{6F}, 1); +assert.sameValue(c.\u2118, 1); +assert.sameValue(c.ZW_\u200C_NJ, 1); +assert.sameValue(c.ZW_\u200D_J, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-rs-field-identifier.js b/js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-rs-field-identifier.js new file mode 100644 index 0000000000..b374d79f0c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-rs-field-identifier.js @@ -0,0 +1,117 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-field-identifier.case +// - src/class-elements/productions/cls-decl-multiple-stacked-definitions.template +/*--- +description: Valid FieldDefinition (multiple stacked fields definitions through ASI) +esid: prod-FieldDefinition +features: [class-fields-public, class] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + ... + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + + PropertyName : + LiteralPropertyName + ComputedPropertyName + + LiteralPropertyName : + IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + $; _; \u{6F}; \u2118; ZW_\u200C_NJ; ZW_\u200D_J + foo = "foobar" + bar = "barbaz"; + +} + +var c = new C(); + +assert.sameValue(c.foo, "foobar"); +assert( + !Object.prototype.hasOwnProperty.call(C, "foo"), + "foo doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "foo"), + "foo doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "foo", { + value: "foobar", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(c.bar, "barbaz"); +assert( + !Object.prototype.hasOwnProperty.call(C, "bar"), + "bar doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "bar"), + "bar doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "bar", { + value: "barbaz", + enumerable: true, + configurable: true, + writable: true, +}); + +c.$ = 1; +c._ = 1; +c.\u{6F} = 1; +c.\u2118 = 1; +c.ZW_\u200C_NJ = 1; +c.ZW_\u200D_J = 1; + +assert.sameValue(c.$, 1); +assert.sameValue(c._, 1); +assert.sameValue(c.\u{6F}, 1); +assert.sameValue(c.\u2118, 1); +assert.sameValue(c.ZW_\u200C_NJ, 1); +assert.sameValue(c.ZW_\u200D_J, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-rs-private-getter-alt.js b/js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-rs-private-getter-alt.js new file mode 100644 index 0000000000..b7f773d106 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-rs-private-getter-alt.js @@ -0,0 +1,151 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-private-getter-alt.case +// - src/class-elements/productions/cls-decl-multiple-stacked-definitions.template +/*--- +description: Valid PrivateName as private getter (multiple stacked fields definitions through ASI) +esid: prod-FieldDefinition +features: [class-methods-private, class-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + ... + ; + + MethodDefinition : + ... + get ClassElementName ( ){ FunctionBody } + ... + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + #$_; #__; #\u{6F}_; #℘_; #ZW_‌_NJ_; #ZW_‍_J_; + get #$() { + return this.#$_; + } + get #_() { + return this.#__; + } + get #\u{6F}() { + return this.#\u{6F}_; + } + get #℘() { + return this.#℘_; + } + get #ZW_‌_NJ() { + return this.#ZW_‌_NJ_; + } + get #ZW_‍_J() { + return this.#ZW_‍_J_; + } + + foo = "foobar" + bar = "barbaz"; + $(value) { + this.#$_ = value; + return this.#$; + } + _(value) { + this.#__ = value; + return this.#_; + } + \u{6F}(value) { + this.#\u{6F}_ = value; + return this.#\u{6F}; + } + ℘(value) { + this.#℘_ = value; + return this.#℘; + } + ZW_‌_NJ(value) { + this.#ZW_‌_NJ_ = value; + return this.#ZW_‌_NJ; + } + ZW_‍_J(value) { + this.#ZW_‍_J_ = value; + return this.#ZW_‍_J; + } + +} + +var c = new C(); + +assert.sameValue(c.foo, "foobar"); +assert( + !Object.prototype.hasOwnProperty.call(C, "foo"), + "foo doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "foo"), + "foo doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "foo", { + value: "foobar", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(c.bar, "barbaz"); +assert( + !Object.prototype.hasOwnProperty.call(C, "bar"), + "bar doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "bar"), + "bar doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "bar", { + value: "barbaz", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(c.$(1), 1); +assert.sameValue(c._(1), 1); +assert.sameValue(c.\u{6F}(1), 1); +assert.sameValue(c.℘(1), 1); +assert.sameValue(c.ZW_‌_NJ(1), 1); +assert.sameValue(c.ZW_‍_J(1), 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-rs-private-getter.js b/js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-rs-private-getter.js new file mode 100644 index 0000000000..48445c7ee5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-rs-private-getter.js @@ -0,0 +1,151 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-private-getter.case +// - src/class-elements/productions/cls-decl-multiple-stacked-definitions.template +/*--- +description: Valid PrivateName as private getter (multiple stacked fields definitions through ASI) +esid: prod-FieldDefinition +features: [class-methods-private, class-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + ... + ; + + MethodDefinition : + ... + get ClassElementName ( ){ FunctionBody } + ... + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + #$_; #__; #\u{6F}_; #\u2118_; #ZW_\u200C_NJ_; #ZW_\u200D_J_; + get #$() { + return this.#$_; + } + get #_() { + return this.#__; + } + get #\u{6F}() { + return this.#\u{6F}_; + } + get #\u2118() { + return this.#\u2118_; + } + get #ZW_\u200C_NJ() { + return this.#ZW_\u200C_NJ_; + } + get #ZW_\u200D_J() { + return this.#ZW_\u200D_J_; + } + + foo = "foobar" + bar = "barbaz"; + $(value) { + this.#$_ = value; + return this.#$; + } + _(value) { + this.#__ = value; + return this.#_; + } + \u{6F}(value) { + this.#\u{6F}_ = value; + return this.#\u{6F}; + } + \u2118(value) { + this.#\u2118_ = value; + return this.#\u2118; + } + ZW_\u200C_NJ(value) { + this.#ZW_\u200C_NJ_ = value; + return this.#ZW_\u200C_NJ; + } + ZW_\u200D_J(value) { + this.#ZW_\u200D_J_ = value; + return this.#ZW_\u200D_J; + } + +} + +var c = new C(); + +assert.sameValue(c.foo, "foobar"); +assert( + !Object.prototype.hasOwnProperty.call(C, "foo"), + "foo doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "foo"), + "foo doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "foo", { + value: "foobar", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(c.bar, "barbaz"); +assert( + !Object.prototype.hasOwnProperty.call(C, "bar"), + "bar doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "bar"), + "bar doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "bar", { + value: "barbaz", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(c.$(1), 1); +assert.sameValue(c._(1), 1); +assert.sameValue(c.\u{6F}(1), 1); +assert.sameValue(c.\u2118(1), 1); +assert.sameValue(c.ZW_\u200C_NJ(1), 1); +assert.sameValue(c.ZW_\u200D_J(1), 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-rs-private-method-alt.js b/js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-rs-private-method-alt.js new file mode 100644 index 0000000000..748cf0bee8 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-rs-private-method-alt.js @@ -0,0 +1,150 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-private-method-alt.case +// - src/class-elements/productions/cls-decl-multiple-stacked-definitions.template +/*--- +description: Valid PrivateName as private method (multiple stacked fields definitions through ASI) +esid: prod-FieldDefinition +features: [class-methods-private, class-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + ... + ; + + MethodDefinition : + ClassElementName ( UniqueFormalParameters ) { FunctionBody } + ... + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + #$_; #__; #\u{6F}_; #℘_; #ZW_‌_NJ_; #ZW_‍_J_; + #$() { + return this.#$_; + } + #_() { + return this.#__; + } + #\u{6F}() { + return this.#\u{6F}_; + } + #℘() { + return this.#℘_; + } + #ZW_‌_NJ() { + return this.#ZW_‌_NJ_; + } + #ZW_‍_J() { + return this.#ZW_‍_J_; + } + + foo = "foobar" + bar = "barbaz"; + $(value) { + this.#$_ = value; + return this.#$(); + } + _(value) { + this.#__ = value; + return this.#_(); + } + \u{6F}(value) { + this.#\u{6F}_ = value; + return this.#\u{6F}(); + } + ℘(value) { + this.#℘_ = value; + return this.#℘(); + } + ZW_‌_NJ(value) { + this.#ZW_‌_NJ_ = value; + return this.#ZW_‌_NJ(); + } + ZW_‍_J(value) { + this.#ZW_‍_J_ = value; + return this.#ZW_‍_J(); + } + +} + +var c = new C(); + +assert.sameValue(c.foo, "foobar"); +assert( + !Object.prototype.hasOwnProperty.call(C, "foo"), + "foo doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "foo"), + "foo doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "foo", { + value: "foobar", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(c.bar, "barbaz"); +assert( + !Object.prototype.hasOwnProperty.call(C, "bar"), + "bar doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "bar"), + "bar doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "bar", { + value: "barbaz", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(c.$(1), 1); +assert.sameValue(c._(1), 1); +assert.sameValue(c.\u{6F}(1), 1); +assert.sameValue(c.℘(1), 1); +assert.sameValue(c.ZW_‌_NJ(1), 1); +assert.sameValue(c.ZW_‍_J(1), 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-rs-private-method.js b/js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-rs-private-method.js new file mode 100644 index 0000000000..a73cd7cae0 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-rs-private-method.js @@ -0,0 +1,150 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-private-method.case +// - src/class-elements/productions/cls-decl-multiple-stacked-definitions.template +/*--- +description: Valid PrivateName as private method (multiple stacked fields definitions through ASI) +esid: prod-FieldDefinition +features: [class-methods-private, class-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + ... + ; + + MethodDefinition : + ClassElementName ( UniqueFormalParameters ) { FunctionBody } + ... + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + #$_; #__; #\u{6F}_; #\u2118_; #ZW_\u200C_NJ_; #ZW_\u200D_J_; + #$() { + return this.#$_; + } + #_() { + return this.#__; + } + #\u{6F}() { + return this.#\u{6F}_; + } + #\u2118() { + return this.#\u2118_; + } + #ZW_\u200C_NJ() { + return this.#ZW_\u200C_NJ_; + } + #ZW_\u200D_J() { + return this.#ZW_\u200D_J_; + } + + foo = "foobar" + bar = "barbaz"; + $(value) { + this.#$_ = value; + return this.#$(); + } + _(value) { + this.#__ = value; + return this.#_(); + } + \u{6F}(value) { + this.#\u{6F}_ = value; + return this.#\u{6F}(); + } + \u2118(value) { + this.#\u2118_ = value; + return this.#\u2118(); + } + ZW_\u200C_NJ(value) { + this.#ZW_\u200C_NJ_ = value; + return this.#ZW_\u200C_NJ(); + } + ZW_\u200D_J(value) { + this.#ZW_\u200D_J_ = value; + return this.#ZW_\u200D_J(); + } + +} + +var c = new C(); + +assert.sameValue(c.foo, "foobar"); +assert( + !Object.prototype.hasOwnProperty.call(C, "foo"), + "foo doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "foo"), + "foo doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "foo", { + value: "foobar", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(c.bar, "barbaz"); +assert( + !Object.prototype.hasOwnProperty.call(C, "bar"), + "bar doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "bar"), + "bar doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "bar", { + value: "barbaz", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(c.$(1), 1); +assert.sameValue(c._(1), 1); +assert.sameValue(c.\u{6F}(1), 1); +assert.sameValue(c.\u2118(1), 1); +assert.sameValue(c.ZW_\u200C_NJ(1), 1); +assert.sameValue(c.ZW_\u200D_J(1), 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-rs-private-setter-alt.js b/js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-rs-private-setter-alt.js new file mode 100644 index 0000000000..06ba60b3aa --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-rs-private-setter-alt.js @@ -0,0 +1,150 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-private-setter-alt.case +// - src/class-elements/productions/cls-decl-multiple-stacked-definitions.template +/*--- +description: Valid PrivateName as private setter (multiple stacked fields definitions through ASI) +esid: prod-FieldDefinition +features: [class-methods-private, class-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + ... + ; + + MethodDefinition : + ... + set ClassElementName ( PropertySetParameterList ) { FunctionBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + #$_; #__; #\u{6F}_; #℘_; #ZW_‌_NJ_; #ZW_‍_J_; + set #$(value) { + this.#$_ = value; + } + set #_(value) { + this.#__ = value; + } + set #\u{6F}(value) { + this.#\u{6F}_ = value; + } + set #℘(value) { + this.#℘_ = value; + } + set #ZW_‌_NJ(value) { + this.#ZW_‌_NJ_ = value; + } + set #ZW_‍_J(value) { + this.#ZW_‍_J_ = value; + } + + foo = "foobar" + bar = "barbaz"; + $(value) { + this.#$ = value; + return this.#$_; + } + _(value) { + this.#_ = value; + return this.#__; + } + \u{6F}(value) { + this.#\u{6F} = value; + return this.#\u{6F}_; + } + ℘(value) { + this.#℘ = value; + return this.#℘_; + } + ZW_‌_NJ(value) { + this.#ZW_‌_NJ = value; + return this.#ZW_‌_NJ_; + } + ZW_‍_J(value) { + this.#ZW_‍_J = value; + return this.#ZW_‍_J_; + } + +} + +var c = new C(); + +assert.sameValue(c.foo, "foobar"); +assert( + !Object.prototype.hasOwnProperty.call(C, "foo"), + "foo doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "foo"), + "foo doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "foo", { + value: "foobar", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(c.bar, "barbaz"); +assert( + !Object.prototype.hasOwnProperty.call(C, "bar"), + "bar doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "bar"), + "bar doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "bar", { + value: "barbaz", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(c.$(1), 1); +assert.sameValue(c._(1), 1); +assert.sameValue(c.\u{6F}(1), 1); +assert.sameValue(c.℘(1), 1); +assert.sameValue(c.ZW_‌_NJ(1), 1); +assert.sameValue(c.ZW_‍_J(1), 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-rs-private-setter.js b/js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-rs-private-setter.js new file mode 100644 index 0000000000..1e148929e7 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-rs-private-setter.js @@ -0,0 +1,150 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-private-setter.case +// - src/class-elements/productions/cls-decl-multiple-stacked-definitions.template +/*--- +description: Valid PrivateName as private setter (multiple stacked fields definitions through ASI) +esid: prod-FieldDefinition +features: [class-methods-private, class-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + ... + ; + + MethodDefinition : + ... + set ClassElementName ( PropertySetParameterList ) { FunctionBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + #$_; #__; #\u{6F}_; #\u2118_; #ZW_\u200C_NJ_; #ZW_\u200D_J_; + set #$(value) { + this.#$_ = value; + } + set #_(value) { + this.#__ = value; + } + set #\u{6F}(value) { + this.#\u{6F}_ = value; + } + set #\u2118(value) { + this.#\u2118_ = value; + } + set #ZW_\u200C_NJ(value) { + this.#ZW_\u200C_NJ_ = value; + } + set #ZW_\u200D_J(value) { + this.#ZW_\u200D_J_ = value; + } + + foo = "foobar" + bar = "barbaz"; + $(value) { + this.#$ = value; + return this.#$_; + } + _(value) { + this.#_ = value; + return this.#__; + } + \u{6F}(value) { + this.#\u{6F} = value; + return this.#\u{6F}_; + } + \u2118(value) { + this.#\u2118 = value; + return this.#\u2118_; + } + ZW_\u200C_NJ(value) { + this.#ZW_\u200C_NJ = value; + return this.#ZW_\u200C_NJ_; + } + ZW_\u200D_J(value) { + this.#ZW_\u200D_J = value; + return this.#ZW_\u200D_J_; + } + +} + +var c = new C(); + +assert.sameValue(c.foo, "foobar"); +assert( + !Object.prototype.hasOwnProperty.call(C, "foo"), + "foo doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "foo"), + "foo doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "foo", { + value: "foobar", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(c.bar, "barbaz"); +assert( + !Object.prototype.hasOwnProperty.call(C, "bar"), + "bar doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "bar"), + "bar doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "bar", { + value: "barbaz", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(c.$(1), 1); +assert.sameValue(c._(1), 1); +assert.sameValue(c.\u{6F}(1), 1); +assert.sameValue(c.\u2118(1), 1); +assert.sameValue(c.ZW_\u200C_NJ(1), 1); +assert.sameValue(c.ZW_\u200D_J(1), 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-rs-privatename-identifier-alt.js b/js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-rs-privatename-identifier-alt.js new file mode 100644 index 0000000000..b091d5ae3d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-rs-privatename-identifier-alt.js @@ -0,0 +1,132 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-privatename-identifier-alt.case +// - src/class-elements/productions/cls-decl-multiple-stacked-definitions.template +/*--- +description: Valid PrivateName (multiple stacked fields definitions through ASI) +esid: prod-FieldDefinition +features: [class-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + #$; #_; #\u{6F}; #℘; #ZW_‌_NJ; #ZW_‍_J + foo = "foobar" + bar = "barbaz"; + $(value) { + this.#$ = value; + return this.#$; + } + _(value) { + this.#_ = value; + return this.#_; + } + \u{6F}(value) { + this.#\u{6F} = value; + return this.#\u{6F}; + } + ℘(value) { + this.#℘ = value; + return this.#℘; + } + ZW_‌_NJ(value) { + this.#ZW_‌_NJ = value; + return this.#ZW_‌_NJ; + } + ZW_‍_J(value) { + this.#ZW_‍_J = value; + return this.#ZW_‍_J; + } +} + +var c = new C(); + +assert.sameValue(c.foo, "foobar"); +assert( + !Object.prototype.hasOwnProperty.call(C, "foo"), + "foo doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "foo"), + "foo doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "foo", { + value: "foobar", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(c.bar, "barbaz"); +assert( + !Object.prototype.hasOwnProperty.call(C, "bar"), + "bar doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "bar"), + "bar doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "bar", { + value: "barbaz", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(c.$(1), 1); +assert.sameValue(c._(1), 1); +assert.sameValue(c.\u{6F}(1), 1); +assert.sameValue(c.℘(1), 1); +assert.sameValue(c.ZW_‌_NJ(1), 1); +assert.sameValue(c.ZW_‍_J(1), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-rs-privatename-identifier-initializer-alt.js b/js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-rs-privatename-identifier-initializer-alt.js new file mode 100644 index 0000000000..e9ad66b790 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-rs-privatename-identifier-initializer-alt.js @@ -0,0 +1,126 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-privatename-identifier-initializer-alt.case +// - src/class-elements/productions/cls-decl-multiple-stacked-definitions.template +/*--- +description: Valid PrivateName (multiple stacked fields definitions through ASI) +esid: prod-FieldDefinition +features: [class-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + #$ = 1; #_ = 1; #\u{6F} = 1; #℘ = 1; #ZW_‌_NJ = 1; #ZW_‍_J = 1 + foo = "foobar" + bar = "barbaz"; + $() { + return this.#$; + } + _() { + return this.#_; + } + \u{6F}() { + return this.#\u{6F}; + } + ℘() { + return this.#℘; + } + ZW_‌_NJ() { + return this.#ZW_‌_NJ; + } + ZW_‍_J() { + return this.#ZW_‍_J; + } +} + +var c = new C(); + +assert.sameValue(c.foo, "foobar"); +assert( + !Object.prototype.hasOwnProperty.call(C, "foo"), + "foo doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "foo"), + "foo doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "foo", { + value: "foobar", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(c.bar, "barbaz"); +assert( + !Object.prototype.hasOwnProperty.call(C, "bar"), + "bar doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "bar"), + "bar doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "bar", { + value: "barbaz", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(c.$(), 1); +assert.sameValue(c._(), 1); +assert.sameValue(c.\u{6F}(), 1); +assert.sameValue(c.℘(), 1); +assert.sameValue(c.ZW_‌_NJ(), 1); +assert.sameValue(c.ZW_‍_J(), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-rs-privatename-identifier-initializer.js b/js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-rs-privatename-identifier-initializer.js new file mode 100644 index 0000000000..d492a9b06f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-rs-privatename-identifier-initializer.js @@ -0,0 +1,126 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-privatename-identifier-initializer.case +// - src/class-elements/productions/cls-decl-multiple-stacked-definitions.template +/*--- +description: Valid PrivateName (multiple stacked fields definitions through ASI) +esid: prod-FieldDefinition +features: [class-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + #$ = 1; #_ = 1; #\u{6F} = 1; #\u2118 = 1; #ZW_\u200C_NJ = 1; #ZW_\u200D_J = 1 + foo = "foobar" + bar = "barbaz"; + $() { + return this.#$; + } + _() { + return this.#_; + } + \u{6F}() { + return this.#\u{6F}; + } + \u2118() { + return this.#\u2118; + } + ZW_\u200C_NJ() { + return this.#ZW_\u200C_NJ; + } + ZW_\u200D_J() { + return this.#ZW_\u200D_J; + } +} + +var c = new C(); + +assert.sameValue(c.foo, "foobar"); +assert( + !Object.prototype.hasOwnProperty.call(C, "foo"), + "foo doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "foo"), + "foo doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "foo", { + value: "foobar", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(c.bar, "barbaz"); +assert( + !Object.prototype.hasOwnProperty.call(C, "bar"), + "bar doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "bar"), + "bar doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "bar", { + value: "barbaz", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(c.$(), 1); +assert.sameValue(c._(), 1); +assert.sameValue(c.\u{6F}(), 1); +assert.sameValue(c.\u2118(), 1); +assert.sameValue(c.ZW_\u200C_NJ(), 1); +assert.sameValue(c.ZW_\u200D_J(), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-rs-privatename-identifier.js b/js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-rs-privatename-identifier.js new file mode 100644 index 0000000000..750081b1a2 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-rs-privatename-identifier.js @@ -0,0 +1,132 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-privatename-identifier.case +// - src/class-elements/productions/cls-decl-multiple-stacked-definitions.template +/*--- +description: Valid PrivateName (multiple stacked fields definitions through ASI) +esid: prod-FieldDefinition +features: [class-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + #$; #_; #\u{6F}; #\u2118; #ZW_\u200C_NJ; #ZW_\u200D_J + foo = "foobar" + bar = "barbaz"; + $(value) { + this.#$ = value; + return this.#$; + } + _(value) { + this.#_ = value; + return this.#_; + } + \u{6F}(value) { + this.#\u{6F} = value; + return this.#\u{6F}; + } + \u2118(value) { + this.#\u2118 = value; + return this.#\u2118; + } + ZW_\u200C_NJ(value) { + this.#ZW_\u200C_NJ = value; + return this.#ZW_\u200C_NJ; + } + ZW_\u200D_J(value) { + this.#ZW_\u200D_J = value; + return this.#ZW_\u200D_J; + } +} + +var c = new C(); + +assert.sameValue(c.foo, "foobar"); +assert( + !Object.prototype.hasOwnProperty.call(C, "foo"), + "foo doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "foo"), + "foo doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "foo", { + value: "foobar", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(c.bar, "barbaz"); +assert( + !Object.prototype.hasOwnProperty.call(C, "bar"), + "bar doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "bar"), + "bar doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "bar", { + value: "barbaz", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(c.$(1), 1); +assert.sameValue(c._(1), 1); +assert.sameValue(c.\u{6F}(1), 1); +assert.sameValue(c.\u2118(1), 1); +assert.sameValue(c.ZW_\u200C_NJ(1), 1); +assert.sameValue(c.ZW_\u200D_J(1), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-rs-static-async-generator-method-privatename-identifier-alt.js b/js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-rs-static-async-generator-method-privatename-identifier-alt.js new file mode 100644 index 0000000000..8acf08510e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-rs-static-async-generator-method-privatename-identifier-alt.js @@ -0,0 +1,157 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-async-generator-method-privatename-identifier-alt.case +// - src/class-elements/productions/cls-decl-multiple-stacked-definitions.template +/*--- +description: Valid Static AsyncGeneratorMethod PrivateName (multiple stacked fields definitions through ASI) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + AsyncGeneratorMethod + + AsyncGeneratorMethod : + async [no LineTerminator here] * ClassElementName ( UniqueFormalParameters){ AsyncGeneratorBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static async * #$(value) { + yield * await value; + } + static async * #_(value) { + yield * await value; + } + static async * #o(value) { + yield * await value; + } + static async * #℘(value) { + yield * await value; + } + static async * #ZW_‌_NJ(value) { + yield * await value; + } + static async * #ZW_‍_J(value) { + yield * await value; + } + foo = "foobar" + bar = "barbaz"; + static get $() { + return this.#$; + } + static get _() { + return this.#_; + } + static get o() { + return this.#o; + } + static get ℘() { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#℘; + } + static get ZW_‌_NJ() { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#ZW_‌_NJ; + } + static get ZW_‍_J() { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#ZW_‍_J; + } + +} + +var c = new C(); + +assert.sameValue(c.foo, "foobar"); +assert( + !Object.prototype.hasOwnProperty.call(C, "foo"), + "foo doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "foo"), + "foo doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "foo", { + value: "foobar", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(c.bar, "barbaz"); +assert( + !Object.prototype.hasOwnProperty.call(C, "bar"), + "bar doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "bar"), + "bar doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "bar", { + value: "barbaz", + enumerable: true, + configurable: true, + writable: true, +}); + +Promise.all([ + C.$([1]).next(), + C._([1]).next(), + C.o([1]).next(), + C.℘([1]).next(), // DO NOT CHANGE THE NAME OF THIS FIELD + C.ZW_‌_NJ([1]).next(), // DO NOT CHANGE THE NAME OF THIS FIELD + C.ZW_‍_J([1]).next(), // DO NOT CHANGE THE NAME OF THIS FIELD +]).then(results => { + + assert.sameValue(results[0].value, 1); + assert.sameValue(results[1].value, 1); + assert.sameValue(results[2].value, 1); + assert.sameValue(results[3].value, 1); + assert.sameValue(results[4].value, 1); + assert.sameValue(results[5].value, 1); + +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-rs-static-async-generator-method-privatename-identifier.js b/js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-rs-static-async-generator-method-privatename-identifier.js new file mode 100644 index 0000000000..f70868376a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-rs-static-async-generator-method-privatename-identifier.js @@ -0,0 +1,158 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-async-generator-method-privatename-identifier.case +// - src/class-elements/productions/cls-decl-multiple-stacked-definitions.template +/*--- +description: Valid Static AsyncGeneratorMethod PrivateName (multiple stacked fields definitions through ASI) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + AsyncGeneratorMethod + + AsyncGeneratorMethod : + async [no LineTerminator here] * ClassElementName ( UniqueFormalParameters){ AsyncGeneratorBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static async * #$(value) { + yield * await value; + } + static async * #_(value) { + yield * await value; + } + static async * #\u{6F}(value) { + yield * await value; + } + static async * #\u2118(value) { + yield * await value; + } + static async * #ZW_\u200C_NJ(value) { + yield * await value; + } + static async * #ZW_\u200D_J(value) { + yield * await value; + } + foo = "foobar" + bar = "barbaz"; + static get $() { + return this.#$; + } + static get _() { + return this.#_; + } + static get \u{6F}() { + return this.#\u{6F}; + } + static get \u2118() { + return this.#\u2118; + } + static get ZW_\u200C_NJ() { + return this.#ZW_\u200C_NJ; + } + static get ZW_\u200D_J() { + return this.#ZW_\u200D_J; + } + +} + +var c = new C(); + +assert.sameValue(c.foo, "foobar"); +assert( + !Object.prototype.hasOwnProperty.call(C, "foo"), + "foo doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "foo"), + "foo doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "foo", { + value: "foobar", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(c.bar, "barbaz"); +assert( + !Object.prototype.hasOwnProperty.call(C, "bar"), + "bar doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "bar"), + "bar doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "bar", { + value: "barbaz", + enumerable: true, + configurable: true, + writable: true, +}); + +Promise.all([ + C.$([1]).next(), + C._([1]).next(), + C.\u{6F}([1]).next(), + C.\u2118([1]).next(), + C.ZW_\u200C_NJ([1]).next(), + C.ZW_\u200D_J([1]).next(), +]).then(results => { + + assert.sameValue(results[0].value, 1); + assert.sameValue(results[1].value, 1); + assert.sameValue(results[2].value, 1); + assert.sameValue(results[3].value, 1); + assert.sameValue(results[4].value, 1); + assert.sameValue(results[5].value, 1); + +}).then($DONE, $DONE); + diff --git a/js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-rs-static-async-method-privatename-identifier-alt.js b/js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-rs-static-async-method-privatename-identifier-alt.js new file mode 100644 index 0000000000..32a2350244 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-rs-static-async-method-privatename-identifier-alt.js @@ -0,0 +1,157 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-async-method-privatename-identifier-alt.case +// - src/class-elements/productions/cls-decl-multiple-stacked-definitions.template +/*--- +description: Valid Static AsyncMethod PrivateName (multiple stacked fields definitions through ASI) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + AsyncMethod + + AsyncMethod : + async [no LineTerminator here] ClassElementName ( UniqueFormalParameters ){ AsyncFunctionBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static async #$(value) { + return await value; + } + static async #_(value) { + return await value; + } + static async #o(value) { + return await value; + } + static async #℘(value) { + return await value; + } + static async #ZW_‌_NJ(value) { + return await value; + } + static async #ZW_‍_J(value) { + return await value; + } + foo = "foobar" + bar = "barbaz"; + static async $(value) { + return await this.#$(value); + } + static async _(value) { + return await this.#_(value); + } + static async o(value) { + return await this.#o(value); + } + static async ℘(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + return await this.#℘(value); + } + static async ZW_‌_NJ(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + return await this.#ZW_‌_NJ(value); + } + static async ZW_‍_J(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + return await this.#ZW_‍_J(value); + } + +} + +var c = new C(); + +assert.sameValue(c.foo, "foobar"); +assert( + !Object.prototype.hasOwnProperty.call(C, "foo"), + "foo doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "foo"), + "foo doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "foo", { + value: "foobar", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(c.bar, "barbaz"); +assert( + !Object.prototype.hasOwnProperty.call(C, "bar"), + "bar doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "bar"), + "bar doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "bar", { + value: "barbaz", + enumerable: true, + configurable: true, + writable: true, +}); + +Promise.all([ + C.$(1), + C._(1), + C.o(1), + C.℘(1), // DO NOT CHANGE THE NAME OF THIS FIELD + C.ZW_‌_NJ(1), // DO NOT CHANGE THE NAME OF THIS FIELD + C.ZW_‍_J(1), // DO NOT CHANGE THE NAME OF THIS FIELD +]).then(results => { + + assert.sameValue(results[0], 1); + assert.sameValue(results[1], 1); + assert.sameValue(results[2], 1); + assert.sameValue(results[3], 1); + assert.sameValue(results[4], 1); + assert.sameValue(results[5], 1); + +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-rs-static-async-method-privatename-identifier.js b/js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-rs-static-async-method-privatename-identifier.js new file mode 100644 index 0000000000..376984d386 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-rs-static-async-method-privatename-identifier.js @@ -0,0 +1,158 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-async-method-privatename-identifier.case +// - src/class-elements/productions/cls-decl-multiple-stacked-definitions.template +/*--- +description: Valid Static AsyncMethod PrivateName (multiple stacked fields definitions through ASI) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + AsyncMethod + + AsyncMethod : + async [no LineTerminator here] ClassElementName ( UniqueFormalParameters ){ AsyncFunctionBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static async #$(value) { + return await value; + } + static async #_(value) { + return await value; + } + static async #\u{6F}(value) { + return await value; + } + static async #\u2118(value) { + return await value; + } + static async #ZW_\u200C_NJ(value) { + return await value; + } + static async #ZW_\u200D_J(value) { + return await value; + } + foo = "foobar" + bar = "barbaz"; + static async $(value) { + return await this.#$(value); + } + static async _(value) { + return await this.#_(value); + } + static async \u{6F}(value) { + return await this.#\u{6F}(value); + } + static async \u2118(value) { + return await this.#\u2118(value); + } + static async ZW_\u200C_NJ(value) { + return await this.#ZW_\u200C_NJ(value); + } + static async ZW_\u200D_J(value) { + return await this.#ZW_\u200D_J(value); + } + +} + +var c = new C(); + +assert.sameValue(c.foo, "foobar"); +assert( + !Object.prototype.hasOwnProperty.call(C, "foo"), + "foo doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "foo"), + "foo doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "foo", { + value: "foobar", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(c.bar, "barbaz"); +assert( + !Object.prototype.hasOwnProperty.call(C, "bar"), + "bar doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "bar"), + "bar doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "bar", { + value: "barbaz", + enumerable: true, + configurable: true, + writable: true, +}); + +Promise.all([ + C.$(1), + C._(1), + C.\u{6F}(1), + C.\u2118(1), + C.ZW_\u200C_NJ(1), + C.ZW_\u200D_J(1), +]).then(results => { + + assert.sameValue(results[0], 1); + assert.sameValue(results[1], 1); + assert.sameValue(results[2], 1); + assert.sameValue(results[3], 1); + assert.sameValue(results[4], 1); + assert.sameValue(results[5], 1); + +}).then($DONE, $DONE); + diff --git a/js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-rs-static-generator-method-privatename-identifier-alt.js b/js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-rs-static-generator-method-privatename-identifier-alt.js new file mode 100644 index 0000000000..3e03c04c06 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-rs-static-generator-method-privatename-identifier-alt.js @@ -0,0 +1,147 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-generator-method-privatename-identifier-alt.case +// - src/class-elements/productions/cls-decl-multiple-stacked-definitions.template +/*--- +description: Valid Static GeneratorMethod PrivateName (multiple stacked fields definitions through ASI) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + GeneratorMethod + + GeneratorMethod : + * ClassElementName ( UniqueFormalParameters ){ GeneratorBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static * #$(value) { + yield * value; + } + static * #_(value) { + yield * value; + } + static * #o(value) { + yield * value; + } + static * #℘(value) { + yield * value; + } + static * #ZW_‌_NJ(value) { + yield * value; + } + static * #ZW_‍_J(value) { + yield * value; + } + foo = "foobar" + bar = "barbaz"; + static get $() { + return this.#$; + } + static get _() { + return this.#_; + } + static get o() { + return this.#o; + } + static get ℘() { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#℘; + } + static get ZW_‌_NJ() { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#ZW_‌_NJ; + } + static get ZW_‍_J() { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#ZW_‍_J; + } + +} + +var c = new C(); + +assert.sameValue(c.foo, "foobar"); +assert( + !Object.prototype.hasOwnProperty.call(C, "foo"), + "foo doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "foo"), + "foo doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "foo", { + value: "foobar", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(c.bar, "barbaz"); +assert( + !Object.prototype.hasOwnProperty.call(C, "bar"), + "bar doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "bar"), + "bar doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "bar", { + value: "barbaz", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(C.$([1]).next().value, 1); +assert.sameValue(C._([1]).next().value, 1); +assert.sameValue(C.o([1]).next().value, 1); +assert.sameValue(C.℘([1]).next().value, 1); +assert.sameValue(C.ZW_‌_NJ([1]).next().value, 1); +assert.sameValue(C.ZW_‍_J([1]).next().value, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-rs-static-generator-method-privatename-identifier.js b/js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-rs-static-generator-method-privatename-identifier.js new file mode 100644 index 0000000000..35b1823259 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-rs-static-generator-method-privatename-identifier.js @@ -0,0 +1,148 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-generator-method-privatename-identifier.case +// - src/class-elements/productions/cls-decl-multiple-stacked-definitions.template +/*--- +description: Valid Static GeneratorMethod PrivateName (multiple stacked fields definitions through ASI) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + GeneratorMethod + + GeneratorMethod : + * ClassElementName ( UniqueFormalParameters ){ GeneratorBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static * #$(value) { + yield * value; + } + static * #_(value) { + yield * value; + } + static * #\u{6F}(value) { + yield * value; + } + static * #\u2118(value) { + yield * value; + } + static * #ZW_\u200C_NJ(value) { + yield * value; + } + static * #ZW_\u200D_J(value) { + yield * value; + } + foo = "foobar" + bar = "barbaz"; + static get $() { + return this.#$; + } + static get _() { + return this.#_; + } + static get \u{6F}() { + return this.#\u{6F}; + } + static get \u2118() { + return this.#\u2118; + } + static get ZW_\u200C_NJ() { + return this.#ZW_\u200C_NJ; + } + static get ZW_\u200D_J() { + return this.#ZW_\u200D_J; + } + +} + +var c = new C(); + +assert.sameValue(c.foo, "foobar"); +assert( + !Object.prototype.hasOwnProperty.call(C, "foo"), + "foo doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "foo"), + "foo doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "foo", { + value: "foobar", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(c.bar, "barbaz"); +assert( + !Object.prototype.hasOwnProperty.call(C, "bar"), + "bar doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "bar"), + "bar doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "bar", { + value: "barbaz", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(C.$([1]).next().value, 1); +assert.sameValue(C._([1]).next().value, 1); +assert.sameValue(C.\u{6F}([1]).next().value, 1); +assert.sameValue(C.\u2118([1]).next().value, 1); +assert.sameValue(C.ZW_\u200C_NJ([1]).next().value, 1); +assert.sameValue(C.ZW_\u200D_J([1]).next().value, 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-rs-static-method-privatename-identifier-alt.js b/js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-rs-static-method-privatename-identifier-alt.js new file mode 100644 index 0000000000..fcf9196c27 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-rs-static-method-privatename-identifier-alt.js @@ -0,0 +1,145 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-method-privatename-identifier-alt.case +// - src/class-elements/productions/cls-decl-multiple-stacked-definitions.template +/*--- +description: Valid Static Method PrivateName (multiple stacked fields definitions through ASI) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + ClassElementName ( UniqueFormalParameters ){ FunctionBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static #$(value) { + return value; + } + static #_(value) { + return value; + } + static #o(value) { + return value; + } + static #℘(value) { + return value; + } + static #ZW_‌_NJ(value) { + return value; + } + static #ZW_‍_J(value) { + return value; + } + foo = "foobar" + bar = "barbaz"; + static $(value) { + return this.#$(value); + } + static _(value) { + return this.#_(value); + } + static o(value) { + return this.#o(value); + } + static ℘(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#℘(value); + } + static ZW_‌_NJ(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#ZW_‌_NJ(value); + } + static ZW_‍_J(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#ZW_‍_J(value); + } + +} + +var c = new C(); + +assert.sameValue(c.foo, "foobar"); +assert( + !Object.prototype.hasOwnProperty.call(C, "foo"), + "foo doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "foo"), + "foo doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "foo", { + value: "foobar", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(c.bar, "barbaz"); +assert( + !Object.prototype.hasOwnProperty.call(C, "bar"), + "bar doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "bar"), + "bar doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "bar", { + value: "barbaz", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(C.$(1), 1); +assert.sameValue(C._(1), 1); +assert.sameValue(C.o(1), 1); +assert.sameValue(C.℘(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD +assert.sameValue(C.ZW_‌_NJ(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD +assert.sameValue(C.ZW_‍_J(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-rs-static-method-privatename-identifier.js b/js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-rs-static-method-privatename-identifier.js new file mode 100644 index 0000000000..6ac8ee35a8 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-rs-static-method-privatename-identifier.js @@ -0,0 +1,145 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-method-privatename-identifier.case +// - src/class-elements/productions/cls-decl-multiple-stacked-definitions.template +/*--- +description: Valid Static Method PrivateName (multiple stacked fields definitions through ASI) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + ClassElementName ( UniqueFormalParameters ){ FunctionBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static #$(value) { + return value; + } + static #_(value) { + return value; + } + static #\u{6F}(value) { + return value; + } + static #\u2118(value) { + return value; + } + static #ZW_\u200C_NJ(value) { + return value; + } + static #ZW_\u200D_J(value) { + return value; + } + foo = "foobar" + bar = "barbaz"; + static $(value) { + return this.#$(value); + } + static _(value) { + return this.#_(value); + } + static \u{6F}(value) { + return this.#\u{6F}(value); + } + static \u2118(value) { + return this.#\u2118(value); + } + static ZW_\u200C_NJ(value) { + return this.#ZW_\u200C_NJ(value); + } + static ZW_\u200D_J(value) { + return this.#ZW_\u200D_J(value); + } + +} + +var c = new C(); + +assert.sameValue(c.foo, "foobar"); +assert( + !Object.prototype.hasOwnProperty.call(C, "foo"), + "foo doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "foo"), + "foo doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "foo", { + value: "foobar", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(c.bar, "barbaz"); +assert( + !Object.prototype.hasOwnProperty.call(C, "bar"), + "bar doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "bar"), + "bar doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "bar", { + value: "barbaz", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(C.$(1), 1); +assert.sameValue(C._(1), 1); +assert.sameValue(C.\u{6F}(1), 1); +assert.sameValue(C.\u2118(1), 1); +assert.sameValue(C.ZW_\u200C_NJ(1), 1); +assert.sameValue(C.ZW_\u200D_J(1), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-rs-static-privatename-identifier-alt-by-classname.js b/js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-rs-static-privatename-identifier-alt-by-classname.js new file mode 100644 index 0000000000..bead6c078e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-rs-static-privatename-identifier-alt-by-classname.js @@ -0,0 +1,133 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-privatename-identifier-alt-by-classname.case +// - src/class-elements/productions/cls-decl-multiple-stacked-definitions.template +/*--- +description: Valid Static PrivateName (multiple stacked fields definitions through ASI) +esid: prod-FieldDefinition +features: [class-static-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static #$; static #_; static #\u{6F}; static #℘; static #ZW_‌_NJ; static #ZW_‍_J + foo = "foobar" + bar = "barbaz"; + static $(value) { + C.#$ = value; + return C.#$; + } + static _(value) { + C.#_ = value; + return C.#_; + } + static o(value) { + C.#\u{6F} = value; + return C.#\u{6F}; + } + static ℘(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + C.#℘ = value; + return C.#℘; + } + static ZW_‌_NJ(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + C.#ZW_‌_NJ = value; + return C.#ZW_‌_NJ; + } + static ZW_‍_J(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + C.#ZW_‍_J = value; + return C.#ZW_‍_J; + } +} + +var c = new C(); + +assert.sameValue(c.foo, "foobar"); +assert( + !Object.prototype.hasOwnProperty.call(C, "foo"), + "foo doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "foo"), + "foo doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "foo", { + value: "foobar", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(c.bar, "barbaz"); +assert( + !Object.prototype.hasOwnProperty.call(C, "bar"), + "bar doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "bar"), + "bar doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "bar", { + value: "barbaz", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(C.$(1), 1); +assert.sameValue(C._(1), 1); +assert.sameValue(C.o(1), 1); +assert.sameValue(C.℘(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD +assert.sameValue(C.ZW_‌_NJ(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD +assert.sameValue(C.ZW_‍_J(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-rs-static-privatename-identifier-alt.js b/js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-rs-static-privatename-identifier-alt.js new file mode 100644 index 0000000000..08cc2b9518 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-rs-static-privatename-identifier-alt.js @@ -0,0 +1,133 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-privatename-identifier-alt.case +// - src/class-elements/productions/cls-decl-multiple-stacked-definitions.template +/*--- +description: Valid Static PrivateName (multiple stacked fields definitions through ASI) +esid: prod-FieldDefinition +features: [class-static-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static #$; static #_; static #\u{6F}; static #℘; static #ZW_‌_NJ; static #ZW_‍_J + foo = "foobar" + bar = "barbaz"; + static $(value) { + this.#$ = value; + return this.#$; + } + static _(value) { + this.#_ = value; + return this.#_; + } + static o(value) { + this.#\u{6F} = value; + return this.#\u{6F}; + } + static ℘(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + this.#℘ = value; + return this.#℘; + } + static ZW_‌_NJ(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + this.#ZW_‌_NJ = value; + return this.#ZW_‌_NJ; + } + static ZW_‍_J(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + this.#ZW_‍_J = value; + return this.#ZW_‍_J; + } +} + +var c = new C(); + +assert.sameValue(c.foo, "foobar"); +assert( + !Object.prototype.hasOwnProperty.call(C, "foo"), + "foo doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "foo"), + "foo doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "foo", { + value: "foobar", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(c.bar, "barbaz"); +assert( + !Object.prototype.hasOwnProperty.call(C, "bar"), + "bar doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "bar"), + "bar doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "bar", { + value: "barbaz", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(C.$(1), 1); +assert.sameValue(C._(1), 1); +assert.sameValue(C.o(1), 1); +assert.sameValue(C.℘(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD +assert.sameValue(C.ZW_‌_NJ(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD +assert.sameValue(C.ZW_‍_J(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-rs-static-privatename-identifier-by-classname.js b/js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-rs-static-privatename-identifier-by-classname.js new file mode 100644 index 0000000000..1a2de43efb --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-rs-static-privatename-identifier-by-classname.js @@ -0,0 +1,133 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-privatename-identifier-by-classname.case +// - src/class-elements/productions/cls-decl-multiple-stacked-definitions.template +/*--- +description: Valid Static PrivateName (multiple stacked fields definitions through ASI) +esid: prod-FieldDefinition +features: [class-static-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static #$; static #_; static #\u{6F}; static #\u2118; static #ZW_\u200C_NJ; static #ZW_\u200D_J + foo = "foobar" + bar = "barbaz"; + static $(value) { + C.#$ = value; + return C.#$; + } + static _(value) { + C.#_ = value; + return C.#_; + } + static \u{6F}(value) { + C.#\u{6F} = value; + return C.#\u{6F}; + } + static \u2118(value) { + C.#\u2118 = value; + return C.#\u2118; + } + static ZW_\u200C_NJ(value) { + C.#ZW_\u200C_NJ = value; + return C.#ZW_\u200C_NJ; + } + static ZW_\u200D_J(value) { + C.#ZW_\u200D_J = value; + return C.#ZW_\u200D_J; + } +} + +var c = new C(); + +assert.sameValue(c.foo, "foobar"); +assert( + !Object.prototype.hasOwnProperty.call(C, "foo"), + "foo doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "foo"), + "foo doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "foo", { + value: "foobar", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(c.bar, "barbaz"); +assert( + !Object.prototype.hasOwnProperty.call(C, "bar"), + "bar doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "bar"), + "bar doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "bar", { + value: "barbaz", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(C.$(1), 1); +assert.sameValue(C._(1), 1); +assert.sameValue(C.\u{6F}(1), 1); +assert.sameValue(C.\u2118(1), 1); +assert.sameValue(C.ZW_\u200C_NJ(1), 1); +assert.sameValue(C.ZW_\u200D_J(1), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-rs-static-privatename-identifier-initializer-alt-by-classname.js b/js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-rs-static-privatename-identifier-initializer-alt-by-classname.js new file mode 100644 index 0000000000..303c606354 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-rs-static-privatename-identifier-initializer-alt-by-classname.js @@ -0,0 +1,127 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-privatename-identifier-initializer-alt-by-classname.case +// - src/class-elements/productions/cls-decl-multiple-stacked-definitions.template +/*--- +description: Valid Static PrivateName (multiple stacked fields definitions through ASI) +esid: prod-FieldDefinition +features: [class-static-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static #$ = 1; static #_ = 1; static #\u{6F} = 1; static #℘ = 1; static #ZW_‌_NJ = 1; static #ZW_‍_J = 1 + foo = "foobar" + bar = "barbaz"; + static $() { + return C.#$; + } + static _() { + return C.#_; + } + static \u{6F}() { + return C.#\u{6F}; + } + static ℘() { + return C.#℘; + } + static ZW_‌_NJ() { + return C.#ZW_‌_NJ; + } + static ZW_‍_J() { + return C.#ZW_‍_J; + } +} + +var c = new C(); + +assert.sameValue(c.foo, "foobar"); +assert( + !Object.prototype.hasOwnProperty.call(C, "foo"), + "foo doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "foo"), + "foo doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "foo", { + value: "foobar", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(c.bar, "barbaz"); +assert( + !Object.prototype.hasOwnProperty.call(C, "bar"), + "bar doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "bar"), + "bar doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "bar", { + value: "barbaz", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(C.$(), 1); +assert.sameValue(C._(), 1); +assert.sameValue(C.\u{6F}(), 1); +assert.sameValue(C.℘(), 1); +assert.sameValue(C.ZW_‌_NJ(), 1); +assert.sameValue(C.ZW_‍_J(), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-rs-static-privatename-identifier-initializer-alt.js b/js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-rs-static-privatename-identifier-initializer-alt.js new file mode 100644 index 0000000000..d2871d3ed9 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-rs-static-privatename-identifier-initializer-alt.js @@ -0,0 +1,127 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-privatename-identifier-initializer-alt.case +// - src/class-elements/productions/cls-decl-multiple-stacked-definitions.template +/*--- +description: Valid Static PrivateName (multiple stacked fields definitions through ASI) +esid: prod-FieldDefinition +features: [class-static-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static #$ = 1; static #_ = 1; static #\u{6F} = 1; static #℘ = 1; static #ZW_‌_NJ = 1; static #ZW_‍_J = 1 + foo = "foobar" + bar = "barbaz"; + static $() { + return this.#$; + } + static _() { + return this.#_; + } + static \u{6F}() { + return this.#\u{6F}; + } + static ℘() { + return this.#℘; + } + static ZW_‌_NJ() { + return this.#ZW_‌_NJ; + } + static ZW_‍_J() { + return this.#ZW_‍_J; + } +} + +var c = new C(); + +assert.sameValue(c.foo, "foobar"); +assert( + !Object.prototype.hasOwnProperty.call(C, "foo"), + "foo doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "foo"), + "foo doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "foo", { + value: "foobar", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(c.bar, "barbaz"); +assert( + !Object.prototype.hasOwnProperty.call(C, "bar"), + "bar doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "bar"), + "bar doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "bar", { + value: "barbaz", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(C.$(), 1); +assert.sameValue(C._(), 1); +assert.sameValue(C.\u{6F}(), 1); +assert.sameValue(C.℘(), 1); +assert.sameValue(C.ZW_‌_NJ(), 1); +assert.sameValue(C.ZW_‍_J(), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-rs-static-privatename-identifier-initializer.js b/js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-rs-static-privatename-identifier-initializer.js new file mode 100644 index 0000000000..71d2d785a4 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-rs-static-privatename-identifier-initializer.js @@ -0,0 +1,127 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-privatename-identifier-initializer.case +// - src/class-elements/productions/cls-decl-multiple-stacked-definitions.template +/*--- +description: Valid Static PrivateName (multiple stacked fields definitions through ASI) +esid: prod-FieldDefinition +features: [class-static-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static #$ = 1; static #_ = 1; static #\u{6F} = 1; static #\u2118 = 1; static #ZW_\u200C_NJ = 1; static #ZW_\u200D_J = 1 + foo = "foobar" + bar = "barbaz"; + static $() { + return this.#$; + } + static _() { + return this.#_; + } + static \u{6F}() { + return this.#\u{6F}; + } + static \u2118() { + return this.#\u2118; + } + static ZW_\u200C_NJ() { + return this.#ZW_\u200C_NJ; + } + static ZW_\u200D_J() { + return this.#ZW_\u200D_J; + } +} + +var c = new C(); + +assert.sameValue(c.foo, "foobar"); +assert( + !Object.prototype.hasOwnProperty.call(C, "foo"), + "foo doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "foo"), + "foo doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "foo", { + value: "foobar", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(c.bar, "barbaz"); +assert( + !Object.prototype.hasOwnProperty.call(C, "bar"), + "bar doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "bar"), + "bar doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "bar", { + value: "barbaz", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(C.$(), 1); +assert.sameValue(C._(), 1); +assert.sameValue(C.\u{6F}(), 1); +assert.sameValue(C.\u2118(), 1); +assert.sameValue(C.ZW_\u200C_NJ(), 1); +assert.sameValue(C.ZW_\u200D_J(), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-rs-static-privatename-identifier.js b/js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-rs-static-privatename-identifier.js new file mode 100644 index 0000000000..981cc5077c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-rs-static-privatename-identifier.js @@ -0,0 +1,133 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-privatename-identifier.case +// - src/class-elements/productions/cls-decl-multiple-stacked-definitions.template +/*--- +description: Valid Static PrivateName (multiple stacked fields definitions through ASI) +esid: prod-FieldDefinition +features: [class-static-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static #$; static #_; static #\u{6F}; static #\u2118; static #ZW_\u200C_NJ; static #ZW_\u200D_J + foo = "foobar" + bar = "barbaz"; + static $(value) { + this.#$ = value; + return this.#$; + } + static _(value) { + this.#_ = value; + return this.#_; + } + static \u{6F}(value) { + this.#\u{6F} = value; + return this.#\u{6F}; + } + static \u2118(value) { + this.#\u2118 = value; + return this.#\u2118; + } + static ZW_\u200C_NJ(value) { + this.#ZW_\u200C_NJ = value; + return this.#ZW_\u200C_NJ; + } + static ZW_\u200D_J(value) { + this.#ZW_\u200D_J = value; + return this.#ZW_\u200D_J; + } +} + +var c = new C(); + +assert.sameValue(c.foo, "foobar"); +assert( + !Object.prototype.hasOwnProperty.call(C, "foo"), + "foo doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "foo"), + "foo doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "foo", { + value: "foobar", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(c.bar, "barbaz"); +assert( + !Object.prototype.hasOwnProperty.call(C, "bar"), + "bar doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "bar"), + "bar doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "bar", { + value: "barbaz", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(C.$(1), 1); +assert.sameValue(C._(1), 1); +assert.sameValue(C.\u{6F}(1), 1); +assert.sameValue(C.\u2118(1), 1); +assert.sameValue(C.ZW_\u200C_NJ(1), 1); +assert.sameValue(C.ZW_\u200D_J(1), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-static-private-fields.js b/js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-static-private-fields.js new file mode 100644 index 0000000000..c6a380b05f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-static-private-fields.js @@ -0,0 +1,94 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/static-private-fields.case +// - src/class-elements/productions/cls-decl-multiple-stacked-definitions.template +/*--- +description: static private fields (multiple stacked fields definitions through ASI) +esid: prod-FieldDefinition +features: [class-static-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + ... + static FieldDefinition ; + + FieldDefinition : + ClassElementName Initializer_opt + + ClassElementName : + PrivateName + + PrivateName : + # IdentifierName + +---*/ + + +class C { + static #x; static #y + foo = "foobar" + bar = "barbaz"; + static x() { + this.#x = 42; + return this.#x; + } + static y() { + this.#y = 43; + return this.#y; + } +} + +var c = new C(); + +assert.sameValue(c.foo, "foobar"); +assert( + !Object.prototype.hasOwnProperty.call(C, "foo"), + "foo doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "foo"), + "foo doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "foo", { + value: "foobar", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(c.bar, "barbaz"); +assert( + !Object.prototype.hasOwnProperty.call(C, "bar"), + "bar doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "bar"), + "bar doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "bar", { + value: "barbaz", + enumerable: true, + configurable: true, + writable: true, +}); + +// Test the private fields do not appear as properties before set to value +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#x"), "test 1"); +assert(!Object.prototype.hasOwnProperty.call(C, "#x"), "test 2"); +assert(!Object.prototype.hasOwnProperty.call(c, "#x"), "test 3"); + +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#y"), "test 4"); +assert(!Object.prototype.hasOwnProperty.call(C, "#y"), "test 5"); +assert(!Object.prototype.hasOwnProperty.call(c, "#y"), "test 6"); + +// Test if private fields can be sucessfully accessed and set to value +assert.sameValue(C.x(), 42, "test 7"); +assert.sameValue(C.y(), 43, "test 8"); + +// Test the private fields do not appear as properties before after set to value +assert(!Object.prototype.hasOwnProperty.call(C, "#x"), "test 9"); +assert(!Object.prototype.hasOwnProperty.call(C, "#y"), "test 10"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-static-private-methods-with-fields.js b/js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-static-private-methods-with-fields.js new file mode 100644 index 0000000000..f277b44498 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-static-private-methods-with-fields.js @@ -0,0 +1,111 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/static-private-methods-with-fields.case +// - src/class-elements/productions/cls-decl-multiple-stacked-definitions.template +/*--- +description: static private methods with fields (multiple stacked fields definitions through ASI) +esid: prod-FieldDefinition +features: [class-static-methods-private, class-static-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + ... + static FieldDefinition ; + + FieldDefinition : + ClassElementName Initializer_opt + + ClassElementName : + PrivateName + + PrivateName : + # IdentifierName + +---*/ + + +class C { + static #xVal; static #yVal + foo = "foobar" + bar = "barbaz"; + static #x(value) { + this.#xVal = value; + return this.#xVal; + } + static #y(value) { + this.#yVal = value; + return this.#yVal; + } + static x() { + return this.#x(42); + } + static y() { + return this.#y(43); + } +} + +var c = new C(); + +assert.sameValue(c.foo, "foobar"); +assert( + !Object.prototype.hasOwnProperty.call(C, "foo"), + "foo doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "foo"), + "foo doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "foo", { + value: "foobar", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(c.bar, "barbaz"); +assert( + !Object.prototype.hasOwnProperty.call(C, "bar"), + "bar doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "bar"), + "bar doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "bar", { + value: "barbaz", + enumerable: true, + configurable: true, + writable: true, +}); + +// Test the private methods do not appear as properties before set to value +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#x"), "test 1"); +assert(!Object.prototype.hasOwnProperty.call(C, "#x"), "test 2"); +assert(!Object.prototype.hasOwnProperty.call(c, "#x"), "test 3"); + +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#y"), "test 4"); +assert(!Object.prototype.hasOwnProperty.call(C, "#y"), "test 5"); +assert(!Object.prototype.hasOwnProperty.call(c, "#y"), "test 6"); + +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#xVal"), "test 7"); +assert(!Object.prototype.hasOwnProperty.call(C, "#xVal"), "test 8"); +assert(!Object.prototype.hasOwnProperty.call(c, "#xVal"), "test 9"); + +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#yVal"), "test 10"); +assert(!Object.prototype.hasOwnProperty.call(C, "#yVal"), "test 11"); +assert(!Object.prototype.hasOwnProperty.call(c, "#yVal"), "test 12"); + +// Test if private fields can be sucessfully accessed and set to value +assert.sameValue(C.x(), 42, "test 13"); +assert.sameValue(C.y(), 43, "test 14"); + +// Test the private fields do not appear as properties before after set to value +assert(!Object.prototype.hasOwnProperty.call(C, "#x"), "test 15"); +assert(!Object.prototype.hasOwnProperty.call(C, "#y"), "test 16"); + +assert(!Object.prototype.hasOwnProperty.call(C, "#xVal"), "test 17"); +assert(!Object.prototype.hasOwnProperty.call(C, "#yVal"), "test 18"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-static-private-methods.js b/js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-static-private-methods.js new file mode 100644 index 0000000000..7eb936ac03 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-static-private-methods.js @@ -0,0 +1,98 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/static-private-methods.case +// - src/class-elements/productions/cls-decl-multiple-stacked-definitions.template +/*--- +description: static private methods (multiple stacked fields definitions through ASI) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + ... + static FieldDefinition ; + + FieldDefinition : + ClassElementName Initializer_opt + + ClassElementName : + PrivateName + + PrivateName : + # IdentifierName + +---*/ + + +class C { + + foo = "foobar" + bar = "barbaz"; + static #x(value) { + return value / 2; + } + static #y(value) { + return value * 2; + } + static x() { + return this.#x(84); + } + static y() { + return this.#y(43); + } +} + +var c = new C(); + +assert.sameValue(c.foo, "foobar"); +assert( + !Object.prototype.hasOwnProperty.call(C, "foo"), + "foo doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "foo"), + "foo doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "foo", { + value: "foobar", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(c.bar, "barbaz"); +assert( + !Object.prototype.hasOwnProperty.call(C, "bar"), + "bar doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "bar"), + "bar doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "bar", { + value: "barbaz", + enumerable: true, + configurable: true, + writable: true, +}); + +// Test the private methods do not appear as properties before set to value +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#x"), "test 1"); +assert(!Object.prototype.hasOwnProperty.call(C, "#x"), "test 2"); +assert(!Object.prototype.hasOwnProperty.call(c, "#x"), "test 3"); + +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#y"), "test 4"); +assert(!Object.prototype.hasOwnProperty.call(C, "#y"), "test 5"); +assert(!Object.prototype.hasOwnProperty.call(c, "#y"), "test 6"); + +// Test if private fields can be sucessfully accessed and set to value +assert.sameValue(C.x(), 42, "test 7"); +assert.sameValue(C.y(), 86, "test 8"); + +// Test the private fields do not appear as properties before after set to value +assert(!Object.prototype.hasOwnProperty.call(C, "#x"), "test 9"); +assert(!Object.prototype.hasOwnProperty.call(C, "#y"), "test 10"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-string-literal-names.js b/js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-string-literal-names.js new file mode 100644 index 0000000000..c9d5175d3f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/multiple-stacked-definitions-string-literal-names.js @@ -0,0 +1,132 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/string-literal-names.case +// - src/class-elements/productions/cls-decl-multiple-stacked-definitions.template +/*--- +description: String literal names (multiple stacked fields definitions through ASI) +esid: prod-FieldDefinition +features: [class-fields-public, class] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PropertyName + +---*/ + + +class C { + 'a'; "b"; 'c' = 39; + "d" = 42 + foo = "foobar" + bar = "barbaz"; + +} + +var c = new C(); + +assert.sameValue(c.foo, "foobar"); +assert( + !Object.prototype.hasOwnProperty.call(C, "foo"), + "foo doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "foo"), + "foo doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "foo", { + value: "foobar", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(c.bar, "barbaz"); +assert( + !Object.prototype.hasOwnProperty.call(C, "bar"), + "bar doesn't appear as an own property on the C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "bar"), + "bar doesn't appear as an own property on the C prototype" +); + +verifyProperty(c, "bar", { + value: "barbaz", + enumerable: true, + configurable: true, + writable: true, +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "a"), + "a does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "a"), + "a does not appear as an own property on C constructor" +); + +verifyProperty(c, "a", { + value: undefined, + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "b"), + "b does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "b"), + "b does not appear as an own property on C constructor" +); + +verifyProperty(c, "b", { + value: undefined, + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "c"), + "c does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "c"), + "c does not appear as an own property on C constructor" +); + +verifyProperty(c, "c", { + value: 39, + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "d"), + "d does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "d"), + "d does not appear as an own property on C constructor" +); + +verifyProperty(c, "d", { + value: 42, + enumerable: true, + writable: true, + configurable: true +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/nested-arrow-fnc-init-err-contains-arguments.js b/js/src/tests/test262/language/statements/class/elements/nested-arrow-fnc-init-err-contains-arguments.js new file mode 100644 index 0000000000..d777f2b55d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/nested-arrow-fnc-init-err-contains-arguments.js @@ -0,0 +1,37 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/init-err-contains-arguments.case +// - src/class-elements/initializer-error/cls-decl-fields-arrow-fnc-nested.template +/*--- +description: Syntax error if `arguments` used in class field (arrow function expression) +esid: sec-class-definitions-static-semantics-early-errors +features: [class, class-fields-public, arrow-function] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Static Semantics: Early Errors + + FieldDefinition: + PropertyNameInitializeropt + + - It is a Syntax Error if ContainsArguments of Initializer is true. + + Static Semantics: ContainsArguments + IdentifierReference : Identifier + + 1. If the StringValue of Identifier is "arguments", return true. + ... + For all other grammatical productions, recurse on all nonterminals. If any piece returns true, then return true. Otherwise return false. + +---*/ + + +$DONOTEVALUATE(); + +class C { + x = () => { + var t = () => arguments; + } +} diff --git a/js/src/tests/test262/language/statements/class/elements/nested-arrow-fnc-init-err-contains-super.js b/js/src/tests/test262/language/statements/class/elements/nested-arrow-fnc-init-err-contains-super.js new file mode 100644 index 0000000000..10f67a1320 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/nested-arrow-fnc-init-err-contains-super.js @@ -0,0 +1,30 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/init-err-contains-super.case +// - src/class-elements/initializer-error/cls-decl-fields-arrow-fnc-nested.template +/*--- +description: Syntax error if `super()` used in class field (arrow function expression) +esid: sec-class-definitions-static-semantics-early-errors +features: [class, class-fields-public, arrow-function] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Static Semantics: Early Errors + + FieldDefinition: + PropertyNameInitializeropt + + - It is a Syntax Error if Initializer is present and Initializer Contains SuperCall is true. + +---*/ + + +$DONOTEVALUATE(); + +class C { + x = () => { + var t = () => super(); + } +} diff --git a/js/src/tests/test262/language/statements/class/elements/nested-comp-name-init-err-contains-arguments.js b/js/src/tests/test262/language/statements/class/elements/nested-comp-name-init-err-contains-arguments.js new file mode 100644 index 0000000000..97177d04c2 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/nested-comp-name-init-err-contains-arguments.js @@ -0,0 +1,35 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/init-err-contains-arguments.case +// - src/class-elements/initializer-error/cls-decl-fields-comp-name-nested.template +/*--- +description: Syntax error if `arguments` used in class field (computed ClassElementName) +esid: sec-class-definitions-static-semantics-early-errors +features: [class, class-fields-public, computed-property-names] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Static Semantics: Early Errors + + FieldDefinition: + PropertyNameInitializeropt + + - It is a Syntax Error if ContainsArguments of Initializer is true. + + Static Semantics: ContainsArguments + IdentifierReference : Identifier + + 1. If the StringValue of Identifier is "arguments", return true. + ... + For all other grammatical productions, recurse on all nonterminals. If any piece returns true, then return true. Otherwise return false. + +---*/ + +$DONOTEVALUATE(); + +var x = "string"; +class C { + [x] = () => arguments; +} diff --git a/js/src/tests/test262/language/statements/class/elements/nested-comp-name-init-err-contains-super.js b/js/src/tests/test262/language/statements/class/elements/nested-comp-name-init-err-contains-super.js new file mode 100644 index 0000000000..e0bd645948 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/nested-comp-name-init-err-contains-super.js @@ -0,0 +1,28 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/init-err-contains-super.case +// - src/class-elements/initializer-error/cls-decl-fields-comp-name-nested.template +/*--- +description: Syntax error if `super()` used in class field (computed ClassElementName) +esid: sec-class-definitions-static-semantics-early-errors +features: [class, class-fields-public, computed-property-names] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Static Semantics: Early Errors + + FieldDefinition: + PropertyNameInitializeropt + + - It is a Syntax Error if Initializer is present and Initializer Contains SuperCall is true. + +---*/ + +$DONOTEVALUATE(); + +var x = "string"; +class C { + [x] = () => super(); +} diff --git a/js/src/tests/test262/language/statements/class/elements/nested-derived-cls-direct-eval-contains-superproperty-1.js b/js/src/tests/test262/language/statements/class/elements/nested-derived-cls-direct-eval-contains-superproperty-1.js new file mode 100644 index 0000000000..d875a6e5b5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/nested-derived-cls-direct-eval-contains-superproperty-1.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/eval-contains-superproperty-1.case +// - src/class-elements/initializer-eval-super-property/cls-decl-fields-eval-nested.template +/*--- +description: super.x in StatementList of eval (direct eval) +esid: sec-performeval-rules-in-initializer +features: [class, class-fields-public] +flags: [generated] +info: | + Additional Early Error Rules for Eval Inside Initializer + These static semantics are applied by PerformEval when a direct eval call occurs inside a class field initializer. + ScriptBody : StatementList + + ... + The remaining eval rules apply as outside a constructor, inside a method, and inside a function. + + Additional Early Error Rules for Eval Outside Methods + These static semantics are applied by PerformEval when a direct eval call occurs outside of a MethodDefinition. + ScriptBody : StatementList + + It is a Syntax Error if StatementList Contains SuperProperty. + +---*/ + + +var executed = false; +class A {} +class C extends A { + x = eval('executed = true; super.x;'); +} + +new C(); + +assert.sameValue(executed, true); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/nested-derived-cls-direct-eval-contains-superproperty-2.js b/js/src/tests/test262/language/statements/class/elements/nested-derived-cls-direct-eval-contains-superproperty-2.js new file mode 100644 index 0000000000..16ae4d6b01 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/nested-derived-cls-direct-eval-contains-superproperty-2.js @@ -0,0 +1,33 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/eval-contains-superproperty-2.case +// - src/class-elements/initializer-eval-super-property/cls-decl-fields-eval-nested.template +/*--- +description: super['x'] in StatementList of eval (direct eval) +esid: sec-performeval-rules-in-initializer +features: [class, class-fields-public] +flags: [generated] +info: | + The remaining eval rules apply as outside a constructor, inside a method, and inside a function. + + Additional Early Error Rules for Eval Outside Methods + + These static semantics are applied by PerformEval when a direct eval call occurs outside of a MethodDefinition. + + ScriptBody : StatementList + + It is a Syntax Error if StatementList Contains SuperProperty. + +---*/ + + +var executed = false; +class A {} +class C extends A { + x = eval('executed = true; super["x"];'); +} + +new C(); + +assert.sameValue(executed, true); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/nested-derived-cls-direct-eval-err-contains-supercall-1.js b/js/src/tests/test262/language/statements/class/elements/nested-derived-cls-direct-eval-err-contains-supercall-1.js new file mode 100644 index 0000000000..569749c78d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/nested-derived-cls-direct-eval-err-contains-supercall-1.js @@ -0,0 +1,38 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/eval-err-contains-supercall-1.case +// - src/class-elements/initializer-eval-super-call/cls-decl-fields-eval-nested.template +/*--- +description: error if `super()['x']` in StatementList of eval (direct eval) +esid: sec-performeval-rules-in-initializer +features: [class, class-fields-public] +flags: [generated] +info: | + Additional Early Error Rules for Eval Inside Initializer + These static semantics are applied by PerformEval when a direct eval call occurs inside a class field initializer. + ScriptBody : StatementList + + ... + The remaining eval rules apply as outside a constructor, inside a method, and inside a function. + + Additional Early Error Rules for Eval Outside Constructor Methods + These static semantics are applied by PerformEval when a direct eval call occurs outside of the constructor method of a ClassDeclaration or ClassExpression. + ScriptBody : StatementList + + It is a Syntax Error if StatementList Contains SuperCall. + +---*/ + + +var executed = false; +class A {} +class C extends A { + x = eval('executed = true; super()["x"];'); +} + +assert.throws(SyntaxError, function() { + new C(); +}); + +assert.sameValue(executed, false); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/nested-derived-cls-direct-eval-err-contains-supercall-2.js b/js/src/tests/test262/language/statements/class/elements/nested-derived-cls-direct-eval-err-contains-supercall-2.js new file mode 100644 index 0000000000..3ab9102756 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/nested-derived-cls-direct-eval-err-contains-supercall-2.js @@ -0,0 +1,31 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/eval-err-contains-supercall-2.case +// - src/class-elements/initializer-eval-super-call/cls-decl-fields-eval-nested.template +/*--- +description: error if `super().x` in StatementList of eval (direct eval) +esid: sec-performeval-rules-in-initializer +features: [class, class-fields-public] +flags: [generated] +info: | + Additional Early Error Rules for Eval Outside Constructor Methods + These static semantics are applied by PerformEval when a direct eval call occurs outside of the constructor method of a ClassDeclaration or ClassExpression. + ScriptBody : StatementList + + It is a Syntax Error if StatementList Contains SuperCall. + +---*/ + + +var executed = false; +class A {} +class C extends A { + x = eval('executed = true; super().x;'); +} + +assert.throws(SyntaxError, function() { + new C(); +}); + +assert.sameValue(executed, false); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/nested-derived-cls-direct-eval-err-contains-supercall.js b/js/src/tests/test262/language/statements/class/elements/nested-derived-cls-direct-eval-err-contains-supercall.js new file mode 100644 index 0000000000..d93ba84757 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/nested-derived-cls-direct-eval-err-contains-supercall.js @@ -0,0 +1,38 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/eval-err-contains-supercall.case +// - src/class-elements/initializer-eval-super-call/cls-decl-fields-eval-nested.template +/*--- +description: error if `super()` in StatementList of eval (direct eval) +esid: sec-performeval-rules-in-initializer +features: [class, class-fields-public] +flags: [generated] +info: | + Additional Early Error Rules for Eval Inside Initializer + These static semantics are applied by PerformEval when a direct eval call occurs inside a class field initializer. + ScriptBody : StatementList + + ... + The remaining eval rules apply as outside a constructor, inside a method, and inside a function. + + Additional Early Error Rules for Eval Outside Constructor Methods + These static semantics are applied by PerformEval when a direct eval call occurs outside of the constructor method of a ClassDeclaration or ClassExpression. + ScriptBody : StatementList + + It is a Syntax Error if StatementList Contains SuperCall. + +---*/ + + +var executed = false; +class A {} +class C extends A { + x = eval('executed = true; super();'); +} + +assert.throws(SyntaxError, function() { + new C(); +}); + +assert.sameValue(executed, false); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/nested-derived-cls-indirect-eval-contains-superproperty-1.js b/js/src/tests/test262/language/statements/class/elements/nested-derived-cls-indirect-eval-contains-superproperty-1.js new file mode 100644 index 0000000000..c1e072e3e8 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/nested-derived-cls-indirect-eval-contains-superproperty-1.js @@ -0,0 +1,38 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/eval-contains-superproperty-1.case +// - src/class-elements/initializer-eval-super-property/cls-decl-fields-indirect-eval-nested.template +/*--- +description: super.x in StatementList of eval (indirect eval) +esid: sec-performeval-rules-in-initializer +features: [class, class-fields-public] +flags: [generated] +info: | + Additional Early Error Rules for Eval Inside Initializer + These static semantics are applied by PerformEval when a direct eval call occurs inside a class field initializer. + ScriptBody : StatementList + + ... + The remaining eval rules apply as outside a constructor, inside a method, and inside a function. + + Additional Early Error Rules for Eval Outside Methods + These static semantics are applied by PerformEval when a direct eval call occurs outside of a MethodDefinition. + ScriptBody : StatementList + + It is a Syntax Error if StatementList Contains SuperProperty. + +---*/ + + +var executed = false; +class A {} +class C extends A { + x = (0, eval)('executed = true; super.x;'); +} + +assert.throws(SyntaxError, function() { + new C(); +}); + +assert.sameValue(executed, false); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/nested-derived-cls-indirect-eval-contains-superproperty-2.js b/js/src/tests/test262/language/statements/class/elements/nested-derived-cls-indirect-eval-contains-superproperty-2.js new file mode 100644 index 0000000000..abc413ecb9 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/nested-derived-cls-indirect-eval-contains-superproperty-2.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/eval-contains-superproperty-2.case +// - src/class-elements/initializer-eval-super-property/cls-decl-fields-indirect-eval-nested.template +/*--- +description: super['x'] in StatementList of eval (indirect eval) +esid: sec-performeval-rules-in-initializer +features: [class, class-fields-public] +flags: [generated] +info: | + The remaining eval rules apply as outside a constructor, inside a method, and inside a function. + + Additional Early Error Rules for Eval Outside Methods + + These static semantics are applied by PerformEval when a direct eval call occurs outside of a MethodDefinition. + + ScriptBody : StatementList + + It is a Syntax Error if StatementList Contains SuperProperty. + +---*/ + + +var executed = false; +class A {} +class C extends A { + x = (0, eval)('executed = true; super["x"];'); +} + +assert.throws(SyntaxError, function() { + new C(); +}); + +assert.sameValue(executed, false); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/nested-derived-cls-indirect-eval-err-contains-supercall-1.js b/js/src/tests/test262/language/statements/class/elements/nested-derived-cls-indirect-eval-err-contains-supercall-1.js new file mode 100644 index 0000000000..d20d056c18 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/nested-derived-cls-indirect-eval-err-contains-supercall-1.js @@ -0,0 +1,38 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/eval-err-contains-supercall-1.case +// - src/class-elements/initializer-eval-super-call/cls-decl-fields-indirect-eval-nested.template +/*--- +description: error if `super()['x']` in StatementList of eval (indirect eval) +esid: sec-performeval-rules-in-initializer +features: [class, class-fields-public] +flags: [generated] +info: | + Additional Early Error Rules for Eval Inside Initializer + These static semantics are applied by PerformEval when a direct eval call occurs inside a class field initializer. + ScriptBody : StatementList + + ... + The remaining eval rules apply as outside a constructor, inside a method, and inside a function. + + Additional Early Error Rules for Eval Outside Constructor Methods + These static semantics are applied by PerformEval when a direct eval call occurs outside of the constructor method of a ClassDeclaration or ClassExpression. + ScriptBody : StatementList + + It is a Syntax Error if StatementList Contains SuperCall. + +---*/ + + +var executed = false; +class A {} +class C extends A { + x = (0, eval)('executed = true; super()["x"];'); +} + +assert.throws(SyntaxError, function() { + new C(); +}); + +assert.sameValue(executed, false); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/nested-derived-cls-indirect-eval-err-contains-supercall-2.js b/js/src/tests/test262/language/statements/class/elements/nested-derived-cls-indirect-eval-err-contains-supercall-2.js new file mode 100644 index 0000000000..0f10cd6926 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/nested-derived-cls-indirect-eval-err-contains-supercall-2.js @@ -0,0 +1,31 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/eval-err-contains-supercall-2.case +// - src/class-elements/initializer-eval-super-call/cls-decl-fields-indirect-eval-nested.template +/*--- +description: error if `super().x` in StatementList of eval (indirect eval) +esid: sec-performeval-rules-in-initializer +features: [class, class-fields-public] +flags: [generated] +info: | + Additional Early Error Rules for Eval Outside Constructor Methods + These static semantics are applied by PerformEval when a direct eval call occurs outside of the constructor method of a ClassDeclaration or ClassExpression. + ScriptBody : StatementList + + It is a Syntax Error if StatementList Contains SuperCall. + +---*/ + + +var executed = false; +class A {} +class C extends A { + x = (0, eval)('executed = true; super().x;'); +} + +assert.throws(SyntaxError, function() { + new C(); +}); + +assert.sameValue(executed, false); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/nested-derived-cls-indirect-eval-err-contains-supercall.js b/js/src/tests/test262/language/statements/class/elements/nested-derived-cls-indirect-eval-err-contains-supercall.js new file mode 100644 index 0000000000..d5a13181f4 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/nested-derived-cls-indirect-eval-err-contains-supercall.js @@ -0,0 +1,38 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/eval-err-contains-supercall.case +// - src/class-elements/initializer-eval-super-call/cls-decl-fields-indirect-eval-nested.template +/*--- +description: error if `super()` in StatementList of eval (indirect eval) +esid: sec-performeval-rules-in-initializer +features: [class, class-fields-public] +flags: [generated] +info: | + Additional Early Error Rules for Eval Inside Initializer + These static semantics are applied by PerformEval when a direct eval call occurs inside a class field initializer. + ScriptBody : StatementList + + ... + The remaining eval rules apply as outside a constructor, inside a method, and inside a function. + + Additional Early Error Rules for Eval Outside Constructor Methods + These static semantics are applied by PerformEval when a direct eval call occurs outside of the constructor method of a ClassDeclaration or ClassExpression. + ScriptBody : StatementList + + It is a Syntax Error if StatementList Contains SuperCall. + +---*/ + + +var executed = false; +class A {} +class C extends A { + x = (0, eval)('executed = true; super();'); +} + +assert.throws(SyntaxError, function() { + new C(); +}); + +assert.sameValue(executed, false); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/nested-direct-eval-err-contains-arguments.js b/js/src/tests/test262/language/statements/class/elements/nested-direct-eval-err-contains-arguments.js new file mode 100644 index 0000000000..031e5086d7 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/nested-direct-eval-err-contains-arguments.js @@ -0,0 +1,41 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/eval-err-contains-arguments.case +// - src/class-elements/initializer-direct-eval-arguments/cls-decl-fields-eval-nested.template +/*--- +description: error if `arguments` in StatementList of eval (direct eval) +esid: sec-performeval-rules-in-initializer +features: [class, class-fields-public] +flags: [generated] +info: | + Additional Early Error Rules for Eval Inside Initializer + These static semantics are applied by PerformEval when a direct eval call occurs inside a class field initializer. + ScriptBody : StatementList + + It is a Syntax Error if ContainsArguments of StatementList is true. + ... + + Static Semantics: ContainsArguments + IdentifierReference : Identifier + + 1. If the StringValue of Identifier is "arguments", return true. + ... + For all other grammatical productions, recurse on all nonterminals. If any piece returns true, then return true. Otherwise return false. + +---*/ + + +var executed = false; +class C { + x = () => { + var t = () => { eval('executed = true; arguments;'); }; + t(); + } +} + +assert.throws(SyntaxError, function() { + new C().x(); +}); + +assert.sameValue(executed, false); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/nested-direct-eval-err-contains-newtarget.js b/js/src/tests/test262/language/statements/class/elements/nested-direct-eval-err-contains-newtarget.js new file mode 100644 index 0000000000..eec4e3a676 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/nested-direct-eval-err-contains-newtarget.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/eval-err-contains-newtarget.case +// - src/class-elements/initializer-eval-newtarget/cls-decl-fields-eval-nested.template +/*--- +description: error if `new.target` in StatementList of eval (direct eval) +esid: sec-performeval-rules-in-initializer +features: [class, new.target, class-fields-public] +flags: [generated] +info: | + Additional Early Error Rules for Eval Inside Initializer + These static semantics are applied by PerformEval when a direct eval call occurs inside a class field initializer. + ScriptBody : StatementList + + ... + The remaining eval rules apply as outside a constructor, inside a method, and inside a function. + + Additional Early Error Rules for Eval Outside Functions + These static semantics are applied by PerformEval when a direct eval call occurs outside of any function. + ScriptBody : StatementList + + It is a Syntax Error if StatementList Contains NewTarget. + +---*/ + + +var executed = false; +class C { + x = eval('executed = true; new.target;'); +} + +var c = new C(); + +assert.sameValue(executed, true); +assert.sameValue(c.x, undefined); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/nested-equality-init-err-contains-arguments.js b/js/src/tests/test262/language/statements/class/elements/nested-equality-init-err-contains-arguments.js new file mode 100644 index 0000000000..097ec48013 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/nested-equality-init-err-contains-arguments.js @@ -0,0 +1,34 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/init-err-contains-arguments.case +// - src/class-elements/initializer-error/cls-decl-fields-equality-nested.template +/*--- +description: Syntax error if `arguments` used in class field (equality expression) +esid: sec-class-definitions-static-semantics-early-errors +features: [class, class-fields-public] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Static Semantics: Early Errors + + FieldDefinition: + PropertyNameInitializeropt + + - It is a Syntax Error if ContainsArguments of Initializer is true. + + Static Semantics: ContainsArguments + IdentifierReference : Identifier + + 1. If the StringValue of Identifier is "arguments", return true. + ... + For all other grammatical productions, recurse on all nonterminals. If any piece returns true, then return true. Otherwise return false. + +---*/ + +$DONOTEVALUATE(); + +class C { + x = () => {} == arguments; +} diff --git a/js/src/tests/test262/language/statements/class/elements/nested-equality-init-err-contains-super.js b/js/src/tests/test262/language/statements/class/elements/nested-equality-init-err-contains-super.js new file mode 100644 index 0000000000..161d0fb529 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/nested-equality-init-err-contains-super.js @@ -0,0 +1,27 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/init-err-contains-super.case +// - src/class-elements/initializer-error/cls-decl-fields-equality-nested.template +/*--- +description: Syntax error if `super()` used in class field (equality expression) +esid: sec-class-definitions-static-semantics-early-errors +features: [class, class-fields-public] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Static Semantics: Early Errors + + FieldDefinition: + PropertyNameInitializeropt + + - It is a Syntax Error if Initializer is present and Initializer Contains SuperCall is true. + +---*/ + +$DONOTEVALUATE(); + +class C { + x = () => {} == super(); +} diff --git a/js/src/tests/test262/language/statements/class/elements/nested-indirect-eval-contains-arguments.js b/js/src/tests/test262/language/statements/class/elements/nested-indirect-eval-contains-arguments.js new file mode 100644 index 0000000000..ac4e817cd0 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/nested-indirect-eval-contains-arguments.js @@ -0,0 +1,25 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/eval-contains-arguments.case +// - src/class-elements/initializer-indirect-eval-arguments/cls-decl-fields-indirect-eval-nested.template +/*--- +description: No error if `arguments` in StatementList of eval (indirect eval) +esid: sec-performeval-rules-in-initializer +features: [class, class-fields-public] +flags: [generated, noStrict] +info: | + For indirect eval, the "Additional Early Error Rules for Eval Inside Initializer" + (in #sec-performeval-rules-in-initializer) are NOT applicable. + +---*/ + + +var arguments = 1; +class C { + x = () => { + var t = () => (0, eval)('arguments;'); + return t(); + } +} +assert.sameValue(new C().x(), arguments); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/nested-indirect-eval-err-contains-newtarget.js b/js/src/tests/test262/language/statements/class/elements/nested-indirect-eval-err-contains-newtarget.js new file mode 100644 index 0000000000..19eae85f80 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/nested-indirect-eval-err-contains-newtarget.js @@ -0,0 +1,37 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/eval-err-contains-newtarget.case +// - src/class-elements/initializer-eval-newtarget/cls-decl-fields-indirect-eval-nested.template +/*--- +description: error if `new.target` in StatementList of eval (indirect eval) +esid: sec-performeval-rules-in-initializer +features: [class, new.target, class-fields-public] +flags: [generated] +info: | + Additional Early Error Rules for Eval Inside Initializer + These static semantics are applied by PerformEval when a direct eval call occurs inside a class field initializer. + ScriptBody : StatementList + + ... + The remaining eval rules apply as outside a constructor, inside a method, and inside a function. + + Additional Early Error Rules for Eval Outside Functions + These static semantics are applied by PerformEval when a direct eval call occurs outside of any function. + ScriptBody : StatementList + + It is a Syntax Error if StatementList Contains NewTarget. + +---*/ + + +var executed = false; +class C { + x = (0, eval)('executed = true; new.target;'); +} + +assert.throws(SyntaxError, function() { + new C(); +}); + +assert.sameValue(executed, false); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/nested-literal-name-init-err-contains-arguments.js b/js/src/tests/test262/language/statements/class/elements/nested-literal-name-init-err-contains-arguments.js new file mode 100644 index 0000000000..1c7453e69d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/nested-literal-name-init-err-contains-arguments.js @@ -0,0 +1,34 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/init-err-contains-arguments.case +// - src/class-elements/initializer-error/cls-decl-fields-literal-name-nested.template +/*--- +description: Syntax error if `arguments` used in class field (literal ClassElementName) +esid: sec-class-definitions-static-semantics-early-errors +features: [class, class-fields-public] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Static Semantics: Early Errors + + FieldDefinition: + PropertyNameInitializeropt + + - It is a Syntax Error if ContainsArguments of Initializer is true. + + Static Semantics: ContainsArguments + IdentifierReference : Identifier + + 1. If the StringValue of Identifier is "arguments", return true. + ... + For all other grammatical productions, recurse on all nonterminals. If any piece returns true, then return true. Otherwise return false. + +---*/ + +$DONOTEVALUATE(); + +class C { + x = () => arguments; +} diff --git a/js/src/tests/test262/language/statements/class/elements/nested-literal-name-init-err-contains-super.js b/js/src/tests/test262/language/statements/class/elements/nested-literal-name-init-err-contains-super.js new file mode 100644 index 0000000000..bda742293c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/nested-literal-name-init-err-contains-super.js @@ -0,0 +1,27 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/init-err-contains-super.case +// - src/class-elements/initializer-error/cls-decl-fields-literal-name-nested.template +/*--- +description: Syntax error if `super()` used in class field (literal ClassElementName) +esid: sec-class-definitions-static-semantics-early-errors +features: [class, class-fields-public] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Static Semantics: Early Errors + + FieldDefinition: + PropertyNameInitializeropt + + - It is a Syntax Error if Initializer is present and Initializer Contains SuperCall is true. + +---*/ + +$DONOTEVALUATE(); + +class C { + x = () => super(); +} diff --git a/js/src/tests/test262/language/statements/class/elements/nested-private-arrow-fnc-init-err-contains-arguments.js b/js/src/tests/test262/language/statements/class/elements/nested-private-arrow-fnc-init-err-contains-arguments.js new file mode 100644 index 0000000000..ad61eb20a4 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/nested-private-arrow-fnc-init-err-contains-arguments.js @@ -0,0 +1,39 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/init-err-contains-arguments.case +// - src/class-elements/initializer-error/cls-decl-fields-private-arrow-fnc-nested.template +/*--- +description: Syntax error if `arguments` used in class field (private field, arrow function expression) +esid: sec-class-definitions-static-semantics-early-errors +features: [class, class-fields-public, arrow-function, class-fields-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Static Semantics: Early Errors + + FieldDefinition: + PropertyNameInitializeropt + + - It is a Syntax Error if ContainsArguments of Initializer is true. + + Static Semantics: ContainsArguments + IdentifierReference : Identifier + + 1. If the StringValue of Identifier is "arguments", return true. + ... + For all other grammatical productions, recurse on all nonterminals. If any piece returns true, then return true. Otherwise return false. + +---*/ + + +$DONOTEVALUATE(); + +class C { + #x = () => { + var t = () => arguments; + t(); + } +} + diff --git a/js/src/tests/test262/language/statements/class/elements/nested-private-arrow-fnc-init-err-contains-super.js b/js/src/tests/test262/language/statements/class/elements/nested-private-arrow-fnc-init-err-contains-super.js new file mode 100644 index 0000000000..57f5aff25e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/nested-private-arrow-fnc-init-err-contains-super.js @@ -0,0 +1,32 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/init-err-contains-super.case +// - src/class-elements/initializer-error/cls-decl-fields-private-arrow-fnc-nested.template +/*--- +description: Syntax error if `super()` used in class field (private field, arrow function expression) +esid: sec-class-definitions-static-semantics-early-errors +features: [class, class-fields-public, arrow-function, class-fields-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Static Semantics: Early Errors + + FieldDefinition: + PropertyNameInitializeropt + + - It is a Syntax Error if Initializer is present and Initializer Contains SuperCall is true. + +---*/ + + +$DONOTEVALUATE(); + +class C { + #x = () => { + var t = () => super(); + t(); + } +} + diff --git a/js/src/tests/test262/language/statements/class/elements/nested-private-derived-cls-direct-eval-contains-superproperty-1.js b/js/src/tests/test262/language/statements/class/elements/nested-private-derived-cls-direct-eval-contains-superproperty-1.js new file mode 100644 index 0000000000..d01a521970 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/nested-private-derived-cls-direct-eval-contains-superproperty-1.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/eval-contains-superproperty-1.case +// - src/class-elements/initializer-eval-super-property/cls-decl-private-fields-eval-nested.template +/*--- +description: super.x in StatementList of eval (direct eval) +esid: sec-performeval-rules-in-initializer +features: [class, class-fields-public, class-fields-private] +flags: [generated] +info: | + Additional Early Error Rules for Eval Inside Initializer + These static semantics are applied by PerformEval when a direct eval call occurs inside a class field initializer. + ScriptBody : StatementList + + ... + The remaining eval rules apply as outside a constructor, inside a method, and inside a function. + + Additional Early Error Rules for Eval Outside Methods + These static semantics are applied by PerformEval when a direct eval call occurs outside of a MethodDefinition. + ScriptBody : StatementList + + It is a Syntax Error if StatementList Contains SuperProperty. + +---*/ + + +var executed = false; +class A {} +class C extends A { + #x = eval('executed = true; super.x;'); +} + +new C(); + +assert.sameValue(executed, true); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/nested-private-derived-cls-direct-eval-contains-superproperty-2.js b/js/src/tests/test262/language/statements/class/elements/nested-private-derived-cls-direct-eval-contains-superproperty-2.js new file mode 100644 index 0000000000..d667ad9743 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/nested-private-derived-cls-direct-eval-contains-superproperty-2.js @@ -0,0 +1,33 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/eval-contains-superproperty-2.case +// - src/class-elements/initializer-eval-super-property/cls-decl-private-fields-eval-nested.template +/*--- +description: super['x'] in StatementList of eval (direct eval) +esid: sec-performeval-rules-in-initializer +features: [class, class-fields-public, class-fields-private] +flags: [generated] +info: | + The remaining eval rules apply as outside a constructor, inside a method, and inside a function. + + Additional Early Error Rules for Eval Outside Methods + + These static semantics are applied by PerformEval when a direct eval call occurs outside of a MethodDefinition. + + ScriptBody : StatementList + + It is a Syntax Error if StatementList Contains SuperProperty. + +---*/ + + +var executed = false; +class A {} +class C extends A { + #x = eval('executed = true; super["x"];'); +} + +new C(); + +assert.sameValue(executed, true); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/nested-private-derived-cls-direct-eval-err-contains-supercall-1.js b/js/src/tests/test262/language/statements/class/elements/nested-private-derived-cls-direct-eval-err-contains-supercall-1.js new file mode 100644 index 0000000000..ed1137492c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/nested-private-derived-cls-direct-eval-err-contains-supercall-1.js @@ -0,0 +1,38 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/eval-err-contains-supercall-1.case +// - src/class-elements/initializer-eval-super-call/cls-decl-private-fields-eval-nested.template +/*--- +description: error if `super()['x']` in StatementList of eval (direct eval) +esid: sec-performeval-rules-in-initializer +features: [class, class-fields-public, class-fields-private] +flags: [generated] +info: | + Additional Early Error Rules for Eval Inside Initializer + These static semantics are applied by PerformEval when a direct eval call occurs inside a class field initializer. + ScriptBody : StatementList + + ... + The remaining eval rules apply as outside a constructor, inside a method, and inside a function. + + Additional Early Error Rules for Eval Outside Constructor Methods + These static semantics are applied by PerformEval when a direct eval call occurs outside of the constructor method of a ClassDeclaration or ClassExpression. + ScriptBody : StatementList + + It is a Syntax Error if StatementList Contains SuperCall. + +---*/ + + +var executed = false; +class A {} +class C extends A { + #x = eval('executed = true; super()["x"];'); +} + +assert.throws(SyntaxError, function() { + new C(); +}); + +assert.sameValue(executed, false); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/nested-private-derived-cls-direct-eval-err-contains-supercall-2.js b/js/src/tests/test262/language/statements/class/elements/nested-private-derived-cls-direct-eval-err-contains-supercall-2.js new file mode 100644 index 0000000000..292515caf1 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/nested-private-derived-cls-direct-eval-err-contains-supercall-2.js @@ -0,0 +1,31 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/eval-err-contains-supercall-2.case +// - src/class-elements/initializer-eval-super-call/cls-decl-private-fields-eval-nested.template +/*--- +description: error if `super().x` in StatementList of eval (direct eval) +esid: sec-performeval-rules-in-initializer +features: [class, class-fields-public, class-fields-private] +flags: [generated] +info: | + Additional Early Error Rules for Eval Outside Constructor Methods + These static semantics are applied by PerformEval when a direct eval call occurs outside of the constructor method of a ClassDeclaration or ClassExpression. + ScriptBody : StatementList + + It is a Syntax Error if StatementList Contains SuperCall. + +---*/ + + +var executed = false; +class A {} +class C extends A { + #x = eval('executed = true; super().x;'); +} + +assert.throws(SyntaxError, function() { + new C(); +}); + +assert.sameValue(executed, false); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/nested-private-derived-cls-direct-eval-err-contains-supercall.js b/js/src/tests/test262/language/statements/class/elements/nested-private-derived-cls-direct-eval-err-contains-supercall.js new file mode 100644 index 0000000000..ca01d01130 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/nested-private-derived-cls-direct-eval-err-contains-supercall.js @@ -0,0 +1,38 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/eval-err-contains-supercall.case +// - src/class-elements/initializer-eval-super-call/cls-decl-private-fields-eval-nested.template +/*--- +description: error if `super()` in StatementList of eval (direct eval) +esid: sec-performeval-rules-in-initializer +features: [class, class-fields-public, class-fields-private] +flags: [generated] +info: | + Additional Early Error Rules for Eval Inside Initializer + These static semantics are applied by PerformEval when a direct eval call occurs inside a class field initializer. + ScriptBody : StatementList + + ... + The remaining eval rules apply as outside a constructor, inside a method, and inside a function. + + Additional Early Error Rules for Eval Outside Constructor Methods + These static semantics are applied by PerformEval when a direct eval call occurs outside of the constructor method of a ClassDeclaration or ClassExpression. + ScriptBody : StatementList + + It is a Syntax Error if StatementList Contains SuperCall. + +---*/ + + +var executed = false; +class A {} +class C extends A { + #x = eval('executed = true; super();'); +} + +assert.throws(SyntaxError, function() { + new C(); +}); + +assert.sameValue(executed, false); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/nested-private-derived-cls-indirect-eval-contains-superproperty-1.js b/js/src/tests/test262/language/statements/class/elements/nested-private-derived-cls-indirect-eval-contains-superproperty-1.js new file mode 100644 index 0000000000..ae20c0061a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/nested-private-derived-cls-indirect-eval-contains-superproperty-1.js @@ -0,0 +1,38 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/eval-contains-superproperty-1.case +// - src/class-elements/initializer-eval-super-property/cls-decl-private-fields-indirect-eval-nested.template +/*--- +description: super.x in StatementList of eval (indirect eval) +esid: sec-performeval-rules-in-initializer +features: [class, class-fields-public, class-fields-private] +flags: [generated] +info: | + Additional Early Error Rules for Eval Inside Initializer + These static semantics are applied by PerformEval when a direct eval call occurs inside a class field initializer. + ScriptBody : StatementList + + ... + The remaining eval rules apply as outside a constructor, inside a method, and inside a function. + + Additional Early Error Rules for Eval Outside Methods + These static semantics are applied by PerformEval when a direct eval call occurs outside of a MethodDefinition. + ScriptBody : StatementList + + It is a Syntax Error if StatementList Contains SuperProperty. + +---*/ + + +var executed = false; +class A {} +class C extends A { + #x = (0, eval)('executed = true; super.x;'); +} + +assert.throws(SyntaxError, function() { + new C(); +}); + +assert.sameValue(executed, false); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/nested-private-derived-cls-indirect-eval-contains-superproperty-2.js b/js/src/tests/test262/language/statements/class/elements/nested-private-derived-cls-indirect-eval-contains-superproperty-2.js new file mode 100644 index 0000000000..1c5fda8bd9 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/nested-private-derived-cls-indirect-eval-contains-superproperty-2.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/eval-contains-superproperty-2.case +// - src/class-elements/initializer-eval-super-property/cls-decl-private-fields-indirect-eval-nested.template +/*--- +description: super['x'] in StatementList of eval (indirect eval) +esid: sec-performeval-rules-in-initializer +features: [class, class-fields-public, class-fields-private] +flags: [generated] +info: | + The remaining eval rules apply as outside a constructor, inside a method, and inside a function. + + Additional Early Error Rules for Eval Outside Methods + + These static semantics are applied by PerformEval when a direct eval call occurs outside of a MethodDefinition. + + ScriptBody : StatementList + + It is a Syntax Error if StatementList Contains SuperProperty. + +---*/ + + +var executed = false; +class A {} +class C extends A { + #x = (0, eval)('executed = true; super["x"];'); +} + +assert.throws(SyntaxError, function() { + new C(); +}); + +assert.sameValue(executed, false); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/nested-private-derived-cls-indirect-eval-err-contains-supercall-1.js b/js/src/tests/test262/language/statements/class/elements/nested-private-derived-cls-indirect-eval-err-contains-supercall-1.js new file mode 100644 index 0000000000..b0f130dc03 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/nested-private-derived-cls-indirect-eval-err-contains-supercall-1.js @@ -0,0 +1,38 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/eval-err-contains-supercall-1.case +// - src/class-elements/initializer-eval-super-call/cls-decl-private-fields-indirect-eval-nested.template +/*--- +description: error if `super()['x']` in StatementList of eval (indirect eval) +esid: sec-performeval-rules-in-initializer +features: [class, class-fields-public, class-fields-private] +flags: [generated] +info: | + Additional Early Error Rules for Eval Inside Initializer + These static semantics are applied by PerformEval when a direct eval call occurs inside a class field initializer. + ScriptBody : StatementList + + ... + The remaining eval rules apply as outside a constructor, inside a method, and inside a function. + + Additional Early Error Rules for Eval Outside Constructor Methods + These static semantics are applied by PerformEval when a direct eval call occurs outside of the constructor method of a ClassDeclaration or ClassExpression. + ScriptBody : StatementList + + It is a Syntax Error if StatementList Contains SuperCall. + +---*/ + + +var executed = false; +class A {} +class C extends A { + #x = (0, eval)('executed = true; super()["x"];'); +} + +assert.throws(SyntaxError, function() { + new C(); +}); + +assert.sameValue(executed, false); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/nested-private-derived-cls-indirect-eval-err-contains-supercall-2.js b/js/src/tests/test262/language/statements/class/elements/nested-private-derived-cls-indirect-eval-err-contains-supercall-2.js new file mode 100644 index 0000000000..4683284688 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/nested-private-derived-cls-indirect-eval-err-contains-supercall-2.js @@ -0,0 +1,31 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/eval-err-contains-supercall-2.case +// - src/class-elements/initializer-eval-super-call/cls-decl-private-fields-indirect-eval-nested.template +/*--- +description: error if `super().x` in StatementList of eval (indirect eval) +esid: sec-performeval-rules-in-initializer +features: [class, class-fields-public, class-fields-private] +flags: [generated] +info: | + Additional Early Error Rules for Eval Outside Constructor Methods + These static semantics are applied by PerformEval when a direct eval call occurs outside of the constructor method of a ClassDeclaration or ClassExpression. + ScriptBody : StatementList + + It is a Syntax Error if StatementList Contains SuperCall. + +---*/ + + +var executed = false; +class A {} +class C extends A { + #x = (0, eval)('executed = true; super().x;'); +} + +assert.throws(SyntaxError, function() { + new C(); +}); + +assert.sameValue(executed, false); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/nested-private-derived-cls-indirect-eval-err-contains-supercall.js b/js/src/tests/test262/language/statements/class/elements/nested-private-derived-cls-indirect-eval-err-contains-supercall.js new file mode 100644 index 0000000000..246de345ba --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/nested-private-derived-cls-indirect-eval-err-contains-supercall.js @@ -0,0 +1,38 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/eval-err-contains-supercall.case +// - src/class-elements/initializer-eval-super-call/cls-decl-private-fields-indirect-eval-nested.template +/*--- +description: error if `super()` in StatementList of eval (indirect eval) +esid: sec-performeval-rules-in-initializer +features: [class, class-fields-public, class-fields-private] +flags: [generated] +info: | + Additional Early Error Rules for Eval Inside Initializer + These static semantics are applied by PerformEval when a direct eval call occurs inside a class field initializer. + ScriptBody : StatementList + + ... + The remaining eval rules apply as outside a constructor, inside a method, and inside a function. + + Additional Early Error Rules for Eval Outside Constructor Methods + These static semantics are applied by PerformEval when a direct eval call occurs outside of the constructor method of a ClassDeclaration or ClassExpression. + ScriptBody : StatementList + + It is a Syntax Error if StatementList Contains SuperCall. + +---*/ + + +var executed = false; +class A {} +class C extends A { + #x = (0, eval)('executed = true; super();'); +} + +assert.throws(SyntaxError, function() { + new C(); +}); + +assert.sameValue(executed, false); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/nested-private-direct-eval-err-contains-arguments.js b/js/src/tests/test262/language/statements/class/elements/nested-private-direct-eval-err-contains-arguments.js new file mode 100644 index 0000000000..d4829e845d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/nested-private-direct-eval-err-contains-arguments.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/eval-err-contains-arguments.case +// - src/class-elements/initializer-direct-eval-arguments/cls-decl-private-fields-eval-nested.template +/*--- +description: error if `arguments` in StatementList of eval (direct eval) +esid: sec-performeval-rules-in-initializer +features: [class, class-fields-public, class-fields-private] +flags: [generated] +info: | + Additional Early Error Rules for Eval Inside Initializer + These static semantics are applied by PerformEval when a direct eval call occurs inside a class field initializer. + ScriptBody : StatementList + + It is a Syntax Error if ContainsArguments of StatementList is true. + ... + + Static Semantics: ContainsArguments + IdentifierReference : Identifier + + 1. If the StringValue of Identifier is "arguments", return true. + ... + For all other grammatical productions, recurse on all nonterminals. If any piece returns true, then return true. Otherwise return false. + +---*/ + + +var executed = false; +class C { + #x = () => { + var t = () => { eval('executed = true; arguments;'); }; + t(); + } + constructor() { + this.#x(); + } +} + +assert.throws(SyntaxError, function() { + new C(); +}); + +assert.sameValue(executed, false); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/nested-private-direct-eval-err-contains-newtarget.js b/js/src/tests/test262/language/statements/class/elements/nested-private-direct-eval-err-contains-newtarget.js new file mode 100644 index 0000000000..c6a569e620 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/nested-private-direct-eval-err-contains-newtarget.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/eval-err-contains-newtarget.case +// - src/class-elements/initializer-eval-newtarget/cls-decl-private-fields-eval-nested.template +/*--- +description: error if `new.target` in StatementList of eval (direct eval) +esid: sec-performeval-rules-in-initializer +features: [class, new.target, class-fields-private] +flags: [generated] +info: | + Additional Early Error Rules for Eval Inside Initializer + These static semantics are applied by PerformEval when a direct eval call occurs inside a class field initializer. + ScriptBody : StatementList + + ... + The remaining eval rules apply as outside a constructor, inside a method, and inside a function. + + Additional Early Error Rules for Eval Outside Functions + These static semantics are applied by PerformEval when a direct eval call occurs outside of any function. + ScriptBody : StatementList + + It is a Syntax Error if StatementList Contains NewTarget. + +---*/ + + +var executed = false; +class C { + #x = eval('executed = true; new.target;'); +} + +var c = new C(); + +assert.sameValue(executed, true); +assert.sameValue(c.x, undefined); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/nested-private-indirect-eval-contains-arguments.js b/js/src/tests/test262/language/statements/class/elements/nested-private-indirect-eval-contains-arguments.js new file mode 100644 index 0000000000..289dc6ac40 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/nested-private-indirect-eval-contains-arguments.js @@ -0,0 +1,26 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/eval-contains-arguments.case +// - src/class-elements/initializer-indirect-eval-arguments/cls-decl-private-fields-indirect-eval-nested.template +/*--- +description: No error if `arguments` in StatementList of eval (indirect eval) +esid: sec-performeval-rules-in-initializer +features: [class, class-fields-public, class-fields-private] +flags: [generated, noStrict] +info: | + For indirect eval, the "Additional Early Error Rules for Eval Inside Initializer" + (in #sec-performeval-rules-in-initializer) are NOT applicable. + +---*/ + + +var arguments = 1; +class C { + #x = (0, eval)('arguments;'); + x() { + return this.#x; + } +} + +assert.sameValue(new C().x(), arguments); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/nested-private-indirect-eval-err-contains-newtarget.js b/js/src/tests/test262/language/statements/class/elements/nested-private-indirect-eval-err-contains-newtarget.js new file mode 100644 index 0000000000..f9f824135c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/nested-private-indirect-eval-err-contains-newtarget.js @@ -0,0 +1,37 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/eval-err-contains-newtarget.case +// - src/class-elements/initializer-eval-newtarget/cls-decl-private-fields-indirect-eval-nested.template +/*--- +description: error if `new.target` in StatementList of eval (indirect eval) +esid: sec-performeval-rules-in-initializer +features: [class, new.target, class-fields-private] +flags: [generated] +info: | + Additional Early Error Rules for Eval Inside Initializer + These static semantics are applied by PerformEval when a direct eval call occurs inside a class field initializer. + ScriptBody : StatementList + + ... + The remaining eval rules apply as outside a constructor, inside a method, and inside a function. + + Additional Early Error Rules for Eval Outside Functions + These static semantics are applied by PerformEval when a direct eval call occurs outside of any function. + ScriptBody : StatementList + + It is a Syntax Error if StatementList Contains NewTarget. + +---*/ + + +var executed = false; +class C { + #x = (0, eval)('executed = true; new.target;'); +} + +assert.throws(SyntaxError, function() { + new C(); +}); + +assert.sameValue(executed, false); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/nested-private-literal-name-init-err-contains-arguments.js b/js/src/tests/test262/language/statements/class/elements/nested-private-literal-name-init-err-contains-arguments.js new file mode 100644 index 0000000000..394b818a8b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/nested-private-literal-name-init-err-contains-arguments.js @@ -0,0 +1,34 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/init-err-contains-arguments.case +// - src/class-elements/initializer-error/cls-decl-fields-private-name-nested.template +/*--- +description: Syntax error if `arguments` used in class field (ClassElementName PrivateName) +esid: sec-class-definitions-static-semantics-early-errors +features: [class, class-fields-public, class-fields-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Static Semantics: Early Errors + + FieldDefinition: + PropertyNameInitializeropt + + - It is a Syntax Error if ContainsArguments of Initializer is true. + + Static Semantics: ContainsArguments + IdentifierReference : Identifier + + 1. If the StringValue of Identifier is "arguments", return true. + ... + For all other grammatical productions, recurse on all nonterminals. If any piece returns true, then return true. Otherwise return false. + +---*/ + +$DONOTEVALUATE(); + +class C { + #x = () => arguments; +} diff --git a/js/src/tests/test262/language/statements/class/elements/nested-private-literal-name-init-err-contains-super.js b/js/src/tests/test262/language/statements/class/elements/nested-private-literal-name-init-err-contains-super.js new file mode 100644 index 0000000000..3897026538 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/nested-private-literal-name-init-err-contains-super.js @@ -0,0 +1,27 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/init-err-contains-super.case +// - src/class-elements/initializer-error/cls-decl-fields-private-name-nested.template +/*--- +description: Syntax error if `super()` used in class field (ClassElementName PrivateName) +esid: sec-class-definitions-static-semantics-early-errors +features: [class, class-fields-public, class-fields-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Static Semantics: Early Errors + + FieldDefinition: + PropertyNameInitializeropt + + - It is a Syntax Error if Initializer is present and Initializer Contains SuperCall is true. + +---*/ + +$DONOTEVALUATE(); + +class C { + #x = () => super(); +} diff --git a/js/src/tests/test262/language/statements/class/elements/nested-private-ternary-init-err-contains-arguments.js b/js/src/tests/test262/language/statements/class/elements/nested-private-ternary-init-err-contains-arguments.js new file mode 100644 index 0000000000..1679bacb40 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/nested-private-ternary-init-err-contains-arguments.js @@ -0,0 +1,34 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/init-err-contains-arguments.case +// - src/class-elements/initializer-error/cls-decl-fields-private-ternary-nested.template +/*--- +description: Syntax error if `arguments` used in class field (private field, ternary expression) +esid: sec-class-definitions-static-semantics-early-errors +features: [class, class-fields-public, class-fields-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Static Semantics: Early Errors + + FieldDefinition: + PropertyNameInitializeropt + + - It is a Syntax Error if ContainsArguments of Initializer is true. + + Static Semantics: ContainsArguments + IdentifierReference : Identifier + + 1. If the StringValue of Identifier is "arguments", return true. + ... + For all other grammatical productions, recurse on all nonterminals. If any piece returns true, then return true. Otherwise return false. + +---*/ + +$DONOTEVALUATE(); + +class C { + #x = () => false ? {} : arguments; +} diff --git a/js/src/tests/test262/language/statements/class/elements/nested-private-ternary-init-err-contains-super.js b/js/src/tests/test262/language/statements/class/elements/nested-private-ternary-init-err-contains-super.js new file mode 100644 index 0000000000..c94b09834e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/nested-private-ternary-init-err-contains-super.js @@ -0,0 +1,27 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/init-err-contains-super.case +// - src/class-elements/initializer-error/cls-decl-fields-private-ternary-nested.template +/*--- +description: Syntax error if `super()` used in class field (private field, ternary expression) +esid: sec-class-definitions-static-semantics-early-errors +features: [class, class-fields-public, class-fields-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Static Semantics: Early Errors + + FieldDefinition: + PropertyNameInitializeropt + + - It is a Syntax Error if Initializer is present and Initializer Contains SuperCall is true. + +---*/ + +$DONOTEVALUATE(); + +class C { + #x = () => false ? {} : super(); +} diff --git a/js/src/tests/test262/language/statements/class/elements/nested-private-typeof-init-err-contains-arguments.js b/js/src/tests/test262/language/statements/class/elements/nested-private-typeof-init-err-contains-arguments.js new file mode 100644 index 0000000000..a065f17a75 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/nested-private-typeof-init-err-contains-arguments.js @@ -0,0 +1,34 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/init-err-contains-arguments.case +// - src/class-elements/initializer-error/cls-decl-fields-private-typeof-nested.template +/*--- +description: Syntax error if `arguments` used in class field (private field, typeof expression) +esid: sec-class-definitions-static-semantics-early-errors +features: [class, class-fields-public, class-fields-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Static Semantics: Early Errors + + FieldDefinition: + PropertyNameInitializeropt + + - It is a Syntax Error if ContainsArguments of Initializer is true. + + Static Semantics: ContainsArguments + IdentifierReference : Identifier + + 1. If the StringValue of Identifier is "arguments", return true. + ... + For all other grammatical productions, recurse on all nonterminals. If any piece returns true, then return true. Otherwise return false. + +---*/ + +$DONOTEVALUATE(); + +class C { + #x = () => typeof arguments; +} diff --git a/js/src/tests/test262/language/statements/class/elements/nested-private-typeof-init-err-contains-super.js b/js/src/tests/test262/language/statements/class/elements/nested-private-typeof-init-err-contains-super.js new file mode 100644 index 0000000000..8932fdcd0b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/nested-private-typeof-init-err-contains-super.js @@ -0,0 +1,27 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/init-err-contains-super.case +// - src/class-elements/initializer-error/cls-decl-fields-private-typeof-nested.template +/*--- +description: Syntax error if `super()` used in class field (private field, typeof expression) +esid: sec-class-definitions-static-semantics-early-errors +features: [class, class-fields-public, class-fields-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Static Semantics: Early Errors + + FieldDefinition: + PropertyNameInitializeropt + + - It is a Syntax Error if Initializer is present and Initializer Contains SuperCall is true. + +---*/ + +$DONOTEVALUATE(); + +class C { + #x = () => typeof super(); +} diff --git a/js/src/tests/test262/language/statements/class/elements/nested-static-comp-name-init-err-contains-arguments.js b/js/src/tests/test262/language/statements/class/elements/nested-static-comp-name-init-err-contains-arguments.js new file mode 100644 index 0000000000..96be893a02 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/nested-static-comp-name-init-err-contains-arguments.js @@ -0,0 +1,35 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/init-err-contains-arguments.case +// - src/class-elements/initializer-error/cls-decl-fields-static-comp-name-nested.template +/*--- +description: Syntax error if `arguments` used in class field (static computed ClassElementName) +esid: sec-class-definitions-static-semantics-early-errors +features: [class, class-fields-public, class-static-fields-public, computed-property-names] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Static Semantics: Early Errors + + FieldDefinition: + PropertyNameInitializeropt + + - It is a Syntax Error if ContainsArguments of Initializer is true. + + Static Semantics: ContainsArguments + IdentifierReference : Identifier + + 1. If the StringValue of Identifier is "arguments", return true. + ... + For all other grammatical productions, recurse on all nonterminals. If any piece returns true, then return true. Otherwise return false. + +---*/ + +$DONOTEVALUATE(); + +var x = "string"; +class C { + static [x] = () => arguments; +} diff --git a/js/src/tests/test262/language/statements/class/elements/nested-static-comp-name-init-err-contains-super.js b/js/src/tests/test262/language/statements/class/elements/nested-static-comp-name-init-err-contains-super.js new file mode 100644 index 0000000000..533d727312 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/nested-static-comp-name-init-err-contains-super.js @@ -0,0 +1,28 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/init-err-contains-super.case +// - src/class-elements/initializer-error/cls-decl-fields-static-comp-name-nested.template +/*--- +description: Syntax error if `super()` used in class field (static computed ClassElementName) +esid: sec-class-definitions-static-semantics-early-errors +features: [class, class-fields-public, class-static-fields-public, computed-property-names] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Static Semantics: Early Errors + + FieldDefinition: + PropertyNameInitializeropt + + - It is a Syntax Error if Initializer is present and Initializer Contains SuperCall is true. + +---*/ + +$DONOTEVALUATE(); + +var x = "string"; +class C { + static [x] = () => super(); +} diff --git a/js/src/tests/test262/language/statements/class/elements/nested-static-literal-init-err-contains-arguments.js b/js/src/tests/test262/language/statements/class/elements/nested-static-literal-init-err-contains-arguments.js new file mode 100644 index 0000000000..3dcf75e485 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/nested-static-literal-init-err-contains-arguments.js @@ -0,0 +1,34 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/init-err-contains-arguments.case +// - src/class-elements/initializer-error/cls-decl-fields-static-literal-name-nested.template +/*--- +description: Syntax error if `arguments` used in class field (static literal ClassElementName) +esid: sec-class-definitions-static-semantics-early-errors +features: [class, class-fields-public, class-static-fields-public] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Static Semantics: Early Errors + + FieldDefinition: + PropertyNameInitializeropt + + - It is a Syntax Error if ContainsArguments of Initializer is true. + + Static Semantics: ContainsArguments + IdentifierReference : Identifier + + 1. If the StringValue of Identifier is "arguments", return true. + ... + For all other grammatical productions, recurse on all nonterminals. If any piece returns true, then return true. Otherwise return false. + +---*/ + +$DONOTEVALUATE(); + +class C { + static x = () => arguments; +} diff --git a/js/src/tests/test262/language/statements/class/elements/nested-static-literal-init-err-contains-super.js b/js/src/tests/test262/language/statements/class/elements/nested-static-literal-init-err-contains-super.js new file mode 100644 index 0000000000..a211594fda --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/nested-static-literal-init-err-contains-super.js @@ -0,0 +1,27 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/init-err-contains-super.case +// - src/class-elements/initializer-error/cls-decl-fields-static-literal-name-nested.template +/*--- +description: Syntax error if `super()` used in class field (static literal ClassElementName) +esid: sec-class-definitions-static-semantics-early-errors +features: [class, class-fields-public, class-static-fields-public] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Static Semantics: Early Errors + + FieldDefinition: + PropertyNameInitializeropt + + - It is a Syntax Error if Initializer is present and Initializer Contains SuperCall is true. + +---*/ + +$DONOTEVALUATE(); + +class C { + static x = () => super(); +} diff --git a/js/src/tests/test262/language/statements/class/elements/nested-static-private-init-err-contains-arguments.js b/js/src/tests/test262/language/statements/class/elements/nested-static-private-init-err-contains-arguments.js new file mode 100644 index 0000000000..a02931ce9a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/nested-static-private-init-err-contains-arguments.js @@ -0,0 +1,34 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/init-err-contains-arguments.case +// - src/class-elements/initializer-error/cls-decl-fields-static-private-name-nested.template +/*--- +description: Syntax error if `arguments` used in class field (static PrivateName) +esid: sec-class-definitions-static-semantics-early-errors +features: [class, class-fields-public, class-static-fields-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Static Semantics: Early Errors + + FieldDefinition: + PropertyNameInitializeropt + + - It is a Syntax Error if ContainsArguments of Initializer is true. + + Static Semantics: ContainsArguments + IdentifierReference : Identifier + + 1. If the StringValue of Identifier is "arguments", return true. + ... + For all other grammatical productions, recurse on all nonterminals. If any piece returns true, then return true. Otherwise return false. + +---*/ + +$DONOTEVALUATE(); + +class C { + static #x = () => arguments; +} diff --git a/js/src/tests/test262/language/statements/class/elements/nested-static-private-init-err-contains-super.js b/js/src/tests/test262/language/statements/class/elements/nested-static-private-init-err-contains-super.js new file mode 100644 index 0000000000..5247871b54 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/nested-static-private-init-err-contains-super.js @@ -0,0 +1,27 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/init-err-contains-super.case +// - src/class-elements/initializer-error/cls-decl-fields-static-private-name-nested.template +/*--- +description: Syntax error if `super()` used in class field (static PrivateName) +esid: sec-class-definitions-static-semantics-early-errors +features: [class, class-fields-public, class-static-fields-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Static Semantics: Early Errors + + FieldDefinition: + PropertyNameInitializeropt + + - It is a Syntax Error if Initializer is present and Initializer Contains SuperCall is true. + +---*/ + +$DONOTEVALUATE(); + +class C { + static #x = () => super(); +} diff --git a/js/src/tests/test262/language/statements/class/elements/nested-static-string-literal-name-init-err-contains-arguments.js b/js/src/tests/test262/language/statements/class/elements/nested-static-string-literal-name-init-err-contains-arguments.js new file mode 100644 index 0000000000..ee3bf5639e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/nested-static-string-literal-name-init-err-contains-arguments.js @@ -0,0 +1,34 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/init-err-contains-arguments.case +// - src/class-elements/initializer-error/cls-decl-fields-static-string-literal-name-nested.template +/*--- +description: Syntax error if `arguments` used in class field (static string literal ClassElementName) +esid: sec-class-definitions-static-semantics-early-errors +features: [class, class-fields-public, class-static-fields-public] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Static Semantics: Early Errors + + FieldDefinition: + PropertyNameInitializeropt + + - It is a Syntax Error if ContainsArguments of Initializer is true. + + Static Semantics: ContainsArguments + IdentifierReference : Identifier + + 1. If the StringValue of Identifier is "arguments", return true. + ... + For all other grammatical productions, recurse on all nonterminals. If any piece returns true, then return true. Otherwise return false. + +---*/ + +$DONOTEVALUATE(); + +class C { + static 'x' = () => arguments; +} diff --git a/js/src/tests/test262/language/statements/class/elements/nested-static-string-literal-name-init-err-contains-super.js b/js/src/tests/test262/language/statements/class/elements/nested-static-string-literal-name-init-err-contains-super.js new file mode 100644 index 0000000000..26c744f4f9 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/nested-static-string-literal-name-init-err-contains-super.js @@ -0,0 +1,27 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/init-err-contains-super.case +// - src/class-elements/initializer-error/cls-decl-fields-static-string-literal-name-nested.template +/*--- +description: Syntax error if `super()` used in class field (static string literal ClassElementName) +esid: sec-class-definitions-static-semantics-early-errors +features: [class, class-fields-public, class-static-fields-public] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Static Semantics: Early Errors + + FieldDefinition: + PropertyNameInitializeropt + + - It is a Syntax Error if Initializer is present and Initializer Contains SuperCall is true. + +---*/ + +$DONOTEVALUATE(); + +class C { + static 'x' = () => super(); +} diff --git a/js/src/tests/test262/language/statements/class/elements/nested-string-literal-name-init-err-contains-arguments.js b/js/src/tests/test262/language/statements/class/elements/nested-string-literal-name-init-err-contains-arguments.js new file mode 100644 index 0000000000..cb03937f68 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/nested-string-literal-name-init-err-contains-arguments.js @@ -0,0 +1,34 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/init-err-contains-arguments.case +// - src/class-elements/initializer-error/cls-decl-fields-string-literal-name-nested.template +/*--- +description: Syntax error if `arguments` used in class field (string literal ClassElementName) +esid: sec-class-definitions-static-semantics-early-errors +features: [class, class-fields-public] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Static Semantics: Early Errors + + FieldDefinition: + PropertyNameInitializeropt + + - It is a Syntax Error if ContainsArguments of Initializer is true. + + Static Semantics: ContainsArguments + IdentifierReference : Identifier + + 1. If the StringValue of Identifier is "arguments", return true. + ... + For all other grammatical productions, recurse on all nonterminals. If any piece returns true, then return true. Otherwise return false. + +---*/ + +$DONOTEVALUATE(); + +class C { + 'x' = () => arguments; +} diff --git a/js/src/tests/test262/language/statements/class/elements/nested-string-literal-name-init-err-contains-super.js b/js/src/tests/test262/language/statements/class/elements/nested-string-literal-name-init-err-contains-super.js new file mode 100644 index 0000000000..08f9b9fe11 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/nested-string-literal-name-init-err-contains-super.js @@ -0,0 +1,27 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/init-err-contains-super.case +// - src/class-elements/initializer-error/cls-decl-fields-string-literal-name-nested.template +/*--- +description: Syntax error if `super()` used in class field (string literal ClassElementName) +esid: sec-class-definitions-static-semantics-early-errors +features: [class, class-fields-public] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Static Semantics: Early Errors + + FieldDefinition: + PropertyNameInitializeropt + + - It is a Syntax Error if Initializer is present and Initializer Contains SuperCall is true. + +---*/ + +$DONOTEVALUATE(); + +class C { + 'x' = () => super(); +} diff --git a/js/src/tests/test262/language/statements/class/elements/nested-ternary-init-err-contains-arguments.js b/js/src/tests/test262/language/statements/class/elements/nested-ternary-init-err-contains-arguments.js new file mode 100644 index 0000000000..4868adf924 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/nested-ternary-init-err-contains-arguments.js @@ -0,0 +1,34 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/init-err-contains-arguments.case +// - src/class-elements/initializer-error/cls-decl-fields-ternary-nested.template +/*--- +description: Syntax error if `arguments` used in class field (ternary expression) +esid: sec-class-definitions-static-semantics-early-errors +features: [class, class-fields-public] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Static Semantics: Early Errors + + FieldDefinition: + PropertyNameInitializeropt + + - It is a Syntax Error if ContainsArguments of Initializer is true. + + Static Semantics: ContainsArguments + IdentifierReference : Identifier + + 1. If the StringValue of Identifier is "arguments", return true. + ... + For all other grammatical productions, recurse on all nonterminals. If any piece returns true, then return true. Otherwise return false. + +---*/ + +$DONOTEVALUATE(); + +class C { + x = () => false ? {} : arguments; +} diff --git a/js/src/tests/test262/language/statements/class/elements/nested-ternary-init-err-contains-super.js b/js/src/tests/test262/language/statements/class/elements/nested-ternary-init-err-contains-super.js new file mode 100644 index 0000000000..2b9ec450d8 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/nested-ternary-init-err-contains-super.js @@ -0,0 +1,27 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/init-err-contains-super.case +// - src/class-elements/initializer-error/cls-decl-fields-ternary-nested.template +/*--- +description: Syntax error if `super()` used in class field (ternary expression) +esid: sec-class-definitions-static-semantics-early-errors +features: [class, class-fields-public] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Static Semantics: Early Errors + + FieldDefinition: + PropertyNameInitializeropt + + - It is a Syntax Error if Initializer is present and Initializer Contains SuperCall is true. + +---*/ + +$DONOTEVALUATE(); + +class C { + x = () => false ? {} : super(); +} diff --git a/js/src/tests/test262/language/statements/class/elements/nested-typeof-init-err-contains-arguments.js b/js/src/tests/test262/language/statements/class/elements/nested-typeof-init-err-contains-arguments.js new file mode 100644 index 0000000000..f3fd252bcc --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/nested-typeof-init-err-contains-arguments.js @@ -0,0 +1,34 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/init-err-contains-arguments.case +// - src/class-elements/initializer-error/cls-decl-fields-typeof-nested.template +/*--- +description: Syntax error if `arguments` used in class field (typeof expression) +esid: sec-class-definitions-static-semantics-early-errors +features: [class, class-fields-public] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Static Semantics: Early Errors + + FieldDefinition: + PropertyNameInitializeropt + + - It is a Syntax Error if ContainsArguments of Initializer is true. + + Static Semantics: ContainsArguments + IdentifierReference : Identifier + + 1. If the StringValue of Identifier is "arguments", return true. + ... + For all other grammatical productions, recurse on all nonterminals. If any piece returns true, then return true. Otherwise return false. + +---*/ + +$DONOTEVALUATE(); + +class C { + x = () => typeof arguments; +} diff --git a/js/src/tests/test262/language/statements/class/elements/nested-typeof-init-err-contains-super.js b/js/src/tests/test262/language/statements/class/elements/nested-typeof-init-err-contains-super.js new file mode 100644 index 0000000000..cffa546d4d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/nested-typeof-init-err-contains-super.js @@ -0,0 +1,27 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/init-err-contains-super.case +// - src/class-elements/initializer-error/cls-decl-fields-typeof-nested.template +/*--- +description: Syntax error if `super()` used in class field (typeof expression) +esid: sec-class-definitions-static-semantics-early-errors +features: [class, class-fields-public] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Static Semantics: Early Errors + + FieldDefinition: + PropertyNameInitializeropt + + - It is a Syntax Error if Initializer is present and Initializer Contains SuperCall is true. + +---*/ + +$DONOTEVALUATE(); + +class C { + x = () => typeof super(); +} diff --git a/js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-computed-names.js b/js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-computed-names.js new file mode 100644 index 0000000000..5772bdea7a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-computed-names.js @@ -0,0 +1,108 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/computed-names.case +// - src/class-elements/productions/cls-decl-new-no-sc-line-method.template +/*--- +description: Computed property names (field definitions followed by a method in a new line without a semicolon) +esid: prod-FieldDefinition +features: [class-fields-public, computed-property-names, class] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PropertyName + +---*/ +var x = "b"; + + + +class C { + [x] = 42; [10] = "meep"; ["not initialized"] + m() { return 42; } + +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "b"), + "b doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "b"), + "b doesn't appear as an own property on C constructor" +); + +verifyProperty(c, "b", { + value: 42, + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "x"), + "x doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "x"), + "x doesn't appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "x"), + "x doesn't appear as an own property on C instance" +); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "10"), + "10 doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "10"), + "10 doesn't appear as an own property on C constructor" +); + +verifyProperty(c, "10", { + value: "meep", + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "not initialized"), + "'not initialized' doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "not initialized"), + "'not initialized' doesn't appear as an own property on C constructor" +); + +verifyProperty(c, "not initialized", { + value: undefined, + enumerable: true, + writable: true, + configurable: true +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-computed-symbol-names.js b/js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-computed-symbol-names.js new file mode 100644 index 0000000000..c65e3a6c7a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-computed-symbol-names.js @@ -0,0 +1,106 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/computed-symbol-names.case +// - src/class-elements/productions/cls-decl-new-no-sc-line-method.template +/*--- +description: Computed property symbol names (field definitions followed by a method in a new line without a semicolon) +esid: prod-FieldDefinition +features: [class-fields-public, Symbol, computed-property-names, class] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PropertyName + +---*/ +var x = Symbol(); +var y = Symbol(); + + + +class C { + [x]; [y] = 42 + m() { return 42; } + +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, x), + "Symbol x doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, x), + "Symbol x doesn't appear as an own property on C constructor" +); + +verifyProperty(c, x, { + value: undefined, + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, y), + "Symbol y doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, y), + "Symbol y doesn't appear as an own property on C constructor" +); + +verifyProperty(c, y, { + value: 42, + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "x"), + "x doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "x"), + "x doesn't appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "x"), + "x doesn't appear as an own property on C instance" +); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "y"), + "y doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "y"), + "y doesn't appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "y"), + "y doesn't appear as an own property on C instance" +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-grammar-privatename-identifier-semantics-stringvalue.js b/js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-grammar-privatename-identifier-semantics-stringvalue.js new file mode 100644 index 0000000000..d5358ecc82 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-grammar-privatename-identifier-semantics-stringvalue.js @@ -0,0 +1,110 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-privatename-identifier-semantics-stringvalue.case +// - src/class-elements/productions/cls-decl-new-no-sc-line-method.template +/*--- +description: PrivateName Static Semantics, StringValue (field definitions followed by a method in a new line without a semicolon) +esid: prod-FieldDefinition +features: [class-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + + + 1. Return the String value consisting of the sequence of code + units corresponding to PrivateName. In determining the sequence + any occurrences of \ UnicodeEscapeSequence are first replaced + with the code point represented by the UnicodeEscapeSequence + and then the code points of the entire PrivateName are converted + to code units by UTF16Encoding (10.1.1) each code point. + +---*/ + + +class C { + #\u{6F}; + #\u2118; + #ZW_\u200C_NJ; + #ZW_\u200D_J; + m() { return 42; } + o(value) { + this.#o = value; + return this.#o; + } + ℘(value) { + this.#℘ = value; + return this.#℘; + } + ZW_‌_NJ(value) { // DO NOT CHANGE THE NAME OF THIS METHOD + this.#ZW_‌_NJ = value; + return this.#ZW_‌_NJ; + } + ZW_‍_J(value) { // DO NOT CHANGE THE NAME OF THIS METHOD + this.#ZW_‍_J = value; + return this.#ZW_‍_J; + } +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.o(1), 1); +assert.sameValue(c.℘(1), 1); +assert.sameValue(c.ZW_‌_NJ(1), 1); +assert.sameValue(c.ZW_‍_J(1), 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-literal-names-asi.js b/js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-literal-names-asi.js new file mode 100644 index 0000000000..730fec9f6b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-literal-names-asi.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/literal-names-asi.case +// - src/class-elements/productions/cls-decl-new-no-sc-line-method.template +/*--- +description: Literal property names with ASI (field definitions followed by a method in a new line without a semicolon) +esid: prod-FieldDefinition +features: [class-fields-public, class] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PropertyName + +---*/ + + +class C { + a + b = 42; + m() { return 42; } + +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "a"), + "a doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "a"), + "a doesn't appear as an own property on C constructor" +); + +verifyProperty(c, "a", { + value: undefined, + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "b"), + "b doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "b"), + "b doesn't appear as an own property on C constructor" +); + +verifyProperty(c, "b", { + value: 42, + enumerable: true, + writable: true, + configurable: true +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-literal-names.js b/js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-literal-names.js new file mode 100644 index 0000000000..2ba4cf4418 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-literal-names.js @@ -0,0 +1,97 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/literal-names.case +// - src/class-elements/productions/cls-decl-new-no-sc-line-method.template +/*--- +description: Literal property names (field definitions followed by a method in a new line without a semicolon) +esid: prod-FieldDefinition +features: [class-fields-public, class] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PropertyName + +---*/ +const fn = function() {} + + + +class C { + a; b = 42; + c = fn + m() { return 42; } + +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "a"), + "a doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "a"), + "a doesn't appear as an own property on C constructor" +); + +verifyProperty(c, "a", { + value: undefined, + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "b"), + "b doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "b"), + "b doesn't appear as an own property on C constructor" +); + +verifyProperty(c, "b", { + value: 42, + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "c"), + "c doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "c"), + "c doesn't appear as an own property on C constructor" +); + +verifyProperty(c, "c", { + value: fn, + enumerable: true, + writable: true, + configurable: true +}); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-private-field-usage.js b/js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-private-field-usage.js new file mode 100644 index 0000000000..f4c1de7f9e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-private-field-usage.js @@ -0,0 +1,50 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/private-field-usage.case +// - src/class-elements/productions/cls-decl-new-no-sc-line-method.template +/*--- +description: PrivateName CallExpression usage (private field) (field definitions followed by a method in a new line without a semicolon) +esid: prod-FieldDefinition +features: [class-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + Updated Productions + + CallExpression[Yield, Await]: + CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await] + SuperCall[?Yield, ?Await] + CallExpression[?Yield, ?Await]Arguments[?Yield, ?Await] + CallExpression[?Yield, ?Await][Expression[+In, ?Yield, ?Await]] + CallExpression[?Yield, ?Await].IdentifierName + CallExpression[?Yield, ?Await]TemplateLiteral[?Yield, ?Await] + CallExpression[?Yield, ?Await].PrivateName + +---*/ + + +class C { + #m = 'test262'; + m() { return 42; } + method() { + return this.#m; + } +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.method(), 'test262'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-private-method-getter-usage.js b/js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-private-method-getter-usage.js new file mode 100644 index 0000000000..cc6ada0071 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-private-method-getter-usage.js @@ -0,0 +1,50 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/private-method-getter-usage.case +// - src/class-elements/productions/cls-decl-new-no-sc-line-method.template +/*--- +description: PrivateName CallExpression usage (Accesor get method) (field definitions followed by a method in a new line without a semicolon) +esid: prod-FieldDefinition +features: [class-methods-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + Updated Productions + + CallExpression[Yield, Await]: + CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await] + SuperCall[?Yield, ?Await] + CallExpression[?Yield, ?Await]Arguments[?Yield, ?Await] + CallExpression[?Yield, ?Await][Expression[+In, ?Yield, ?Await]] + CallExpression[?Yield, ?Await].IdentifierName + CallExpression[?Yield, ?Await]TemplateLiteral[?Yield, ?Await] + CallExpression[?Yield, ?Await].PrivateName + +---*/ + + +class C { + get #m() { return 'test262'; } + m() { return 42; } + method() { + return this.#m; + } +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.method(), 'test262'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-private-method-usage.js b/js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-private-method-usage.js new file mode 100644 index 0000000000..ed4e7aa0ba --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-private-method-usage.js @@ -0,0 +1,50 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/private-method-usage.case +// - src/class-elements/productions/cls-decl-new-no-sc-line-method.template +/*--- +description: PrivateName CallExpression usage (private method) (field definitions followed by a method in a new line without a semicolon) +esid: prod-FieldDefinition +features: [class-methods-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + Updated Productions + + CallExpression[Yield, Await]: + CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await] + SuperCall[?Yield, ?Await] + CallExpression[?Yield, ?Await]Arguments[?Yield, ?Await] + CallExpression[?Yield, ?Await][Expression[+In, ?Yield, ?Await]] + CallExpression[?Yield, ?Await].IdentifierName + CallExpression[?Yield, ?Await]TemplateLiteral[?Yield, ?Await] + CallExpression[?Yield, ?Await].PrivateName + +---*/ + + +class C { + #m() { return 'test262'; } + m() { return 42; } + method() { + return this.#m(); + } +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.method(), 'test262'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-private-names.js b/js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-private-names.js new file mode 100644 index 0000000000..7e7e12716a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-private-names.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/private-names.case +// - src/class-elements/productions/cls-decl-new-no-sc-line-method.template +/*--- +description: private names (field definitions followed by a method in a new line without a semicolon) +esid: prod-FieldDefinition +features: [class-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + ... + FieldDefinition ; + + FieldDefinition : + ClassElementName Initializer_opt + + ClassElementName : + PrivateName + + PrivateName : + # IdentifierName + +---*/ + + +class C { + #x; #y + m() { return 42; } + x() { + this.#x = 42; + return this.#x; + } + y() { + this.#y = 43; + return this.#y; + } +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +// Test the private fields do not appear as properties before set to value +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#x"), "test 1"); +assert(!Object.prototype.hasOwnProperty.call(C, "#x"), "test 2"); +assert(!Object.prototype.hasOwnProperty.call(c, "#x"), "test 3"); + +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#y"), "test 4"); +assert(!Object.prototype.hasOwnProperty.call(C, "#y"), "test 5"); +assert(!Object.prototype.hasOwnProperty.call(c, "#y"), "test 6"); + +// Test if private fields can be sucessfully accessed and set to value +assert.sameValue(c.x(), 42, "test 7"); +assert.sameValue(c.y(), 43, "test 8"); + +// Test the private fields do not appear as properties before after set to value +assert(!Object.prototype.hasOwnProperty.call(c, "#x"), "test 9"); +assert(!Object.prototype.hasOwnProperty.call(c, "#y"), "test 10"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-rs-field-identifier-initializer.js b/js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-rs-field-identifier-initializer.js new file mode 100644 index 0000000000..0aa8cf5549 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-rs-field-identifier-initializer.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-field-identifier-initializer.case +// - src/class-elements/productions/cls-decl-new-no-sc-line-method.template +/*--- +description: Valid FieldDefinition (field definitions followed by a method in a new line without a semicolon) +esid: prod-FieldDefinition +features: [class-fields-public, class] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + ... + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + + PropertyName : + LiteralPropertyName + ComputedPropertyName + + LiteralPropertyName : + IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + $ = 1; _ = 1; \u{6F} = 1; \u2118 = 1; ZW_\u200C_NJ = 1; ZW_\u200D_J = 1 + m() { return 42; } + +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.$, 1); +assert.sameValue(c._, 1); +assert.sameValue(c.\u{6F}, 1); +assert.sameValue(c.\u2118, 1); +assert.sameValue(c.ZW_\u200C_NJ, 1); +assert.sameValue(c.ZW_\u200D_J, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-rs-field-identifier.js b/js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-rs-field-identifier.js new file mode 100644 index 0000000000..f82c1d13b3 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-rs-field-identifier.js @@ -0,0 +1,95 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-field-identifier.case +// - src/class-elements/productions/cls-decl-new-no-sc-line-method.template +/*--- +description: Valid FieldDefinition (field definitions followed by a method in a new line without a semicolon) +esid: prod-FieldDefinition +features: [class-fields-public, class] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + ... + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + + PropertyName : + LiteralPropertyName + ComputedPropertyName + + LiteralPropertyName : + IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + $; _; \u{6F}; \u2118; ZW_\u200C_NJ; ZW_\u200D_J + m() { return 42; } + +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +c.$ = 1; +c._ = 1; +c.\u{6F} = 1; +c.\u2118 = 1; +c.ZW_\u200C_NJ = 1; +c.ZW_\u200D_J = 1; + +assert.sameValue(c.$, 1); +assert.sameValue(c._, 1); +assert.sameValue(c.\u{6F}, 1); +assert.sameValue(c.\u2118, 1); +assert.sameValue(c.ZW_\u200C_NJ, 1); +assert.sameValue(c.ZW_\u200D_J, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-rs-private-getter-alt.js b/js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-rs-private-getter-alt.js new file mode 100644 index 0000000000..25431263b4 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-rs-private-getter-alt.js @@ -0,0 +1,129 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-private-getter-alt.case +// - src/class-elements/productions/cls-decl-new-no-sc-line-method.template +/*--- +description: Valid PrivateName as private getter (field definitions followed by a method in a new line without a semicolon) +esid: prod-FieldDefinition +features: [class-methods-private, class-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + ... + ; + + MethodDefinition : + ... + get ClassElementName ( ){ FunctionBody } + ... + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + #$_; #__; #\u{6F}_; #℘_; #ZW_‌_NJ_; #ZW_‍_J_; + get #$() { + return this.#$_; + } + get #_() { + return this.#__; + } + get #\u{6F}() { + return this.#\u{6F}_; + } + get #℘() { + return this.#℘_; + } + get #ZW_‌_NJ() { + return this.#ZW_‌_NJ_; + } + get #ZW_‍_J() { + return this.#ZW_‍_J_; + } + + m() { return 42; } + $(value) { + this.#$_ = value; + return this.#$; + } + _(value) { + this.#__ = value; + return this.#_; + } + \u{6F}(value) { + this.#\u{6F}_ = value; + return this.#\u{6F}; + } + ℘(value) { + this.#℘_ = value; + return this.#℘; + } + ZW_‌_NJ(value) { + this.#ZW_‌_NJ_ = value; + return this.#ZW_‌_NJ; + } + ZW_‍_J(value) { + this.#ZW_‍_J_ = value; + return this.#ZW_‍_J; + } + +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.$(1), 1); +assert.sameValue(c._(1), 1); +assert.sameValue(c.\u{6F}(1), 1); +assert.sameValue(c.℘(1), 1); +assert.sameValue(c.ZW_‌_NJ(1), 1); +assert.sameValue(c.ZW_‍_J(1), 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-rs-private-getter.js b/js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-rs-private-getter.js new file mode 100644 index 0000000000..642a2eb491 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-rs-private-getter.js @@ -0,0 +1,129 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-private-getter.case +// - src/class-elements/productions/cls-decl-new-no-sc-line-method.template +/*--- +description: Valid PrivateName as private getter (field definitions followed by a method in a new line without a semicolon) +esid: prod-FieldDefinition +features: [class-methods-private, class-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + ... + ; + + MethodDefinition : + ... + get ClassElementName ( ){ FunctionBody } + ... + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + #$_; #__; #\u{6F}_; #\u2118_; #ZW_\u200C_NJ_; #ZW_\u200D_J_; + get #$() { + return this.#$_; + } + get #_() { + return this.#__; + } + get #\u{6F}() { + return this.#\u{6F}_; + } + get #\u2118() { + return this.#\u2118_; + } + get #ZW_\u200C_NJ() { + return this.#ZW_\u200C_NJ_; + } + get #ZW_\u200D_J() { + return this.#ZW_\u200D_J_; + } + + m() { return 42; } + $(value) { + this.#$_ = value; + return this.#$; + } + _(value) { + this.#__ = value; + return this.#_; + } + \u{6F}(value) { + this.#\u{6F}_ = value; + return this.#\u{6F}; + } + \u2118(value) { + this.#\u2118_ = value; + return this.#\u2118; + } + ZW_\u200C_NJ(value) { + this.#ZW_\u200C_NJ_ = value; + return this.#ZW_\u200C_NJ; + } + ZW_\u200D_J(value) { + this.#ZW_\u200D_J_ = value; + return this.#ZW_\u200D_J; + } + +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.$(1), 1); +assert.sameValue(c._(1), 1); +assert.sameValue(c.\u{6F}(1), 1); +assert.sameValue(c.\u2118(1), 1); +assert.sameValue(c.ZW_\u200C_NJ(1), 1); +assert.sameValue(c.ZW_\u200D_J(1), 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-rs-private-method-alt.js b/js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-rs-private-method-alt.js new file mode 100644 index 0000000000..6bb366ad75 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-rs-private-method-alt.js @@ -0,0 +1,128 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-private-method-alt.case +// - src/class-elements/productions/cls-decl-new-no-sc-line-method.template +/*--- +description: Valid PrivateName as private method (field definitions followed by a method in a new line without a semicolon) +esid: prod-FieldDefinition +features: [class-methods-private, class-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + ... + ; + + MethodDefinition : + ClassElementName ( UniqueFormalParameters ) { FunctionBody } + ... + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + #$_; #__; #\u{6F}_; #℘_; #ZW_‌_NJ_; #ZW_‍_J_; + #$() { + return this.#$_; + } + #_() { + return this.#__; + } + #\u{6F}() { + return this.#\u{6F}_; + } + #℘() { + return this.#℘_; + } + #ZW_‌_NJ() { + return this.#ZW_‌_NJ_; + } + #ZW_‍_J() { + return this.#ZW_‍_J_; + } + + m() { return 42; } + $(value) { + this.#$_ = value; + return this.#$(); + } + _(value) { + this.#__ = value; + return this.#_(); + } + \u{6F}(value) { + this.#\u{6F}_ = value; + return this.#\u{6F}(); + } + ℘(value) { + this.#℘_ = value; + return this.#℘(); + } + ZW_‌_NJ(value) { + this.#ZW_‌_NJ_ = value; + return this.#ZW_‌_NJ(); + } + ZW_‍_J(value) { + this.#ZW_‍_J_ = value; + return this.#ZW_‍_J(); + } + +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.$(1), 1); +assert.sameValue(c._(1), 1); +assert.sameValue(c.\u{6F}(1), 1); +assert.sameValue(c.℘(1), 1); +assert.sameValue(c.ZW_‌_NJ(1), 1); +assert.sameValue(c.ZW_‍_J(1), 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-rs-private-method.js b/js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-rs-private-method.js new file mode 100644 index 0000000000..72947f435c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-rs-private-method.js @@ -0,0 +1,128 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-private-method.case +// - src/class-elements/productions/cls-decl-new-no-sc-line-method.template +/*--- +description: Valid PrivateName as private method (field definitions followed by a method in a new line without a semicolon) +esid: prod-FieldDefinition +features: [class-methods-private, class-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + ... + ; + + MethodDefinition : + ClassElementName ( UniqueFormalParameters ) { FunctionBody } + ... + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + #$_; #__; #\u{6F}_; #\u2118_; #ZW_\u200C_NJ_; #ZW_\u200D_J_; + #$() { + return this.#$_; + } + #_() { + return this.#__; + } + #\u{6F}() { + return this.#\u{6F}_; + } + #\u2118() { + return this.#\u2118_; + } + #ZW_\u200C_NJ() { + return this.#ZW_\u200C_NJ_; + } + #ZW_\u200D_J() { + return this.#ZW_\u200D_J_; + } + + m() { return 42; } + $(value) { + this.#$_ = value; + return this.#$(); + } + _(value) { + this.#__ = value; + return this.#_(); + } + \u{6F}(value) { + this.#\u{6F}_ = value; + return this.#\u{6F}(); + } + \u2118(value) { + this.#\u2118_ = value; + return this.#\u2118(); + } + ZW_\u200C_NJ(value) { + this.#ZW_\u200C_NJ_ = value; + return this.#ZW_\u200C_NJ(); + } + ZW_\u200D_J(value) { + this.#ZW_\u200D_J_ = value; + return this.#ZW_\u200D_J(); + } + +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.$(1), 1); +assert.sameValue(c._(1), 1); +assert.sameValue(c.\u{6F}(1), 1); +assert.sameValue(c.\u2118(1), 1); +assert.sameValue(c.ZW_\u200C_NJ(1), 1); +assert.sameValue(c.ZW_\u200D_J(1), 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-rs-private-setter-alt.js b/js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-rs-private-setter-alt.js new file mode 100644 index 0000000000..04a7af2f92 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-rs-private-setter-alt.js @@ -0,0 +1,128 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-private-setter-alt.case +// - src/class-elements/productions/cls-decl-new-no-sc-line-method.template +/*--- +description: Valid PrivateName as private setter (field definitions followed by a method in a new line without a semicolon) +esid: prod-FieldDefinition +features: [class-methods-private, class-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + ... + ; + + MethodDefinition : + ... + set ClassElementName ( PropertySetParameterList ) { FunctionBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + #$_; #__; #\u{6F}_; #℘_; #ZW_‌_NJ_; #ZW_‍_J_; + set #$(value) { + this.#$_ = value; + } + set #_(value) { + this.#__ = value; + } + set #\u{6F}(value) { + this.#\u{6F}_ = value; + } + set #℘(value) { + this.#℘_ = value; + } + set #ZW_‌_NJ(value) { + this.#ZW_‌_NJ_ = value; + } + set #ZW_‍_J(value) { + this.#ZW_‍_J_ = value; + } + + m() { return 42; } + $(value) { + this.#$ = value; + return this.#$_; + } + _(value) { + this.#_ = value; + return this.#__; + } + \u{6F}(value) { + this.#\u{6F} = value; + return this.#\u{6F}_; + } + ℘(value) { + this.#℘ = value; + return this.#℘_; + } + ZW_‌_NJ(value) { + this.#ZW_‌_NJ = value; + return this.#ZW_‌_NJ_; + } + ZW_‍_J(value) { + this.#ZW_‍_J = value; + return this.#ZW_‍_J_; + } + +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.$(1), 1); +assert.sameValue(c._(1), 1); +assert.sameValue(c.\u{6F}(1), 1); +assert.sameValue(c.℘(1), 1); +assert.sameValue(c.ZW_‌_NJ(1), 1); +assert.sameValue(c.ZW_‍_J(1), 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-rs-private-setter.js b/js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-rs-private-setter.js new file mode 100644 index 0000000000..478b154ae1 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-rs-private-setter.js @@ -0,0 +1,128 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-private-setter.case +// - src/class-elements/productions/cls-decl-new-no-sc-line-method.template +/*--- +description: Valid PrivateName as private setter (field definitions followed by a method in a new line without a semicolon) +esid: prod-FieldDefinition +features: [class-methods-private, class-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + ... + ; + + MethodDefinition : + ... + set ClassElementName ( PropertySetParameterList ) { FunctionBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + #$_; #__; #\u{6F}_; #\u2118_; #ZW_\u200C_NJ_; #ZW_\u200D_J_; + set #$(value) { + this.#$_ = value; + } + set #_(value) { + this.#__ = value; + } + set #\u{6F}(value) { + this.#\u{6F}_ = value; + } + set #\u2118(value) { + this.#\u2118_ = value; + } + set #ZW_\u200C_NJ(value) { + this.#ZW_\u200C_NJ_ = value; + } + set #ZW_\u200D_J(value) { + this.#ZW_\u200D_J_ = value; + } + + m() { return 42; } + $(value) { + this.#$ = value; + return this.#$_; + } + _(value) { + this.#_ = value; + return this.#__; + } + \u{6F}(value) { + this.#\u{6F} = value; + return this.#\u{6F}_; + } + \u2118(value) { + this.#\u2118 = value; + return this.#\u2118_; + } + ZW_\u200C_NJ(value) { + this.#ZW_\u200C_NJ = value; + return this.#ZW_\u200C_NJ_; + } + ZW_\u200D_J(value) { + this.#ZW_\u200D_J = value; + return this.#ZW_\u200D_J_; + } + +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.$(1), 1); +assert.sameValue(c._(1), 1); +assert.sameValue(c.\u{6F}(1), 1); +assert.sameValue(c.\u2118(1), 1); +assert.sameValue(c.ZW_\u200C_NJ(1), 1); +assert.sameValue(c.ZW_\u200D_J(1), 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-rs-privatename-identifier-alt.js b/js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-rs-privatename-identifier-alt.js new file mode 100644 index 0000000000..71a5f0d71e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-rs-privatename-identifier-alt.js @@ -0,0 +1,110 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-privatename-identifier-alt.case +// - src/class-elements/productions/cls-decl-new-no-sc-line-method.template +/*--- +description: Valid PrivateName (field definitions followed by a method in a new line without a semicolon) +esid: prod-FieldDefinition +features: [class-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + #$; #_; #\u{6F}; #℘; #ZW_‌_NJ; #ZW_‍_J + m() { return 42; } + $(value) { + this.#$ = value; + return this.#$; + } + _(value) { + this.#_ = value; + return this.#_; + } + \u{6F}(value) { + this.#\u{6F} = value; + return this.#\u{6F}; + } + ℘(value) { + this.#℘ = value; + return this.#℘; + } + ZW_‌_NJ(value) { + this.#ZW_‌_NJ = value; + return this.#ZW_‌_NJ; + } + ZW_‍_J(value) { + this.#ZW_‍_J = value; + return this.#ZW_‍_J; + } +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.$(1), 1); +assert.sameValue(c._(1), 1); +assert.sameValue(c.\u{6F}(1), 1); +assert.sameValue(c.℘(1), 1); +assert.sameValue(c.ZW_‌_NJ(1), 1); +assert.sameValue(c.ZW_‍_J(1), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-rs-privatename-identifier-initializer-alt.js b/js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-rs-privatename-identifier-initializer-alt.js new file mode 100644 index 0000000000..6401ea1ada --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-rs-privatename-identifier-initializer-alt.js @@ -0,0 +1,104 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-privatename-identifier-initializer-alt.case +// - src/class-elements/productions/cls-decl-new-no-sc-line-method.template +/*--- +description: Valid PrivateName (field definitions followed by a method in a new line without a semicolon) +esid: prod-FieldDefinition +features: [class-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + #$ = 1; #_ = 1; #\u{6F} = 1; #℘ = 1; #ZW_‌_NJ = 1; #ZW_‍_J = 1 + m() { return 42; } + $() { + return this.#$; + } + _() { + return this.#_; + } + \u{6F}() { + return this.#\u{6F}; + } + ℘() { + return this.#℘; + } + ZW_‌_NJ() { + return this.#ZW_‌_NJ; + } + ZW_‍_J() { + return this.#ZW_‍_J; + } +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.$(), 1); +assert.sameValue(c._(), 1); +assert.sameValue(c.\u{6F}(), 1); +assert.sameValue(c.℘(), 1); +assert.sameValue(c.ZW_‌_NJ(), 1); +assert.sameValue(c.ZW_‍_J(), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-rs-privatename-identifier-initializer.js b/js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-rs-privatename-identifier-initializer.js new file mode 100644 index 0000000000..cddab94cb3 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-rs-privatename-identifier-initializer.js @@ -0,0 +1,104 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-privatename-identifier-initializer.case +// - src/class-elements/productions/cls-decl-new-no-sc-line-method.template +/*--- +description: Valid PrivateName (field definitions followed by a method in a new line without a semicolon) +esid: prod-FieldDefinition +features: [class-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + #$ = 1; #_ = 1; #\u{6F} = 1; #\u2118 = 1; #ZW_\u200C_NJ = 1; #ZW_\u200D_J = 1 + m() { return 42; } + $() { + return this.#$; + } + _() { + return this.#_; + } + \u{6F}() { + return this.#\u{6F}; + } + \u2118() { + return this.#\u2118; + } + ZW_\u200C_NJ() { + return this.#ZW_\u200C_NJ; + } + ZW_\u200D_J() { + return this.#ZW_\u200D_J; + } +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.$(), 1); +assert.sameValue(c._(), 1); +assert.sameValue(c.\u{6F}(), 1); +assert.sameValue(c.\u2118(), 1); +assert.sameValue(c.ZW_\u200C_NJ(), 1); +assert.sameValue(c.ZW_\u200D_J(), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-rs-privatename-identifier.js b/js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-rs-privatename-identifier.js new file mode 100644 index 0000000000..9cd8abddef --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-rs-privatename-identifier.js @@ -0,0 +1,110 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-privatename-identifier.case +// - src/class-elements/productions/cls-decl-new-no-sc-line-method.template +/*--- +description: Valid PrivateName (field definitions followed by a method in a new line without a semicolon) +esid: prod-FieldDefinition +features: [class-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + #$; #_; #\u{6F}; #\u2118; #ZW_\u200C_NJ; #ZW_\u200D_J + m() { return 42; } + $(value) { + this.#$ = value; + return this.#$; + } + _(value) { + this.#_ = value; + return this.#_; + } + \u{6F}(value) { + this.#\u{6F} = value; + return this.#\u{6F}; + } + \u2118(value) { + this.#\u2118 = value; + return this.#\u2118; + } + ZW_\u200C_NJ(value) { + this.#ZW_\u200C_NJ = value; + return this.#ZW_\u200C_NJ; + } + ZW_\u200D_J(value) { + this.#ZW_\u200D_J = value; + return this.#ZW_\u200D_J; + } +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.$(1), 1); +assert.sameValue(c._(1), 1); +assert.sameValue(c.\u{6F}(1), 1); +assert.sameValue(c.\u2118(1), 1); +assert.sameValue(c.ZW_\u200C_NJ(1), 1); +assert.sameValue(c.ZW_\u200D_J(1), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-rs-static-async-generator-method-privatename-identifier-alt.js b/js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-rs-static-async-generator-method-privatename-identifier-alt.js new file mode 100644 index 0000000000..1115796bfd --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-rs-static-async-generator-method-privatename-identifier-alt.js @@ -0,0 +1,135 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-async-generator-method-privatename-identifier-alt.case +// - src/class-elements/productions/cls-decl-new-no-sc-line-method.template +/*--- +description: Valid Static AsyncGeneratorMethod PrivateName (field definitions followed by a method in a new line without a semicolon) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + AsyncGeneratorMethod + + AsyncGeneratorMethod : + async [no LineTerminator here] * ClassElementName ( UniqueFormalParameters){ AsyncGeneratorBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static async * #$(value) { + yield * await value; + } + static async * #_(value) { + yield * await value; + } + static async * #o(value) { + yield * await value; + } + static async * #℘(value) { + yield * await value; + } + static async * #ZW_‌_NJ(value) { + yield * await value; + } + static async * #ZW_‍_J(value) { + yield * await value; + } + m() { return 42; } + static get $() { + return this.#$; + } + static get _() { + return this.#_; + } + static get o() { + return this.#o; + } + static get ℘() { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#℘; + } + static get ZW_‌_NJ() { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#ZW_‌_NJ; + } + static get ZW_‍_J() { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#ZW_‍_J; + } + +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +Promise.all([ + C.$([1]).next(), + C._([1]).next(), + C.o([1]).next(), + C.℘([1]).next(), // DO NOT CHANGE THE NAME OF THIS FIELD + C.ZW_‌_NJ([1]).next(), // DO NOT CHANGE THE NAME OF THIS FIELD + C.ZW_‍_J([1]).next(), // DO NOT CHANGE THE NAME OF THIS FIELD +]).then(results => { + + assert.sameValue(results[0].value, 1); + assert.sameValue(results[1].value, 1); + assert.sameValue(results[2].value, 1); + assert.sameValue(results[3].value, 1); + assert.sameValue(results[4].value, 1); + assert.sameValue(results[5].value, 1); + +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-rs-static-async-generator-method-privatename-identifier.js b/js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-rs-static-async-generator-method-privatename-identifier.js new file mode 100644 index 0000000000..01c5527c19 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-rs-static-async-generator-method-privatename-identifier.js @@ -0,0 +1,136 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-async-generator-method-privatename-identifier.case +// - src/class-elements/productions/cls-decl-new-no-sc-line-method.template +/*--- +description: Valid Static AsyncGeneratorMethod PrivateName (field definitions followed by a method in a new line without a semicolon) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + AsyncGeneratorMethod + + AsyncGeneratorMethod : + async [no LineTerminator here] * ClassElementName ( UniqueFormalParameters){ AsyncGeneratorBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static async * #$(value) { + yield * await value; + } + static async * #_(value) { + yield * await value; + } + static async * #\u{6F}(value) { + yield * await value; + } + static async * #\u2118(value) { + yield * await value; + } + static async * #ZW_\u200C_NJ(value) { + yield * await value; + } + static async * #ZW_\u200D_J(value) { + yield * await value; + } + m() { return 42; } + static get $() { + return this.#$; + } + static get _() { + return this.#_; + } + static get \u{6F}() { + return this.#\u{6F}; + } + static get \u2118() { + return this.#\u2118; + } + static get ZW_\u200C_NJ() { + return this.#ZW_\u200C_NJ; + } + static get ZW_\u200D_J() { + return this.#ZW_\u200D_J; + } + +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +Promise.all([ + C.$([1]).next(), + C._([1]).next(), + C.\u{6F}([1]).next(), + C.\u2118([1]).next(), + C.ZW_\u200C_NJ([1]).next(), + C.ZW_\u200D_J([1]).next(), +]).then(results => { + + assert.sameValue(results[0].value, 1); + assert.sameValue(results[1].value, 1); + assert.sameValue(results[2].value, 1); + assert.sameValue(results[3].value, 1); + assert.sameValue(results[4].value, 1); + assert.sameValue(results[5].value, 1); + +}).then($DONE, $DONE); + diff --git a/js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-rs-static-async-method-privatename-identifier-alt.js b/js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-rs-static-async-method-privatename-identifier-alt.js new file mode 100644 index 0000000000..6fb19f0e10 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-rs-static-async-method-privatename-identifier-alt.js @@ -0,0 +1,135 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-async-method-privatename-identifier-alt.case +// - src/class-elements/productions/cls-decl-new-no-sc-line-method.template +/*--- +description: Valid Static AsyncMethod PrivateName (field definitions followed by a method in a new line without a semicolon) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + AsyncMethod + + AsyncMethod : + async [no LineTerminator here] ClassElementName ( UniqueFormalParameters ){ AsyncFunctionBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static async #$(value) { + return await value; + } + static async #_(value) { + return await value; + } + static async #o(value) { + return await value; + } + static async #℘(value) { + return await value; + } + static async #ZW_‌_NJ(value) { + return await value; + } + static async #ZW_‍_J(value) { + return await value; + } + m() { return 42; } + static async $(value) { + return await this.#$(value); + } + static async _(value) { + return await this.#_(value); + } + static async o(value) { + return await this.#o(value); + } + static async ℘(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + return await this.#℘(value); + } + static async ZW_‌_NJ(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + return await this.#ZW_‌_NJ(value); + } + static async ZW_‍_J(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + return await this.#ZW_‍_J(value); + } + +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +Promise.all([ + C.$(1), + C._(1), + C.o(1), + C.℘(1), // DO NOT CHANGE THE NAME OF THIS FIELD + C.ZW_‌_NJ(1), // DO NOT CHANGE THE NAME OF THIS FIELD + C.ZW_‍_J(1), // DO NOT CHANGE THE NAME OF THIS FIELD +]).then(results => { + + assert.sameValue(results[0], 1); + assert.sameValue(results[1], 1); + assert.sameValue(results[2], 1); + assert.sameValue(results[3], 1); + assert.sameValue(results[4], 1); + assert.sameValue(results[5], 1); + +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-rs-static-async-method-privatename-identifier.js b/js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-rs-static-async-method-privatename-identifier.js new file mode 100644 index 0000000000..2fedbcc4e9 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-rs-static-async-method-privatename-identifier.js @@ -0,0 +1,136 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-async-method-privatename-identifier.case +// - src/class-elements/productions/cls-decl-new-no-sc-line-method.template +/*--- +description: Valid Static AsyncMethod PrivateName (field definitions followed by a method in a new line without a semicolon) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + AsyncMethod + + AsyncMethod : + async [no LineTerminator here] ClassElementName ( UniqueFormalParameters ){ AsyncFunctionBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static async #$(value) { + return await value; + } + static async #_(value) { + return await value; + } + static async #\u{6F}(value) { + return await value; + } + static async #\u2118(value) { + return await value; + } + static async #ZW_\u200C_NJ(value) { + return await value; + } + static async #ZW_\u200D_J(value) { + return await value; + } + m() { return 42; } + static async $(value) { + return await this.#$(value); + } + static async _(value) { + return await this.#_(value); + } + static async \u{6F}(value) { + return await this.#\u{6F}(value); + } + static async \u2118(value) { + return await this.#\u2118(value); + } + static async ZW_\u200C_NJ(value) { + return await this.#ZW_\u200C_NJ(value); + } + static async ZW_\u200D_J(value) { + return await this.#ZW_\u200D_J(value); + } + +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +Promise.all([ + C.$(1), + C._(1), + C.\u{6F}(1), + C.\u2118(1), + C.ZW_\u200C_NJ(1), + C.ZW_\u200D_J(1), +]).then(results => { + + assert.sameValue(results[0], 1); + assert.sameValue(results[1], 1); + assert.sameValue(results[2], 1); + assert.sameValue(results[3], 1); + assert.sameValue(results[4], 1); + assert.sameValue(results[5], 1); + +}).then($DONE, $DONE); + diff --git a/js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-rs-static-generator-method-privatename-identifier-alt.js b/js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-rs-static-generator-method-privatename-identifier-alt.js new file mode 100644 index 0000000000..3db89f438d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-rs-static-generator-method-privatename-identifier-alt.js @@ -0,0 +1,125 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-generator-method-privatename-identifier-alt.case +// - src/class-elements/productions/cls-decl-new-no-sc-line-method.template +/*--- +description: Valid Static GeneratorMethod PrivateName (field definitions followed by a method in a new line without a semicolon) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + GeneratorMethod + + GeneratorMethod : + * ClassElementName ( UniqueFormalParameters ){ GeneratorBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static * #$(value) { + yield * value; + } + static * #_(value) { + yield * value; + } + static * #o(value) { + yield * value; + } + static * #℘(value) { + yield * value; + } + static * #ZW_‌_NJ(value) { + yield * value; + } + static * #ZW_‍_J(value) { + yield * value; + } + m() { return 42; } + static get $() { + return this.#$; + } + static get _() { + return this.#_; + } + static get o() { + return this.#o; + } + static get ℘() { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#℘; + } + static get ZW_‌_NJ() { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#ZW_‌_NJ; + } + static get ZW_‍_J() { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#ZW_‍_J; + } + +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(C.$([1]).next().value, 1); +assert.sameValue(C._([1]).next().value, 1); +assert.sameValue(C.o([1]).next().value, 1); +assert.sameValue(C.℘([1]).next().value, 1); +assert.sameValue(C.ZW_‌_NJ([1]).next().value, 1); +assert.sameValue(C.ZW_‍_J([1]).next().value, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-rs-static-generator-method-privatename-identifier.js b/js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-rs-static-generator-method-privatename-identifier.js new file mode 100644 index 0000000000..b65b950b05 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-rs-static-generator-method-privatename-identifier.js @@ -0,0 +1,126 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-generator-method-privatename-identifier.case +// - src/class-elements/productions/cls-decl-new-no-sc-line-method.template +/*--- +description: Valid Static GeneratorMethod PrivateName (field definitions followed by a method in a new line without a semicolon) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + GeneratorMethod + + GeneratorMethod : + * ClassElementName ( UniqueFormalParameters ){ GeneratorBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static * #$(value) { + yield * value; + } + static * #_(value) { + yield * value; + } + static * #\u{6F}(value) { + yield * value; + } + static * #\u2118(value) { + yield * value; + } + static * #ZW_\u200C_NJ(value) { + yield * value; + } + static * #ZW_\u200D_J(value) { + yield * value; + } + m() { return 42; } + static get $() { + return this.#$; + } + static get _() { + return this.#_; + } + static get \u{6F}() { + return this.#\u{6F}; + } + static get \u2118() { + return this.#\u2118; + } + static get ZW_\u200C_NJ() { + return this.#ZW_\u200C_NJ; + } + static get ZW_\u200D_J() { + return this.#ZW_\u200D_J; + } + +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(C.$([1]).next().value, 1); +assert.sameValue(C._([1]).next().value, 1); +assert.sameValue(C.\u{6F}([1]).next().value, 1); +assert.sameValue(C.\u2118([1]).next().value, 1); +assert.sameValue(C.ZW_\u200C_NJ([1]).next().value, 1); +assert.sameValue(C.ZW_\u200D_J([1]).next().value, 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-rs-static-method-privatename-identifier-alt.js b/js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-rs-static-method-privatename-identifier-alt.js new file mode 100644 index 0000000000..f60b0ac875 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-rs-static-method-privatename-identifier-alt.js @@ -0,0 +1,123 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-method-privatename-identifier-alt.case +// - src/class-elements/productions/cls-decl-new-no-sc-line-method.template +/*--- +description: Valid Static Method PrivateName (field definitions followed by a method in a new line without a semicolon) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + ClassElementName ( UniqueFormalParameters ){ FunctionBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static #$(value) { + return value; + } + static #_(value) { + return value; + } + static #o(value) { + return value; + } + static #℘(value) { + return value; + } + static #ZW_‌_NJ(value) { + return value; + } + static #ZW_‍_J(value) { + return value; + } + m() { return 42; } + static $(value) { + return this.#$(value); + } + static _(value) { + return this.#_(value); + } + static o(value) { + return this.#o(value); + } + static ℘(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#℘(value); + } + static ZW_‌_NJ(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#ZW_‌_NJ(value); + } + static ZW_‍_J(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#ZW_‍_J(value); + } + +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(C.$(1), 1); +assert.sameValue(C._(1), 1); +assert.sameValue(C.o(1), 1); +assert.sameValue(C.℘(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD +assert.sameValue(C.ZW_‌_NJ(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD +assert.sameValue(C.ZW_‍_J(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-rs-static-method-privatename-identifier.js b/js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-rs-static-method-privatename-identifier.js new file mode 100644 index 0000000000..f5bf797fff --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-rs-static-method-privatename-identifier.js @@ -0,0 +1,123 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-method-privatename-identifier.case +// - src/class-elements/productions/cls-decl-new-no-sc-line-method.template +/*--- +description: Valid Static Method PrivateName (field definitions followed by a method in a new line without a semicolon) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + ClassElementName ( UniqueFormalParameters ){ FunctionBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static #$(value) { + return value; + } + static #_(value) { + return value; + } + static #\u{6F}(value) { + return value; + } + static #\u2118(value) { + return value; + } + static #ZW_\u200C_NJ(value) { + return value; + } + static #ZW_\u200D_J(value) { + return value; + } + m() { return 42; } + static $(value) { + return this.#$(value); + } + static _(value) { + return this.#_(value); + } + static \u{6F}(value) { + return this.#\u{6F}(value); + } + static \u2118(value) { + return this.#\u2118(value); + } + static ZW_\u200C_NJ(value) { + return this.#ZW_\u200C_NJ(value); + } + static ZW_\u200D_J(value) { + return this.#ZW_\u200D_J(value); + } + +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(C.$(1), 1); +assert.sameValue(C._(1), 1); +assert.sameValue(C.\u{6F}(1), 1); +assert.sameValue(C.\u2118(1), 1); +assert.sameValue(C.ZW_\u200C_NJ(1), 1); +assert.sameValue(C.ZW_\u200D_J(1), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-rs-static-privatename-identifier-alt-by-classname.js b/js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-rs-static-privatename-identifier-alt-by-classname.js new file mode 100644 index 0000000000..4b82b013c9 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-rs-static-privatename-identifier-alt-by-classname.js @@ -0,0 +1,111 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-privatename-identifier-alt-by-classname.case +// - src/class-elements/productions/cls-decl-new-no-sc-line-method.template +/*--- +description: Valid Static PrivateName (field definitions followed by a method in a new line without a semicolon) +esid: prod-FieldDefinition +features: [class-static-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static #$; static #_; static #\u{6F}; static #℘; static #ZW_‌_NJ; static #ZW_‍_J + m() { return 42; } + static $(value) { + C.#$ = value; + return C.#$; + } + static _(value) { + C.#_ = value; + return C.#_; + } + static o(value) { + C.#\u{6F} = value; + return C.#\u{6F}; + } + static ℘(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + C.#℘ = value; + return C.#℘; + } + static ZW_‌_NJ(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + C.#ZW_‌_NJ = value; + return C.#ZW_‌_NJ; + } + static ZW_‍_J(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + C.#ZW_‍_J = value; + return C.#ZW_‍_J; + } +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(C.$(1), 1); +assert.sameValue(C._(1), 1); +assert.sameValue(C.o(1), 1); +assert.sameValue(C.℘(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD +assert.sameValue(C.ZW_‌_NJ(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD +assert.sameValue(C.ZW_‍_J(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-rs-static-privatename-identifier-alt.js b/js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-rs-static-privatename-identifier-alt.js new file mode 100644 index 0000000000..47b387cfb6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-rs-static-privatename-identifier-alt.js @@ -0,0 +1,111 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-privatename-identifier-alt.case +// - src/class-elements/productions/cls-decl-new-no-sc-line-method.template +/*--- +description: Valid Static PrivateName (field definitions followed by a method in a new line without a semicolon) +esid: prod-FieldDefinition +features: [class-static-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static #$; static #_; static #\u{6F}; static #℘; static #ZW_‌_NJ; static #ZW_‍_J + m() { return 42; } + static $(value) { + this.#$ = value; + return this.#$; + } + static _(value) { + this.#_ = value; + return this.#_; + } + static o(value) { + this.#\u{6F} = value; + return this.#\u{6F}; + } + static ℘(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + this.#℘ = value; + return this.#℘; + } + static ZW_‌_NJ(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + this.#ZW_‌_NJ = value; + return this.#ZW_‌_NJ; + } + static ZW_‍_J(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + this.#ZW_‍_J = value; + return this.#ZW_‍_J; + } +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(C.$(1), 1); +assert.sameValue(C._(1), 1); +assert.sameValue(C.o(1), 1); +assert.sameValue(C.℘(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD +assert.sameValue(C.ZW_‌_NJ(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD +assert.sameValue(C.ZW_‍_J(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-rs-static-privatename-identifier-by-classname.js b/js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-rs-static-privatename-identifier-by-classname.js new file mode 100644 index 0000000000..0e2b75505c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-rs-static-privatename-identifier-by-classname.js @@ -0,0 +1,111 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-privatename-identifier-by-classname.case +// - src/class-elements/productions/cls-decl-new-no-sc-line-method.template +/*--- +description: Valid Static PrivateName (field definitions followed by a method in a new line without a semicolon) +esid: prod-FieldDefinition +features: [class-static-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static #$; static #_; static #\u{6F}; static #\u2118; static #ZW_\u200C_NJ; static #ZW_\u200D_J + m() { return 42; } + static $(value) { + C.#$ = value; + return C.#$; + } + static _(value) { + C.#_ = value; + return C.#_; + } + static \u{6F}(value) { + C.#\u{6F} = value; + return C.#\u{6F}; + } + static \u2118(value) { + C.#\u2118 = value; + return C.#\u2118; + } + static ZW_\u200C_NJ(value) { + C.#ZW_\u200C_NJ = value; + return C.#ZW_\u200C_NJ; + } + static ZW_\u200D_J(value) { + C.#ZW_\u200D_J = value; + return C.#ZW_\u200D_J; + } +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(C.$(1), 1); +assert.sameValue(C._(1), 1); +assert.sameValue(C.\u{6F}(1), 1); +assert.sameValue(C.\u2118(1), 1); +assert.sameValue(C.ZW_\u200C_NJ(1), 1); +assert.sameValue(C.ZW_\u200D_J(1), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-rs-static-privatename-identifier-initializer-alt-by-classname.js b/js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-rs-static-privatename-identifier-initializer-alt-by-classname.js new file mode 100644 index 0000000000..932cab6817 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-rs-static-privatename-identifier-initializer-alt-by-classname.js @@ -0,0 +1,105 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-privatename-identifier-initializer-alt-by-classname.case +// - src/class-elements/productions/cls-decl-new-no-sc-line-method.template +/*--- +description: Valid Static PrivateName (field definitions followed by a method in a new line without a semicolon) +esid: prod-FieldDefinition +features: [class-static-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static #$ = 1; static #_ = 1; static #\u{6F} = 1; static #℘ = 1; static #ZW_‌_NJ = 1; static #ZW_‍_J = 1 + m() { return 42; } + static $() { + return C.#$; + } + static _() { + return C.#_; + } + static \u{6F}() { + return C.#\u{6F}; + } + static ℘() { + return C.#℘; + } + static ZW_‌_NJ() { + return C.#ZW_‌_NJ; + } + static ZW_‍_J() { + return C.#ZW_‍_J; + } +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(C.$(), 1); +assert.sameValue(C._(), 1); +assert.sameValue(C.\u{6F}(), 1); +assert.sameValue(C.℘(), 1); +assert.sameValue(C.ZW_‌_NJ(), 1); +assert.sameValue(C.ZW_‍_J(), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-rs-static-privatename-identifier-initializer-alt.js b/js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-rs-static-privatename-identifier-initializer-alt.js new file mode 100644 index 0000000000..0fd537d010 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-rs-static-privatename-identifier-initializer-alt.js @@ -0,0 +1,105 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-privatename-identifier-initializer-alt.case +// - src/class-elements/productions/cls-decl-new-no-sc-line-method.template +/*--- +description: Valid Static PrivateName (field definitions followed by a method in a new line without a semicolon) +esid: prod-FieldDefinition +features: [class-static-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static #$ = 1; static #_ = 1; static #\u{6F} = 1; static #℘ = 1; static #ZW_‌_NJ = 1; static #ZW_‍_J = 1 + m() { return 42; } + static $() { + return this.#$; + } + static _() { + return this.#_; + } + static \u{6F}() { + return this.#\u{6F}; + } + static ℘() { + return this.#℘; + } + static ZW_‌_NJ() { + return this.#ZW_‌_NJ; + } + static ZW_‍_J() { + return this.#ZW_‍_J; + } +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(C.$(), 1); +assert.sameValue(C._(), 1); +assert.sameValue(C.\u{6F}(), 1); +assert.sameValue(C.℘(), 1); +assert.sameValue(C.ZW_‌_NJ(), 1); +assert.sameValue(C.ZW_‍_J(), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-rs-static-privatename-identifier-initializer.js b/js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-rs-static-privatename-identifier-initializer.js new file mode 100644 index 0000000000..6c7ca87eac --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-rs-static-privatename-identifier-initializer.js @@ -0,0 +1,105 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-privatename-identifier-initializer.case +// - src/class-elements/productions/cls-decl-new-no-sc-line-method.template +/*--- +description: Valid Static PrivateName (field definitions followed by a method in a new line without a semicolon) +esid: prod-FieldDefinition +features: [class-static-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static #$ = 1; static #_ = 1; static #\u{6F} = 1; static #\u2118 = 1; static #ZW_\u200C_NJ = 1; static #ZW_\u200D_J = 1 + m() { return 42; } + static $() { + return this.#$; + } + static _() { + return this.#_; + } + static \u{6F}() { + return this.#\u{6F}; + } + static \u2118() { + return this.#\u2118; + } + static ZW_\u200C_NJ() { + return this.#ZW_\u200C_NJ; + } + static ZW_\u200D_J() { + return this.#ZW_\u200D_J; + } +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(C.$(), 1); +assert.sameValue(C._(), 1); +assert.sameValue(C.\u{6F}(), 1); +assert.sameValue(C.\u2118(), 1); +assert.sameValue(C.ZW_\u200C_NJ(), 1); +assert.sameValue(C.ZW_\u200D_J(), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-rs-static-privatename-identifier.js b/js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-rs-static-privatename-identifier.js new file mode 100644 index 0000000000..a275dbeeee --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-rs-static-privatename-identifier.js @@ -0,0 +1,111 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-privatename-identifier.case +// - src/class-elements/productions/cls-decl-new-no-sc-line-method.template +/*--- +description: Valid Static PrivateName (field definitions followed by a method in a new line without a semicolon) +esid: prod-FieldDefinition +features: [class-static-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static #$; static #_; static #\u{6F}; static #\u2118; static #ZW_\u200C_NJ; static #ZW_\u200D_J + m() { return 42; } + static $(value) { + this.#$ = value; + return this.#$; + } + static _(value) { + this.#_ = value; + return this.#_; + } + static \u{6F}(value) { + this.#\u{6F} = value; + return this.#\u{6F}; + } + static \u2118(value) { + this.#\u2118 = value; + return this.#\u2118; + } + static ZW_\u200C_NJ(value) { + this.#ZW_\u200C_NJ = value; + return this.#ZW_\u200C_NJ; + } + static ZW_\u200D_J(value) { + this.#ZW_\u200D_J = value; + return this.#ZW_\u200D_J; + } +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(C.$(1), 1); +assert.sameValue(C._(1), 1); +assert.sameValue(C.\u{6F}(1), 1); +assert.sameValue(C.\u2118(1), 1); +assert.sameValue(C.ZW_\u200C_NJ(1), 1); +assert.sameValue(C.ZW_\u200D_J(1), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-static-private-fields.js b/js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-static-private-fields.js new file mode 100644 index 0000000000..6c01d01493 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-static-private-fields.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/static-private-fields.case +// - src/class-elements/productions/cls-decl-new-no-sc-line-method.template +/*--- +description: static private fields (field definitions followed by a method in a new line without a semicolon) +esid: prod-FieldDefinition +features: [class-static-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + ... + static FieldDefinition ; + + FieldDefinition : + ClassElementName Initializer_opt + + ClassElementName : + PrivateName + + PrivateName : + # IdentifierName + +---*/ + + +class C { + static #x; static #y + m() { return 42; } + static x() { + this.#x = 42; + return this.#x; + } + static y() { + this.#y = 43; + return this.#y; + } +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +// Test the private fields do not appear as properties before set to value +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#x"), "test 1"); +assert(!Object.prototype.hasOwnProperty.call(C, "#x"), "test 2"); +assert(!Object.prototype.hasOwnProperty.call(c, "#x"), "test 3"); + +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#y"), "test 4"); +assert(!Object.prototype.hasOwnProperty.call(C, "#y"), "test 5"); +assert(!Object.prototype.hasOwnProperty.call(c, "#y"), "test 6"); + +// Test if private fields can be sucessfully accessed and set to value +assert.sameValue(C.x(), 42, "test 7"); +assert.sameValue(C.y(), 43, "test 8"); + +// Test the private fields do not appear as properties before after set to value +assert(!Object.prototype.hasOwnProperty.call(C, "#x"), "test 9"); +assert(!Object.prototype.hasOwnProperty.call(C, "#y"), "test 10"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-static-private-methods-with-fields.js b/js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-static-private-methods-with-fields.js new file mode 100644 index 0000000000..ea43ef6308 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-static-private-methods-with-fields.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/static-private-methods-with-fields.case +// - src/class-elements/productions/cls-decl-new-no-sc-line-method.template +/*--- +description: static private methods with fields (field definitions followed by a method in a new line without a semicolon) +esid: prod-FieldDefinition +features: [class-static-methods-private, class-static-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + ... + static FieldDefinition ; + + FieldDefinition : + ClassElementName Initializer_opt + + ClassElementName : + PrivateName + + PrivateName : + # IdentifierName + +---*/ + + +class C { + static #xVal; static #yVal + m() { return 42; } + static #x(value) { + this.#xVal = value; + return this.#xVal; + } + static #y(value) { + this.#yVal = value; + return this.#yVal; + } + static x() { + return this.#x(42); + } + static y() { + return this.#y(43); + } +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +// Test the private methods do not appear as properties before set to value +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#x"), "test 1"); +assert(!Object.prototype.hasOwnProperty.call(C, "#x"), "test 2"); +assert(!Object.prototype.hasOwnProperty.call(c, "#x"), "test 3"); + +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#y"), "test 4"); +assert(!Object.prototype.hasOwnProperty.call(C, "#y"), "test 5"); +assert(!Object.prototype.hasOwnProperty.call(c, "#y"), "test 6"); + +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#xVal"), "test 7"); +assert(!Object.prototype.hasOwnProperty.call(C, "#xVal"), "test 8"); +assert(!Object.prototype.hasOwnProperty.call(c, "#xVal"), "test 9"); + +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#yVal"), "test 10"); +assert(!Object.prototype.hasOwnProperty.call(C, "#yVal"), "test 11"); +assert(!Object.prototype.hasOwnProperty.call(c, "#yVal"), "test 12"); + +// Test if private fields can be sucessfully accessed and set to value +assert.sameValue(C.x(), 42, "test 13"); +assert.sameValue(C.y(), 43, "test 14"); + +// Test the private fields do not appear as properties before after set to value +assert(!Object.prototype.hasOwnProperty.call(C, "#x"), "test 15"); +assert(!Object.prototype.hasOwnProperty.call(C, "#y"), "test 16"); + +assert(!Object.prototype.hasOwnProperty.call(C, "#xVal"), "test 17"); +assert(!Object.prototype.hasOwnProperty.call(C, "#yVal"), "test 18"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-static-private-methods.js b/js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-static-private-methods.js new file mode 100644 index 0000000000..a1368e60ad --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-static-private-methods.js @@ -0,0 +1,76 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/static-private-methods.case +// - src/class-elements/productions/cls-decl-new-no-sc-line-method.template +/*--- +description: static private methods (field definitions followed by a method in a new line without a semicolon) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + ... + static FieldDefinition ; + + FieldDefinition : + ClassElementName Initializer_opt + + ClassElementName : + PrivateName + + PrivateName : + # IdentifierName + +---*/ + + +class C { + + m() { return 42; } + static #x(value) { + return value / 2; + } + static #y(value) { + return value * 2; + } + static x() { + return this.#x(84); + } + static y() { + return this.#y(43); + } +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +// Test the private methods do not appear as properties before set to value +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#x"), "test 1"); +assert(!Object.prototype.hasOwnProperty.call(C, "#x"), "test 2"); +assert(!Object.prototype.hasOwnProperty.call(c, "#x"), "test 3"); + +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#y"), "test 4"); +assert(!Object.prototype.hasOwnProperty.call(C, "#y"), "test 5"); +assert(!Object.prototype.hasOwnProperty.call(c, "#y"), "test 6"); + +// Test if private fields can be sucessfully accessed and set to value +assert.sameValue(C.x(), 42, "test 7"); +assert.sameValue(C.y(), 86, "test 8"); + +// Test the private fields do not appear as properties before after set to value +assert(!Object.prototype.hasOwnProperty.call(C, "#x"), "test 9"); +assert(!Object.prototype.hasOwnProperty.call(C, "#y"), "test 10"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-string-literal-names.js b/js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-string-literal-names.js new file mode 100644 index 0000000000..1d90148868 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/new-no-sc-line-method-string-literal-names.js @@ -0,0 +1,110 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/string-literal-names.case +// - src/class-elements/productions/cls-decl-new-no-sc-line-method.template +/*--- +description: String literal names (field definitions followed by a method in a new line without a semicolon) +esid: prod-FieldDefinition +features: [class-fields-public, class] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PropertyName + +---*/ + + +class C { + 'a'; "b"; 'c' = 39; + "d" = 42 + m() { return 42; } + +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "a"), + "a does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "a"), + "a does not appear as an own property on C constructor" +); + +verifyProperty(c, "a", { + value: undefined, + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "b"), + "b does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "b"), + "b does not appear as an own property on C constructor" +); + +verifyProperty(c, "b", { + value: undefined, + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "c"), + "c does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "c"), + "c does not appear as an own property on C constructor" +); + +verifyProperty(c, "c", { + value: 39, + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "d"), + "d does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "d"), + "d does not appear as an own property on C constructor" +); + +verifyProperty(c, "d", { + value: 42, + enumerable: true, + writable: true, + configurable: true +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-computed-names.js b/js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-computed-names.js new file mode 100644 index 0000000000..0d162e255e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-computed-names.js @@ -0,0 +1,108 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/computed-names.case +// - src/class-elements/productions/cls-decl-new-sc-line-generator.template +/*--- +description: Computed property names (field definitions followed by a method in a new line with a semicolon) +esid: prod-FieldDefinition +features: [class-fields-public, computed-property-names, class, generators] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PropertyName + +---*/ +var x = "b"; + + + +class C { + [x] = 42; [10] = "meep"; ["not initialized"]; + *m() { return 42; } + +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "b"), + "b doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "b"), + "b doesn't appear as an own property on C constructor" +); + +verifyProperty(c, "b", { + value: 42, + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "x"), + "x doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "x"), + "x doesn't appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "x"), + "x doesn't appear as an own property on C instance" +); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "10"), + "10 doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "10"), + "10 doesn't appear as an own property on C constructor" +); + +verifyProperty(c, "10", { + value: "meep", + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "not initialized"), + "'not initialized' doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "not initialized"), + "'not initialized' doesn't appear as an own property on C constructor" +); + +verifyProperty(c, "not initialized", { + value: undefined, + enumerable: true, + writable: true, + configurable: true +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-computed-symbol-names.js b/js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-computed-symbol-names.js new file mode 100644 index 0000000000..7dc9395d6e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-computed-symbol-names.js @@ -0,0 +1,106 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/computed-symbol-names.case +// - src/class-elements/productions/cls-decl-new-sc-line-generator.template +/*--- +description: Computed property symbol names (field definitions followed by a method in a new line with a semicolon) +esid: prod-FieldDefinition +features: [class-fields-public, Symbol, computed-property-names, class, generators] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PropertyName + +---*/ +var x = Symbol(); +var y = Symbol(); + + + +class C { + [x]; [y] = 42; + *m() { return 42; } + +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, x), + "Symbol x doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, x), + "Symbol x doesn't appear as an own property on C constructor" +); + +verifyProperty(c, x, { + value: undefined, + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, y), + "Symbol y doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, y), + "Symbol y doesn't appear as an own property on C constructor" +); + +verifyProperty(c, y, { + value: 42, + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "x"), + "x doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "x"), + "x doesn't appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "x"), + "x doesn't appear as an own property on C instance" +); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "y"), + "y doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "y"), + "y doesn't appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "y"), + "y doesn't appear as an own property on C instance" +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-grammar-privatename-identifier-semantics-stringvalue.js b/js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-grammar-privatename-identifier-semantics-stringvalue.js new file mode 100644 index 0000000000..026640d37a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-grammar-privatename-identifier-semantics-stringvalue.js @@ -0,0 +1,110 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-privatename-identifier-semantics-stringvalue.case +// - src/class-elements/productions/cls-decl-new-sc-line-generator.template +/*--- +description: PrivateName Static Semantics, StringValue (field definitions followed by a method in a new line with a semicolon) +esid: prod-FieldDefinition +features: [class-fields-private, class, class-fields-public, generators] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + + + 1. Return the String value consisting of the sequence of code + units corresponding to PrivateName. In determining the sequence + any occurrences of \ UnicodeEscapeSequence are first replaced + with the code point represented by the UnicodeEscapeSequence + and then the code points of the entire PrivateName are converted + to code units by UTF16Encoding (10.1.1) each code point. + +---*/ + + +class C { + #\u{6F}; + #\u2118; + #ZW_\u200C_NJ; + #ZW_\u200D_J;; + *m() { return 42; } + o(value) { + this.#o = value; + return this.#o; + } + ℘(value) { + this.#℘ = value; + return this.#℘; + } + ZW_‌_NJ(value) { // DO NOT CHANGE THE NAME OF THIS METHOD + this.#ZW_‌_NJ = value; + return this.#ZW_‌_NJ; + } + ZW_‍_J(value) { // DO NOT CHANGE THE NAME OF THIS METHOD + this.#ZW_‍_J = value; + return this.#ZW_‍_J; + } +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.o(1), 1); +assert.sameValue(c.℘(1), 1); +assert.sameValue(c.ZW_‌_NJ(1), 1); +assert.sameValue(c.ZW_‍_J(1), 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-literal-names-asi.js b/js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-literal-names-asi.js new file mode 100644 index 0000000000..a5d140da93 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-literal-names-asi.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/literal-names-asi.case +// - src/class-elements/productions/cls-decl-new-sc-line-generator.template +/*--- +description: Literal property names with ASI (field definitions followed by a method in a new line with a semicolon) +esid: prod-FieldDefinition +features: [class-fields-public, class, generators] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PropertyName + +---*/ + + +class C { + a + b = 42;; + *m() { return 42; } + +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "a"), + "a doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "a"), + "a doesn't appear as an own property on C constructor" +); + +verifyProperty(c, "a", { + value: undefined, + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "b"), + "b doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "b"), + "b doesn't appear as an own property on C constructor" +); + +verifyProperty(c, "b", { + value: 42, + enumerable: true, + writable: true, + configurable: true +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-literal-names.js b/js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-literal-names.js new file mode 100644 index 0000000000..2725d067a6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-literal-names.js @@ -0,0 +1,97 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/literal-names.case +// - src/class-elements/productions/cls-decl-new-sc-line-generator.template +/*--- +description: Literal property names (field definitions followed by a method in a new line with a semicolon) +esid: prod-FieldDefinition +features: [class-fields-public, class, generators] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PropertyName + +---*/ +const fn = function() {} + + + +class C { + a; b = 42; + c = fn; + *m() { return 42; } + +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "a"), + "a doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "a"), + "a doesn't appear as an own property on C constructor" +); + +verifyProperty(c, "a", { + value: undefined, + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "b"), + "b doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "b"), + "b doesn't appear as an own property on C constructor" +); + +verifyProperty(c, "b", { + value: 42, + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "c"), + "c doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "c"), + "c doesn't appear as an own property on C constructor" +); + +verifyProperty(c, "c", { + value: fn, + enumerable: true, + writable: true, + configurable: true +}); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-private-field-usage.js b/js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-private-field-usage.js new file mode 100644 index 0000000000..81e3a294de --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-private-field-usage.js @@ -0,0 +1,50 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/private-field-usage.case +// - src/class-elements/productions/cls-decl-new-sc-line-generator.template +/*--- +description: PrivateName CallExpression usage (private field) (field definitions followed by a method in a new line with a semicolon) +esid: prod-FieldDefinition +features: [class-fields-private, class, class-fields-public, generators] +flags: [generated] +includes: [propertyHelper.js] +info: | + Updated Productions + + CallExpression[Yield, Await]: + CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await] + SuperCall[?Yield, ?Await] + CallExpression[?Yield, ?Await]Arguments[?Yield, ?Await] + CallExpression[?Yield, ?Await][Expression[+In, ?Yield, ?Await]] + CallExpression[?Yield, ?Await].IdentifierName + CallExpression[?Yield, ?Await]TemplateLiteral[?Yield, ?Await] + CallExpression[?Yield, ?Await].PrivateName + +---*/ + + +class C { + #m = 'test262';; + *m() { return 42; } + method() { + return this.#m; + } +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.method(), 'test262'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-private-method-getter-usage.js b/js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-private-method-getter-usage.js new file mode 100644 index 0000000000..7cfb03aad9 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-private-method-getter-usage.js @@ -0,0 +1,50 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/private-method-getter-usage.case +// - src/class-elements/productions/cls-decl-new-sc-line-generator.template +/*--- +description: PrivateName CallExpression usage (Accesor get method) (field definitions followed by a method in a new line with a semicolon) +esid: prod-FieldDefinition +features: [class-methods-private, class, class-fields-public, generators] +flags: [generated] +includes: [propertyHelper.js] +info: | + Updated Productions + + CallExpression[Yield, Await]: + CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await] + SuperCall[?Yield, ?Await] + CallExpression[?Yield, ?Await]Arguments[?Yield, ?Await] + CallExpression[?Yield, ?Await][Expression[+In, ?Yield, ?Await]] + CallExpression[?Yield, ?Await].IdentifierName + CallExpression[?Yield, ?Await]TemplateLiteral[?Yield, ?Await] + CallExpression[?Yield, ?Await].PrivateName + +---*/ + + +class C { + get #m() { return 'test262'; }; + *m() { return 42; } + method() { + return this.#m; + } +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.method(), 'test262'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-private-method-usage.js b/js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-private-method-usage.js new file mode 100644 index 0000000000..ed69bf33f0 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-private-method-usage.js @@ -0,0 +1,50 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/private-method-usage.case +// - src/class-elements/productions/cls-decl-new-sc-line-generator.template +/*--- +description: PrivateName CallExpression usage (private method) (field definitions followed by a method in a new line with a semicolon) +esid: prod-FieldDefinition +features: [class-methods-private, class, class-fields-public, generators] +flags: [generated] +includes: [propertyHelper.js] +info: | + Updated Productions + + CallExpression[Yield, Await]: + CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await] + SuperCall[?Yield, ?Await] + CallExpression[?Yield, ?Await]Arguments[?Yield, ?Await] + CallExpression[?Yield, ?Await][Expression[+In, ?Yield, ?Await]] + CallExpression[?Yield, ?Await].IdentifierName + CallExpression[?Yield, ?Await]TemplateLiteral[?Yield, ?Await] + CallExpression[?Yield, ?Await].PrivateName + +---*/ + + +class C { + #m() { return 'test262'; }; + *m() { return 42; } + method() { + return this.#m(); + } +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.method(), 'test262'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-private-names.js b/js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-private-names.js new file mode 100644 index 0000000000..939372768d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-private-names.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/private-names.case +// - src/class-elements/productions/cls-decl-new-sc-line-generator.template +/*--- +description: private names (field definitions followed by a method in a new line with a semicolon) +esid: prod-FieldDefinition +features: [class-fields-private, class, class-fields-public, generators] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + ... + FieldDefinition ; + + FieldDefinition : + ClassElementName Initializer_opt + + ClassElementName : + PrivateName + + PrivateName : + # IdentifierName + +---*/ + + +class C { + #x; #y; + *m() { return 42; } + x() { + this.#x = 42; + return this.#x; + } + y() { + this.#y = 43; + return this.#y; + } +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +// Test the private fields do not appear as properties before set to value +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#x"), "test 1"); +assert(!Object.prototype.hasOwnProperty.call(C, "#x"), "test 2"); +assert(!Object.prototype.hasOwnProperty.call(c, "#x"), "test 3"); + +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#y"), "test 4"); +assert(!Object.prototype.hasOwnProperty.call(C, "#y"), "test 5"); +assert(!Object.prototype.hasOwnProperty.call(c, "#y"), "test 6"); + +// Test if private fields can be sucessfully accessed and set to value +assert.sameValue(c.x(), 42, "test 7"); +assert.sameValue(c.y(), 43, "test 8"); + +// Test the private fields do not appear as properties before after set to value +assert(!Object.prototype.hasOwnProperty.call(c, "#x"), "test 9"); +assert(!Object.prototype.hasOwnProperty.call(c, "#y"), "test 10"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-rs-field-identifier-initializer.js b/js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-rs-field-identifier-initializer.js new file mode 100644 index 0000000000..2dc3866901 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-rs-field-identifier-initializer.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-field-identifier-initializer.case +// - src/class-elements/productions/cls-decl-new-sc-line-generator.template +/*--- +description: Valid FieldDefinition (field definitions followed by a method in a new line with a semicolon) +esid: prod-FieldDefinition +features: [class-fields-public, class, generators] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + ... + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + + PropertyName : + LiteralPropertyName + ComputedPropertyName + + LiteralPropertyName : + IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + $ = 1; _ = 1; \u{6F} = 1; \u2118 = 1; ZW_\u200C_NJ = 1; ZW_\u200D_J = 1; + *m() { return 42; } + +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.$, 1); +assert.sameValue(c._, 1); +assert.sameValue(c.\u{6F}, 1); +assert.sameValue(c.\u2118, 1); +assert.sameValue(c.ZW_\u200C_NJ, 1); +assert.sameValue(c.ZW_\u200D_J, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-rs-field-identifier.js b/js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-rs-field-identifier.js new file mode 100644 index 0000000000..71d68269be --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-rs-field-identifier.js @@ -0,0 +1,95 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-field-identifier.case +// - src/class-elements/productions/cls-decl-new-sc-line-generator.template +/*--- +description: Valid FieldDefinition (field definitions followed by a method in a new line with a semicolon) +esid: prod-FieldDefinition +features: [class-fields-public, class, generators] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + ... + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + + PropertyName : + LiteralPropertyName + ComputedPropertyName + + LiteralPropertyName : + IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + $; _; \u{6F}; \u2118; ZW_\u200C_NJ; ZW_\u200D_J; + *m() { return 42; } + +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +c.$ = 1; +c._ = 1; +c.\u{6F} = 1; +c.\u2118 = 1; +c.ZW_\u200C_NJ = 1; +c.ZW_\u200D_J = 1; + +assert.sameValue(c.$, 1); +assert.sameValue(c._, 1); +assert.sameValue(c.\u{6F}, 1); +assert.sameValue(c.\u2118, 1); +assert.sameValue(c.ZW_\u200C_NJ, 1); +assert.sameValue(c.ZW_\u200D_J, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-rs-private-getter-alt.js b/js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-rs-private-getter-alt.js new file mode 100644 index 0000000000..c189c19726 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-rs-private-getter-alt.js @@ -0,0 +1,129 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-private-getter-alt.case +// - src/class-elements/productions/cls-decl-new-sc-line-generator.template +/*--- +description: Valid PrivateName as private getter (field definitions followed by a method in a new line with a semicolon) +esid: prod-FieldDefinition +features: [class-methods-private, class-fields-private, class, class-fields-public, generators] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + ... + ; + + MethodDefinition : + ... + get ClassElementName ( ){ FunctionBody } + ... + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + #$_; #__; #\u{6F}_; #℘_; #ZW_‌_NJ_; #ZW_‍_J_; + get #$() { + return this.#$_; + } + get #_() { + return this.#__; + } + get #\u{6F}() { + return this.#\u{6F}_; + } + get #℘() { + return this.#℘_; + } + get #ZW_‌_NJ() { + return this.#ZW_‌_NJ_; + } + get #ZW_‍_J() { + return this.#ZW_‍_J_; + } +; + *m() { return 42; } + $(value) { + this.#$_ = value; + return this.#$; + } + _(value) { + this.#__ = value; + return this.#_; + } + \u{6F}(value) { + this.#\u{6F}_ = value; + return this.#\u{6F}; + } + ℘(value) { + this.#℘_ = value; + return this.#℘; + } + ZW_‌_NJ(value) { + this.#ZW_‌_NJ_ = value; + return this.#ZW_‌_NJ; + } + ZW_‍_J(value) { + this.#ZW_‍_J_ = value; + return this.#ZW_‍_J; + } + +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.$(1), 1); +assert.sameValue(c._(1), 1); +assert.sameValue(c.\u{6F}(1), 1); +assert.sameValue(c.℘(1), 1); +assert.sameValue(c.ZW_‌_NJ(1), 1); +assert.sameValue(c.ZW_‍_J(1), 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-rs-private-getter.js b/js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-rs-private-getter.js new file mode 100644 index 0000000000..8d6f5c08ed --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-rs-private-getter.js @@ -0,0 +1,129 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-private-getter.case +// - src/class-elements/productions/cls-decl-new-sc-line-generator.template +/*--- +description: Valid PrivateName as private getter (field definitions followed by a method in a new line with a semicolon) +esid: prod-FieldDefinition +features: [class-methods-private, class-fields-private, class, class-fields-public, generators] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + ... + ; + + MethodDefinition : + ... + get ClassElementName ( ){ FunctionBody } + ... + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + #$_; #__; #\u{6F}_; #\u2118_; #ZW_\u200C_NJ_; #ZW_\u200D_J_; + get #$() { + return this.#$_; + } + get #_() { + return this.#__; + } + get #\u{6F}() { + return this.#\u{6F}_; + } + get #\u2118() { + return this.#\u2118_; + } + get #ZW_\u200C_NJ() { + return this.#ZW_\u200C_NJ_; + } + get #ZW_\u200D_J() { + return this.#ZW_\u200D_J_; + } +; + *m() { return 42; } + $(value) { + this.#$_ = value; + return this.#$; + } + _(value) { + this.#__ = value; + return this.#_; + } + \u{6F}(value) { + this.#\u{6F}_ = value; + return this.#\u{6F}; + } + \u2118(value) { + this.#\u2118_ = value; + return this.#\u2118; + } + ZW_\u200C_NJ(value) { + this.#ZW_\u200C_NJ_ = value; + return this.#ZW_\u200C_NJ; + } + ZW_\u200D_J(value) { + this.#ZW_\u200D_J_ = value; + return this.#ZW_\u200D_J; + } + +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.$(1), 1); +assert.sameValue(c._(1), 1); +assert.sameValue(c.\u{6F}(1), 1); +assert.sameValue(c.\u2118(1), 1); +assert.sameValue(c.ZW_\u200C_NJ(1), 1); +assert.sameValue(c.ZW_\u200D_J(1), 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-rs-private-method-alt.js b/js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-rs-private-method-alt.js new file mode 100644 index 0000000000..ba250447a2 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-rs-private-method-alt.js @@ -0,0 +1,128 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-private-method-alt.case +// - src/class-elements/productions/cls-decl-new-sc-line-generator.template +/*--- +description: Valid PrivateName as private method (field definitions followed by a method in a new line with a semicolon) +esid: prod-FieldDefinition +features: [class-methods-private, class-fields-private, class, class-fields-public, generators] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + ... + ; + + MethodDefinition : + ClassElementName ( UniqueFormalParameters ) { FunctionBody } + ... + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + #$_; #__; #\u{6F}_; #℘_; #ZW_‌_NJ_; #ZW_‍_J_; + #$() { + return this.#$_; + } + #_() { + return this.#__; + } + #\u{6F}() { + return this.#\u{6F}_; + } + #℘() { + return this.#℘_; + } + #ZW_‌_NJ() { + return this.#ZW_‌_NJ_; + } + #ZW_‍_J() { + return this.#ZW_‍_J_; + } +; + *m() { return 42; } + $(value) { + this.#$_ = value; + return this.#$(); + } + _(value) { + this.#__ = value; + return this.#_(); + } + \u{6F}(value) { + this.#\u{6F}_ = value; + return this.#\u{6F}(); + } + ℘(value) { + this.#℘_ = value; + return this.#℘(); + } + ZW_‌_NJ(value) { + this.#ZW_‌_NJ_ = value; + return this.#ZW_‌_NJ(); + } + ZW_‍_J(value) { + this.#ZW_‍_J_ = value; + return this.#ZW_‍_J(); + } + +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.$(1), 1); +assert.sameValue(c._(1), 1); +assert.sameValue(c.\u{6F}(1), 1); +assert.sameValue(c.℘(1), 1); +assert.sameValue(c.ZW_‌_NJ(1), 1); +assert.sameValue(c.ZW_‍_J(1), 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-rs-private-method.js b/js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-rs-private-method.js new file mode 100644 index 0000000000..b900f33e56 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-rs-private-method.js @@ -0,0 +1,128 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-private-method.case +// - src/class-elements/productions/cls-decl-new-sc-line-generator.template +/*--- +description: Valid PrivateName as private method (field definitions followed by a method in a new line with a semicolon) +esid: prod-FieldDefinition +features: [class-methods-private, class-fields-private, class, class-fields-public, generators] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + ... + ; + + MethodDefinition : + ClassElementName ( UniqueFormalParameters ) { FunctionBody } + ... + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + #$_; #__; #\u{6F}_; #\u2118_; #ZW_\u200C_NJ_; #ZW_\u200D_J_; + #$() { + return this.#$_; + } + #_() { + return this.#__; + } + #\u{6F}() { + return this.#\u{6F}_; + } + #\u2118() { + return this.#\u2118_; + } + #ZW_\u200C_NJ() { + return this.#ZW_\u200C_NJ_; + } + #ZW_\u200D_J() { + return this.#ZW_\u200D_J_; + } +; + *m() { return 42; } + $(value) { + this.#$_ = value; + return this.#$(); + } + _(value) { + this.#__ = value; + return this.#_(); + } + \u{6F}(value) { + this.#\u{6F}_ = value; + return this.#\u{6F}(); + } + \u2118(value) { + this.#\u2118_ = value; + return this.#\u2118(); + } + ZW_\u200C_NJ(value) { + this.#ZW_\u200C_NJ_ = value; + return this.#ZW_\u200C_NJ(); + } + ZW_\u200D_J(value) { + this.#ZW_\u200D_J_ = value; + return this.#ZW_\u200D_J(); + } + +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.$(1), 1); +assert.sameValue(c._(1), 1); +assert.sameValue(c.\u{6F}(1), 1); +assert.sameValue(c.\u2118(1), 1); +assert.sameValue(c.ZW_\u200C_NJ(1), 1); +assert.sameValue(c.ZW_\u200D_J(1), 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-rs-private-setter-alt.js b/js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-rs-private-setter-alt.js new file mode 100644 index 0000000000..225e4b4edb --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-rs-private-setter-alt.js @@ -0,0 +1,128 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-private-setter-alt.case +// - src/class-elements/productions/cls-decl-new-sc-line-generator.template +/*--- +description: Valid PrivateName as private setter (field definitions followed by a method in a new line with a semicolon) +esid: prod-FieldDefinition +features: [class-methods-private, class-fields-private, class, class-fields-public, generators] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + ... + ; + + MethodDefinition : + ... + set ClassElementName ( PropertySetParameterList ) { FunctionBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + #$_; #__; #\u{6F}_; #℘_; #ZW_‌_NJ_; #ZW_‍_J_; + set #$(value) { + this.#$_ = value; + } + set #_(value) { + this.#__ = value; + } + set #\u{6F}(value) { + this.#\u{6F}_ = value; + } + set #℘(value) { + this.#℘_ = value; + } + set #ZW_‌_NJ(value) { + this.#ZW_‌_NJ_ = value; + } + set #ZW_‍_J(value) { + this.#ZW_‍_J_ = value; + } +; + *m() { return 42; } + $(value) { + this.#$ = value; + return this.#$_; + } + _(value) { + this.#_ = value; + return this.#__; + } + \u{6F}(value) { + this.#\u{6F} = value; + return this.#\u{6F}_; + } + ℘(value) { + this.#℘ = value; + return this.#℘_; + } + ZW_‌_NJ(value) { + this.#ZW_‌_NJ = value; + return this.#ZW_‌_NJ_; + } + ZW_‍_J(value) { + this.#ZW_‍_J = value; + return this.#ZW_‍_J_; + } + +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.$(1), 1); +assert.sameValue(c._(1), 1); +assert.sameValue(c.\u{6F}(1), 1); +assert.sameValue(c.℘(1), 1); +assert.sameValue(c.ZW_‌_NJ(1), 1); +assert.sameValue(c.ZW_‍_J(1), 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-rs-private-setter.js b/js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-rs-private-setter.js new file mode 100644 index 0000000000..c41b4487a5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-rs-private-setter.js @@ -0,0 +1,128 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-private-setter.case +// - src/class-elements/productions/cls-decl-new-sc-line-generator.template +/*--- +description: Valid PrivateName as private setter (field definitions followed by a method in a new line with a semicolon) +esid: prod-FieldDefinition +features: [class-methods-private, class-fields-private, class, class-fields-public, generators] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + ... + ; + + MethodDefinition : + ... + set ClassElementName ( PropertySetParameterList ) { FunctionBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + #$_; #__; #\u{6F}_; #\u2118_; #ZW_\u200C_NJ_; #ZW_\u200D_J_; + set #$(value) { + this.#$_ = value; + } + set #_(value) { + this.#__ = value; + } + set #\u{6F}(value) { + this.#\u{6F}_ = value; + } + set #\u2118(value) { + this.#\u2118_ = value; + } + set #ZW_\u200C_NJ(value) { + this.#ZW_\u200C_NJ_ = value; + } + set #ZW_\u200D_J(value) { + this.#ZW_\u200D_J_ = value; + } +; + *m() { return 42; } + $(value) { + this.#$ = value; + return this.#$_; + } + _(value) { + this.#_ = value; + return this.#__; + } + \u{6F}(value) { + this.#\u{6F} = value; + return this.#\u{6F}_; + } + \u2118(value) { + this.#\u2118 = value; + return this.#\u2118_; + } + ZW_\u200C_NJ(value) { + this.#ZW_\u200C_NJ = value; + return this.#ZW_\u200C_NJ_; + } + ZW_\u200D_J(value) { + this.#ZW_\u200D_J = value; + return this.#ZW_\u200D_J_; + } + +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.$(1), 1); +assert.sameValue(c._(1), 1); +assert.sameValue(c.\u{6F}(1), 1); +assert.sameValue(c.\u2118(1), 1); +assert.sameValue(c.ZW_\u200C_NJ(1), 1); +assert.sameValue(c.ZW_\u200D_J(1), 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-rs-privatename-identifier-alt.js b/js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-rs-privatename-identifier-alt.js new file mode 100644 index 0000000000..35498f2223 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-rs-privatename-identifier-alt.js @@ -0,0 +1,110 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-privatename-identifier-alt.case +// - src/class-elements/productions/cls-decl-new-sc-line-generator.template +/*--- +description: Valid PrivateName (field definitions followed by a method in a new line with a semicolon) +esid: prod-FieldDefinition +features: [class-fields-private, class, class-fields-public, generators] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + #$; #_; #\u{6F}; #℘; #ZW_‌_NJ; #ZW_‍_J; + *m() { return 42; } + $(value) { + this.#$ = value; + return this.#$; + } + _(value) { + this.#_ = value; + return this.#_; + } + \u{6F}(value) { + this.#\u{6F} = value; + return this.#\u{6F}; + } + ℘(value) { + this.#℘ = value; + return this.#℘; + } + ZW_‌_NJ(value) { + this.#ZW_‌_NJ = value; + return this.#ZW_‌_NJ; + } + ZW_‍_J(value) { + this.#ZW_‍_J = value; + return this.#ZW_‍_J; + } +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.$(1), 1); +assert.sameValue(c._(1), 1); +assert.sameValue(c.\u{6F}(1), 1); +assert.sameValue(c.℘(1), 1); +assert.sameValue(c.ZW_‌_NJ(1), 1); +assert.sameValue(c.ZW_‍_J(1), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-rs-privatename-identifier-initializer-alt.js b/js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-rs-privatename-identifier-initializer-alt.js new file mode 100644 index 0000000000..fba538c7d6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-rs-privatename-identifier-initializer-alt.js @@ -0,0 +1,104 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-privatename-identifier-initializer-alt.case +// - src/class-elements/productions/cls-decl-new-sc-line-generator.template +/*--- +description: Valid PrivateName (field definitions followed by a method in a new line with a semicolon) +esid: prod-FieldDefinition +features: [class-fields-private, class, class-fields-public, generators] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + #$ = 1; #_ = 1; #\u{6F} = 1; #℘ = 1; #ZW_‌_NJ = 1; #ZW_‍_J = 1; + *m() { return 42; } + $() { + return this.#$; + } + _() { + return this.#_; + } + \u{6F}() { + return this.#\u{6F}; + } + ℘() { + return this.#℘; + } + ZW_‌_NJ() { + return this.#ZW_‌_NJ; + } + ZW_‍_J() { + return this.#ZW_‍_J; + } +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.$(), 1); +assert.sameValue(c._(), 1); +assert.sameValue(c.\u{6F}(), 1); +assert.sameValue(c.℘(), 1); +assert.sameValue(c.ZW_‌_NJ(), 1); +assert.sameValue(c.ZW_‍_J(), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-rs-privatename-identifier-initializer.js b/js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-rs-privatename-identifier-initializer.js new file mode 100644 index 0000000000..b145ef1dd4 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-rs-privatename-identifier-initializer.js @@ -0,0 +1,104 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-privatename-identifier-initializer.case +// - src/class-elements/productions/cls-decl-new-sc-line-generator.template +/*--- +description: Valid PrivateName (field definitions followed by a method in a new line with a semicolon) +esid: prod-FieldDefinition +features: [class-fields-private, class, class-fields-public, generators] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + #$ = 1; #_ = 1; #\u{6F} = 1; #\u2118 = 1; #ZW_\u200C_NJ = 1; #ZW_\u200D_J = 1; + *m() { return 42; } + $() { + return this.#$; + } + _() { + return this.#_; + } + \u{6F}() { + return this.#\u{6F}; + } + \u2118() { + return this.#\u2118; + } + ZW_\u200C_NJ() { + return this.#ZW_\u200C_NJ; + } + ZW_\u200D_J() { + return this.#ZW_\u200D_J; + } +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.$(), 1); +assert.sameValue(c._(), 1); +assert.sameValue(c.\u{6F}(), 1); +assert.sameValue(c.\u2118(), 1); +assert.sameValue(c.ZW_\u200C_NJ(), 1); +assert.sameValue(c.ZW_\u200D_J(), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-rs-privatename-identifier.js b/js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-rs-privatename-identifier.js new file mode 100644 index 0000000000..855a649b26 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-rs-privatename-identifier.js @@ -0,0 +1,110 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-privatename-identifier.case +// - src/class-elements/productions/cls-decl-new-sc-line-generator.template +/*--- +description: Valid PrivateName (field definitions followed by a method in a new line with a semicolon) +esid: prod-FieldDefinition +features: [class-fields-private, class, class-fields-public, generators] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + #$; #_; #\u{6F}; #\u2118; #ZW_\u200C_NJ; #ZW_\u200D_J; + *m() { return 42; } + $(value) { + this.#$ = value; + return this.#$; + } + _(value) { + this.#_ = value; + return this.#_; + } + \u{6F}(value) { + this.#\u{6F} = value; + return this.#\u{6F}; + } + \u2118(value) { + this.#\u2118 = value; + return this.#\u2118; + } + ZW_\u200C_NJ(value) { + this.#ZW_\u200C_NJ = value; + return this.#ZW_\u200C_NJ; + } + ZW_\u200D_J(value) { + this.#ZW_\u200D_J = value; + return this.#ZW_\u200D_J; + } +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.$(1), 1); +assert.sameValue(c._(1), 1); +assert.sameValue(c.\u{6F}(1), 1); +assert.sameValue(c.\u2118(1), 1); +assert.sameValue(c.ZW_\u200C_NJ(1), 1); +assert.sameValue(c.ZW_\u200D_J(1), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-rs-static-async-generator-method-privatename-identifier-alt.js b/js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-rs-static-async-generator-method-privatename-identifier-alt.js new file mode 100644 index 0000000000..67cfec91a6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-rs-static-async-generator-method-privatename-identifier-alt.js @@ -0,0 +1,135 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-async-generator-method-privatename-identifier-alt.case +// - src/class-elements/productions/cls-decl-new-sc-line-generator.template +/*--- +description: Valid Static AsyncGeneratorMethod PrivateName (field definitions followed by a method in a new line with a semicolon) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public, generators] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + AsyncGeneratorMethod + + AsyncGeneratorMethod : + async [no LineTerminator here] * ClassElementName ( UniqueFormalParameters){ AsyncGeneratorBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static async * #$(value) { + yield * await value; + } + static async * #_(value) { + yield * await value; + } + static async * #o(value) { + yield * await value; + } + static async * #℘(value) { + yield * await value; + } + static async * #ZW_‌_NJ(value) { + yield * await value; + } + static async * #ZW_‍_J(value) { + yield * await value; + }; + *m() { return 42; } + static get $() { + return this.#$; + } + static get _() { + return this.#_; + } + static get o() { + return this.#o; + } + static get ℘() { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#℘; + } + static get ZW_‌_NJ() { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#ZW_‌_NJ; + } + static get ZW_‍_J() { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#ZW_‍_J; + } + +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +Promise.all([ + C.$([1]).next(), + C._([1]).next(), + C.o([1]).next(), + C.℘([1]).next(), // DO NOT CHANGE THE NAME OF THIS FIELD + C.ZW_‌_NJ([1]).next(), // DO NOT CHANGE THE NAME OF THIS FIELD + C.ZW_‍_J([1]).next(), // DO NOT CHANGE THE NAME OF THIS FIELD +]).then(results => { + + assert.sameValue(results[0].value, 1); + assert.sameValue(results[1].value, 1); + assert.sameValue(results[2].value, 1); + assert.sameValue(results[3].value, 1); + assert.sameValue(results[4].value, 1); + assert.sameValue(results[5].value, 1); + +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-rs-static-async-generator-method-privatename-identifier.js b/js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-rs-static-async-generator-method-privatename-identifier.js new file mode 100644 index 0000000000..d11b746cb8 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-rs-static-async-generator-method-privatename-identifier.js @@ -0,0 +1,136 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-async-generator-method-privatename-identifier.case +// - src/class-elements/productions/cls-decl-new-sc-line-generator.template +/*--- +description: Valid Static AsyncGeneratorMethod PrivateName (field definitions followed by a method in a new line with a semicolon) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public, generators] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + AsyncGeneratorMethod + + AsyncGeneratorMethod : + async [no LineTerminator here] * ClassElementName ( UniqueFormalParameters){ AsyncGeneratorBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static async * #$(value) { + yield * await value; + } + static async * #_(value) { + yield * await value; + } + static async * #\u{6F}(value) { + yield * await value; + } + static async * #\u2118(value) { + yield * await value; + } + static async * #ZW_\u200C_NJ(value) { + yield * await value; + } + static async * #ZW_\u200D_J(value) { + yield * await value; + }; + *m() { return 42; } + static get $() { + return this.#$; + } + static get _() { + return this.#_; + } + static get \u{6F}() { + return this.#\u{6F}; + } + static get \u2118() { + return this.#\u2118; + } + static get ZW_\u200C_NJ() { + return this.#ZW_\u200C_NJ; + } + static get ZW_\u200D_J() { + return this.#ZW_\u200D_J; + } + +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +Promise.all([ + C.$([1]).next(), + C._([1]).next(), + C.\u{6F}([1]).next(), + C.\u2118([1]).next(), + C.ZW_\u200C_NJ([1]).next(), + C.ZW_\u200D_J([1]).next(), +]).then(results => { + + assert.sameValue(results[0].value, 1); + assert.sameValue(results[1].value, 1); + assert.sameValue(results[2].value, 1); + assert.sameValue(results[3].value, 1); + assert.sameValue(results[4].value, 1); + assert.sameValue(results[5].value, 1); + +}).then($DONE, $DONE); + diff --git a/js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-rs-static-async-method-privatename-identifier-alt.js b/js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-rs-static-async-method-privatename-identifier-alt.js new file mode 100644 index 0000000000..2829df2ddf --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-rs-static-async-method-privatename-identifier-alt.js @@ -0,0 +1,135 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-async-method-privatename-identifier-alt.case +// - src/class-elements/productions/cls-decl-new-sc-line-generator.template +/*--- +description: Valid Static AsyncMethod PrivateName (field definitions followed by a method in a new line with a semicolon) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public, generators] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + AsyncMethod + + AsyncMethod : + async [no LineTerminator here] ClassElementName ( UniqueFormalParameters ){ AsyncFunctionBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static async #$(value) { + return await value; + } + static async #_(value) { + return await value; + } + static async #o(value) { + return await value; + } + static async #℘(value) { + return await value; + } + static async #ZW_‌_NJ(value) { + return await value; + } + static async #ZW_‍_J(value) { + return await value; + }; + *m() { return 42; } + static async $(value) { + return await this.#$(value); + } + static async _(value) { + return await this.#_(value); + } + static async o(value) { + return await this.#o(value); + } + static async ℘(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + return await this.#℘(value); + } + static async ZW_‌_NJ(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + return await this.#ZW_‌_NJ(value); + } + static async ZW_‍_J(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + return await this.#ZW_‍_J(value); + } + +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +Promise.all([ + C.$(1), + C._(1), + C.o(1), + C.℘(1), // DO NOT CHANGE THE NAME OF THIS FIELD + C.ZW_‌_NJ(1), // DO NOT CHANGE THE NAME OF THIS FIELD + C.ZW_‍_J(1), // DO NOT CHANGE THE NAME OF THIS FIELD +]).then(results => { + + assert.sameValue(results[0], 1); + assert.sameValue(results[1], 1); + assert.sameValue(results[2], 1); + assert.sameValue(results[3], 1); + assert.sameValue(results[4], 1); + assert.sameValue(results[5], 1); + +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-rs-static-async-method-privatename-identifier.js b/js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-rs-static-async-method-privatename-identifier.js new file mode 100644 index 0000000000..3a0eee48bb --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-rs-static-async-method-privatename-identifier.js @@ -0,0 +1,136 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-async-method-privatename-identifier.case +// - src/class-elements/productions/cls-decl-new-sc-line-generator.template +/*--- +description: Valid Static AsyncMethod PrivateName (field definitions followed by a method in a new line with a semicolon) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public, generators] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + AsyncMethod + + AsyncMethod : + async [no LineTerminator here] ClassElementName ( UniqueFormalParameters ){ AsyncFunctionBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static async #$(value) { + return await value; + } + static async #_(value) { + return await value; + } + static async #\u{6F}(value) { + return await value; + } + static async #\u2118(value) { + return await value; + } + static async #ZW_\u200C_NJ(value) { + return await value; + } + static async #ZW_\u200D_J(value) { + return await value; + }; + *m() { return 42; } + static async $(value) { + return await this.#$(value); + } + static async _(value) { + return await this.#_(value); + } + static async \u{6F}(value) { + return await this.#\u{6F}(value); + } + static async \u2118(value) { + return await this.#\u2118(value); + } + static async ZW_\u200C_NJ(value) { + return await this.#ZW_\u200C_NJ(value); + } + static async ZW_\u200D_J(value) { + return await this.#ZW_\u200D_J(value); + } + +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +Promise.all([ + C.$(1), + C._(1), + C.\u{6F}(1), + C.\u2118(1), + C.ZW_\u200C_NJ(1), + C.ZW_\u200D_J(1), +]).then(results => { + + assert.sameValue(results[0], 1); + assert.sameValue(results[1], 1); + assert.sameValue(results[2], 1); + assert.sameValue(results[3], 1); + assert.sameValue(results[4], 1); + assert.sameValue(results[5], 1); + +}).then($DONE, $DONE); + diff --git a/js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-rs-static-generator-method-privatename-identifier-alt.js b/js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-rs-static-generator-method-privatename-identifier-alt.js new file mode 100644 index 0000000000..6432137d51 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-rs-static-generator-method-privatename-identifier-alt.js @@ -0,0 +1,125 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-generator-method-privatename-identifier-alt.case +// - src/class-elements/productions/cls-decl-new-sc-line-generator.template +/*--- +description: Valid Static GeneratorMethod PrivateName (field definitions followed by a method in a new line with a semicolon) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public, generators] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + GeneratorMethod + + GeneratorMethod : + * ClassElementName ( UniqueFormalParameters ){ GeneratorBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static * #$(value) { + yield * value; + } + static * #_(value) { + yield * value; + } + static * #o(value) { + yield * value; + } + static * #℘(value) { + yield * value; + } + static * #ZW_‌_NJ(value) { + yield * value; + } + static * #ZW_‍_J(value) { + yield * value; + }; + *m() { return 42; } + static get $() { + return this.#$; + } + static get _() { + return this.#_; + } + static get o() { + return this.#o; + } + static get ℘() { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#℘; + } + static get ZW_‌_NJ() { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#ZW_‌_NJ; + } + static get ZW_‍_J() { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#ZW_‍_J; + } + +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(C.$([1]).next().value, 1); +assert.sameValue(C._([1]).next().value, 1); +assert.sameValue(C.o([1]).next().value, 1); +assert.sameValue(C.℘([1]).next().value, 1); +assert.sameValue(C.ZW_‌_NJ([1]).next().value, 1); +assert.sameValue(C.ZW_‍_J([1]).next().value, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-rs-static-generator-method-privatename-identifier.js b/js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-rs-static-generator-method-privatename-identifier.js new file mode 100644 index 0000000000..6c3c2e45bb --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-rs-static-generator-method-privatename-identifier.js @@ -0,0 +1,126 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-generator-method-privatename-identifier.case +// - src/class-elements/productions/cls-decl-new-sc-line-generator.template +/*--- +description: Valid Static GeneratorMethod PrivateName (field definitions followed by a method in a new line with a semicolon) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public, generators] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + GeneratorMethod + + GeneratorMethod : + * ClassElementName ( UniqueFormalParameters ){ GeneratorBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static * #$(value) { + yield * value; + } + static * #_(value) { + yield * value; + } + static * #\u{6F}(value) { + yield * value; + } + static * #\u2118(value) { + yield * value; + } + static * #ZW_\u200C_NJ(value) { + yield * value; + } + static * #ZW_\u200D_J(value) { + yield * value; + }; + *m() { return 42; } + static get $() { + return this.#$; + } + static get _() { + return this.#_; + } + static get \u{6F}() { + return this.#\u{6F}; + } + static get \u2118() { + return this.#\u2118; + } + static get ZW_\u200C_NJ() { + return this.#ZW_\u200C_NJ; + } + static get ZW_\u200D_J() { + return this.#ZW_\u200D_J; + } + +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(C.$([1]).next().value, 1); +assert.sameValue(C._([1]).next().value, 1); +assert.sameValue(C.\u{6F}([1]).next().value, 1); +assert.sameValue(C.\u2118([1]).next().value, 1); +assert.sameValue(C.ZW_\u200C_NJ([1]).next().value, 1); +assert.sameValue(C.ZW_\u200D_J([1]).next().value, 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-rs-static-method-privatename-identifier-alt.js b/js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-rs-static-method-privatename-identifier-alt.js new file mode 100644 index 0000000000..2397b6c820 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-rs-static-method-privatename-identifier-alt.js @@ -0,0 +1,123 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-method-privatename-identifier-alt.case +// - src/class-elements/productions/cls-decl-new-sc-line-generator.template +/*--- +description: Valid Static Method PrivateName (field definitions followed by a method in a new line with a semicolon) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public, generators] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + ClassElementName ( UniqueFormalParameters ){ FunctionBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static #$(value) { + return value; + } + static #_(value) { + return value; + } + static #o(value) { + return value; + } + static #℘(value) { + return value; + } + static #ZW_‌_NJ(value) { + return value; + } + static #ZW_‍_J(value) { + return value; + }; + *m() { return 42; } + static $(value) { + return this.#$(value); + } + static _(value) { + return this.#_(value); + } + static o(value) { + return this.#o(value); + } + static ℘(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#℘(value); + } + static ZW_‌_NJ(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#ZW_‌_NJ(value); + } + static ZW_‍_J(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#ZW_‍_J(value); + } + +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(C.$(1), 1); +assert.sameValue(C._(1), 1); +assert.sameValue(C.o(1), 1); +assert.sameValue(C.℘(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD +assert.sameValue(C.ZW_‌_NJ(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD +assert.sameValue(C.ZW_‍_J(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-rs-static-method-privatename-identifier.js b/js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-rs-static-method-privatename-identifier.js new file mode 100644 index 0000000000..acb708bb49 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-rs-static-method-privatename-identifier.js @@ -0,0 +1,123 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-method-privatename-identifier.case +// - src/class-elements/productions/cls-decl-new-sc-line-generator.template +/*--- +description: Valid Static Method PrivateName (field definitions followed by a method in a new line with a semicolon) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public, generators] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + ClassElementName ( UniqueFormalParameters ){ FunctionBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static #$(value) { + return value; + } + static #_(value) { + return value; + } + static #\u{6F}(value) { + return value; + } + static #\u2118(value) { + return value; + } + static #ZW_\u200C_NJ(value) { + return value; + } + static #ZW_\u200D_J(value) { + return value; + }; + *m() { return 42; } + static $(value) { + return this.#$(value); + } + static _(value) { + return this.#_(value); + } + static \u{6F}(value) { + return this.#\u{6F}(value); + } + static \u2118(value) { + return this.#\u2118(value); + } + static ZW_\u200C_NJ(value) { + return this.#ZW_\u200C_NJ(value); + } + static ZW_\u200D_J(value) { + return this.#ZW_\u200D_J(value); + } + +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(C.$(1), 1); +assert.sameValue(C._(1), 1); +assert.sameValue(C.\u{6F}(1), 1); +assert.sameValue(C.\u2118(1), 1); +assert.sameValue(C.ZW_\u200C_NJ(1), 1); +assert.sameValue(C.ZW_\u200D_J(1), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-rs-static-privatename-identifier-alt-by-classname.js b/js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-rs-static-privatename-identifier-alt-by-classname.js new file mode 100644 index 0000000000..a558cd6148 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-rs-static-privatename-identifier-alt-by-classname.js @@ -0,0 +1,111 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-privatename-identifier-alt-by-classname.case +// - src/class-elements/productions/cls-decl-new-sc-line-generator.template +/*--- +description: Valid Static PrivateName (field definitions followed by a method in a new line with a semicolon) +esid: prod-FieldDefinition +features: [class-static-fields-private, class, class-fields-public, generators] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static #$; static #_; static #\u{6F}; static #℘; static #ZW_‌_NJ; static #ZW_‍_J; + *m() { return 42; } + static $(value) { + C.#$ = value; + return C.#$; + } + static _(value) { + C.#_ = value; + return C.#_; + } + static o(value) { + C.#\u{6F} = value; + return C.#\u{6F}; + } + static ℘(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + C.#℘ = value; + return C.#℘; + } + static ZW_‌_NJ(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + C.#ZW_‌_NJ = value; + return C.#ZW_‌_NJ; + } + static ZW_‍_J(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + C.#ZW_‍_J = value; + return C.#ZW_‍_J; + } +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(C.$(1), 1); +assert.sameValue(C._(1), 1); +assert.sameValue(C.o(1), 1); +assert.sameValue(C.℘(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD +assert.sameValue(C.ZW_‌_NJ(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD +assert.sameValue(C.ZW_‍_J(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-rs-static-privatename-identifier-alt.js b/js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-rs-static-privatename-identifier-alt.js new file mode 100644 index 0000000000..03efb13b72 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-rs-static-privatename-identifier-alt.js @@ -0,0 +1,111 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-privatename-identifier-alt.case +// - src/class-elements/productions/cls-decl-new-sc-line-generator.template +/*--- +description: Valid Static PrivateName (field definitions followed by a method in a new line with a semicolon) +esid: prod-FieldDefinition +features: [class-static-fields-private, class, class-fields-public, generators] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static #$; static #_; static #\u{6F}; static #℘; static #ZW_‌_NJ; static #ZW_‍_J; + *m() { return 42; } + static $(value) { + this.#$ = value; + return this.#$; + } + static _(value) { + this.#_ = value; + return this.#_; + } + static o(value) { + this.#\u{6F} = value; + return this.#\u{6F}; + } + static ℘(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + this.#℘ = value; + return this.#℘; + } + static ZW_‌_NJ(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + this.#ZW_‌_NJ = value; + return this.#ZW_‌_NJ; + } + static ZW_‍_J(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + this.#ZW_‍_J = value; + return this.#ZW_‍_J; + } +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(C.$(1), 1); +assert.sameValue(C._(1), 1); +assert.sameValue(C.o(1), 1); +assert.sameValue(C.℘(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD +assert.sameValue(C.ZW_‌_NJ(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD +assert.sameValue(C.ZW_‍_J(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-rs-static-privatename-identifier-by-classname.js b/js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-rs-static-privatename-identifier-by-classname.js new file mode 100644 index 0000000000..3ba13a2e10 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-rs-static-privatename-identifier-by-classname.js @@ -0,0 +1,111 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-privatename-identifier-by-classname.case +// - src/class-elements/productions/cls-decl-new-sc-line-generator.template +/*--- +description: Valid Static PrivateName (field definitions followed by a method in a new line with a semicolon) +esid: prod-FieldDefinition +features: [class-static-fields-private, class, class-fields-public, generators] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static #$; static #_; static #\u{6F}; static #\u2118; static #ZW_\u200C_NJ; static #ZW_\u200D_J; + *m() { return 42; } + static $(value) { + C.#$ = value; + return C.#$; + } + static _(value) { + C.#_ = value; + return C.#_; + } + static \u{6F}(value) { + C.#\u{6F} = value; + return C.#\u{6F}; + } + static \u2118(value) { + C.#\u2118 = value; + return C.#\u2118; + } + static ZW_\u200C_NJ(value) { + C.#ZW_\u200C_NJ = value; + return C.#ZW_\u200C_NJ; + } + static ZW_\u200D_J(value) { + C.#ZW_\u200D_J = value; + return C.#ZW_\u200D_J; + } +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(C.$(1), 1); +assert.sameValue(C._(1), 1); +assert.sameValue(C.\u{6F}(1), 1); +assert.sameValue(C.\u2118(1), 1); +assert.sameValue(C.ZW_\u200C_NJ(1), 1); +assert.sameValue(C.ZW_\u200D_J(1), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-rs-static-privatename-identifier-initializer-alt-by-classname.js b/js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-rs-static-privatename-identifier-initializer-alt-by-classname.js new file mode 100644 index 0000000000..d6d305fc67 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-rs-static-privatename-identifier-initializer-alt-by-classname.js @@ -0,0 +1,105 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-privatename-identifier-initializer-alt-by-classname.case +// - src/class-elements/productions/cls-decl-new-sc-line-generator.template +/*--- +description: Valid Static PrivateName (field definitions followed by a method in a new line with a semicolon) +esid: prod-FieldDefinition +features: [class-static-fields-private, class, class-fields-public, generators] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static #$ = 1; static #_ = 1; static #\u{6F} = 1; static #℘ = 1; static #ZW_‌_NJ = 1; static #ZW_‍_J = 1; + *m() { return 42; } + static $() { + return C.#$; + } + static _() { + return C.#_; + } + static \u{6F}() { + return C.#\u{6F}; + } + static ℘() { + return C.#℘; + } + static ZW_‌_NJ() { + return C.#ZW_‌_NJ; + } + static ZW_‍_J() { + return C.#ZW_‍_J; + } +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(C.$(), 1); +assert.sameValue(C._(), 1); +assert.sameValue(C.\u{6F}(), 1); +assert.sameValue(C.℘(), 1); +assert.sameValue(C.ZW_‌_NJ(), 1); +assert.sameValue(C.ZW_‍_J(), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-rs-static-privatename-identifier-initializer-alt.js b/js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-rs-static-privatename-identifier-initializer-alt.js new file mode 100644 index 0000000000..dba6c15312 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-rs-static-privatename-identifier-initializer-alt.js @@ -0,0 +1,105 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-privatename-identifier-initializer-alt.case +// - src/class-elements/productions/cls-decl-new-sc-line-generator.template +/*--- +description: Valid Static PrivateName (field definitions followed by a method in a new line with a semicolon) +esid: prod-FieldDefinition +features: [class-static-fields-private, class, class-fields-public, generators] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static #$ = 1; static #_ = 1; static #\u{6F} = 1; static #℘ = 1; static #ZW_‌_NJ = 1; static #ZW_‍_J = 1; + *m() { return 42; } + static $() { + return this.#$; + } + static _() { + return this.#_; + } + static \u{6F}() { + return this.#\u{6F}; + } + static ℘() { + return this.#℘; + } + static ZW_‌_NJ() { + return this.#ZW_‌_NJ; + } + static ZW_‍_J() { + return this.#ZW_‍_J; + } +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(C.$(), 1); +assert.sameValue(C._(), 1); +assert.sameValue(C.\u{6F}(), 1); +assert.sameValue(C.℘(), 1); +assert.sameValue(C.ZW_‌_NJ(), 1); +assert.sameValue(C.ZW_‍_J(), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-rs-static-privatename-identifier-initializer.js b/js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-rs-static-privatename-identifier-initializer.js new file mode 100644 index 0000000000..73f5afb3a4 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-rs-static-privatename-identifier-initializer.js @@ -0,0 +1,105 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-privatename-identifier-initializer.case +// - src/class-elements/productions/cls-decl-new-sc-line-generator.template +/*--- +description: Valid Static PrivateName (field definitions followed by a method in a new line with a semicolon) +esid: prod-FieldDefinition +features: [class-static-fields-private, class, class-fields-public, generators] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static #$ = 1; static #_ = 1; static #\u{6F} = 1; static #\u2118 = 1; static #ZW_\u200C_NJ = 1; static #ZW_\u200D_J = 1; + *m() { return 42; } + static $() { + return this.#$; + } + static _() { + return this.#_; + } + static \u{6F}() { + return this.#\u{6F}; + } + static \u2118() { + return this.#\u2118; + } + static ZW_\u200C_NJ() { + return this.#ZW_\u200C_NJ; + } + static ZW_\u200D_J() { + return this.#ZW_\u200D_J; + } +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(C.$(), 1); +assert.sameValue(C._(), 1); +assert.sameValue(C.\u{6F}(), 1); +assert.sameValue(C.\u2118(), 1); +assert.sameValue(C.ZW_\u200C_NJ(), 1); +assert.sameValue(C.ZW_\u200D_J(), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-rs-static-privatename-identifier.js b/js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-rs-static-privatename-identifier.js new file mode 100644 index 0000000000..0c59b4f671 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-rs-static-privatename-identifier.js @@ -0,0 +1,111 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-privatename-identifier.case +// - src/class-elements/productions/cls-decl-new-sc-line-generator.template +/*--- +description: Valid Static PrivateName (field definitions followed by a method in a new line with a semicolon) +esid: prod-FieldDefinition +features: [class-static-fields-private, class, class-fields-public, generators] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static #$; static #_; static #\u{6F}; static #\u2118; static #ZW_\u200C_NJ; static #ZW_\u200D_J; + *m() { return 42; } + static $(value) { + this.#$ = value; + return this.#$; + } + static _(value) { + this.#_ = value; + return this.#_; + } + static \u{6F}(value) { + this.#\u{6F} = value; + return this.#\u{6F}; + } + static \u2118(value) { + this.#\u2118 = value; + return this.#\u2118; + } + static ZW_\u200C_NJ(value) { + this.#ZW_\u200C_NJ = value; + return this.#ZW_\u200C_NJ; + } + static ZW_\u200D_J(value) { + this.#ZW_\u200D_J = value; + return this.#ZW_\u200D_J; + } +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(C.$(1), 1); +assert.sameValue(C._(1), 1); +assert.sameValue(C.\u{6F}(1), 1); +assert.sameValue(C.\u2118(1), 1); +assert.sameValue(C.ZW_\u200C_NJ(1), 1); +assert.sameValue(C.ZW_\u200D_J(1), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-static-private-fields.js b/js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-static-private-fields.js new file mode 100644 index 0000000000..4a158fc799 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-static-private-fields.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/static-private-fields.case +// - src/class-elements/productions/cls-decl-new-sc-line-generator.template +/*--- +description: static private fields (field definitions followed by a method in a new line with a semicolon) +esid: prod-FieldDefinition +features: [class-static-fields-private, class, class-fields-public, generators] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + ... + static FieldDefinition ; + + FieldDefinition : + ClassElementName Initializer_opt + + ClassElementName : + PrivateName + + PrivateName : + # IdentifierName + +---*/ + + +class C { + static #x; static #y; + *m() { return 42; } + static x() { + this.#x = 42; + return this.#x; + } + static y() { + this.#y = 43; + return this.#y; + } +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +// Test the private fields do not appear as properties before set to value +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#x"), "test 1"); +assert(!Object.prototype.hasOwnProperty.call(C, "#x"), "test 2"); +assert(!Object.prototype.hasOwnProperty.call(c, "#x"), "test 3"); + +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#y"), "test 4"); +assert(!Object.prototype.hasOwnProperty.call(C, "#y"), "test 5"); +assert(!Object.prototype.hasOwnProperty.call(c, "#y"), "test 6"); + +// Test if private fields can be sucessfully accessed and set to value +assert.sameValue(C.x(), 42, "test 7"); +assert.sameValue(C.y(), 43, "test 8"); + +// Test the private fields do not appear as properties before after set to value +assert(!Object.prototype.hasOwnProperty.call(C, "#x"), "test 9"); +assert(!Object.prototype.hasOwnProperty.call(C, "#y"), "test 10"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-static-private-methods-with-fields.js b/js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-static-private-methods-with-fields.js new file mode 100644 index 0000000000..9e35870051 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-static-private-methods-with-fields.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/static-private-methods-with-fields.case +// - src/class-elements/productions/cls-decl-new-sc-line-generator.template +/*--- +description: static private methods with fields (field definitions followed by a method in a new line with a semicolon) +esid: prod-FieldDefinition +features: [class-static-methods-private, class-static-fields-private, class, class-fields-public, generators] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + ... + static FieldDefinition ; + + FieldDefinition : + ClassElementName Initializer_opt + + ClassElementName : + PrivateName + + PrivateName : + # IdentifierName + +---*/ + + +class C { + static #xVal; static #yVal; + *m() { return 42; } + static #x(value) { + this.#xVal = value; + return this.#xVal; + } + static #y(value) { + this.#yVal = value; + return this.#yVal; + } + static x() { + return this.#x(42); + } + static y() { + return this.#y(43); + } +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +// Test the private methods do not appear as properties before set to value +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#x"), "test 1"); +assert(!Object.prototype.hasOwnProperty.call(C, "#x"), "test 2"); +assert(!Object.prototype.hasOwnProperty.call(c, "#x"), "test 3"); + +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#y"), "test 4"); +assert(!Object.prototype.hasOwnProperty.call(C, "#y"), "test 5"); +assert(!Object.prototype.hasOwnProperty.call(c, "#y"), "test 6"); + +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#xVal"), "test 7"); +assert(!Object.prototype.hasOwnProperty.call(C, "#xVal"), "test 8"); +assert(!Object.prototype.hasOwnProperty.call(c, "#xVal"), "test 9"); + +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#yVal"), "test 10"); +assert(!Object.prototype.hasOwnProperty.call(C, "#yVal"), "test 11"); +assert(!Object.prototype.hasOwnProperty.call(c, "#yVal"), "test 12"); + +// Test if private fields can be sucessfully accessed and set to value +assert.sameValue(C.x(), 42, "test 13"); +assert.sameValue(C.y(), 43, "test 14"); + +// Test the private fields do not appear as properties before after set to value +assert(!Object.prototype.hasOwnProperty.call(C, "#x"), "test 15"); +assert(!Object.prototype.hasOwnProperty.call(C, "#y"), "test 16"); + +assert(!Object.prototype.hasOwnProperty.call(C, "#xVal"), "test 17"); +assert(!Object.prototype.hasOwnProperty.call(C, "#yVal"), "test 18"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-static-private-methods.js b/js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-static-private-methods.js new file mode 100644 index 0000000000..f184130b48 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-static-private-methods.js @@ -0,0 +1,76 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/static-private-methods.case +// - src/class-elements/productions/cls-decl-new-sc-line-generator.template +/*--- +description: static private methods (field definitions followed by a method in a new line with a semicolon) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public, generators] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + ... + static FieldDefinition ; + + FieldDefinition : + ClassElementName Initializer_opt + + ClassElementName : + PrivateName + + PrivateName : + # IdentifierName + +---*/ + + +class C { + ; + *m() { return 42; } + static #x(value) { + return value / 2; + } + static #y(value) { + return value * 2; + } + static x() { + return this.#x(84); + } + static y() { + return this.#y(43); + } +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +// Test the private methods do not appear as properties before set to value +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#x"), "test 1"); +assert(!Object.prototype.hasOwnProperty.call(C, "#x"), "test 2"); +assert(!Object.prototype.hasOwnProperty.call(c, "#x"), "test 3"); + +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#y"), "test 4"); +assert(!Object.prototype.hasOwnProperty.call(C, "#y"), "test 5"); +assert(!Object.prototype.hasOwnProperty.call(c, "#y"), "test 6"); + +// Test if private fields can be sucessfully accessed and set to value +assert.sameValue(C.x(), 42, "test 7"); +assert.sameValue(C.y(), 86, "test 8"); + +// Test the private fields do not appear as properties before after set to value +assert(!Object.prototype.hasOwnProperty.call(C, "#x"), "test 9"); +assert(!Object.prototype.hasOwnProperty.call(C, "#y"), "test 10"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-string-literal-names.js b/js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-string-literal-names.js new file mode 100644 index 0000000000..9eae83137e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/new-sc-line-gen-string-literal-names.js @@ -0,0 +1,110 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/string-literal-names.case +// - src/class-elements/productions/cls-decl-new-sc-line-generator.template +/*--- +description: String literal names (field definitions followed by a method in a new line with a semicolon) +esid: prod-FieldDefinition +features: [class-fields-public, class, generators] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PropertyName + +---*/ + + +class C { + 'a'; "b"; 'c' = 39; + "d" = 42; + *m() { return 42; } + +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "a"), + "a does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "a"), + "a does not appear as an own property on C constructor" +); + +verifyProperty(c, "a", { + value: undefined, + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "b"), + "b does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "b"), + "b does not appear as an own property on C constructor" +); + +verifyProperty(c, "b", { + value: undefined, + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "c"), + "c does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "c"), + "c does not appear as an own property on C constructor" +); + +verifyProperty(c, "c", { + value: 39, + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "d"), + "d does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "d"), + "d does not appear as an own property on C constructor" +); + +verifyProperty(c, "d", { + value: 42, + enumerable: true, + writable: true, + configurable: true +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/new-sc-line-method-computed-names.js b/js/src/tests/test262/language/statements/class/elements/new-sc-line-method-computed-names.js new file mode 100644 index 0000000000..1fc29ec2ed --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/new-sc-line-method-computed-names.js @@ -0,0 +1,108 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/computed-names.case +// - src/class-elements/productions/cls-decl-new-sc-line-method.template +/*--- +description: Computed property names (field definitions followed by a method in a new line with a semicolon) +esid: prod-FieldDefinition +features: [class-fields-public, computed-property-names, class] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PropertyName + +---*/ +var x = "b"; + + + +class C { + [x] = 42; [10] = "meep"; ["not initialized"]; + m() { return 42; } + +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "b"), + "b doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "b"), + "b doesn't appear as an own property on C constructor" +); + +verifyProperty(c, "b", { + value: 42, + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "x"), + "x doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "x"), + "x doesn't appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "x"), + "x doesn't appear as an own property on C instance" +); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "10"), + "10 doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "10"), + "10 doesn't appear as an own property on C constructor" +); + +verifyProperty(c, "10", { + value: "meep", + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "not initialized"), + "'not initialized' doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "not initialized"), + "'not initialized' doesn't appear as an own property on C constructor" +); + +verifyProperty(c, "not initialized", { + value: undefined, + enumerable: true, + writable: true, + configurable: true +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/new-sc-line-method-computed-symbol-names.js b/js/src/tests/test262/language/statements/class/elements/new-sc-line-method-computed-symbol-names.js new file mode 100644 index 0000000000..a056e38fb3 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/new-sc-line-method-computed-symbol-names.js @@ -0,0 +1,106 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/computed-symbol-names.case +// - src/class-elements/productions/cls-decl-new-sc-line-method.template +/*--- +description: Computed property symbol names (field definitions followed by a method in a new line with a semicolon) +esid: prod-FieldDefinition +features: [class-fields-public, Symbol, computed-property-names, class] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PropertyName + +---*/ +var x = Symbol(); +var y = Symbol(); + + + +class C { + [x]; [y] = 42; + m() { return 42; } + +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, x), + "Symbol x doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, x), + "Symbol x doesn't appear as an own property on C constructor" +); + +verifyProperty(c, x, { + value: undefined, + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, y), + "Symbol y doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, y), + "Symbol y doesn't appear as an own property on C constructor" +); + +verifyProperty(c, y, { + value: 42, + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "x"), + "x doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "x"), + "x doesn't appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "x"), + "x doesn't appear as an own property on C instance" +); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "y"), + "y doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "y"), + "y doesn't appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "y"), + "y doesn't appear as an own property on C instance" +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/new-sc-line-method-grammar-privatename-identifier-semantics-stringvalue.js b/js/src/tests/test262/language/statements/class/elements/new-sc-line-method-grammar-privatename-identifier-semantics-stringvalue.js new file mode 100644 index 0000000000..da1063e3e4 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/new-sc-line-method-grammar-privatename-identifier-semantics-stringvalue.js @@ -0,0 +1,110 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-privatename-identifier-semantics-stringvalue.case +// - src/class-elements/productions/cls-decl-new-sc-line-method.template +/*--- +description: PrivateName Static Semantics, StringValue (field definitions followed by a method in a new line with a semicolon) +esid: prod-FieldDefinition +features: [class-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + + + 1. Return the String value consisting of the sequence of code + units corresponding to PrivateName. In determining the sequence + any occurrences of \ UnicodeEscapeSequence are first replaced + with the code point represented by the UnicodeEscapeSequence + and then the code points of the entire PrivateName are converted + to code units by UTF16Encoding (10.1.1) each code point. + +---*/ + + +class C { + #\u{6F}; + #\u2118; + #ZW_\u200C_NJ; + #ZW_\u200D_J;; + m() { return 42; } + o(value) { + this.#o = value; + return this.#o; + } + ℘(value) { + this.#℘ = value; + return this.#℘; + } + ZW_‌_NJ(value) { // DO NOT CHANGE THE NAME OF THIS METHOD + this.#ZW_‌_NJ = value; + return this.#ZW_‌_NJ; + } + ZW_‍_J(value) { // DO NOT CHANGE THE NAME OF THIS METHOD + this.#ZW_‍_J = value; + return this.#ZW_‍_J; + } +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.o(1), 1); +assert.sameValue(c.℘(1), 1); +assert.sameValue(c.ZW_‌_NJ(1), 1); +assert.sameValue(c.ZW_‍_J(1), 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/new-sc-line-method-literal-names-asi.js b/js/src/tests/test262/language/statements/class/elements/new-sc-line-method-literal-names-asi.js new file mode 100644 index 0000000000..1d58676f76 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/new-sc-line-method-literal-names-asi.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/literal-names-asi.case +// - src/class-elements/productions/cls-decl-new-sc-line-method.template +/*--- +description: Literal property names with ASI (field definitions followed by a method in a new line with a semicolon) +esid: prod-FieldDefinition +features: [class-fields-public, class] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PropertyName + +---*/ + + +class C { + a + b = 42;; + m() { return 42; } + +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "a"), + "a doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "a"), + "a doesn't appear as an own property on C constructor" +); + +verifyProperty(c, "a", { + value: undefined, + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "b"), + "b doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "b"), + "b doesn't appear as an own property on C constructor" +); + +verifyProperty(c, "b", { + value: 42, + enumerable: true, + writable: true, + configurable: true +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/new-sc-line-method-literal-names.js b/js/src/tests/test262/language/statements/class/elements/new-sc-line-method-literal-names.js new file mode 100644 index 0000000000..182103077c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/new-sc-line-method-literal-names.js @@ -0,0 +1,97 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/literal-names.case +// - src/class-elements/productions/cls-decl-new-sc-line-method.template +/*--- +description: Literal property names (field definitions followed by a method in a new line with a semicolon) +esid: prod-FieldDefinition +features: [class-fields-public, class] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PropertyName + +---*/ +const fn = function() {} + + + +class C { + a; b = 42; + c = fn; + m() { return 42; } + +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "a"), + "a doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "a"), + "a doesn't appear as an own property on C constructor" +); + +verifyProperty(c, "a", { + value: undefined, + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "b"), + "b doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "b"), + "b doesn't appear as an own property on C constructor" +); + +verifyProperty(c, "b", { + value: 42, + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "c"), + "c doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "c"), + "c doesn't appear as an own property on C constructor" +); + +verifyProperty(c, "c", { + value: fn, + enumerable: true, + writable: true, + configurable: true +}); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/new-sc-line-method-private-field-usage.js b/js/src/tests/test262/language/statements/class/elements/new-sc-line-method-private-field-usage.js new file mode 100644 index 0000000000..9bc9044082 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/new-sc-line-method-private-field-usage.js @@ -0,0 +1,50 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/private-field-usage.case +// - src/class-elements/productions/cls-decl-new-sc-line-method.template +/*--- +description: PrivateName CallExpression usage (private field) (field definitions followed by a method in a new line with a semicolon) +esid: prod-FieldDefinition +features: [class-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + Updated Productions + + CallExpression[Yield, Await]: + CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await] + SuperCall[?Yield, ?Await] + CallExpression[?Yield, ?Await]Arguments[?Yield, ?Await] + CallExpression[?Yield, ?Await][Expression[+In, ?Yield, ?Await]] + CallExpression[?Yield, ?Await].IdentifierName + CallExpression[?Yield, ?Await]TemplateLiteral[?Yield, ?Await] + CallExpression[?Yield, ?Await].PrivateName + +---*/ + + +class C { + #m = 'test262';; + m() { return 42; } + method() { + return this.#m; + } +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.method(), 'test262'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/new-sc-line-method-private-method-getter-usage.js b/js/src/tests/test262/language/statements/class/elements/new-sc-line-method-private-method-getter-usage.js new file mode 100644 index 0000000000..e879cf66c5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/new-sc-line-method-private-method-getter-usage.js @@ -0,0 +1,50 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/private-method-getter-usage.case +// - src/class-elements/productions/cls-decl-new-sc-line-method.template +/*--- +description: PrivateName CallExpression usage (Accesor get method) (field definitions followed by a method in a new line with a semicolon) +esid: prod-FieldDefinition +features: [class-methods-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + Updated Productions + + CallExpression[Yield, Await]: + CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await] + SuperCall[?Yield, ?Await] + CallExpression[?Yield, ?Await]Arguments[?Yield, ?Await] + CallExpression[?Yield, ?Await][Expression[+In, ?Yield, ?Await]] + CallExpression[?Yield, ?Await].IdentifierName + CallExpression[?Yield, ?Await]TemplateLiteral[?Yield, ?Await] + CallExpression[?Yield, ?Await].PrivateName + +---*/ + + +class C { + get #m() { return 'test262'; }; + m() { return 42; } + method() { + return this.#m; + } +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.method(), 'test262'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/new-sc-line-method-private-method-usage.js b/js/src/tests/test262/language/statements/class/elements/new-sc-line-method-private-method-usage.js new file mode 100644 index 0000000000..a3c1f7b671 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/new-sc-line-method-private-method-usage.js @@ -0,0 +1,50 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/private-method-usage.case +// - src/class-elements/productions/cls-decl-new-sc-line-method.template +/*--- +description: PrivateName CallExpression usage (private method) (field definitions followed by a method in a new line with a semicolon) +esid: prod-FieldDefinition +features: [class-methods-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + Updated Productions + + CallExpression[Yield, Await]: + CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await] + SuperCall[?Yield, ?Await] + CallExpression[?Yield, ?Await]Arguments[?Yield, ?Await] + CallExpression[?Yield, ?Await][Expression[+In, ?Yield, ?Await]] + CallExpression[?Yield, ?Await].IdentifierName + CallExpression[?Yield, ?Await]TemplateLiteral[?Yield, ?Await] + CallExpression[?Yield, ?Await].PrivateName + +---*/ + + +class C { + #m() { return 'test262'; }; + m() { return 42; } + method() { + return this.#m(); + } +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.method(), 'test262'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/new-sc-line-method-private-names.js b/js/src/tests/test262/language/statements/class/elements/new-sc-line-method-private-names.js new file mode 100644 index 0000000000..4874428248 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/new-sc-line-method-private-names.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/private-names.case +// - src/class-elements/productions/cls-decl-new-sc-line-method.template +/*--- +description: private names (field definitions followed by a method in a new line with a semicolon) +esid: prod-FieldDefinition +features: [class-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + ... + FieldDefinition ; + + FieldDefinition : + ClassElementName Initializer_opt + + ClassElementName : + PrivateName + + PrivateName : + # IdentifierName + +---*/ + + +class C { + #x; #y; + m() { return 42; } + x() { + this.#x = 42; + return this.#x; + } + y() { + this.#y = 43; + return this.#y; + } +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +// Test the private fields do not appear as properties before set to value +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#x"), "test 1"); +assert(!Object.prototype.hasOwnProperty.call(C, "#x"), "test 2"); +assert(!Object.prototype.hasOwnProperty.call(c, "#x"), "test 3"); + +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#y"), "test 4"); +assert(!Object.prototype.hasOwnProperty.call(C, "#y"), "test 5"); +assert(!Object.prototype.hasOwnProperty.call(c, "#y"), "test 6"); + +// Test if private fields can be sucessfully accessed and set to value +assert.sameValue(c.x(), 42, "test 7"); +assert.sameValue(c.y(), 43, "test 8"); + +// Test the private fields do not appear as properties before after set to value +assert(!Object.prototype.hasOwnProperty.call(c, "#x"), "test 9"); +assert(!Object.prototype.hasOwnProperty.call(c, "#y"), "test 10"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/new-sc-line-method-rs-field-identifier-initializer.js b/js/src/tests/test262/language/statements/class/elements/new-sc-line-method-rs-field-identifier-initializer.js new file mode 100644 index 0000000000..c4d712146c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/new-sc-line-method-rs-field-identifier-initializer.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-field-identifier-initializer.case +// - src/class-elements/productions/cls-decl-new-sc-line-method.template +/*--- +description: Valid FieldDefinition (field definitions followed by a method in a new line with a semicolon) +esid: prod-FieldDefinition +features: [class-fields-public, class] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + ... + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + + PropertyName : + LiteralPropertyName + ComputedPropertyName + + LiteralPropertyName : + IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + $ = 1; _ = 1; \u{6F} = 1; \u2118 = 1; ZW_\u200C_NJ = 1; ZW_\u200D_J = 1; + m() { return 42; } + +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.$, 1); +assert.sameValue(c._, 1); +assert.sameValue(c.\u{6F}, 1); +assert.sameValue(c.\u2118, 1); +assert.sameValue(c.ZW_\u200C_NJ, 1); +assert.sameValue(c.ZW_\u200D_J, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/new-sc-line-method-rs-field-identifier.js b/js/src/tests/test262/language/statements/class/elements/new-sc-line-method-rs-field-identifier.js new file mode 100644 index 0000000000..2372787738 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/new-sc-line-method-rs-field-identifier.js @@ -0,0 +1,95 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-field-identifier.case +// - src/class-elements/productions/cls-decl-new-sc-line-method.template +/*--- +description: Valid FieldDefinition (field definitions followed by a method in a new line with a semicolon) +esid: prod-FieldDefinition +features: [class-fields-public, class] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + ... + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + + PropertyName : + LiteralPropertyName + ComputedPropertyName + + LiteralPropertyName : + IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + $; _; \u{6F}; \u2118; ZW_\u200C_NJ; ZW_\u200D_J; + m() { return 42; } + +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +c.$ = 1; +c._ = 1; +c.\u{6F} = 1; +c.\u2118 = 1; +c.ZW_\u200C_NJ = 1; +c.ZW_\u200D_J = 1; + +assert.sameValue(c.$, 1); +assert.sameValue(c._, 1); +assert.sameValue(c.\u{6F}, 1); +assert.sameValue(c.\u2118, 1); +assert.sameValue(c.ZW_\u200C_NJ, 1); +assert.sameValue(c.ZW_\u200D_J, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/new-sc-line-method-rs-private-getter-alt.js b/js/src/tests/test262/language/statements/class/elements/new-sc-line-method-rs-private-getter-alt.js new file mode 100644 index 0000000000..bb4149d6ba --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/new-sc-line-method-rs-private-getter-alt.js @@ -0,0 +1,129 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-private-getter-alt.case +// - src/class-elements/productions/cls-decl-new-sc-line-method.template +/*--- +description: Valid PrivateName as private getter (field definitions followed by a method in a new line with a semicolon) +esid: prod-FieldDefinition +features: [class-methods-private, class-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + ... + ; + + MethodDefinition : + ... + get ClassElementName ( ){ FunctionBody } + ... + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + #$_; #__; #\u{6F}_; #℘_; #ZW_‌_NJ_; #ZW_‍_J_; + get #$() { + return this.#$_; + } + get #_() { + return this.#__; + } + get #\u{6F}() { + return this.#\u{6F}_; + } + get #℘() { + return this.#℘_; + } + get #ZW_‌_NJ() { + return this.#ZW_‌_NJ_; + } + get #ZW_‍_J() { + return this.#ZW_‍_J_; + } +; + m() { return 42; } + $(value) { + this.#$_ = value; + return this.#$; + } + _(value) { + this.#__ = value; + return this.#_; + } + \u{6F}(value) { + this.#\u{6F}_ = value; + return this.#\u{6F}; + } + ℘(value) { + this.#℘_ = value; + return this.#℘; + } + ZW_‌_NJ(value) { + this.#ZW_‌_NJ_ = value; + return this.#ZW_‌_NJ; + } + ZW_‍_J(value) { + this.#ZW_‍_J_ = value; + return this.#ZW_‍_J; + } + +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.$(1), 1); +assert.sameValue(c._(1), 1); +assert.sameValue(c.\u{6F}(1), 1); +assert.sameValue(c.℘(1), 1); +assert.sameValue(c.ZW_‌_NJ(1), 1); +assert.sameValue(c.ZW_‍_J(1), 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/new-sc-line-method-rs-private-getter.js b/js/src/tests/test262/language/statements/class/elements/new-sc-line-method-rs-private-getter.js new file mode 100644 index 0000000000..9f5b4ece4e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/new-sc-line-method-rs-private-getter.js @@ -0,0 +1,129 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-private-getter.case +// - src/class-elements/productions/cls-decl-new-sc-line-method.template +/*--- +description: Valid PrivateName as private getter (field definitions followed by a method in a new line with a semicolon) +esid: prod-FieldDefinition +features: [class-methods-private, class-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + ... + ; + + MethodDefinition : + ... + get ClassElementName ( ){ FunctionBody } + ... + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + #$_; #__; #\u{6F}_; #\u2118_; #ZW_\u200C_NJ_; #ZW_\u200D_J_; + get #$() { + return this.#$_; + } + get #_() { + return this.#__; + } + get #\u{6F}() { + return this.#\u{6F}_; + } + get #\u2118() { + return this.#\u2118_; + } + get #ZW_\u200C_NJ() { + return this.#ZW_\u200C_NJ_; + } + get #ZW_\u200D_J() { + return this.#ZW_\u200D_J_; + } +; + m() { return 42; } + $(value) { + this.#$_ = value; + return this.#$; + } + _(value) { + this.#__ = value; + return this.#_; + } + \u{6F}(value) { + this.#\u{6F}_ = value; + return this.#\u{6F}; + } + \u2118(value) { + this.#\u2118_ = value; + return this.#\u2118; + } + ZW_\u200C_NJ(value) { + this.#ZW_\u200C_NJ_ = value; + return this.#ZW_\u200C_NJ; + } + ZW_\u200D_J(value) { + this.#ZW_\u200D_J_ = value; + return this.#ZW_\u200D_J; + } + +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.$(1), 1); +assert.sameValue(c._(1), 1); +assert.sameValue(c.\u{6F}(1), 1); +assert.sameValue(c.\u2118(1), 1); +assert.sameValue(c.ZW_\u200C_NJ(1), 1); +assert.sameValue(c.ZW_\u200D_J(1), 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/new-sc-line-method-rs-private-method-alt.js b/js/src/tests/test262/language/statements/class/elements/new-sc-line-method-rs-private-method-alt.js new file mode 100644 index 0000000000..239d65744e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/new-sc-line-method-rs-private-method-alt.js @@ -0,0 +1,128 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-private-method-alt.case +// - src/class-elements/productions/cls-decl-new-sc-line-method.template +/*--- +description: Valid PrivateName as private method (field definitions followed by a method in a new line with a semicolon) +esid: prod-FieldDefinition +features: [class-methods-private, class-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + ... + ; + + MethodDefinition : + ClassElementName ( UniqueFormalParameters ) { FunctionBody } + ... + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + #$_; #__; #\u{6F}_; #℘_; #ZW_‌_NJ_; #ZW_‍_J_; + #$() { + return this.#$_; + } + #_() { + return this.#__; + } + #\u{6F}() { + return this.#\u{6F}_; + } + #℘() { + return this.#℘_; + } + #ZW_‌_NJ() { + return this.#ZW_‌_NJ_; + } + #ZW_‍_J() { + return this.#ZW_‍_J_; + } +; + m() { return 42; } + $(value) { + this.#$_ = value; + return this.#$(); + } + _(value) { + this.#__ = value; + return this.#_(); + } + \u{6F}(value) { + this.#\u{6F}_ = value; + return this.#\u{6F}(); + } + ℘(value) { + this.#℘_ = value; + return this.#℘(); + } + ZW_‌_NJ(value) { + this.#ZW_‌_NJ_ = value; + return this.#ZW_‌_NJ(); + } + ZW_‍_J(value) { + this.#ZW_‍_J_ = value; + return this.#ZW_‍_J(); + } + +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.$(1), 1); +assert.sameValue(c._(1), 1); +assert.sameValue(c.\u{6F}(1), 1); +assert.sameValue(c.℘(1), 1); +assert.sameValue(c.ZW_‌_NJ(1), 1); +assert.sameValue(c.ZW_‍_J(1), 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/new-sc-line-method-rs-private-method.js b/js/src/tests/test262/language/statements/class/elements/new-sc-line-method-rs-private-method.js new file mode 100644 index 0000000000..0056ecde83 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/new-sc-line-method-rs-private-method.js @@ -0,0 +1,128 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-private-method.case +// - src/class-elements/productions/cls-decl-new-sc-line-method.template +/*--- +description: Valid PrivateName as private method (field definitions followed by a method in a new line with a semicolon) +esid: prod-FieldDefinition +features: [class-methods-private, class-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + ... + ; + + MethodDefinition : + ClassElementName ( UniqueFormalParameters ) { FunctionBody } + ... + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + #$_; #__; #\u{6F}_; #\u2118_; #ZW_\u200C_NJ_; #ZW_\u200D_J_; + #$() { + return this.#$_; + } + #_() { + return this.#__; + } + #\u{6F}() { + return this.#\u{6F}_; + } + #\u2118() { + return this.#\u2118_; + } + #ZW_\u200C_NJ() { + return this.#ZW_\u200C_NJ_; + } + #ZW_\u200D_J() { + return this.#ZW_\u200D_J_; + } +; + m() { return 42; } + $(value) { + this.#$_ = value; + return this.#$(); + } + _(value) { + this.#__ = value; + return this.#_(); + } + \u{6F}(value) { + this.#\u{6F}_ = value; + return this.#\u{6F}(); + } + \u2118(value) { + this.#\u2118_ = value; + return this.#\u2118(); + } + ZW_\u200C_NJ(value) { + this.#ZW_\u200C_NJ_ = value; + return this.#ZW_\u200C_NJ(); + } + ZW_\u200D_J(value) { + this.#ZW_\u200D_J_ = value; + return this.#ZW_\u200D_J(); + } + +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.$(1), 1); +assert.sameValue(c._(1), 1); +assert.sameValue(c.\u{6F}(1), 1); +assert.sameValue(c.\u2118(1), 1); +assert.sameValue(c.ZW_\u200C_NJ(1), 1); +assert.sameValue(c.ZW_\u200D_J(1), 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/new-sc-line-method-rs-private-setter-alt.js b/js/src/tests/test262/language/statements/class/elements/new-sc-line-method-rs-private-setter-alt.js new file mode 100644 index 0000000000..c95ce333ff --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/new-sc-line-method-rs-private-setter-alt.js @@ -0,0 +1,128 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-private-setter-alt.case +// - src/class-elements/productions/cls-decl-new-sc-line-method.template +/*--- +description: Valid PrivateName as private setter (field definitions followed by a method in a new line with a semicolon) +esid: prod-FieldDefinition +features: [class-methods-private, class-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + ... + ; + + MethodDefinition : + ... + set ClassElementName ( PropertySetParameterList ) { FunctionBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + #$_; #__; #\u{6F}_; #℘_; #ZW_‌_NJ_; #ZW_‍_J_; + set #$(value) { + this.#$_ = value; + } + set #_(value) { + this.#__ = value; + } + set #\u{6F}(value) { + this.#\u{6F}_ = value; + } + set #℘(value) { + this.#℘_ = value; + } + set #ZW_‌_NJ(value) { + this.#ZW_‌_NJ_ = value; + } + set #ZW_‍_J(value) { + this.#ZW_‍_J_ = value; + } +; + m() { return 42; } + $(value) { + this.#$ = value; + return this.#$_; + } + _(value) { + this.#_ = value; + return this.#__; + } + \u{6F}(value) { + this.#\u{6F} = value; + return this.#\u{6F}_; + } + ℘(value) { + this.#℘ = value; + return this.#℘_; + } + ZW_‌_NJ(value) { + this.#ZW_‌_NJ = value; + return this.#ZW_‌_NJ_; + } + ZW_‍_J(value) { + this.#ZW_‍_J = value; + return this.#ZW_‍_J_; + } + +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.$(1), 1); +assert.sameValue(c._(1), 1); +assert.sameValue(c.\u{6F}(1), 1); +assert.sameValue(c.℘(1), 1); +assert.sameValue(c.ZW_‌_NJ(1), 1); +assert.sameValue(c.ZW_‍_J(1), 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/new-sc-line-method-rs-private-setter.js b/js/src/tests/test262/language/statements/class/elements/new-sc-line-method-rs-private-setter.js new file mode 100644 index 0000000000..33b324895b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/new-sc-line-method-rs-private-setter.js @@ -0,0 +1,128 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-private-setter.case +// - src/class-elements/productions/cls-decl-new-sc-line-method.template +/*--- +description: Valid PrivateName as private setter (field definitions followed by a method in a new line with a semicolon) +esid: prod-FieldDefinition +features: [class-methods-private, class-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + ... + ; + + MethodDefinition : + ... + set ClassElementName ( PropertySetParameterList ) { FunctionBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + #$_; #__; #\u{6F}_; #\u2118_; #ZW_\u200C_NJ_; #ZW_\u200D_J_; + set #$(value) { + this.#$_ = value; + } + set #_(value) { + this.#__ = value; + } + set #\u{6F}(value) { + this.#\u{6F}_ = value; + } + set #\u2118(value) { + this.#\u2118_ = value; + } + set #ZW_\u200C_NJ(value) { + this.#ZW_\u200C_NJ_ = value; + } + set #ZW_\u200D_J(value) { + this.#ZW_\u200D_J_ = value; + } +; + m() { return 42; } + $(value) { + this.#$ = value; + return this.#$_; + } + _(value) { + this.#_ = value; + return this.#__; + } + \u{6F}(value) { + this.#\u{6F} = value; + return this.#\u{6F}_; + } + \u2118(value) { + this.#\u2118 = value; + return this.#\u2118_; + } + ZW_\u200C_NJ(value) { + this.#ZW_\u200C_NJ = value; + return this.#ZW_\u200C_NJ_; + } + ZW_\u200D_J(value) { + this.#ZW_\u200D_J = value; + return this.#ZW_\u200D_J_; + } + +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.$(1), 1); +assert.sameValue(c._(1), 1); +assert.sameValue(c.\u{6F}(1), 1); +assert.sameValue(c.\u2118(1), 1); +assert.sameValue(c.ZW_\u200C_NJ(1), 1); +assert.sameValue(c.ZW_\u200D_J(1), 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/new-sc-line-method-rs-privatename-identifier-alt.js b/js/src/tests/test262/language/statements/class/elements/new-sc-line-method-rs-privatename-identifier-alt.js new file mode 100644 index 0000000000..6826cb6dea --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/new-sc-line-method-rs-privatename-identifier-alt.js @@ -0,0 +1,110 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-privatename-identifier-alt.case +// - src/class-elements/productions/cls-decl-new-sc-line-method.template +/*--- +description: Valid PrivateName (field definitions followed by a method in a new line with a semicolon) +esid: prod-FieldDefinition +features: [class-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + #$; #_; #\u{6F}; #℘; #ZW_‌_NJ; #ZW_‍_J; + m() { return 42; } + $(value) { + this.#$ = value; + return this.#$; + } + _(value) { + this.#_ = value; + return this.#_; + } + \u{6F}(value) { + this.#\u{6F} = value; + return this.#\u{6F}; + } + ℘(value) { + this.#℘ = value; + return this.#℘; + } + ZW_‌_NJ(value) { + this.#ZW_‌_NJ = value; + return this.#ZW_‌_NJ; + } + ZW_‍_J(value) { + this.#ZW_‍_J = value; + return this.#ZW_‍_J; + } +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.$(1), 1); +assert.sameValue(c._(1), 1); +assert.sameValue(c.\u{6F}(1), 1); +assert.sameValue(c.℘(1), 1); +assert.sameValue(c.ZW_‌_NJ(1), 1); +assert.sameValue(c.ZW_‍_J(1), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/new-sc-line-method-rs-privatename-identifier-initializer-alt.js b/js/src/tests/test262/language/statements/class/elements/new-sc-line-method-rs-privatename-identifier-initializer-alt.js new file mode 100644 index 0000000000..a01e4f7b14 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/new-sc-line-method-rs-privatename-identifier-initializer-alt.js @@ -0,0 +1,104 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-privatename-identifier-initializer-alt.case +// - src/class-elements/productions/cls-decl-new-sc-line-method.template +/*--- +description: Valid PrivateName (field definitions followed by a method in a new line with a semicolon) +esid: prod-FieldDefinition +features: [class-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + #$ = 1; #_ = 1; #\u{6F} = 1; #℘ = 1; #ZW_‌_NJ = 1; #ZW_‍_J = 1; + m() { return 42; } + $() { + return this.#$; + } + _() { + return this.#_; + } + \u{6F}() { + return this.#\u{6F}; + } + ℘() { + return this.#℘; + } + ZW_‌_NJ() { + return this.#ZW_‌_NJ; + } + ZW_‍_J() { + return this.#ZW_‍_J; + } +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.$(), 1); +assert.sameValue(c._(), 1); +assert.sameValue(c.\u{6F}(), 1); +assert.sameValue(c.℘(), 1); +assert.sameValue(c.ZW_‌_NJ(), 1); +assert.sameValue(c.ZW_‍_J(), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/new-sc-line-method-rs-privatename-identifier-initializer.js b/js/src/tests/test262/language/statements/class/elements/new-sc-line-method-rs-privatename-identifier-initializer.js new file mode 100644 index 0000000000..5fe94107f8 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/new-sc-line-method-rs-privatename-identifier-initializer.js @@ -0,0 +1,104 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-privatename-identifier-initializer.case +// - src/class-elements/productions/cls-decl-new-sc-line-method.template +/*--- +description: Valid PrivateName (field definitions followed by a method in a new line with a semicolon) +esid: prod-FieldDefinition +features: [class-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + #$ = 1; #_ = 1; #\u{6F} = 1; #\u2118 = 1; #ZW_\u200C_NJ = 1; #ZW_\u200D_J = 1; + m() { return 42; } + $() { + return this.#$; + } + _() { + return this.#_; + } + \u{6F}() { + return this.#\u{6F}; + } + \u2118() { + return this.#\u2118; + } + ZW_\u200C_NJ() { + return this.#ZW_\u200C_NJ; + } + ZW_\u200D_J() { + return this.#ZW_\u200D_J; + } +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.$(), 1); +assert.sameValue(c._(), 1); +assert.sameValue(c.\u{6F}(), 1); +assert.sameValue(c.\u2118(), 1); +assert.sameValue(c.ZW_\u200C_NJ(), 1); +assert.sameValue(c.ZW_\u200D_J(), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/new-sc-line-method-rs-privatename-identifier.js b/js/src/tests/test262/language/statements/class/elements/new-sc-line-method-rs-privatename-identifier.js new file mode 100644 index 0000000000..01c917154e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/new-sc-line-method-rs-privatename-identifier.js @@ -0,0 +1,110 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-privatename-identifier.case +// - src/class-elements/productions/cls-decl-new-sc-line-method.template +/*--- +description: Valid PrivateName (field definitions followed by a method in a new line with a semicolon) +esid: prod-FieldDefinition +features: [class-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + #$; #_; #\u{6F}; #\u2118; #ZW_\u200C_NJ; #ZW_\u200D_J; + m() { return 42; } + $(value) { + this.#$ = value; + return this.#$; + } + _(value) { + this.#_ = value; + return this.#_; + } + \u{6F}(value) { + this.#\u{6F} = value; + return this.#\u{6F}; + } + \u2118(value) { + this.#\u2118 = value; + return this.#\u2118; + } + ZW_\u200C_NJ(value) { + this.#ZW_\u200C_NJ = value; + return this.#ZW_\u200C_NJ; + } + ZW_\u200D_J(value) { + this.#ZW_\u200D_J = value; + return this.#ZW_\u200D_J; + } +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.$(1), 1); +assert.sameValue(c._(1), 1); +assert.sameValue(c.\u{6F}(1), 1); +assert.sameValue(c.\u2118(1), 1); +assert.sameValue(c.ZW_\u200C_NJ(1), 1); +assert.sameValue(c.ZW_\u200D_J(1), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/new-sc-line-method-rs-static-async-generator-method-privatename-identifier-alt.js b/js/src/tests/test262/language/statements/class/elements/new-sc-line-method-rs-static-async-generator-method-privatename-identifier-alt.js new file mode 100644 index 0000000000..5ad352be49 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/new-sc-line-method-rs-static-async-generator-method-privatename-identifier-alt.js @@ -0,0 +1,135 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-async-generator-method-privatename-identifier-alt.case +// - src/class-elements/productions/cls-decl-new-sc-line-method.template +/*--- +description: Valid Static AsyncGeneratorMethod PrivateName (field definitions followed by a method in a new line with a semicolon) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + AsyncGeneratorMethod + + AsyncGeneratorMethod : + async [no LineTerminator here] * ClassElementName ( UniqueFormalParameters){ AsyncGeneratorBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static async * #$(value) { + yield * await value; + } + static async * #_(value) { + yield * await value; + } + static async * #o(value) { + yield * await value; + } + static async * #℘(value) { + yield * await value; + } + static async * #ZW_‌_NJ(value) { + yield * await value; + } + static async * #ZW_‍_J(value) { + yield * await value; + }; + m() { return 42; } + static get $() { + return this.#$; + } + static get _() { + return this.#_; + } + static get o() { + return this.#o; + } + static get ℘() { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#℘; + } + static get ZW_‌_NJ() { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#ZW_‌_NJ; + } + static get ZW_‍_J() { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#ZW_‍_J; + } + +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +Promise.all([ + C.$([1]).next(), + C._([1]).next(), + C.o([1]).next(), + C.℘([1]).next(), // DO NOT CHANGE THE NAME OF THIS FIELD + C.ZW_‌_NJ([1]).next(), // DO NOT CHANGE THE NAME OF THIS FIELD + C.ZW_‍_J([1]).next(), // DO NOT CHANGE THE NAME OF THIS FIELD +]).then(results => { + + assert.sameValue(results[0].value, 1); + assert.sameValue(results[1].value, 1); + assert.sameValue(results[2].value, 1); + assert.sameValue(results[3].value, 1); + assert.sameValue(results[4].value, 1); + assert.sameValue(results[5].value, 1); + +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/new-sc-line-method-rs-static-async-generator-method-privatename-identifier.js b/js/src/tests/test262/language/statements/class/elements/new-sc-line-method-rs-static-async-generator-method-privatename-identifier.js new file mode 100644 index 0000000000..13bf7cefb5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/new-sc-line-method-rs-static-async-generator-method-privatename-identifier.js @@ -0,0 +1,136 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-async-generator-method-privatename-identifier.case +// - src/class-elements/productions/cls-decl-new-sc-line-method.template +/*--- +description: Valid Static AsyncGeneratorMethod PrivateName (field definitions followed by a method in a new line with a semicolon) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + AsyncGeneratorMethod + + AsyncGeneratorMethod : + async [no LineTerminator here] * ClassElementName ( UniqueFormalParameters){ AsyncGeneratorBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static async * #$(value) { + yield * await value; + } + static async * #_(value) { + yield * await value; + } + static async * #\u{6F}(value) { + yield * await value; + } + static async * #\u2118(value) { + yield * await value; + } + static async * #ZW_\u200C_NJ(value) { + yield * await value; + } + static async * #ZW_\u200D_J(value) { + yield * await value; + }; + m() { return 42; } + static get $() { + return this.#$; + } + static get _() { + return this.#_; + } + static get \u{6F}() { + return this.#\u{6F}; + } + static get \u2118() { + return this.#\u2118; + } + static get ZW_\u200C_NJ() { + return this.#ZW_\u200C_NJ; + } + static get ZW_\u200D_J() { + return this.#ZW_\u200D_J; + } + +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +Promise.all([ + C.$([1]).next(), + C._([1]).next(), + C.\u{6F}([1]).next(), + C.\u2118([1]).next(), + C.ZW_\u200C_NJ([1]).next(), + C.ZW_\u200D_J([1]).next(), +]).then(results => { + + assert.sameValue(results[0].value, 1); + assert.sameValue(results[1].value, 1); + assert.sameValue(results[2].value, 1); + assert.sameValue(results[3].value, 1); + assert.sameValue(results[4].value, 1); + assert.sameValue(results[5].value, 1); + +}).then($DONE, $DONE); + diff --git a/js/src/tests/test262/language/statements/class/elements/new-sc-line-method-rs-static-async-method-privatename-identifier-alt.js b/js/src/tests/test262/language/statements/class/elements/new-sc-line-method-rs-static-async-method-privatename-identifier-alt.js new file mode 100644 index 0000000000..4ddcf3c8c1 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/new-sc-line-method-rs-static-async-method-privatename-identifier-alt.js @@ -0,0 +1,135 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-async-method-privatename-identifier-alt.case +// - src/class-elements/productions/cls-decl-new-sc-line-method.template +/*--- +description: Valid Static AsyncMethod PrivateName (field definitions followed by a method in a new line with a semicolon) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + AsyncMethod + + AsyncMethod : + async [no LineTerminator here] ClassElementName ( UniqueFormalParameters ){ AsyncFunctionBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static async #$(value) { + return await value; + } + static async #_(value) { + return await value; + } + static async #o(value) { + return await value; + } + static async #℘(value) { + return await value; + } + static async #ZW_‌_NJ(value) { + return await value; + } + static async #ZW_‍_J(value) { + return await value; + }; + m() { return 42; } + static async $(value) { + return await this.#$(value); + } + static async _(value) { + return await this.#_(value); + } + static async o(value) { + return await this.#o(value); + } + static async ℘(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + return await this.#℘(value); + } + static async ZW_‌_NJ(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + return await this.#ZW_‌_NJ(value); + } + static async ZW_‍_J(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + return await this.#ZW_‍_J(value); + } + +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +Promise.all([ + C.$(1), + C._(1), + C.o(1), + C.℘(1), // DO NOT CHANGE THE NAME OF THIS FIELD + C.ZW_‌_NJ(1), // DO NOT CHANGE THE NAME OF THIS FIELD + C.ZW_‍_J(1), // DO NOT CHANGE THE NAME OF THIS FIELD +]).then(results => { + + assert.sameValue(results[0], 1); + assert.sameValue(results[1], 1); + assert.sameValue(results[2], 1); + assert.sameValue(results[3], 1); + assert.sameValue(results[4], 1); + assert.sameValue(results[5], 1); + +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/new-sc-line-method-rs-static-async-method-privatename-identifier.js b/js/src/tests/test262/language/statements/class/elements/new-sc-line-method-rs-static-async-method-privatename-identifier.js new file mode 100644 index 0000000000..85de245b7f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/new-sc-line-method-rs-static-async-method-privatename-identifier.js @@ -0,0 +1,136 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-async-method-privatename-identifier.case +// - src/class-elements/productions/cls-decl-new-sc-line-method.template +/*--- +description: Valid Static AsyncMethod PrivateName (field definitions followed by a method in a new line with a semicolon) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + AsyncMethod + + AsyncMethod : + async [no LineTerminator here] ClassElementName ( UniqueFormalParameters ){ AsyncFunctionBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static async #$(value) { + return await value; + } + static async #_(value) { + return await value; + } + static async #\u{6F}(value) { + return await value; + } + static async #\u2118(value) { + return await value; + } + static async #ZW_\u200C_NJ(value) { + return await value; + } + static async #ZW_\u200D_J(value) { + return await value; + }; + m() { return 42; } + static async $(value) { + return await this.#$(value); + } + static async _(value) { + return await this.#_(value); + } + static async \u{6F}(value) { + return await this.#\u{6F}(value); + } + static async \u2118(value) { + return await this.#\u2118(value); + } + static async ZW_\u200C_NJ(value) { + return await this.#ZW_\u200C_NJ(value); + } + static async ZW_\u200D_J(value) { + return await this.#ZW_\u200D_J(value); + } + +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +Promise.all([ + C.$(1), + C._(1), + C.\u{6F}(1), + C.\u2118(1), + C.ZW_\u200C_NJ(1), + C.ZW_\u200D_J(1), +]).then(results => { + + assert.sameValue(results[0], 1); + assert.sameValue(results[1], 1); + assert.sameValue(results[2], 1); + assert.sameValue(results[3], 1); + assert.sameValue(results[4], 1); + assert.sameValue(results[5], 1); + +}).then($DONE, $DONE); + diff --git a/js/src/tests/test262/language/statements/class/elements/new-sc-line-method-rs-static-generator-method-privatename-identifier-alt.js b/js/src/tests/test262/language/statements/class/elements/new-sc-line-method-rs-static-generator-method-privatename-identifier-alt.js new file mode 100644 index 0000000000..78a95feb85 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/new-sc-line-method-rs-static-generator-method-privatename-identifier-alt.js @@ -0,0 +1,125 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-generator-method-privatename-identifier-alt.case +// - src/class-elements/productions/cls-decl-new-sc-line-method.template +/*--- +description: Valid Static GeneratorMethod PrivateName (field definitions followed by a method in a new line with a semicolon) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + GeneratorMethod + + GeneratorMethod : + * ClassElementName ( UniqueFormalParameters ){ GeneratorBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static * #$(value) { + yield * value; + } + static * #_(value) { + yield * value; + } + static * #o(value) { + yield * value; + } + static * #℘(value) { + yield * value; + } + static * #ZW_‌_NJ(value) { + yield * value; + } + static * #ZW_‍_J(value) { + yield * value; + }; + m() { return 42; } + static get $() { + return this.#$; + } + static get _() { + return this.#_; + } + static get o() { + return this.#o; + } + static get ℘() { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#℘; + } + static get ZW_‌_NJ() { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#ZW_‌_NJ; + } + static get ZW_‍_J() { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#ZW_‍_J; + } + +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(C.$([1]).next().value, 1); +assert.sameValue(C._([1]).next().value, 1); +assert.sameValue(C.o([1]).next().value, 1); +assert.sameValue(C.℘([1]).next().value, 1); +assert.sameValue(C.ZW_‌_NJ([1]).next().value, 1); +assert.sameValue(C.ZW_‍_J([1]).next().value, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/new-sc-line-method-rs-static-generator-method-privatename-identifier.js b/js/src/tests/test262/language/statements/class/elements/new-sc-line-method-rs-static-generator-method-privatename-identifier.js new file mode 100644 index 0000000000..82b2ec6d18 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/new-sc-line-method-rs-static-generator-method-privatename-identifier.js @@ -0,0 +1,126 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-generator-method-privatename-identifier.case +// - src/class-elements/productions/cls-decl-new-sc-line-method.template +/*--- +description: Valid Static GeneratorMethod PrivateName (field definitions followed by a method in a new line with a semicolon) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + GeneratorMethod + + GeneratorMethod : + * ClassElementName ( UniqueFormalParameters ){ GeneratorBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static * #$(value) { + yield * value; + } + static * #_(value) { + yield * value; + } + static * #\u{6F}(value) { + yield * value; + } + static * #\u2118(value) { + yield * value; + } + static * #ZW_\u200C_NJ(value) { + yield * value; + } + static * #ZW_\u200D_J(value) { + yield * value; + }; + m() { return 42; } + static get $() { + return this.#$; + } + static get _() { + return this.#_; + } + static get \u{6F}() { + return this.#\u{6F}; + } + static get \u2118() { + return this.#\u2118; + } + static get ZW_\u200C_NJ() { + return this.#ZW_\u200C_NJ; + } + static get ZW_\u200D_J() { + return this.#ZW_\u200D_J; + } + +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(C.$([1]).next().value, 1); +assert.sameValue(C._([1]).next().value, 1); +assert.sameValue(C.\u{6F}([1]).next().value, 1); +assert.sameValue(C.\u2118([1]).next().value, 1); +assert.sameValue(C.ZW_\u200C_NJ([1]).next().value, 1); +assert.sameValue(C.ZW_\u200D_J([1]).next().value, 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/new-sc-line-method-rs-static-method-privatename-identifier-alt.js b/js/src/tests/test262/language/statements/class/elements/new-sc-line-method-rs-static-method-privatename-identifier-alt.js new file mode 100644 index 0000000000..35b209fff2 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/new-sc-line-method-rs-static-method-privatename-identifier-alt.js @@ -0,0 +1,123 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-method-privatename-identifier-alt.case +// - src/class-elements/productions/cls-decl-new-sc-line-method.template +/*--- +description: Valid Static Method PrivateName (field definitions followed by a method in a new line with a semicolon) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + ClassElementName ( UniqueFormalParameters ){ FunctionBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static #$(value) { + return value; + } + static #_(value) { + return value; + } + static #o(value) { + return value; + } + static #℘(value) { + return value; + } + static #ZW_‌_NJ(value) { + return value; + } + static #ZW_‍_J(value) { + return value; + }; + m() { return 42; } + static $(value) { + return this.#$(value); + } + static _(value) { + return this.#_(value); + } + static o(value) { + return this.#o(value); + } + static ℘(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#℘(value); + } + static ZW_‌_NJ(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#ZW_‌_NJ(value); + } + static ZW_‍_J(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#ZW_‍_J(value); + } + +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(C.$(1), 1); +assert.sameValue(C._(1), 1); +assert.sameValue(C.o(1), 1); +assert.sameValue(C.℘(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD +assert.sameValue(C.ZW_‌_NJ(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD +assert.sameValue(C.ZW_‍_J(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/new-sc-line-method-rs-static-method-privatename-identifier.js b/js/src/tests/test262/language/statements/class/elements/new-sc-line-method-rs-static-method-privatename-identifier.js new file mode 100644 index 0000000000..7fbc907383 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/new-sc-line-method-rs-static-method-privatename-identifier.js @@ -0,0 +1,123 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-method-privatename-identifier.case +// - src/class-elements/productions/cls-decl-new-sc-line-method.template +/*--- +description: Valid Static Method PrivateName (field definitions followed by a method in a new line with a semicolon) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + ClassElementName ( UniqueFormalParameters ){ FunctionBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static #$(value) { + return value; + } + static #_(value) { + return value; + } + static #\u{6F}(value) { + return value; + } + static #\u2118(value) { + return value; + } + static #ZW_\u200C_NJ(value) { + return value; + } + static #ZW_\u200D_J(value) { + return value; + }; + m() { return 42; } + static $(value) { + return this.#$(value); + } + static _(value) { + return this.#_(value); + } + static \u{6F}(value) { + return this.#\u{6F}(value); + } + static \u2118(value) { + return this.#\u2118(value); + } + static ZW_\u200C_NJ(value) { + return this.#ZW_\u200C_NJ(value); + } + static ZW_\u200D_J(value) { + return this.#ZW_\u200D_J(value); + } + +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(C.$(1), 1); +assert.sameValue(C._(1), 1); +assert.sameValue(C.\u{6F}(1), 1); +assert.sameValue(C.\u2118(1), 1); +assert.sameValue(C.ZW_\u200C_NJ(1), 1); +assert.sameValue(C.ZW_\u200D_J(1), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/new-sc-line-method-rs-static-privatename-identifier-alt-by-classname.js b/js/src/tests/test262/language/statements/class/elements/new-sc-line-method-rs-static-privatename-identifier-alt-by-classname.js new file mode 100644 index 0000000000..ba19461f26 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/new-sc-line-method-rs-static-privatename-identifier-alt-by-classname.js @@ -0,0 +1,111 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-privatename-identifier-alt-by-classname.case +// - src/class-elements/productions/cls-decl-new-sc-line-method.template +/*--- +description: Valid Static PrivateName (field definitions followed by a method in a new line with a semicolon) +esid: prod-FieldDefinition +features: [class-static-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static #$; static #_; static #\u{6F}; static #℘; static #ZW_‌_NJ; static #ZW_‍_J; + m() { return 42; } + static $(value) { + C.#$ = value; + return C.#$; + } + static _(value) { + C.#_ = value; + return C.#_; + } + static o(value) { + C.#\u{6F} = value; + return C.#\u{6F}; + } + static ℘(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + C.#℘ = value; + return C.#℘; + } + static ZW_‌_NJ(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + C.#ZW_‌_NJ = value; + return C.#ZW_‌_NJ; + } + static ZW_‍_J(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + C.#ZW_‍_J = value; + return C.#ZW_‍_J; + } +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(C.$(1), 1); +assert.sameValue(C._(1), 1); +assert.sameValue(C.o(1), 1); +assert.sameValue(C.℘(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD +assert.sameValue(C.ZW_‌_NJ(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD +assert.sameValue(C.ZW_‍_J(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/new-sc-line-method-rs-static-privatename-identifier-alt.js b/js/src/tests/test262/language/statements/class/elements/new-sc-line-method-rs-static-privatename-identifier-alt.js new file mode 100644 index 0000000000..3f64c4b090 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/new-sc-line-method-rs-static-privatename-identifier-alt.js @@ -0,0 +1,111 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-privatename-identifier-alt.case +// - src/class-elements/productions/cls-decl-new-sc-line-method.template +/*--- +description: Valid Static PrivateName (field definitions followed by a method in a new line with a semicolon) +esid: prod-FieldDefinition +features: [class-static-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static #$; static #_; static #\u{6F}; static #℘; static #ZW_‌_NJ; static #ZW_‍_J; + m() { return 42; } + static $(value) { + this.#$ = value; + return this.#$; + } + static _(value) { + this.#_ = value; + return this.#_; + } + static o(value) { + this.#\u{6F} = value; + return this.#\u{6F}; + } + static ℘(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + this.#℘ = value; + return this.#℘; + } + static ZW_‌_NJ(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + this.#ZW_‌_NJ = value; + return this.#ZW_‌_NJ; + } + static ZW_‍_J(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + this.#ZW_‍_J = value; + return this.#ZW_‍_J; + } +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(C.$(1), 1); +assert.sameValue(C._(1), 1); +assert.sameValue(C.o(1), 1); +assert.sameValue(C.℘(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD +assert.sameValue(C.ZW_‌_NJ(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD +assert.sameValue(C.ZW_‍_J(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/new-sc-line-method-rs-static-privatename-identifier-by-classname.js b/js/src/tests/test262/language/statements/class/elements/new-sc-line-method-rs-static-privatename-identifier-by-classname.js new file mode 100644 index 0000000000..6702dff50a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/new-sc-line-method-rs-static-privatename-identifier-by-classname.js @@ -0,0 +1,111 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-privatename-identifier-by-classname.case +// - src/class-elements/productions/cls-decl-new-sc-line-method.template +/*--- +description: Valid Static PrivateName (field definitions followed by a method in a new line with a semicolon) +esid: prod-FieldDefinition +features: [class-static-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static #$; static #_; static #\u{6F}; static #\u2118; static #ZW_\u200C_NJ; static #ZW_\u200D_J; + m() { return 42; } + static $(value) { + C.#$ = value; + return C.#$; + } + static _(value) { + C.#_ = value; + return C.#_; + } + static \u{6F}(value) { + C.#\u{6F} = value; + return C.#\u{6F}; + } + static \u2118(value) { + C.#\u2118 = value; + return C.#\u2118; + } + static ZW_\u200C_NJ(value) { + C.#ZW_\u200C_NJ = value; + return C.#ZW_\u200C_NJ; + } + static ZW_\u200D_J(value) { + C.#ZW_\u200D_J = value; + return C.#ZW_\u200D_J; + } +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(C.$(1), 1); +assert.sameValue(C._(1), 1); +assert.sameValue(C.\u{6F}(1), 1); +assert.sameValue(C.\u2118(1), 1); +assert.sameValue(C.ZW_\u200C_NJ(1), 1); +assert.sameValue(C.ZW_\u200D_J(1), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/new-sc-line-method-rs-static-privatename-identifier-initializer-alt-by-classname.js b/js/src/tests/test262/language/statements/class/elements/new-sc-line-method-rs-static-privatename-identifier-initializer-alt-by-classname.js new file mode 100644 index 0000000000..45a772c8f2 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/new-sc-line-method-rs-static-privatename-identifier-initializer-alt-by-classname.js @@ -0,0 +1,105 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-privatename-identifier-initializer-alt-by-classname.case +// - src/class-elements/productions/cls-decl-new-sc-line-method.template +/*--- +description: Valid Static PrivateName (field definitions followed by a method in a new line with a semicolon) +esid: prod-FieldDefinition +features: [class-static-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static #$ = 1; static #_ = 1; static #\u{6F} = 1; static #℘ = 1; static #ZW_‌_NJ = 1; static #ZW_‍_J = 1; + m() { return 42; } + static $() { + return C.#$; + } + static _() { + return C.#_; + } + static \u{6F}() { + return C.#\u{6F}; + } + static ℘() { + return C.#℘; + } + static ZW_‌_NJ() { + return C.#ZW_‌_NJ; + } + static ZW_‍_J() { + return C.#ZW_‍_J; + } +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(C.$(), 1); +assert.sameValue(C._(), 1); +assert.sameValue(C.\u{6F}(), 1); +assert.sameValue(C.℘(), 1); +assert.sameValue(C.ZW_‌_NJ(), 1); +assert.sameValue(C.ZW_‍_J(), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/new-sc-line-method-rs-static-privatename-identifier-initializer-alt.js b/js/src/tests/test262/language/statements/class/elements/new-sc-line-method-rs-static-privatename-identifier-initializer-alt.js new file mode 100644 index 0000000000..42f363a9cd --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/new-sc-line-method-rs-static-privatename-identifier-initializer-alt.js @@ -0,0 +1,105 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-privatename-identifier-initializer-alt.case +// - src/class-elements/productions/cls-decl-new-sc-line-method.template +/*--- +description: Valid Static PrivateName (field definitions followed by a method in a new line with a semicolon) +esid: prod-FieldDefinition +features: [class-static-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static #$ = 1; static #_ = 1; static #\u{6F} = 1; static #℘ = 1; static #ZW_‌_NJ = 1; static #ZW_‍_J = 1; + m() { return 42; } + static $() { + return this.#$; + } + static _() { + return this.#_; + } + static \u{6F}() { + return this.#\u{6F}; + } + static ℘() { + return this.#℘; + } + static ZW_‌_NJ() { + return this.#ZW_‌_NJ; + } + static ZW_‍_J() { + return this.#ZW_‍_J; + } +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(C.$(), 1); +assert.sameValue(C._(), 1); +assert.sameValue(C.\u{6F}(), 1); +assert.sameValue(C.℘(), 1); +assert.sameValue(C.ZW_‌_NJ(), 1); +assert.sameValue(C.ZW_‍_J(), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/new-sc-line-method-rs-static-privatename-identifier-initializer.js b/js/src/tests/test262/language/statements/class/elements/new-sc-line-method-rs-static-privatename-identifier-initializer.js new file mode 100644 index 0000000000..b5b7b7e340 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/new-sc-line-method-rs-static-privatename-identifier-initializer.js @@ -0,0 +1,105 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-privatename-identifier-initializer.case +// - src/class-elements/productions/cls-decl-new-sc-line-method.template +/*--- +description: Valid Static PrivateName (field definitions followed by a method in a new line with a semicolon) +esid: prod-FieldDefinition +features: [class-static-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static #$ = 1; static #_ = 1; static #\u{6F} = 1; static #\u2118 = 1; static #ZW_\u200C_NJ = 1; static #ZW_\u200D_J = 1; + m() { return 42; } + static $() { + return this.#$; + } + static _() { + return this.#_; + } + static \u{6F}() { + return this.#\u{6F}; + } + static \u2118() { + return this.#\u2118; + } + static ZW_\u200C_NJ() { + return this.#ZW_\u200C_NJ; + } + static ZW_\u200D_J() { + return this.#ZW_\u200D_J; + } +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(C.$(), 1); +assert.sameValue(C._(), 1); +assert.sameValue(C.\u{6F}(), 1); +assert.sameValue(C.\u2118(), 1); +assert.sameValue(C.ZW_\u200C_NJ(), 1); +assert.sameValue(C.ZW_\u200D_J(), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/new-sc-line-method-rs-static-privatename-identifier.js b/js/src/tests/test262/language/statements/class/elements/new-sc-line-method-rs-static-privatename-identifier.js new file mode 100644 index 0000000000..4c51ca0bd4 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/new-sc-line-method-rs-static-privatename-identifier.js @@ -0,0 +1,111 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-privatename-identifier.case +// - src/class-elements/productions/cls-decl-new-sc-line-method.template +/*--- +description: Valid Static PrivateName (field definitions followed by a method in a new line with a semicolon) +esid: prod-FieldDefinition +features: [class-static-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static #$; static #_; static #\u{6F}; static #\u2118; static #ZW_\u200C_NJ; static #ZW_\u200D_J; + m() { return 42; } + static $(value) { + this.#$ = value; + return this.#$; + } + static _(value) { + this.#_ = value; + return this.#_; + } + static \u{6F}(value) { + this.#\u{6F} = value; + return this.#\u{6F}; + } + static \u2118(value) { + this.#\u2118 = value; + return this.#\u2118; + } + static ZW_\u200C_NJ(value) { + this.#ZW_\u200C_NJ = value; + return this.#ZW_\u200C_NJ; + } + static ZW_\u200D_J(value) { + this.#ZW_\u200D_J = value; + return this.#ZW_\u200D_J; + } +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(C.$(1), 1); +assert.sameValue(C._(1), 1); +assert.sameValue(C.\u{6F}(1), 1); +assert.sameValue(C.\u2118(1), 1); +assert.sameValue(C.ZW_\u200C_NJ(1), 1); +assert.sameValue(C.ZW_\u200D_J(1), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/new-sc-line-method-static-private-fields.js b/js/src/tests/test262/language/statements/class/elements/new-sc-line-method-static-private-fields.js new file mode 100644 index 0000000000..ecb032989a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/new-sc-line-method-static-private-fields.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/static-private-fields.case +// - src/class-elements/productions/cls-decl-new-sc-line-method.template +/*--- +description: static private fields (field definitions followed by a method in a new line with a semicolon) +esid: prod-FieldDefinition +features: [class-static-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + ... + static FieldDefinition ; + + FieldDefinition : + ClassElementName Initializer_opt + + ClassElementName : + PrivateName + + PrivateName : + # IdentifierName + +---*/ + + +class C { + static #x; static #y; + m() { return 42; } + static x() { + this.#x = 42; + return this.#x; + } + static y() { + this.#y = 43; + return this.#y; + } +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +// Test the private fields do not appear as properties before set to value +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#x"), "test 1"); +assert(!Object.prototype.hasOwnProperty.call(C, "#x"), "test 2"); +assert(!Object.prototype.hasOwnProperty.call(c, "#x"), "test 3"); + +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#y"), "test 4"); +assert(!Object.prototype.hasOwnProperty.call(C, "#y"), "test 5"); +assert(!Object.prototype.hasOwnProperty.call(c, "#y"), "test 6"); + +// Test if private fields can be sucessfully accessed and set to value +assert.sameValue(C.x(), 42, "test 7"); +assert.sameValue(C.y(), 43, "test 8"); + +// Test the private fields do not appear as properties before after set to value +assert(!Object.prototype.hasOwnProperty.call(C, "#x"), "test 9"); +assert(!Object.prototype.hasOwnProperty.call(C, "#y"), "test 10"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/new-sc-line-method-static-private-methods-with-fields.js b/js/src/tests/test262/language/statements/class/elements/new-sc-line-method-static-private-methods-with-fields.js new file mode 100644 index 0000000000..fa2cf48168 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/new-sc-line-method-static-private-methods-with-fields.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/static-private-methods-with-fields.case +// - src/class-elements/productions/cls-decl-new-sc-line-method.template +/*--- +description: static private methods with fields (field definitions followed by a method in a new line with a semicolon) +esid: prod-FieldDefinition +features: [class-static-methods-private, class-static-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + ... + static FieldDefinition ; + + FieldDefinition : + ClassElementName Initializer_opt + + ClassElementName : + PrivateName + + PrivateName : + # IdentifierName + +---*/ + + +class C { + static #xVal; static #yVal; + m() { return 42; } + static #x(value) { + this.#xVal = value; + return this.#xVal; + } + static #y(value) { + this.#yVal = value; + return this.#yVal; + } + static x() { + return this.#x(42); + } + static y() { + return this.#y(43); + } +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +// Test the private methods do not appear as properties before set to value +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#x"), "test 1"); +assert(!Object.prototype.hasOwnProperty.call(C, "#x"), "test 2"); +assert(!Object.prototype.hasOwnProperty.call(c, "#x"), "test 3"); + +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#y"), "test 4"); +assert(!Object.prototype.hasOwnProperty.call(C, "#y"), "test 5"); +assert(!Object.prototype.hasOwnProperty.call(c, "#y"), "test 6"); + +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#xVal"), "test 7"); +assert(!Object.prototype.hasOwnProperty.call(C, "#xVal"), "test 8"); +assert(!Object.prototype.hasOwnProperty.call(c, "#xVal"), "test 9"); + +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#yVal"), "test 10"); +assert(!Object.prototype.hasOwnProperty.call(C, "#yVal"), "test 11"); +assert(!Object.prototype.hasOwnProperty.call(c, "#yVal"), "test 12"); + +// Test if private fields can be sucessfully accessed and set to value +assert.sameValue(C.x(), 42, "test 13"); +assert.sameValue(C.y(), 43, "test 14"); + +// Test the private fields do not appear as properties before after set to value +assert(!Object.prototype.hasOwnProperty.call(C, "#x"), "test 15"); +assert(!Object.prototype.hasOwnProperty.call(C, "#y"), "test 16"); + +assert(!Object.prototype.hasOwnProperty.call(C, "#xVal"), "test 17"); +assert(!Object.prototype.hasOwnProperty.call(C, "#yVal"), "test 18"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/new-sc-line-method-static-private-methods.js b/js/src/tests/test262/language/statements/class/elements/new-sc-line-method-static-private-methods.js new file mode 100644 index 0000000000..160950265f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/new-sc-line-method-static-private-methods.js @@ -0,0 +1,76 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/static-private-methods.case +// - src/class-elements/productions/cls-decl-new-sc-line-method.template +/*--- +description: static private methods (field definitions followed by a method in a new line with a semicolon) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + ... + static FieldDefinition ; + + FieldDefinition : + ClassElementName Initializer_opt + + ClassElementName : + PrivateName + + PrivateName : + # IdentifierName + +---*/ + + +class C { + ; + m() { return 42; } + static #x(value) { + return value / 2; + } + static #y(value) { + return value * 2; + } + static x() { + return this.#x(84); + } + static y() { + return this.#y(43); + } +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +// Test the private methods do not appear as properties before set to value +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#x"), "test 1"); +assert(!Object.prototype.hasOwnProperty.call(C, "#x"), "test 2"); +assert(!Object.prototype.hasOwnProperty.call(c, "#x"), "test 3"); + +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#y"), "test 4"); +assert(!Object.prototype.hasOwnProperty.call(C, "#y"), "test 5"); +assert(!Object.prototype.hasOwnProperty.call(c, "#y"), "test 6"); + +// Test if private fields can be sucessfully accessed and set to value +assert.sameValue(C.x(), 42, "test 7"); +assert.sameValue(C.y(), 86, "test 8"); + +// Test the private fields do not appear as properties before after set to value +assert(!Object.prototype.hasOwnProperty.call(C, "#x"), "test 9"); +assert(!Object.prototype.hasOwnProperty.call(C, "#y"), "test 10"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/new-sc-line-method-string-literal-names.js b/js/src/tests/test262/language/statements/class/elements/new-sc-line-method-string-literal-names.js new file mode 100644 index 0000000000..09c7a06843 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/new-sc-line-method-string-literal-names.js @@ -0,0 +1,110 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/string-literal-names.case +// - src/class-elements/productions/cls-decl-new-sc-line-method.template +/*--- +description: String literal names (field definitions followed by a method in a new line with a semicolon) +esid: prod-FieldDefinition +features: [class-fields-public, class] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PropertyName + +---*/ + + +class C { + 'a'; "b"; 'c' = 39; + "d" = 42; + m() { return 42; } + +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "a"), + "a does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "a"), + "a does not appear as an own property on C constructor" +); + +verifyProperty(c, "a", { + value: undefined, + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "b"), + "b does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "b"), + "b does not appear as an own property on C constructor" +); + +verifyProperty(c, "b", { + value: undefined, + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "c"), + "c does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "c"), + "c does not appear as an own property on C constructor" +); + +verifyProperty(c, "c", { + value: 39, + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "d"), + "d does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "d"), + "d does not appear as an own property on C constructor" +); + +verifyProperty(c, "d", { + value: 42, + enumerable: true, + writable: true, + configurable: true +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-accessor-is-visible-in-computed-properties.js b/js/src/tests/test262/language/statements/class/elements/private-accessor-is-visible-in-computed-properties.js new file mode 100644 index 0000000000..0084349ef3 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-accessor-is-visible-in-computed-properties.js @@ -0,0 +1,34 @@ +// Copyright (C) 2019 Caio Lima (Igalia SL). All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Private getter of a class is visible in its ComputetProperty scope +esid: prod-ClassTail +info: | + ClassTail : ClassHeritage { ClassBody } + 1. Let lex be the LexicalEnvironment of the running execution context. + 2. Let classScope be NewDeclarativeEnvironment(lex). + 3. Let classScopeEnvRec be classScope's EnvironmentRecord. + ... + 15. Set the running execution context's LexicalEnvironment to classScope. + 16. Set the running execution context's PrivateEnvironment to classPrivateEnvironment. + ... + 27. For each ClassElement e in order from elements + a. If IsStatic of e is false, then + i. Let field be the result of ClassElementEvaluation for e with arguments proto and false. + ... +features: [class-methods-private, class-fields-public, class] +---*/ + +assert.throws(TypeError, function() { + class C { + get #f() { + throw new Test262Error(); + } + + [this.#f] = 'Test262'; + } +}, 'access to a private acessor from ordinary object'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-accessor-name/browser.js b/js/src/tests/test262/language/statements/class/elements/private-accessor-name/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/elements/private-accessor-name/inst-private-escape-sequence-ZWJ.js b/js/src/tests/test262/language/statements/class/elements/private-accessor-name/inst-private-escape-sequence-ZWJ.js new file mode 100644 index 0000000000..ac75d7fc59 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-accessor-name/inst-private-escape-sequence-ZWJ.js @@ -0,0 +1,80 @@ +// This file was procedurally generated from the following sources: +// - src/accessor-names/private-escape-sequence-ZWJ.case +// - src/accessor-names/private/cls-private-decl-inst.template +/*--- +description: Private IdentifierName - ZWJ (Class declaration, private instance method) +features: [class, class-methods-private] +flags: [generated] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + Initializer : + = AssignmentExpression + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + +var stringSet; + +class C { + get #ZW_\u200D_J() { return 'get string'; } + set #ZW_\u200D_J(param) { stringSet = param; } + + getPrivateReference() { + return this.#ZW_‍_J; + } + + setPrivateReference(value) { + this.#ZW_‍_J = value; + } +}; + +var inst = new C(); + +assert.sameValue(inst.getPrivateReference(), 'get string'); + +inst.setPrivateReference('set string'); +assert.sameValue(stringSet, 'set string'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-accessor-name/inst-private-escape-sequence-ZWNJ.js b/js/src/tests/test262/language/statements/class/elements/private-accessor-name/inst-private-escape-sequence-ZWNJ.js new file mode 100644 index 0000000000..d99e759d6d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-accessor-name/inst-private-escape-sequence-ZWNJ.js @@ -0,0 +1,80 @@ +// This file was procedurally generated from the following sources: +// - src/accessor-names/private-escape-sequence-ZWNJ.case +// - src/accessor-names/private/cls-private-decl-inst.template +/*--- +description: Private IdentifierName - ZWNJ (Class declaration, private instance method) +features: [class, class-methods-private] +flags: [generated] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + Initializer : + = AssignmentExpression + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + +var stringSet; + +class C { + get #ZW_\u200C_NJ() { return 'get string'; } + set #ZW_\u200C_NJ(param) { stringSet = param; } + + getPrivateReference() { + return this.#ZW_‌_NJ; + } + + setPrivateReference(value) { + this.#ZW_‌_NJ = value; + } +}; + +var inst = new C(); + +assert.sameValue(inst.getPrivateReference(), 'get string'); + +inst.setPrivateReference('set string'); +assert.sameValue(stringSet, 'set string'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-accessor-name/inst-private-escape-sequence-u2118.js b/js/src/tests/test262/language/statements/class/elements/private-accessor-name/inst-private-escape-sequence-u2118.js new file mode 100644 index 0000000000..c9470c32e0 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-accessor-name/inst-private-escape-sequence-u2118.js @@ -0,0 +1,80 @@ +// This file was procedurally generated from the following sources: +// - src/accessor-names/private-escape-sequence-u2118.case +// - src/accessor-names/private/cls-private-decl-inst.template +/*--- +description: Private IdentifierName - u2118 (℘) (Class declaration, private instance method) +features: [class, class-methods-private] +flags: [generated] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + Initializer : + = AssignmentExpression + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + +var stringSet; + +class C { + get #\u2118() { return 'get string'; } + set #\u2118(param) { stringSet = param; } + + getPrivateReference() { + return this.#℘; + } + + setPrivateReference(value) { + this.#℘ = value; + } +}; + +var inst = new C(); + +assert.sameValue(inst.getPrivateReference(), 'get string'); + +inst.setPrivateReference('set string'); +assert.sameValue(stringSet, 'set string'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-accessor-name/inst-private-escape-sequence-u6F.js b/js/src/tests/test262/language/statements/class/elements/private-accessor-name/inst-private-escape-sequence-u6F.js new file mode 100644 index 0000000000..7bd39f4bb0 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-accessor-name/inst-private-escape-sequence-u6F.js @@ -0,0 +1,80 @@ +// This file was procedurally generated from the following sources: +// - src/accessor-names/private-escape-sequence-u6F.case +// - src/accessor-names/private/cls-private-decl-inst.template +/*--- +description: Private IdentifierName - u6F (o) (Class declaration, private instance method) +features: [class, class-methods-private] +flags: [generated] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + Initializer : + = AssignmentExpression + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + +var stringSet; + +class C { + get #\u{6F}() { return 'get string'; } + set #\u{6F}(param) { stringSet = param; } + + getPrivateReference() { + return this.#o; + } + + setPrivateReference(value) { + this.#o = value; + } +}; + +var inst = new C(); + +assert.sameValue(inst.getPrivateReference(), 'get string'); + +inst.setPrivateReference('set string'); +assert.sameValue(stringSet, 'set string'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-accessor-name/inst-private-name-ZWJ.js b/js/src/tests/test262/language/statements/class/elements/private-accessor-name/inst-private-name-ZWJ.js new file mode 100644 index 0000000000..5c8ebeaef5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-accessor-name/inst-private-name-ZWJ.js @@ -0,0 +1,80 @@ +// This file was procedurally generated from the following sources: +// - src/accessor-names/private-name-ZWJ.case +// - src/accessor-names/private/cls-private-decl-inst.template +/*--- +description: Private IdentifierName - ZWJ (Class declaration, private instance method) +features: [class, class-methods-private] +flags: [generated] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + Initializer : + = AssignmentExpression + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + +var stringSet; + +class C { + get #ZW_‍_J() { return 'get string'; } + set #ZW_‍_J(param) { stringSet = param; } + + getPrivateReference() { + return this.#ZW_‍_J; + } + + setPrivateReference(value) { + this.#ZW_‍_J = value; + } +}; + +var inst = new C(); + +assert.sameValue(inst.getPrivateReference(), 'get string'); + +inst.setPrivateReference('set string'); +assert.sameValue(stringSet, 'set string'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-accessor-name/inst-private-name-ZWNJ.js b/js/src/tests/test262/language/statements/class/elements/private-accessor-name/inst-private-name-ZWNJ.js new file mode 100644 index 0000000000..85a6a43601 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-accessor-name/inst-private-name-ZWNJ.js @@ -0,0 +1,80 @@ +// This file was procedurally generated from the following sources: +// - src/accessor-names/private-name-ZWNJ.case +// - src/accessor-names/private/cls-private-decl-inst.template +/*--- +description: Private IdentifierName - ZWNJ (Class declaration, private instance method) +features: [class, class-methods-private] +flags: [generated] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + Initializer : + = AssignmentExpression + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + +var stringSet; + +class C { + get #ZW_‌_NJ() { return 'get string'; } + set #ZW_‌_NJ(param) { stringSet = param; } + + getPrivateReference() { + return this.#ZW_‌_NJ; + } + + setPrivateReference(value) { + this.#ZW_‌_NJ = value; + } +}; + +var inst = new C(); + +assert.sameValue(inst.getPrivateReference(), 'get string'); + +inst.setPrivateReference('set string'); +assert.sameValue(stringSet, 'set string'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-accessor-name/inst-private-name-common.js b/js/src/tests/test262/language/statements/class/elements/private-accessor-name/inst-private-name-common.js new file mode 100644 index 0000000000..70756ae6ff --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-accessor-name/inst-private-name-common.js @@ -0,0 +1,80 @@ +// This file was procedurally generated from the following sources: +// - src/accessor-names/private-name-common.case +// - src/accessor-names/private/cls-private-decl-inst.template +/*--- +description: Private IdentifierName - common (Class declaration, private instance method) +features: [class, class-methods-private] +flags: [generated] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + Initializer : + = AssignmentExpression + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + +var stringSet; + +class C { + get #test262() { return 'get string'; } + set #test262(param) { stringSet = param; } + + getPrivateReference() { + return this.#test262; + } + + setPrivateReference(value) { + this.#test262 = value; + } +}; + +var inst = new C(); + +assert.sameValue(inst.getPrivateReference(), 'get string'); + +inst.setPrivateReference('set string'); +assert.sameValue(stringSet, 'set string'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-accessor-name/inst-private-name-dollar.js b/js/src/tests/test262/language/statements/class/elements/private-accessor-name/inst-private-name-dollar.js new file mode 100644 index 0000000000..e151c45262 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-accessor-name/inst-private-name-dollar.js @@ -0,0 +1,80 @@ +// This file was procedurally generated from the following sources: +// - src/accessor-names/private-name-dollar.case +// - src/accessor-names/private/cls-private-decl-inst.template +/*--- +description: Private IdentifierName - $ (Class declaration, private instance method) +features: [class, class-methods-private] +flags: [generated] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + Initializer : + = AssignmentExpression + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + +var stringSet; + +class C { + get #$() { return 'get string'; } + set #$(param) { stringSet = param; } + + getPrivateReference() { + return this.#$; + } + + setPrivateReference(value) { + this.#$ = value; + } +}; + +var inst = new C(); + +assert.sameValue(inst.getPrivateReference(), 'get string'); + +inst.setPrivateReference('set string'); +assert.sameValue(stringSet, 'set string'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-accessor-name/inst-private-name-u2118.js b/js/src/tests/test262/language/statements/class/elements/private-accessor-name/inst-private-name-u2118.js new file mode 100644 index 0000000000..9e000f3a63 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-accessor-name/inst-private-name-u2118.js @@ -0,0 +1,80 @@ +// This file was procedurally generated from the following sources: +// - src/accessor-names/private-name-u2118.case +// - src/accessor-names/private/cls-private-decl-inst.template +/*--- +description: Private IdentifierName - ℘ (Class declaration, private instance method) +features: [class, class-methods-private] +flags: [generated] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + Initializer : + = AssignmentExpression + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + +var stringSet; + +class C { + get #℘() { return 'get string'; } + set #℘(param) { stringSet = param; } + + getPrivateReference() { + return this.#℘; + } + + setPrivateReference(value) { + this.#℘ = value; + } +}; + +var inst = new C(); + +assert.sameValue(inst.getPrivateReference(), 'get string'); + +inst.setPrivateReference('set string'); +assert.sameValue(stringSet, 'set string'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-accessor-name/inst-private-name-underscore.js b/js/src/tests/test262/language/statements/class/elements/private-accessor-name/inst-private-name-underscore.js new file mode 100644 index 0000000000..febea21fec --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-accessor-name/inst-private-name-underscore.js @@ -0,0 +1,80 @@ +// This file was procedurally generated from the following sources: +// - src/accessor-names/private-name-underscore.case +// - src/accessor-names/private/cls-private-decl-inst.template +/*--- +description: Private IdentifierName - _ (Class declaration, private instance method) +features: [class, class-methods-private] +flags: [generated] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + Initializer : + = AssignmentExpression + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + +var stringSet; + +class C { + get #_() { return 'get string'; } + set #_(param) { stringSet = param; } + + getPrivateReference() { + return this.#_; + } + + setPrivateReference(value) { + this.#_ = value; + } +}; + +var inst = new C(); + +assert.sameValue(inst.getPrivateReference(), 'get string'); + +inst.setPrivateReference('set string'); +assert.sameValue(stringSet, 'set string'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-accessor-name/shell.js b/js/src/tests/test262/language/statements/class/elements/private-accessor-name/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/elements/private-accessor-name/static-private-escape-sequence-ZWJ.js b/js/src/tests/test262/language/statements/class/elements/private-accessor-name/static-private-escape-sequence-ZWJ.js new file mode 100644 index 0000000000..351eb7f5b4 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-accessor-name/static-private-escape-sequence-ZWJ.js @@ -0,0 +1,79 @@ +// This file was procedurally generated from the following sources: +// - src/accessor-names/private-escape-sequence-ZWJ.case +// - src/accessor-names/private/cls-private-decl-static.template +/*--- +description: Private IdentifierName - ZWJ (Class declaration, static method) +features: [class, class-static-methods-private] +flags: [generated] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + Initializer : + = AssignmentExpression + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + +var stringSet; + +class C { + static get #ZW_\u200D_J() { return 'get string'; } + static set #ZW_\u200D_J(param) { stringSet = param; } + + static getPrivateReference() { + return this.#ZW_‍_J; + } + + static setPrivateReference(value) { + this.#ZW_‍_J = value; + } +} + +assert.sameValue(C.getPrivateReference(), 'get string'); + +C.setPrivateReference('set string'); +assert.sameValue(stringSet, 'set string'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-accessor-name/static-private-escape-sequence-ZWNJ.js b/js/src/tests/test262/language/statements/class/elements/private-accessor-name/static-private-escape-sequence-ZWNJ.js new file mode 100644 index 0000000000..05ea4118f2 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-accessor-name/static-private-escape-sequence-ZWNJ.js @@ -0,0 +1,79 @@ +// This file was procedurally generated from the following sources: +// - src/accessor-names/private-escape-sequence-ZWNJ.case +// - src/accessor-names/private/cls-private-decl-static.template +/*--- +description: Private IdentifierName - ZWNJ (Class declaration, static method) +features: [class, class-static-methods-private] +flags: [generated] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + Initializer : + = AssignmentExpression + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + +var stringSet; + +class C { + static get #ZW_\u200C_NJ() { return 'get string'; } + static set #ZW_\u200C_NJ(param) { stringSet = param; } + + static getPrivateReference() { + return this.#ZW_‌_NJ; + } + + static setPrivateReference(value) { + this.#ZW_‌_NJ = value; + } +} + +assert.sameValue(C.getPrivateReference(), 'get string'); + +C.setPrivateReference('set string'); +assert.sameValue(stringSet, 'set string'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-accessor-name/static-private-escape-sequence-u2118.js b/js/src/tests/test262/language/statements/class/elements/private-accessor-name/static-private-escape-sequence-u2118.js new file mode 100644 index 0000000000..554a6a1034 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-accessor-name/static-private-escape-sequence-u2118.js @@ -0,0 +1,79 @@ +// This file was procedurally generated from the following sources: +// - src/accessor-names/private-escape-sequence-u2118.case +// - src/accessor-names/private/cls-private-decl-static.template +/*--- +description: Private IdentifierName - u2118 (℘) (Class declaration, static method) +features: [class, class-static-methods-private] +flags: [generated] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + Initializer : + = AssignmentExpression + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + +var stringSet; + +class C { + static get #\u2118() { return 'get string'; } + static set #\u2118(param) { stringSet = param; } + + static getPrivateReference() { + return this.#℘; + } + + static setPrivateReference(value) { + this.#℘ = value; + } +} + +assert.sameValue(C.getPrivateReference(), 'get string'); + +C.setPrivateReference('set string'); +assert.sameValue(stringSet, 'set string'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-accessor-name/static-private-escape-sequence-u6F.js b/js/src/tests/test262/language/statements/class/elements/private-accessor-name/static-private-escape-sequence-u6F.js new file mode 100644 index 0000000000..1420f0d547 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-accessor-name/static-private-escape-sequence-u6F.js @@ -0,0 +1,79 @@ +// This file was procedurally generated from the following sources: +// - src/accessor-names/private-escape-sequence-u6F.case +// - src/accessor-names/private/cls-private-decl-static.template +/*--- +description: Private IdentifierName - u6F (o) (Class declaration, static method) +features: [class, class-static-methods-private] +flags: [generated] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + Initializer : + = AssignmentExpression + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + +var stringSet; + +class C { + static get #\u{6F}() { return 'get string'; } + static set #\u{6F}(param) { stringSet = param; } + + static getPrivateReference() { + return this.#o; + } + + static setPrivateReference(value) { + this.#o = value; + } +} + +assert.sameValue(C.getPrivateReference(), 'get string'); + +C.setPrivateReference('set string'); +assert.sameValue(stringSet, 'set string'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-accessor-name/static-private-name-ZWJ.js b/js/src/tests/test262/language/statements/class/elements/private-accessor-name/static-private-name-ZWJ.js new file mode 100644 index 0000000000..fa0d3b1a6a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-accessor-name/static-private-name-ZWJ.js @@ -0,0 +1,79 @@ +// This file was procedurally generated from the following sources: +// - src/accessor-names/private-name-ZWJ.case +// - src/accessor-names/private/cls-private-decl-static.template +/*--- +description: Private IdentifierName - ZWJ (Class declaration, static method) +features: [class, class-static-methods-private] +flags: [generated] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + Initializer : + = AssignmentExpression + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + +var stringSet; + +class C { + static get #ZW_‍_J() { return 'get string'; } + static set #ZW_‍_J(param) { stringSet = param; } + + static getPrivateReference() { + return this.#ZW_‍_J; + } + + static setPrivateReference(value) { + this.#ZW_‍_J = value; + } +} + +assert.sameValue(C.getPrivateReference(), 'get string'); + +C.setPrivateReference('set string'); +assert.sameValue(stringSet, 'set string'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-accessor-name/static-private-name-ZWNJ.js b/js/src/tests/test262/language/statements/class/elements/private-accessor-name/static-private-name-ZWNJ.js new file mode 100644 index 0000000000..15fc7dbbd8 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-accessor-name/static-private-name-ZWNJ.js @@ -0,0 +1,79 @@ +// This file was procedurally generated from the following sources: +// - src/accessor-names/private-name-ZWNJ.case +// - src/accessor-names/private/cls-private-decl-static.template +/*--- +description: Private IdentifierName - ZWNJ (Class declaration, static method) +features: [class, class-static-methods-private] +flags: [generated] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + Initializer : + = AssignmentExpression + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + +var stringSet; + +class C { + static get #ZW_‌_NJ() { return 'get string'; } + static set #ZW_‌_NJ(param) { stringSet = param; } + + static getPrivateReference() { + return this.#ZW_‌_NJ; + } + + static setPrivateReference(value) { + this.#ZW_‌_NJ = value; + } +} + +assert.sameValue(C.getPrivateReference(), 'get string'); + +C.setPrivateReference('set string'); +assert.sameValue(stringSet, 'set string'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-accessor-name/static-private-name-common.js b/js/src/tests/test262/language/statements/class/elements/private-accessor-name/static-private-name-common.js new file mode 100644 index 0000000000..ddc98e5e34 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-accessor-name/static-private-name-common.js @@ -0,0 +1,79 @@ +// This file was procedurally generated from the following sources: +// - src/accessor-names/private-name-common.case +// - src/accessor-names/private/cls-private-decl-static.template +/*--- +description: Private IdentifierName - common (Class declaration, static method) +features: [class, class-static-methods-private] +flags: [generated] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + Initializer : + = AssignmentExpression + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + +var stringSet; + +class C { + static get #test262() { return 'get string'; } + static set #test262(param) { stringSet = param; } + + static getPrivateReference() { + return this.#test262; + } + + static setPrivateReference(value) { + this.#test262 = value; + } +} + +assert.sameValue(C.getPrivateReference(), 'get string'); + +C.setPrivateReference('set string'); +assert.sameValue(stringSet, 'set string'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-accessor-name/static-private-name-dollar.js b/js/src/tests/test262/language/statements/class/elements/private-accessor-name/static-private-name-dollar.js new file mode 100644 index 0000000000..a71d3733a5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-accessor-name/static-private-name-dollar.js @@ -0,0 +1,79 @@ +// This file was procedurally generated from the following sources: +// - src/accessor-names/private-name-dollar.case +// - src/accessor-names/private/cls-private-decl-static.template +/*--- +description: Private IdentifierName - $ (Class declaration, static method) +features: [class, class-static-methods-private] +flags: [generated] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + Initializer : + = AssignmentExpression + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + +var stringSet; + +class C { + static get #$() { return 'get string'; } + static set #$(param) { stringSet = param; } + + static getPrivateReference() { + return this.#$; + } + + static setPrivateReference(value) { + this.#$ = value; + } +} + +assert.sameValue(C.getPrivateReference(), 'get string'); + +C.setPrivateReference('set string'); +assert.sameValue(stringSet, 'set string'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-accessor-name/static-private-name-u2118.js b/js/src/tests/test262/language/statements/class/elements/private-accessor-name/static-private-name-u2118.js new file mode 100644 index 0000000000..914573983b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-accessor-name/static-private-name-u2118.js @@ -0,0 +1,79 @@ +// This file was procedurally generated from the following sources: +// - src/accessor-names/private-name-u2118.case +// - src/accessor-names/private/cls-private-decl-static.template +/*--- +description: Private IdentifierName - ℘ (Class declaration, static method) +features: [class, class-static-methods-private] +flags: [generated] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + Initializer : + = AssignmentExpression + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + +var stringSet; + +class C { + static get #℘() { return 'get string'; } + static set #℘(param) { stringSet = param; } + + static getPrivateReference() { + return this.#℘; + } + + static setPrivateReference(value) { + this.#℘ = value; + } +} + +assert.sameValue(C.getPrivateReference(), 'get string'); + +C.setPrivateReference('set string'); +assert.sameValue(stringSet, 'set string'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-accessor-name/static-private-name-underscore.js b/js/src/tests/test262/language/statements/class/elements/private-accessor-name/static-private-name-underscore.js new file mode 100644 index 0000000000..7356830d4f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-accessor-name/static-private-name-underscore.js @@ -0,0 +1,79 @@ +// This file was procedurally generated from the following sources: +// - src/accessor-names/private-name-underscore.case +// - src/accessor-names/private/cls-private-decl-static.template +/*--- +description: Private IdentifierName - _ (Class declaration, static method) +features: [class, class-static-methods-private] +flags: [generated] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + Initializer : + = AssignmentExpression + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + +var stringSet; + +class C { + static get #_() { return 'get string'; } + static set #_(param) { stringSet = param; } + + static getPrivateReference() { + return this.#_; + } + + static setPrivateReference(value) { + this.#_ = value; + } +} + +assert.sameValue(C.getPrivateReference(), 'get string'); + +C.setPrivateReference('set string'); +assert.sameValue(stringSet, 'set string'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-arrow-fnc-init-err-contains-arguments.js b/js/src/tests/test262/language/statements/class/elements/private-arrow-fnc-init-err-contains-arguments.js new file mode 100644 index 0000000000..651ce6c2e3 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-arrow-fnc-init-err-contains-arguments.js @@ -0,0 +1,36 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/init-err-contains-arguments.case +// - src/class-elements/initializer-error/cls-decl-fields-private-arrow-fnc.template +/*--- +description: Syntax error if `arguments` used in class field (private field, arrow function expression) +esid: sec-class-definitions-static-semantics-early-errors +features: [class, class-fields-public, arrow-function, class-fields-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Static Semantics: Early Errors + + FieldDefinition: + PropertyNameInitializeropt + + - It is a Syntax Error if ContainsArguments of Initializer is true. + + Static Semantics: ContainsArguments + IdentifierReference : Identifier + + 1. If the StringValue of Identifier is "arguments", return true. + ... + For all other grammatical productions, recurse on all nonterminals. If any piece returns true, then return true. Otherwise return false. + +---*/ + + +$DONOTEVALUATE(); + +class C { + #x = () => arguments; +} + diff --git a/js/src/tests/test262/language/statements/class/elements/private-arrow-fnc-init-err-contains-super.js b/js/src/tests/test262/language/statements/class/elements/private-arrow-fnc-init-err-contains-super.js new file mode 100644 index 0000000000..63e05382c6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-arrow-fnc-init-err-contains-super.js @@ -0,0 +1,29 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/init-err-contains-super.case +// - src/class-elements/initializer-error/cls-decl-fields-private-arrow-fnc.template +/*--- +description: Syntax error if `super()` used in class field (private field, arrow function expression) +esid: sec-class-definitions-static-semantics-early-errors +features: [class, class-fields-public, arrow-function, class-fields-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Static Semantics: Early Errors + + FieldDefinition: + PropertyNameInitializeropt + + - It is a Syntax Error if Initializer is present and Initializer Contains SuperCall is true. + +---*/ + + +$DONOTEVALUATE(); + +class C { + #x = () => super(); +} + diff --git a/js/src/tests/test262/language/statements/class/elements/private-async-generator-method-name.js b/js/src/tests/test262/language/statements/class/elements/private-async-generator-method-name.js new file mode 100644 index 0000000000..6d631f0d72 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-async-generator-method-name.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/private-async-generator-method-name.case +// - src/class-elements/default/cls-decl.template +/*--- +description: Private async generators methods have name property properly configured (field definitions in a class declaration) +esid: prod-FieldDefinition +features: [class-methods-private, class] +flags: [generated] +info: | + Updated Productions + + ClassElement : MethodDefinition + 1. Return ClassElementEvaluation of MethodDefinition with arguments ! Get(homeObject, "prototype"),enumerable, and "prototype". + + ClassElement : MethodDefinition + ClassElement : static MethodDefinition + 1. Perform ? PropertyDefinitionEvaluation with parameters object and enumerable. + 2. Return empty. + + AsyncMethod : async [no LineTerminator here] * ClassElementName (UniqueFormalParameters) { AsyncFunctionBody } + 1. Let propKey be the result of evaluating ClassElementName. + ... + 12. Perform ? DefineOrdinaryMethod(key, homeObject, closure, enumerable). + + ClassElementName : PrivateIdentifier + 1. Let bindingName be StringValue of PrivateIdentifier. + ... + 5. If scopeEnvRec's binding for bindingName is uninitialized, + a. Let field be NewPrivateName(bindingName). + b. Perform ! scopeEnvRec.InitializeBinding(bindingName, field). + 6. Otherwise, + a. Let field be scopeEnvRec.GetBindingValue(bindingName). + 7. Assert: field.[[Description]] is bindingName. + 8. Return field. + + DefineOrdinaryMethod(key, homeObject, closure, enumerable) + 1. Perform SetFunctionName(closure, key). + 2. If key is a Private Name, + a. Assert: key does not have a [[Kind]] field. + b. Set key.[[Kind]] to "method". + c. Set key.[[Value]] to closure. + d. Set key.[[Brand]] to homeObject. + 3. Else, + a. Let desc be the PropertyDescriptor{[[Value]]: closure, [[Writable]]: true, [[Enumerable]]: enumerable, [[Configurable]]: true}. + b. Perform ? DefinePropertyOrThrow(homeObject, key, desc). + +---*/ + + +class C { + async * #method() {}; + + getPrivateMethod() { + return this.#method; + } +} + +let c = new C(); +assert.sameValue(c.getPrivateMethod().name, "#method"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-async-method-name.js b/js/src/tests/test262/language/statements/class/elements/private-async-method-name.js new file mode 100644 index 0000000000..f7318e2cea --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-async-method-name.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/private-async-method-name.case +// - src/class-elements/default/cls-decl.template +/*--- +description: Private async methods have name property properly configured (field definitions in a class declaration) +esid: prod-FieldDefinition +features: [class-methods-private, class] +flags: [generated] +info: | + Updated Productions + + ClassElement : MethodDefinition + 1. Return ClassElementEvaluation of MethodDefinition with arguments ! Get(homeObject, "prototype"),enumerable, and "prototype". + + ClassElement : MethodDefinition + ClassElement : static MethodDefinition + 1. Perform ? PropertyDefinitionEvaluation with parameters object and enumerable. + 2. Return empty. + + AsyncMethod : async [no LineTerminator here] ClassElementName (UniqueFormalParameters) { AsyncFunctionBody } + 1. Let propKey be the result of evaluating ClassElementName. + ... + 10. Perform ? DefineOrdinaryMethod(key, homeObject, closure, enumerable). + + ClassElementName : PrivateIdentifier + 1. Let bindingName be StringValue of PrivateIdentifier. + ... + 5. If scopeEnvRec's binding for bindingName is uninitialized, + a. Let field be NewPrivateName(bindingName). + b. Perform ! scopeEnvRec.InitializeBinding(bindingName, field). + 6. Otherwise, + a. Let field be scopeEnvRec.GetBindingValue(bindingName). + 7. Assert: field.[[Description]] is bindingName. + 8. Return field. + + DefineOrdinaryMethod(key, homeObject, closure, enumerable) + 1. Perform SetFunctionName(closure, key). + 2. If key is a Private Name, + a. Assert: key does not have a [[Kind]] field. + b. Set key.[[Kind]] to "method". + c. Set key.[[Value]] to closure. + d. Set key.[[Brand]] to homeObject. + 3. Else, + a. Let desc be the PropertyDescriptor{[[Value]]: closure, [[Writable]]: true, [[Enumerable]]: enumerable, [[Configurable]]: true}. + b. Perform ? DefinePropertyOrThrow(homeObject, key, desc). + +---*/ + + +class C { + async #method() {}; + + getPrivateMethod() { + return this.#method; + } +} + +let c = new C(); +assert.sameValue(c.getPrivateMethod().name, "#method"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-class-field-on-frozen-objects-strict.js b/js/src/tests/test262/language/statements/class/elements/private-class-field-on-frozen-objects-strict.js new file mode 100644 index 0000000000..8c90bfdd31 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-class-field-on-frozen-objects-strict.js @@ -0,0 +1,34 @@ +'use strict'; +// Copyright (C) 2019 Caio Lima. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is possible to add private fields on frozen objects +esid: sec-define-field +info: | + DefineField(receiver, fieldRecord) + ... + 8. If fieldName is a Private Name, + a. Perform ? PrivateFieldAdd(fieldName, receiver, initValue). + 9. Else, + a. Assert: IsPropertyKey(fieldName) is true. + b. Perform ? CreateDataPropertyOrThrow(receiver, fieldName, initValue). + 10. Return. +features: [class, class-fields-private, class-fields-public] +flags: [onlyStrict] +---*/ + +class Test { + f = this; + #g = (Object.freeze(this), "Test262"); + + get g() { + return this.#g; + } +} + +let t = new Test(); +assert.sameValue(t.f, t); +assert.sameValue(t.g, "Test262"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-derived-cls-direct-eval-contains-superproperty-1.js b/js/src/tests/test262/language/statements/class/elements/private-derived-cls-direct-eval-contains-superproperty-1.js new file mode 100644 index 0000000000..b7a7ecf1b1 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-derived-cls-direct-eval-contains-superproperty-1.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/eval-contains-superproperty-1.case +// - src/class-elements/initializer-eval-super-property/cls-decl-private-fields-eval.template +/*--- +description: super.x in StatementList of eval (direct eval) +esid: sec-performeval-rules-in-initializer +features: [class, class-fields-public, class-fields-private] +flags: [generated] +info: | + Additional Early Error Rules for Eval Inside Initializer + These static semantics are applied by PerformEval when a direct eval call occurs inside a class field initializer. + ScriptBody : StatementList + + ... + The remaining eval rules apply as outside a constructor, inside a method, and inside a function. + + Additional Early Error Rules for Eval Outside Methods + These static semantics are applied by PerformEval when a direct eval call occurs outside of a MethodDefinition. + ScriptBody : StatementList + + It is a Syntax Error if StatementList Contains SuperProperty. + +---*/ + + +var executed = false; +class A {} +class C extends A { + #x = eval('executed = true; super.x;'); +} + +new C(); + +assert.sameValue(executed, true); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-derived-cls-direct-eval-contains-superproperty-2.js b/js/src/tests/test262/language/statements/class/elements/private-derived-cls-direct-eval-contains-superproperty-2.js new file mode 100644 index 0000000000..ba434a3f39 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-derived-cls-direct-eval-contains-superproperty-2.js @@ -0,0 +1,33 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/eval-contains-superproperty-2.case +// - src/class-elements/initializer-eval-super-property/cls-decl-private-fields-eval.template +/*--- +description: super['x'] in StatementList of eval (direct eval) +esid: sec-performeval-rules-in-initializer +features: [class, class-fields-public, class-fields-private] +flags: [generated] +info: | + The remaining eval rules apply as outside a constructor, inside a method, and inside a function. + + Additional Early Error Rules for Eval Outside Methods + + These static semantics are applied by PerformEval when a direct eval call occurs outside of a MethodDefinition. + + ScriptBody : StatementList + + It is a Syntax Error if StatementList Contains SuperProperty. + +---*/ + + +var executed = false; +class A {} +class C extends A { + #x = eval('executed = true; super["x"];'); +} + +new C(); + +assert.sameValue(executed, true); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-derived-cls-direct-eval-err-contains-supercall-1.js b/js/src/tests/test262/language/statements/class/elements/private-derived-cls-direct-eval-err-contains-supercall-1.js new file mode 100644 index 0000000000..5a6449746f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-derived-cls-direct-eval-err-contains-supercall-1.js @@ -0,0 +1,38 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/eval-err-contains-supercall-1.case +// - src/class-elements/initializer-eval-super-call/cls-decl-private-fields-eval.template +/*--- +description: error if `super()['x']` in StatementList of eval (direct eval) +esid: sec-performeval-rules-in-initializer +features: [class, class-fields-public, class-fields-private] +flags: [generated] +info: | + Additional Early Error Rules for Eval Inside Initializer + These static semantics are applied by PerformEval when a direct eval call occurs inside a class field initializer. + ScriptBody : StatementList + + ... + The remaining eval rules apply as outside a constructor, inside a method, and inside a function. + + Additional Early Error Rules for Eval Outside Constructor Methods + These static semantics are applied by PerformEval when a direct eval call occurs outside of the constructor method of a ClassDeclaration or ClassExpression. + ScriptBody : StatementList + + It is a Syntax Error if StatementList Contains SuperCall. + +---*/ + + +var executed = false; +class A {} +class C extends A { + #x = eval('executed = true; super()["x"];'); +} + +assert.throws(SyntaxError, function() { + new C(); +}); + +assert.sameValue(executed, false); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-derived-cls-direct-eval-err-contains-supercall-2.js b/js/src/tests/test262/language/statements/class/elements/private-derived-cls-direct-eval-err-contains-supercall-2.js new file mode 100644 index 0000000000..31b908edd1 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-derived-cls-direct-eval-err-contains-supercall-2.js @@ -0,0 +1,31 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/eval-err-contains-supercall-2.case +// - src/class-elements/initializer-eval-super-call/cls-decl-private-fields-eval.template +/*--- +description: error if `super().x` in StatementList of eval (direct eval) +esid: sec-performeval-rules-in-initializer +features: [class, class-fields-public, class-fields-private] +flags: [generated] +info: | + Additional Early Error Rules for Eval Outside Constructor Methods + These static semantics are applied by PerformEval when a direct eval call occurs outside of the constructor method of a ClassDeclaration or ClassExpression. + ScriptBody : StatementList + + It is a Syntax Error if StatementList Contains SuperCall. + +---*/ + + +var executed = false; +class A {} +class C extends A { + #x = eval('executed = true; super().x;'); +} + +assert.throws(SyntaxError, function() { + new C(); +}); + +assert.sameValue(executed, false); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-derived-cls-direct-eval-err-contains-supercall.js b/js/src/tests/test262/language/statements/class/elements/private-derived-cls-direct-eval-err-contains-supercall.js new file mode 100644 index 0000000000..e565f03a28 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-derived-cls-direct-eval-err-contains-supercall.js @@ -0,0 +1,38 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/eval-err-contains-supercall.case +// - src/class-elements/initializer-eval-super-call/cls-decl-private-fields-eval.template +/*--- +description: error if `super()` in StatementList of eval (direct eval) +esid: sec-performeval-rules-in-initializer +features: [class, class-fields-public, class-fields-private] +flags: [generated] +info: | + Additional Early Error Rules for Eval Inside Initializer + These static semantics are applied by PerformEval when a direct eval call occurs inside a class field initializer. + ScriptBody : StatementList + + ... + The remaining eval rules apply as outside a constructor, inside a method, and inside a function. + + Additional Early Error Rules for Eval Outside Constructor Methods + These static semantics are applied by PerformEval when a direct eval call occurs outside of the constructor method of a ClassDeclaration or ClassExpression. + ScriptBody : StatementList + + It is a Syntax Error if StatementList Contains SuperCall. + +---*/ + + +var executed = false; +class A {} +class C extends A { + #x = eval('executed = true; super();'); +} + +assert.throws(SyntaxError, function() { + new C(); +}); + +assert.sameValue(executed, false); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-derived-cls-indirect-eval-contains-superproperty-1.js b/js/src/tests/test262/language/statements/class/elements/private-derived-cls-indirect-eval-contains-superproperty-1.js new file mode 100644 index 0000000000..2d40dd1074 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-derived-cls-indirect-eval-contains-superproperty-1.js @@ -0,0 +1,38 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/eval-contains-superproperty-1.case +// - src/class-elements/initializer-eval-super-property/cls-decl-private-fields-indirect-eval.template +/*--- +description: super.x in StatementList of eval (indirect eval) +esid: sec-performeval-rules-in-initializer +features: [class, class-fields-public, class-fields-private] +flags: [generated] +info: | + Additional Early Error Rules for Eval Inside Initializer + These static semantics are applied by PerformEval when a direct eval call occurs inside a class field initializer. + ScriptBody : StatementList + + ... + The remaining eval rules apply as outside a constructor, inside a method, and inside a function. + + Additional Early Error Rules for Eval Outside Methods + These static semantics are applied by PerformEval when a direct eval call occurs outside of a MethodDefinition. + ScriptBody : StatementList + + It is a Syntax Error if StatementList Contains SuperProperty. + +---*/ + + +var executed = false; +class A {} +class C extends A { + #x = (0, eval)('executed = true; super.x;'); +} + +assert.throws(SyntaxError, function() { + new C(); +}); + +assert.sameValue(executed, false); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-derived-cls-indirect-eval-contains-superproperty-2.js b/js/src/tests/test262/language/statements/class/elements/private-derived-cls-indirect-eval-contains-superproperty-2.js new file mode 100644 index 0000000000..f8a3a172f0 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-derived-cls-indirect-eval-contains-superproperty-2.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/eval-contains-superproperty-2.case +// - src/class-elements/initializer-eval-super-property/cls-decl-private-fields-indirect-eval.template +/*--- +description: super['x'] in StatementList of eval (indirect eval) +esid: sec-performeval-rules-in-initializer +features: [class, class-fields-public, class-fields-private] +flags: [generated] +info: | + The remaining eval rules apply as outside a constructor, inside a method, and inside a function. + + Additional Early Error Rules for Eval Outside Methods + + These static semantics are applied by PerformEval when a direct eval call occurs outside of a MethodDefinition. + + ScriptBody : StatementList + + It is a Syntax Error if StatementList Contains SuperProperty. + +---*/ + + +var executed = false; +class A {} +class C extends A { + #x = (0, eval)('executed = true; super["x"];'); +} + +assert.throws(SyntaxError, function() { + new C(); +}); + +assert.sameValue(executed, false); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-derived-cls-indirect-eval-err-contains-supercall-1.js b/js/src/tests/test262/language/statements/class/elements/private-derived-cls-indirect-eval-err-contains-supercall-1.js new file mode 100644 index 0000000000..531cb1436b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-derived-cls-indirect-eval-err-contains-supercall-1.js @@ -0,0 +1,38 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/eval-err-contains-supercall-1.case +// - src/class-elements/initializer-eval-super-call/cls-decl-private-fields-indirect-eval.template +/*--- +description: error if `super()['x']` in StatementList of eval (indirect eval) +esid: sec-performeval-rules-in-initializer +features: [class, class-fields-public, class-fields-private] +flags: [generated] +info: | + Additional Early Error Rules for Eval Inside Initializer + These static semantics are applied by PerformEval when a direct eval call occurs inside a class field initializer. + ScriptBody : StatementList + + ... + The remaining eval rules apply as outside a constructor, inside a method, and inside a function. + + Additional Early Error Rules for Eval Outside Constructor Methods + These static semantics are applied by PerformEval when a direct eval call occurs outside of the constructor method of a ClassDeclaration or ClassExpression. + ScriptBody : StatementList + + It is a Syntax Error if StatementList Contains SuperCall. + +---*/ + + +var executed = false; +class A {} +class C extends A { + #x = (0, eval)('executed = true; super()["x"];'); +} + +assert.throws(SyntaxError, function() { + new C(); +}); + +assert.sameValue(executed, false); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-derived-cls-indirect-eval-err-contains-supercall-2.js b/js/src/tests/test262/language/statements/class/elements/private-derived-cls-indirect-eval-err-contains-supercall-2.js new file mode 100644 index 0000000000..1f2393a9c7 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-derived-cls-indirect-eval-err-contains-supercall-2.js @@ -0,0 +1,31 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/eval-err-contains-supercall-2.case +// - src/class-elements/initializer-eval-super-call/cls-decl-private-fields-indirect-eval.template +/*--- +description: error if `super().x` in StatementList of eval (indirect eval) +esid: sec-performeval-rules-in-initializer +features: [class, class-fields-public, class-fields-private] +flags: [generated] +info: | + Additional Early Error Rules for Eval Outside Constructor Methods + These static semantics are applied by PerformEval when a direct eval call occurs outside of the constructor method of a ClassDeclaration or ClassExpression. + ScriptBody : StatementList + + It is a Syntax Error if StatementList Contains SuperCall. + +---*/ + + +var executed = false; +class A {} +class C extends A { + #x = (0, eval)('executed = true; super().x;'); +} + +assert.throws(SyntaxError, function() { + new C(); +}); + +assert.sameValue(executed, false); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-derived-cls-indirect-eval-err-contains-supercall.js b/js/src/tests/test262/language/statements/class/elements/private-derived-cls-indirect-eval-err-contains-supercall.js new file mode 100644 index 0000000000..b034236fee --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-derived-cls-indirect-eval-err-contains-supercall.js @@ -0,0 +1,38 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/eval-err-contains-supercall.case +// - src/class-elements/initializer-eval-super-call/cls-decl-private-fields-indirect-eval.template +/*--- +description: error if `super()` in StatementList of eval (indirect eval) +esid: sec-performeval-rules-in-initializer +features: [class, class-fields-public, class-fields-private] +flags: [generated] +info: | + Additional Early Error Rules for Eval Inside Initializer + These static semantics are applied by PerformEval when a direct eval call occurs inside a class field initializer. + ScriptBody : StatementList + + ... + The remaining eval rules apply as outside a constructor, inside a method, and inside a function. + + Additional Early Error Rules for Eval Outside Constructor Methods + These static semantics are applied by PerformEval when a direct eval call occurs outside of the constructor method of a ClassDeclaration or ClassExpression. + ScriptBody : StatementList + + It is a Syntax Error if StatementList Contains SuperCall. + +---*/ + + +var executed = false; +class A {} +class C extends A { + #x = (0, eval)('executed = true; super();'); +} + +assert.throws(SyntaxError, function() { + new C(); +}); + +assert.sameValue(executed, false); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-direct-eval-err-contains-arguments.js b/js/src/tests/test262/language/statements/class/elements/private-direct-eval-err-contains-arguments.js new file mode 100644 index 0000000000..1e10f34afd --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-direct-eval-err-contains-arguments.js @@ -0,0 +1,38 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/eval-err-contains-arguments.case +// - src/class-elements/initializer-direct-eval-arguments/cls-decl-private-fields-eval.template +/*--- +description: error if `arguments` in StatementList of eval (direct eval) +esid: sec-performeval-rules-in-initializer +features: [class, class-fields-public, class-fields-private] +flags: [generated] +info: | + Additional Early Error Rules for Eval Inside Initializer + These static semantics are applied by PerformEval when a direct eval call occurs inside a class field initializer. + ScriptBody : StatementList + + It is a Syntax Error if ContainsArguments of StatementList is true. + ... + + Static Semantics: ContainsArguments + IdentifierReference : Identifier + + 1. If the StringValue of Identifier is "arguments", return true. + ... + For all other grammatical productions, recurse on all nonterminals. If any piece returns true, then return true. Otherwise return false. + +---*/ + + +var executed = false; +class C { + #x = eval('executed = true; arguments;'); +} + +assert.throws(SyntaxError, function() { + new C(); +}); + +assert.sameValue(executed, false); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-direct-eval-err-contains-newtarget.js b/js/src/tests/test262/language/statements/class/elements/private-direct-eval-err-contains-newtarget.js new file mode 100644 index 0000000000..296e3c82f4 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-direct-eval-err-contains-newtarget.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/eval-err-contains-newtarget.case +// - src/class-elements/initializer-eval-newtarget/cls-decl-private-fields-eval.template +/*--- +description: error if `new.target` in StatementList of eval (direct eval) +esid: sec-performeval-rules-in-initializer +features: [class, new.target, class-fields-private] +flags: [generated] +info: | + Additional Early Error Rules for Eval Inside Initializer + These static semantics are applied by PerformEval when a direct eval call occurs inside a class field initializer. + ScriptBody : StatementList + + ... + The remaining eval rules apply as outside a constructor, inside a method, and inside a function. + + Additional Early Error Rules for Eval Outside Functions + These static semantics are applied by PerformEval when a direct eval call occurs outside of any function. + ScriptBody : StatementList + + It is a Syntax Error if StatementList Contains NewTarget. + +---*/ + + +var executed = false; +class C { + #x = eval('executed = true; new.target;'); +} + +var c = new C(); + +assert.sameValue(executed, true); +assert.sameValue(c.x, undefined); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-field-access-on-inner-arrow-function.js b/js/src/tests/test262/language/statements/class/elements/private-field-access-on-inner-arrow-function.js new file mode 100644 index 0000000000..15051fcb92 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-field-access-on-inner-arrow-function.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/private-field-access-on-inner-arrow-function.case +// - src/class-elements/default/cls-decl.template +/*--- +description: PrivateName of private field is visible on inner arrow function of class scope (field definitions in a class declaration) +esid: prod-FieldDefinition +features: [class-fields-private, class] +flags: [generated] +info: | + Updated Productions + + CallExpression[Yield, Await]: + CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await] + SuperCall[?Yield, ?Await] + CallExpression[?Yield, ?Await]Arguments[?Yield, ?Await] + CallExpression[?Yield, ?Await][Expression[+In, ?Yield, ?Await]] + CallExpression[?Yield, ?Await].IdentifierName + CallExpression[?Yield, ?Await]TemplateLiteral[?Yield, ?Await] + CallExpression[?Yield, ?Await].PrivateName + +---*/ + + +class C { + #f = 'Test262'; + + method() { + let arrowFunction = () => { + return this.#f; + } + + return arrowFunction(); + } +} + +let c = new C(); +assert.sameValue(c.method(), 'Test262'); +let o = {}; +assert.throws(TypeError, function() { + c.method.call(o); +}, 'accessed private field from an ordinary object'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-field-access-on-inner-function.js b/js/src/tests/test262/language/statements/class/elements/private-field-access-on-inner-function.js new file mode 100644 index 0000000000..e2d3d663ee --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-field-access-on-inner-function.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/private-field-access-on-inner-function.case +// - src/class-elements/default/cls-decl.template +/*--- +description: PrivateName of private field is visible on inner function of class scope (field definitions in a class declaration) +esid: prod-FieldDefinition +features: [class-fields-private, class] +flags: [generated] +info: | + Updated Productions + + CallExpression[Yield, Await]: + CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await] + SuperCall[?Yield, ?Await] + CallExpression[?Yield, ?Await]Arguments[?Yield, ?Await] + CallExpression[?Yield, ?Await][Expression[+In, ?Yield, ?Await]] + CallExpression[?Yield, ?Await].IdentifierName + CallExpression[?Yield, ?Await]TemplateLiteral[?Yield, ?Await] + CallExpression[?Yield, ?Await].PrivateName + +---*/ + + +class C { + #f = 'Test262'; + + method() { + let self = this; + function innerFunction() { + return self.#f; + } + + return innerFunction(); + } +} + +let c = new C(); +assert.sameValue(c.method(), 'Test262'); +let o = {}; +assert.throws(TypeError, function() { + c.method.call(o); +}, 'accessed private field from an ordinary object'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-field-after-optional-chain.js b/js/src/tests/test262/language/statements/class/elements/private-field-after-optional-chain.js new file mode 100644 index 0000000000..9ed4c44f1b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-field-after-optional-chain.js @@ -0,0 +1,46 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/private-field-after-optional-chain.case +// - src/class-elements/default/cls-decl.template +/*--- +description: OptionalChain.PrivateIdentifier is a valid syntax (field definitions in a class declaration) +esid: prod-FieldDefinition +features: [class-fields-private, optional-chaining, class] +flags: [generated] +info: | + Updated Productions + + OptionalChain[Yield, Await] : + `?.` `[` Expression[+In, ?Yield, ?Await] `]` + `?.` IdentifierName + `?.` Arguments[?Yield, ?Await] + `?.` TemplateLiteral[?Yield, ?Await, +Tagged] + OptionalChain[?Yield, ?Await] `[` Expression[+In, ?Yield, ?Await] `]` + OptionalChain[?Yield, ?Await] `.` IdentifierName + OptionalChain[?Yield, ?Await] Arguments[?Yield, ?Await] + OptionalChain[?Yield, ?Await] TemplateLiteral[?Yield, ?Await, +Tagged] + OptionalChain[?Yield, ?Await] `.` PrivateIdentifier + +---*/ + + +class C { + #f = 'Test262'; + + method(o) { + return o?.c.#f; + } +} + +let c = new C(); +let o = {c: c}; +assert.sameValue(c.method(o), 'Test262'); + +assert.sameValue(c.method(null), undefined); +assert.sameValue(c.method(undefined), undefined); + +o = {c: new Object()}; +assert.throws(TypeError, function() { + c.method(o); +}, 'accessed private field from an ordinary object'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-field-as-arrow-function.js b/js/src/tests/test262/language/statements/class/elements/private-field-as-arrow-function.js new file mode 100644 index 0000000000..85e3f2c133 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-field-as-arrow-function.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/private-field-as-arrow-function.case +// - src/class-elements/default/cls-decl.template +/*--- +description: Calling arrow function returned from private field access (field definitions in a class declaration) +esid: prod-FieldDefinition +features: [class-fields-private, arrow-function, class] +flags: [generated] +info: | + Updated Productions + + CallExpression[Yield, Await]: + CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await] + SuperCall[?Yield, ?Await] + CallExpression[?Yield, ?Await]Arguments[?Yield, ?Await] + CallExpression[?Yield, ?Await][Expression[+In, ?Yield, ?Await]] + CallExpression[?Yield, ?Await].IdentifierName + CallExpression[?Yield, ?Await]TemplateLiteral[?Yield, ?Await] + CallExpression[?Yield, ?Await].PrivateName + +---*/ + + +class C { + #m = () => 'test262'; + + method() { + return this.#m(); + } +} + +let c = new C(); +assert.sameValue(c.method(), 'test262'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-field-as-async-arrow-function.js b/js/src/tests/test262/language/statements/class/elements/private-field-as-async-arrow-function.js new file mode 100644 index 0000000000..1adaa1c557 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-field-as-async-arrow-function.js @@ -0,0 +1,37 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/private-field-as-async-arrow-function.case +// - src/class-elements/default/cls-decl.template +/*--- +description: Calling async arrow function returned from private field access (field definitions in a class declaration) +esid: prod-FieldDefinition +features: [class-fields-private, async-functions, arrow-function, class] +flags: [generated, async] +info: | + Updated Productions + + CallExpression[Yield, Await]: + CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await] + SuperCall[?Yield, ?Await] + CallExpression[?Yield, ?Await]Arguments[?Yield, ?Await] + CallExpression[?Yield, ?Await][Expression[+In, ?Yield, ?Await]] + CallExpression[?Yield, ?Await].IdentifierName + CallExpression[?Yield, ?Await]TemplateLiteral[?Yield, ?Await] + CallExpression[?Yield, ?Await].PrivateName + +---*/ + + +class C { + #m = async () => 'test262'; + + method() { + return this.#m(); + } +} + +let c = new C(); + +c.method().then((value) => assert.sameValue(value, 'test262')) + .then($DONE, $DONE); + diff --git a/js/src/tests/test262/language/statements/class/elements/private-field-as-async-function.js b/js/src/tests/test262/language/statements/class/elements/private-field-as-async-function.js new file mode 100644 index 0000000000..80d08d209b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-field-as-async-function.js @@ -0,0 +1,37 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/private-field-as-async-function.case +// - src/class-elements/default/cls-decl.template +/*--- +description: Calling async function returned from private field access (field definitions in a class declaration) +esid: prod-FieldDefinition +features: [class-fields-private, async-functions, class] +flags: [generated, async] +info: | + Updated Productions + + CallExpression[Yield, Await]: + CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await] + SuperCall[?Yield, ?Await] + CallExpression[?Yield, ?Await]Arguments[?Yield, ?Await] + CallExpression[?Yield, ?Await][Expression[+In, ?Yield, ?Await]] + CallExpression[?Yield, ?Await].IdentifierName + CallExpression[?Yield, ?Await]TemplateLiteral[?Yield, ?Await] + CallExpression[?Yield, ?Await].PrivateName + +---*/ + + +class C { + #m = async function() { return 'test262'; }; + + method() { + return this.#m(); + } +} + +let c = new C(); + +c.method().then((value) => assert.sameValue(value, 'test262')) + .then($DONE, $DONE); + diff --git a/js/src/tests/test262/language/statements/class/elements/private-field-as-function.js b/js/src/tests/test262/language/statements/class/elements/private-field-as-function.js new file mode 100644 index 0000000000..e710d58eb3 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-field-as-function.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/private-field-as-function.case +// - src/class-elements/default/cls-decl.template +/*--- +description: Calling result returned from private field access (field definitions in a class declaration) +esid: prod-FieldDefinition +features: [class-fields-private, class] +flags: [generated] +info: | + Updated Productions + + CallExpression[Yield, Await]: + CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await] + SuperCall[?Yield, ?Await] + CallExpression[?Yield, ?Await]Arguments[?Yield, ?Await] + CallExpression[?Yield, ?Await][Expression[+In, ?Yield, ?Await]] + CallExpression[?Yield, ?Await].IdentifierName + CallExpression[?Yield, ?Await]TemplateLiteral[?Yield, ?Await] + CallExpression[?Yield, ?Await].PrivateName + +---*/ + + +class C { + #m = function () { return 'test262'; }; + + method() { + return this.#m(); + } +} + +let c = new C(); +assert.sameValue(c.method(), 'test262'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-field-is-not-clobbered-by-computed-property.js b/js/src/tests/test262/language/statements/class/elements/private-field-is-not-clobbered-by-computed-property.js new file mode 100644 index 0000000000..1121bb41f2 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-field-is-not-clobbered-by-computed-property.js @@ -0,0 +1,45 @@ +// Copyright (C) 2019 Caio Lima (Igalia SL). All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Private field is not clobbered by computed property +esid: sec-privatefieldget +info: | + PrivateFieldGet (P, O) + 1. Assert: P is a Private Name. + 2. If O is not an object, throw a TypeError exception. + 3. If P.[[Kind]] is "field", + a. Let entry be PrivateFieldFind(P, O). + b. If entry is empty, throw a TypeError exception. + c. Return entry.[[PrivateFieldValue]]. + 4. Perform ? PrivateBrandCheck(O, P). + 5. If P.[[Kind]] is "method", + a. Return P.[[Value]]. + 6. Else, + a. Assert: P.[[Kind]] is "accessor". + b. If P does not have a [[Get]] field, throw a TypeError exception. + c. Let getter be P.[[Get]]. + d. Return ? Call(getter, O). +features: [class-fields-public, class-fields-private, class] +---*/ + +class C { + #m = 44; + ["#m"] = this.#m / 11; + + checkPrivateField() { + assert.sameValue(this.hasOwnProperty("#m"), true); + assert.sameValue("#m" in this, true); + + assert.sameValue(this["#m"], 4); + + assert.sameValue(this.#m, 44); + + return 0; + } +} + +let c = new C(); +assert.sameValue(c.checkPrivateField(), 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-field-is-visible-in-computed-properties.js b/js/src/tests/test262/language/statements/class/elements/private-field-is-visible-in-computed-properties.js new file mode 100644 index 0000000000..cb2bb60987 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-field-is-visible-in-computed-properties.js @@ -0,0 +1,51 @@ +// Copyright (C) 2019 Caio Lima (Igalia SL). All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: PrivateName of a class is visible in its ComputetProperty scope +esid: prod-ClassTail +info: | + ClassTail : ClassHeritage { ClassBody } + 1. Let lex be the LexicalEnvironment of the running execution context. + 2. Let classScope be NewDeclarativeEnvironment(lex). + 3. Let classScopeEnvRec be classScope's EnvironmentRecord. + ... + 8. If ClassBodyopt is present, then + a. For each element dn of the PrivateBoundIdentifiers of ClassBodyopt, + i. Perform classPrivateEnvRec.CreateImmutableBinding(dn, true). + ii. Let privateName be NewPrivateName(dn). + iii. Perform ! classPrivateEnvRec.InitializeBinding(dn, dn). + ... + 15. Set the running execution context's LexicalEnvironment to classScope. + 16. Set the running execution context's PrivateEnvironment to classPrivateEnvironment. + ... + 27. For each ClassElement e in order from elements + a. If IsStatic of e is false, then + i. Let field be the result of ClassElementEvaluation for e with arguments proto and false. + ... + + GetValue ( V ) + ... + 5. If IsPropertyReference(V), then + ... + b. If IsPrivateReference(V), then + i. Return ? PrivateFieldGet(GetReferencedName(V), base). + + PrivateFieldGet ( P, O ) + ... + 4. If entry is empty, throw a TypeError exception. + ... + +features: [class-fields-private, class-fields-public, class] +---*/ + +const self = this; +assert.throws(TypeError, function() { + class C { + [self.#f] = 'Test262'; + #f = 'foo'; + } +}, 'access to a not defined private field in object should throw a TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-field-on-nested-class.js b/js/src/tests/test262/language/statements/class/elements/private-field-on-nested-class.js new file mode 100644 index 0000000000..fe62912de9 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-field-on-nested-class.js @@ -0,0 +1,47 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/private-field-on-nested-class.case +// - src/class-elements/default/cls-decl.template +/*--- +description: PrivateName CallExpression usage (private field) (field definitions in a class declaration) +esid: prod-FieldDefinition +features: [class-fields-private, class-fields-public, class] +flags: [generated] +info: | + Updated Productions + + CallExpression[Yield, Await]: + CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await] + SuperCall[?Yield, ?Await] + CallExpression[?Yield, ?Await]Arguments[?Yield, ?Await] + CallExpression[?Yield, ?Await][Expression[+In, ?Yield, ?Await]] + CallExpression[?Yield, ?Await].IdentifierName + CallExpression[?Yield, ?Await]TemplateLiteral[?Yield, ?Await] + CallExpression[?Yield, ?Await].PrivateName + +---*/ + + +class C { + #outer = 'test262'; + + B_withoutPrivateField = class { + method(o) { + return o.#outer; + } + } + + B_withPrivateField = class { + #inner = 42; + method(o) { + return o.#outer; + } + } +} + +let c = new C(); +let innerB1 = new c.B_withoutPrivateField(); +assert.sameValue(innerB1.method(c), 'test262'); +let innerB2 = new c.B_withPrivateField(); +assert.sameValue(innerB2.method(c), 'test262'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-field-visible-to-direct-eval-on-initializer.js b/js/src/tests/test262/language/statements/class/elements/private-field-visible-to-direct-eval-on-initializer.js new file mode 100644 index 0000000000..5abd78669d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-field-visible-to-direct-eval-on-initializer.js @@ -0,0 +1,49 @@ +// Copyright (C) 2019 Caio Lima (Igalia SL). All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Private field is visible on initializer with direct eval +esid: sec-privatefieldget +info: | + PrivateFieldGet (P, O) + 1. Assert: P is a Private Name. + 2. If O is not an object, throw a TypeError exception. + 3. If P.[[Kind]] is "field", + a. Let entry be PrivateFieldFind(P, O). + b. If entry is empty, throw a TypeError exception. + c. Return entry.[[PrivateFieldValue]]. + 4. Perform ? PrivateBrandCheck(O, P). + 5. If P.[[Kind]] is "method", + a. Return P.[[Value]]. + 6. Else, + a. Assert: P.[[Kind]] is "accessor". + b. If P does not have a [[Get]] field, throw a TypeError exception. + c. Let getter be P.[[Get]]. + d. Return ? Call(getter, O). + + ClassElementName : PrivateIdentifier + 1. Let privateIdentifier be StringValue of PrivateIdentifier. + 2. Let privateName be NewPrivateName(privateIdentifier). + 3. Let scope be the running execution context's PrivateEnvironment. + 4. Let scopeEnvRec be scope's EnvironmentRecord. + 5. Perform ! scopeEnvRec.InitializeBinding(privateIdentifier, privateName). + 6. Return privateName. + + MakePrivateReference ( baseValue, privateIdentifier ) + 1. Let env be the running execution context's PrivateEnvironment. + 2. Let privateNameBinding be ? ResolveBinding(privateIdentifier, env). + 3. Let privateName be GetValue(privateNameBinding). + 4. Assert: privateName is a Private Name. + 5. Return a value of type Reference whose base value is baseValue, whose referenced name is privateName, whose strict reference flag is true. +features: [class-fields-private, class-fields-public, class] +---*/ + +class C { + #m = 44; + v = eval("this.#m"); +} + +let c = new C(); +assert.sameValue(c.v, 44); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-field-visible-to-direct-eval.js b/js/src/tests/test262/language/statements/class/elements/private-field-visible-to-direct-eval.js new file mode 100644 index 0000000000..706e4a64b8 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-field-visible-to-direct-eval.js @@ -0,0 +1,61 @@ +// Copyright (C) 2019 Caio Lima (Igalia SL). All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Private field is visible to direct eval code +esid: sec-privatefieldget +info: | + PrivateFieldGet (P, O) + 1. Assert: P is a Private Name. + 2. If O is not an object, throw a TypeError exception. + 3. If P.[[Kind]] is "field", + a. Let entry be PrivateFieldFind(P, O). + b. If entry is empty, throw a TypeError exception. + c. Return entry.[[PrivateFieldValue]]. + 4. Perform ? PrivateBrandCheck(O, P). + 5. If P.[[Kind]] is "method", + a. Return P.[[Value]]. + 6. Else, + a. Assert: P.[[Kind]] is "accessor". + b. If P does not have a [[Get]] field, throw a TypeError exception. + c. Let getter be P.[[Get]]. + d. Return ? Call(getter, O). + + ClassElementName : PrivateIdentifier + 1. Let privateIdentifier be StringValue of PrivateIdentifier. + 2. Let privateName be NewPrivateName(privateIdentifier). + 3. Let scope be the running execution context's PrivateEnvironment. + 4. Let scopeEnvRec be scope's EnvironmentRecord. + 5. Perform ! scopeEnvRec.InitializeBinding(privateIdentifier, privateName). + 6. Return privateName. + + MakePrivateReference ( baseValue, privateIdentifier ) + 1. Let env be the running execution context's PrivateEnvironment. + 2. Let privateNameBinding be ? ResolveBinding(privateIdentifier, env). + 3. Let privateName be GetValue(privateNameBinding). + 4. Assert: privateName is a Private Name. + 5. Return a value of type Reference whose base value is baseValue, whose referenced name is privateName, whose strict reference flag is true. +features: [class-fields-private, class] +---*/ + +class C { + #m = 44; + + getWithEval() { + return eval("this.#m"); + } +} + +class D { + #m = 44; +} + +let c = new C(); +assert.sameValue(c.getWithEval(), 44); + +let d = new D(); +assert.throws(TypeError, function() { + c.getWithEval.call(d); +}, "invalid access to a private field"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-field-with-initialized-id-is-visible-in-computed-properties.js b/js/src/tests/test262/language/statements/class/elements/private-field-with-initialized-id-is-visible-in-computed-properties.js new file mode 100644 index 0000000000..5945177e73 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-field-with-initialized-id-is-visible-in-computed-properties.js @@ -0,0 +1,78 @@ +// Copyright (C) 2019 Caio Lima (Igalia SL). All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: PrivateName of a class is visible in its ComputetProperty scope +esid: prod-ClassTail +info: | + ClassTail : ClassHeritage { ClassBody } + 1. Let lex be the LexicalEnvironment of the running execution context. + 2. Let classScope be NewDeclarativeEnvironment(lex). + 3. Let classScopeEnvRec be classScope's EnvironmentRecord. + ... + 8. If ClassBodyopt is present, then + a. For each element dn of the PrivateBoundIdentifiers of ClassBodyopt, + i. Perform classPrivateEnvRec.CreateImmutableBinding(dn, true). + ... + 15. Set the running execution context's LexicalEnvironment to classScope. + 16. Set the running execution context's PrivateEnvironment to classPrivateEnvironment. + ... + 27. For each ClassElement e in order from elements + a. If IsStatic of e is false, then + i. Let field be the result of ClassElementEvaluation for e with arguments proto and false. + ... + + FieldDefinition : ClassElementName Initializer + 1. Let name be the result of evaluating ClassElementName. + ... + + ClassElementName : PrivateIdentifier + 1. Let privateIdentifier be StringValue of PrivateIdentifier. + 2. Let privateName be NewPrivateName(privateIdentifier). + 3. Let scope be the running execution context's PrivateEnvironment. + 4. Let scopeEnvRec be scope's EnvironmentRecord. + 5. Perform ! scopeEnvRec.InitializeBinding(privateIdentifier, privateName). + 6. Return privateName. + + MemberExpression : MemberExpression . PrivateIdentifier + ... + 5. Return MakePrivateReference(bv, fieldNameString). + + MakePrivateReference ( baseValue, privateIdentifier ) + ... + 2. Let privateNameBinding be ? ResolveBinding(privateIdentifier, env). + 3. Let privateName be GetValue(privateNameBinding). + ... + + GetValue (V) + ... + 5. If IsPropertyReference(V), then + a. If HasPrimitiveBase(V), then + i. Assert: In this case, base will never be null or undefined. + ii. Let base be ToObject(base). + b. If IsPrivateReference(V), then + i. Return ? PrivateFieldGet(GetReferencedName(V), base). + 6. Else, + a. Assert: base is an Environment Record. + b. Return ? base.GetBindingValue(GetReferencedName(V), IsStrictReference(V)). + + PrivateFieldGet (P, O) + 1. Assert: P is a Private Name. + 2. Assert: Type(O) is Object. + 3. Let entry be PrivateFieldFind(P, O). + 4. If entry is empty, throw a TypeError exception. + 5. Return entry.[[PrivateFieldValue]]. + +features: [class-fields-private, class-fields-public, class] +---*/ + +const self = this; +assert.throws(TypeError, function() { + class C { + #f = 'foo'; + [self.#f] = 'Test262'; + } +}, 'access to a not defined private field in object should throw a TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-generator-method-name.js b/js/src/tests/test262/language/statements/class/elements/private-generator-method-name.js new file mode 100644 index 0000000000..d2650dbbdf --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-generator-method-name.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/private-generator-method-name.case +// - src/class-elements/default/cls-decl.template +/*--- +description: Private generator methods have name property properly configured (field definitions in a class declaration) +esid: prod-FieldDefinition +features: [class-methods-private, class] +flags: [generated] +info: | + Updated Productions + + ClassElement : MethodDefinition + 1. Return ClassElementEvaluation of MethodDefinition with arguments ! Get(homeObject, "prototype"),enumerable, and "prototype". + + GeneratorMethod : * ClassElementName (UniqueFormalParameters) { GeneratorBody } + 1. Let key be the result of evaluating ClassElementName. + ... + 12. Return DefineOrdinaryMethod(key, homeObject, closure, enumerable). + + ClassElement : MethodDefinition + ClassElement : static MethodDefinition + 1. Perform ? PropertyDefinitionEvaluation with parameters object and enumerable. + 2. Return empty. + + ClassElementName : PrivateIdentifier + 1. Let bindingName be StringValue of PrivateIdentifier. + ... + 5. If scopeEnvRec's binding for bindingName is uninitialized, + a. Let field be NewPrivateName(bindingName). + b. Perform ! scopeEnvRec.InitializeBinding(bindingName, field). + 6. Otherwise, + a. Let field be scopeEnvRec.GetBindingValue(bindingName). + 7. Assert: field.[[Description]] is bindingName. + 8. Return field. + + DefineOrdinaryMethod(key, homeObject, closure, enumerable) + 1. Perform SetFunctionName(closure, key). + 2. If key is a Private Name, + a. Assert: key does not have a [[Kind]] field. + b. Set key.[[Kind]] to "method". + c. Set key.[[Value]] to closure. + d. Set key.[[Brand]] to homeObject. + 3. Else, + a. Let desc be the PropertyDescriptor{[[Value]]: closure, [[Writable]]: true, [[Enumerable]]: enumerable, [[Configurable]]: true}. + b. Perform ? DefinePropertyOrThrow(homeObject, key, desc). + +---*/ + + +class C { + * #method() {}; + + getPrivateMethod() { + return this.#method; + } +} + +let c = new C(); +assert.sameValue(c.getPrivateMethod().name, "#method"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-getter-access-on-inner-arrow-function.js b/js/src/tests/test262/language/statements/class/elements/private-getter-access-on-inner-arrow-function.js new file mode 100644 index 0000000000..eb230b531f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-getter-access-on-inner-arrow-function.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/private-getter-access-on-inner-arrow-function.case +// - src/class-elements/default/cls-decl.template +/*--- +description: PrivateName of private getter is visible on inner arrow function of class scope (field definitions in a class declaration) +esid: prod-FieldDefinition +features: [class-methods-private, class] +flags: [generated] +info: | + Updated Productions + + CallExpression[Yield, Await]: + CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await] + SuperCall[?Yield, ?Await] + CallExpression[?Yield, ?Await]Arguments[?Yield, ?Await] + CallExpression[?Yield, ?Await][Expression[+In, ?Yield, ?Await]] + CallExpression[?Yield, ?Await].IdentifierName + CallExpression[?Yield, ?Await]TemplateLiteral[?Yield, ?Await] + CallExpression[?Yield, ?Await].PrivateName + +---*/ + + +class C { + get #m() { return 'Test262'; } + + method() { + let arrowFunction = () => { + return this.#m; + } + + return arrowFunction(); + } +} + +let c = new C(); +assert.sameValue(c.method(), 'Test262'); +let o = {}; +assert.throws(TypeError, function() { + c.method.call(o); +}, 'accessed private accessor from an ordinary object'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-getter-access-on-inner-function.js b/js/src/tests/test262/language/statements/class/elements/private-getter-access-on-inner-function.js new file mode 100644 index 0000000000..0f5ea60b1c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-getter-access-on-inner-function.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/private-getter-access-on-inner-function.case +// - src/class-elements/default/cls-decl.template +/*--- +description: PrivateName of private getter is visible on inner function of class scope (field definitions in a class declaration) +esid: prod-FieldDefinition +features: [class-methods-private, class] +flags: [generated] +info: | + Updated Productions + + CallExpression[Yield, Await]: + CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await] + SuperCall[?Yield, ?Await] + CallExpression[?Yield, ?Await]Arguments[?Yield, ?Await] + CallExpression[?Yield, ?Await][Expression[+In, ?Yield, ?Await]] + CallExpression[?Yield, ?Await].IdentifierName + CallExpression[?Yield, ?Await]TemplateLiteral[?Yield, ?Await] + CallExpression[?Yield, ?Await].PrivateName + +---*/ + + +class C { + get #m() { return 'Test262'; } + + method() { + let self = this; + function innerFunction() { + return self.#m; + } + + return innerFunction(); + } +} + +let c = new C(); +assert.sameValue(c.method(), 'Test262'); +let o = {}; +assert.throws(TypeError, function() { + c.method.call(o); +}, 'accessed private accessor from an ordinary object'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-getter-brand-check-multiple-evaluations-of-class.js b/js/src/tests/test262/language/statements/class/elements/private-getter-brand-check-multiple-evaluations-of-class.js new file mode 100644 index 0000000000..ce8089407e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-getter-brand-check-multiple-evaluations-of-class.js @@ -0,0 +1,49 @@ +// Copyright (C) 2019 Caio Lima (Igalia SL). All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Every new evaluation of a class creates a different brand (private getter) +esid: sec-privatefieldget +info: | + ClassTail : ClassHeritage { ClassBody } + ... + 11. Let proto be ObjectCreate(protoParent). + ... + 31. If PrivateBoundIdentifiers of ClassBody contains a Private Name P such that the P's [[Kind]] field is either "method" or "accessor", + a. Set F.[[PrivateBrand]] to proto. + ... + + PrivateBrandCheck(O, P) + 1. If O.[[PrivateBrands]] does not contain an entry e such that SameValue(e, P.[[Brand]]) is true, + a. Throw a TypeError exception. +features: [class, class-methods-private] +---*/ + +let createAndInstantiateClass = function () { + class C { + get #m() { return 'test262'; } + + access(o) { + return o.#m; + } + } + + let c = new C(); + return c; +}; + +let c1 = createAndInstantiateClass(); +let c2 = createAndInstantiateClass(); + +assert.sameValue(c1.access(c1), 'test262'); +assert.sameValue(c2.access(c2), 'test262'); + +assert.throws(TypeError, function() { + c1.access(c2); +}, 'invalid access of c1 private method'); + +assert.throws(TypeError, function() { + c2.access(c1); +}, 'invalid access of c2 private method'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-getter-brand-check-super-class.js b/js/src/tests/test262/language/statements/class/elements/private-getter-brand-check-super-class.js new file mode 100644 index 0000000000..e0fd805fed --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-getter-brand-check-super-class.js @@ -0,0 +1,50 @@ +// Copyright (C) 2019 Caio Lima (Igalia SL). All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Subclass can access private methods of a superclass (private getter) +esid: sec-privatefieldget +info: | + SuperCall : super Arguments + ... + 10. Perform ? InitializeInstanceElements(result, F). + ... + + InitializeInstanceFieldsElements ( O, constructor ) + 1. Assert: Type ( O ) is Object. + 2. Assert: Assert constructor is an ECMAScript function object. + 3. If constructor.[[PrivateBrand]] is not undefined, + a. Perform ? PrivateBrandAdd(O, constructor.[[PrivateBrand]]). + 4. Let fieldRecords be the value of constructor's [[Fields]] internal slot. + 5. For each item fieldRecord in order from fieldRecords, + a. Perform ? DefineField(O, fieldRecord). + 6. Return. +features: [class, class-methods-private] +---*/ + +class S { + get #m() { return 'super class'; } + + superAccess() { return this.#m; } +} + +class C extends S { + get #m() { return 'test262'; } + + access() { + return this.#m; + } +} + +let c = new C(); + +assert.sameValue(c.access(), 'test262'); +assert.sameValue(c.superAccess(), 'super class'); + +let s = new S(); +assert.sameValue(s.superAccess(), 'super class'); +assert.throws(TypeError, function() { + c.access.call(s); +}, 'invalid access of C private method'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-getter-brand-check.js b/js/src/tests/test262/language/statements/class/elements/private-getter-brand-check.js new file mode 100644 index 0000000000..775a26d7bd --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-getter-brand-check.js @@ -0,0 +1,47 @@ +// Copyright (C) 2019 Caio Lima (Igalia SL). All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: PrivateBrandCheck fails when the object O doesn't have P.[[Brand]] (private getter) +esid: sec-privatefieldget +info: | + PrivateFieldGet (P, O) + 1. Assert: P is a Private Name. + 2. If O is not an object, throw a TypeError exception. + 3. If P.[[Kind]] is "field", + a. Let entry be PrivateFieldFind(P, O). + b. If entry is empty, throw a TypeError exception. + c. Return entry.[[PrivateFieldValue]]. + 4. Perform ? PrivateBrandCheck(O, P). + 5. If P.[[Kind]] is "method", + a. Return P.[[Value]]. + 6. Else, + a. Assert: P.[[Kind]] is "accessor". + b. If P does not have a [[Get]] field, throw a TypeError exception. + c. Let getter be P.[[Get]]. + d. Return ? Call(getter, O). + + PrivateBrandCheck(O, P) + 1. If O.[[PrivateBrands]] does not contain an entry e such that SameValue(e, P.[[Brand]]) is true, + a. Throw a TypeError exception. +features: [class, class-methods-private] +---*/ + +class C { + get #m() { return 'test262'; } + + access(o) { + return o.#m; + } +} + +let c = new C(); +assert.sameValue(c.access(c), 'test262'); + +let o = {}; +assert.throws(TypeError, function() { + c.access(o); +}, 'invalid access a private method'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-getter-is-not-a-own-property.js b/js/src/tests/test262/language/statements/class/elements/private-getter-is-not-a-own-property.js new file mode 100644 index 0000000000..71901a7d2b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-getter-is-not-a-own-property.js @@ -0,0 +1,47 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/private-getter-is-not-a-own-property.case +// - src/class-elements/default/cls-decl.template +/*--- +description: Private getter is not stored as an own property of objects (field definitions in a class declaration) +esid: prod-FieldDefinition +features: [class-methods-private, class] +flags: [generated] +info: | + PrivateFieldGet (P, O) + 1. Assert: P is a Private Name. + 2. If O is not an object, throw a TypeError exception. + 3. If P.[[Kind]] is "field", + a. Let entry be PrivateFieldFind(P, O). + b. If entry is empty, throw a TypeError exception. + c. Return entry.[[PrivateFieldValue]]. + 4. Perform ? PrivateBrandCheck(O, P). + 5. If P.[[Kind]] is "method", + a. Return P.[[Value]]. + 6. Else, + a. Assert: P.[[Kind]] is "accessor". + b. If P does not have a [[Get]] field, throw a TypeError exception. + c. Let getter be P.[[Get]]. + d. Return ? Call(getter, O). + +---*/ + + +class C { + get #m() { return "Test262"; } + + checkPrivateGetter() { + assert.sameValue(this.hasOwnProperty("#m"), false); + assert.sameValue("#m" in this, false); + + assert.sameValue(this.__lookupGetter__("#m"), undefined); + + assert.sameValue(this.#m, "Test262"); + + return 0; + } +} + +let c = new C(); +assert.sameValue(c.checkPrivateGetter(), 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-getter-is-not-clobbered-by-computed-property.js b/js/src/tests/test262/language/statements/class/elements/private-getter-is-not-clobbered-by-computed-property.js new file mode 100644 index 0000000000..14bae94912 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-getter-is-not-clobbered-by-computed-property.js @@ -0,0 +1,45 @@ +// Copyright (C) 2019 Caio Lima (Igalia SL). All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Private getter is not clobbered by computed property +esid: sec-privatefieldget +info: | + PrivateFieldGet (P, O) + 1. Assert: P is a Private Name. + 2. If O is not an object, throw a TypeError exception. + 3. If P.[[Kind]] is "field", + a. Let entry be PrivateFieldFind(P, O). + b. If entry is empty, throw a TypeError exception. + c. Return entry.[[PrivateFieldValue]]. + 4. Perform ? PrivateBrandCheck(O, P). + 5. If P.[[Kind]] is "method", + a. Return P.[[Value]]. + 6. Else, + a. Assert: P.[[Kind]] is "accessor". + b. If P does not have a [[Get]] field, throw a TypeError exception. + c. Let getter be P.[[Get]]. + d. Return ? Call(getter, O). +features: [class-methods-private, class-fields-public, class] +---*/ + +class C { + get #m() { return "Test262"; } + ["#m"] = 0; + + checkPrivateGetter() { + assert.sameValue(this.hasOwnProperty("#m"), true); + assert.sameValue("#m" in this, true); + + assert.sameValue(this["#m"], 0); + + assert.sameValue(this.#m, "Test262"); + + return 0; + } +} + +let c = new C(); +assert.sameValue(c.checkPrivateGetter(), 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-getter-on-nested-class.js b/js/src/tests/test262/language/statements/class/elements/private-getter-on-nested-class.js new file mode 100644 index 0000000000..bdda163475 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-getter-on-nested-class.js @@ -0,0 +1,38 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/private-getter-on-nested-class.case +// - src/class-elements/default/cls-decl.template +/*--- +description: PrivateName of private getter is available on inner classes (field definitions in a class declaration) +esid: prod-FieldDefinition +features: [class-methods-private, class-fields-public, class] +flags: [generated] +info: | + Updated Productions + + CallExpression[Yield, Await]: + CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await] + SuperCall[?Yield, ?Await] + CallExpression[?Yield, ?Await]Arguments[?Yield, ?Await] + CallExpression[?Yield, ?Await][Expression[+In, ?Yield, ?Await]] + CallExpression[?Yield, ?Await].IdentifierName + CallExpression[?Yield, ?Await]TemplateLiteral[?Yield, ?Await] + CallExpression[?Yield, ?Await].PrivateName + +---*/ + + +class C { + get #m() { return 'test262'; } + + B = class { + method(o) { + return o.#m; + } + } +} + +let c = new C(); +let innerB = new c.B(); +assert.sameValue(innerB.method(c), 'test262'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-getter-shadowed-by-field-on-nested-class.js b/js/src/tests/test262/language/statements/class/elements/private-getter-shadowed-by-field-on-nested-class.js new file mode 100644 index 0000000000..94bcb313bf --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-getter-shadowed-by-field-on-nested-class.js @@ -0,0 +1,46 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/private-getter-shadowed-by-field-on-nested-class.case +// - src/class-elements/default/cls-decl.template +/*--- +description: PrivateName of private getter can be shadowed on inner classes by a private field (field definitions in a class declaration) +esid: prod-FieldDefinition +features: [class-methods-private, class-fields-private, class-fields-public, class] +flags: [generated] +info: | + Updated Productions + + CallExpression[Yield, Await]: + CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await] + SuperCall[?Yield, ?Await] + CallExpression[?Yield, ?Await]Arguments[?Yield, ?Await] + CallExpression[?Yield, ?Await][Expression[+In, ?Yield, ?Await]] + CallExpression[?Yield, ?Await].IdentifierName + CallExpression[?Yield, ?Await]TemplateLiteral[?Yield, ?Await] + CallExpression[?Yield, ?Await].PrivateName + +---*/ + + +class C { + get #m() { return 'outer class'; } + + method() { return this.#m; } + + B = class { + method(o) { + return o.#m; + } + + #m = 'test262'; + } +} + +let c = new C(); +let innerB = new c.B(); +assert.sameValue(innerB.method(innerB), 'test262'); +assert.sameValue(c.method(), 'outer class'); +assert.throws(TypeError, function() { + innerB.method(c); +}, 'accessed inner class field from an object of outer class'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-getter-shadowed-by-getter-on-nested-class.js b/js/src/tests/test262/language/statements/class/elements/private-getter-shadowed-by-getter-on-nested-class.js new file mode 100644 index 0000000000..b1d797b880 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-getter-shadowed-by-getter-on-nested-class.js @@ -0,0 +1,46 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/private-getter-shadowed-by-getter-on-nested-class.case +// - src/class-elements/default/cls-decl.template +/*--- +description: PrivateName of private getter can be shadowed on inner classes by a private getter (field definitions in a class declaration) +esid: prod-FieldDefinition +features: [class-methods-private, class-fields-public, class] +flags: [generated] +info: | + Updated Productions + + CallExpression[Yield, Await]: + CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await] + SuperCall[?Yield, ?Await] + CallExpression[?Yield, ?Await]Arguments[?Yield, ?Await] + CallExpression[?Yield, ?Await][Expression[+In, ?Yield, ?Await]] + CallExpression[?Yield, ?Await].IdentifierName + CallExpression[?Yield, ?Await]TemplateLiteral[?Yield, ?Await] + CallExpression[?Yield, ?Await].PrivateName + +---*/ + + +class C { + get #m() { return 'outer class'; } + + method() { return this.#m; } + + B = class { + method(o) { + return o.#m; + } + + get #m() { return 'test262'; } + } +} + +let c = new C(); +let innerB = new c.B(); +assert.sameValue(innerB.method(innerB), 'test262'); +assert.sameValue(c.method(), 'outer class'); +assert.throws(TypeError, function() { + innerB.method(c); +}, 'accessed inner class getter from an object of outer class'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-getter-shadowed-by-method-on-nested-class.js b/js/src/tests/test262/language/statements/class/elements/private-getter-shadowed-by-method-on-nested-class.js new file mode 100644 index 0000000000..941ce75429 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-getter-shadowed-by-method-on-nested-class.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/private-getter-shadowed-by-method-on-nested-class.case +// - src/class-elements/default/cls-decl.template +/*--- +description: PrivateName of private getter can be shadowed on inner class by a private method (field definitions in a class declaration) +esid: prod-FieldDefinition +features: [class-methods-private, class-fields-public, class] +flags: [generated] +info: | + Updated Productions + + CallExpression[Yield, Await]: + CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await] + SuperCall[?Yield, ?Await] + CallExpression[?Yield, ?Await]Arguments[?Yield, ?Await] + CallExpression[?Yield, ?Await][Expression[+In, ?Yield, ?Await]] + CallExpression[?Yield, ?Await].IdentifierName + CallExpression[?Yield, ?Await]TemplateLiteral[?Yield, ?Await] + CallExpression[?Yield, ?Await].PrivateName + +---*/ + + +class C { + get #m() { throw new Test262Error(); } + + B = class { + method(o) { + return o.#m(); + } + + #m() { return 'test262'; } + } +} + +let c = new C(); +let innerB = new c.B(); +assert.sameValue(innerB.method(innerB), 'test262'); +assert.throws(TypeError, function() { + innerB.method(c); +}, 'accessed inner class method from an object of outer class'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-getter-shadowed-by-setter-on-nested-class.js b/js/src/tests/test262/language/statements/class/elements/private-getter-shadowed-by-setter-on-nested-class.js new file mode 100644 index 0000000000..4a042516a8 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-getter-shadowed-by-setter-on-nested-class.js @@ -0,0 +1,51 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/private-getter-shadowed-by-setter-on-nested-class.case +// - src/class-elements/default/cls-decl.template +/*--- +description: PrivateName of private getter can be shadowed on inner classes by a private setter (field definitions in a class declaration) +esid: prod-FieldDefinition +features: [class-methods-private, class-fields-public, class] +flags: [generated] +info: | + Updated Productions + + CallExpression[Yield, Await]: + CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await] + SuperCall[?Yield, ?Await] + CallExpression[?Yield, ?Await]Arguments[?Yield, ?Await] + CallExpression[?Yield, ?Await][Expression[+In, ?Yield, ?Await]] + CallExpression[?Yield, ?Await].IdentifierName + CallExpression[?Yield, ?Await]TemplateLiteral[?Yield, ?Await] + CallExpression[?Yield, ?Await].PrivateName + +---*/ + + +class C { + get #m() { return 'outer class'; } + + method() { return this.#m; } + + B = class { + method(o) { + return o.#m; + } + + set #m(v) { this._v = v; } + } +} + +let c = new C(); +let innerB = new c.B(); + +assert.throws(TypeError, function() { + innerB.method(innerB); +}, '[[Get]] operation of an accessor without getter'); + +assert.sameValue(c.method(), 'outer class'); + +assert.throws(TypeError, function() { + innerB.method(c); +}, 'access of inner class accessor from an object of outer class'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-getter-visible-to-direct-eval-on-initializer.js b/js/src/tests/test262/language/statements/class/elements/private-getter-visible-to-direct-eval-on-initializer.js new file mode 100644 index 0000000000..113f29c138 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-getter-visible-to-direct-eval-on-initializer.js @@ -0,0 +1,49 @@ +// Copyright (C) 2019 Caio Lima (Igalia SL). All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Private getter is visible on initializer with direct eval +esid: sec-privatefieldget +info: | + PrivateFieldGet (P, O) + 1. Assert: P is a Private Name. + 2. If O is not an object, throw a TypeError exception. + 3. If P.[[Kind]] is "field", + a. Let entry be PrivateFieldFind(P, O). + b. If entry is empty, throw a TypeError exception. + c. Return entry.[[PrivateFieldValue]]. + 4. Perform ? PrivateBrandCheck(O, P). + 5. If P.[[Kind]] is "method", + a. Return P.[[Value]]. + 6. Else, + a. Assert: P.[[Kind]] is "accessor". + b. If P does not have a [[Get]] field, throw a TypeError exception. + c. Let getter be P.[[Get]]. + d. Return ? Call(getter, O). + + ClassElementName : PrivateIdentifier + 1. Let privateIdentifier be StringValue of PrivateIdentifier. + 2. Let privateName be NewPrivateName(privateIdentifier). + 3. Let scope be the running execution context's PrivateEnvironment. + 4. Let scopeEnvRec be scope's EnvironmentRecord. + 5. Perform ! scopeEnvRec.InitializeBinding(privateIdentifier, privateName). + 6. Return privateName. + + MakePrivateReference ( baseValue, privateIdentifier ) + 1. Let env be the running execution context's PrivateEnvironment. + 2. Let privateNameBinding be ? ResolveBinding(privateIdentifier, env). + 3. Let privateName be GetValue(privateNameBinding). + 4. Assert: privateName is a Private Name. + 5. Return a value of type Reference whose base value is baseValue, whose referenced name is privateName, whose strict reference flag is true. +features: [class-methods-private, class-fields-public, class] +---*/ + +class C { + get #m() { return "Test262"; }; + v = eval("this.#m"); +} + +let c = new C(); +assert.sameValue(c.v, "Test262"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-getter-visible-to-direct-eval.js b/js/src/tests/test262/language/statements/class/elements/private-getter-visible-to-direct-eval.js new file mode 100644 index 0000000000..55a54f0d16 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-getter-visible-to-direct-eval.js @@ -0,0 +1,61 @@ +// Copyright (C) 2019 Caio Lima (Igalia SL). All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Private getter is visible to direct eval code +esid: sec-privatefieldget +info: | + PrivateFieldGet (P, O) + 1. Assert: P is a Private Name. + 2. If O is not an object, throw a TypeError exception. + 3. If P.[[Kind]] is "field", + a. Let entry be PrivateFieldFind(P, O). + b. If entry is empty, throw a TypeError exception. + c. Return entry.[[PrivateFieldValue]]. + 4. Perform ? PrivateBrandCheck(O, P). + 5. If P.[[Kind]] is "method", + a. Return P.[[Value]]. + 6. Else, + a. Assert: P.[[Kind]] is "accessor". + b. If P does not have a [[Get]] field, throw a TypeError exception. + c. Let getter be P.[[Get]]. + d. Return ? Call(getter, O). + + ClassElementName : PrivateIdentifier + 1. Let privateIdentifier be StringValue of PrivateIdentifier. + 2. Let privateName be NewPrivateName(privateIdentifier). + 3. Let scope be the running execution context's PrivateEnvironment. + 4. Let scopeEnvRec be scope's EnvironmentRecord. + 5. Perform ! scopeEnvRec.InitializeBinding(privateIdentifier, privateName). + 6. Return privateName. + + MakePrivateReference ( baseValue, privateIdentifier ) + 1. Let env be the running execution context's PrivateEnvironment. + 2. Let privateNameBinding be ? ResolveBinding(privateIdentifier, env). + 3. Let privateName be GetValue(privateNameBinding). + 4. Assert: privateName is a Private Name. + 5. Return a value of type Reference whose base value is baseValue, whose referenced name is privateName, whose strict reference flag is true. +features: [class-methods-private, class] +---*/ + +class C { + get #m() { return "Test262"; }; + + getWithEval() { + return eval("this.#m"); + } +} + +class D { + get #m() { throw new Test262Error(); }; +} + +let c = new C(); +assert.sameValue(c.getWithEval(), "Test262"); + +let d = new D(); +assert.throws(TypeError, function() { + c.getWithEval.call(d); +}, "invalid access to a private getter"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-indirect-eval-contains-arguments.js b/js/src/tests/test262/language/statements/class/elements/private-indirect-eval-contains-arguments.js new file mode 100644 index 0000000000..4b58b0b29e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-indirect-eval-contains-arguments.js @@ -0,0 +1,25 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/eval-contains-arguments.case +// - src/class-elements/initializer-indirect-eval-arguments/cls-decl-private-fields-indirect-eval.template +/*--- +description: No error if `arguments` in StatementList of eval (indirect eval) +esid: sec-performeval-rules-in-initializer +features: [class, class-fields-public, class-fields-private] +flags: [generated, noStrict] +info: | + For indirect eval, the "Additional Early Error Rules for Eval Inside Initializer" + (in #sec-performeval-rules-in-initializer) are NOT applicable. + +---*/ + + +var arguments = 1; +class C { + #x = (0, eval)('arguments;'); + x() { + return this.#x; + } +} +assert.sameValue(new C().x(), arguments); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-indirect-eval-err-contains-newtarget.js b/js/src/tests/test262/language/statements/class/elements/private-indirect-eval-err-contains-newtarget.js new file mode 100644 index 0000000000..a55ad8388d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-indirect-eval-err-contains-newtarget.js @@ -0,0 +1,37 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/eval-err-contains-newtarget.case +// - src/class-elements/initializer-eval-newtarget/cls-decl-private-fields-indirect-eval.template +/*--- +description: error if `new.target` in StatementList of eval (indirect eval) +esid: sec-performeval-rules-in-initializer +features: [class, new.target, class-fields-private] +flags: [generated] +info: | + Additional Early Error Rules for Eval Inside Initializer + These static semantics are applied by PerformEval when a direct eval call occurs inside a class field initializer. + ScriptBody : StatementList + + ... + The remaining eval rules apply as outside a constructor, inside a method, and inside a function. + + Additional Early Error Rules for Eval Outside Functions + These static semantics are applied by PerformEval when a direct eval call occurs outside of any function. + ScriptBody : StatementList + + It is a Syntax Error if StatementList Contains NewTarget. + +---*/ + + +var executed = false; +class C { + #x = (0, eval)('executed = true; new.target;'); +} + +assert.throws(SyntaxError, function() { + new C(); +}); + +assert.sameValue(executed, false); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-literal-name-init-err-contains-arguments.js b/js/src/tests/test262/language/statements/class/elements/private-literal-name-init-err-contains-arguments.js new file mode 100644 index 0000000000..bc1117bcfc --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-literal-name-init-err-contains-arguments.js @@ -0,0 +1,35 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/init-err-contains-arguments.case +// - src/class-elements/initializer-error/cls-decl-fields-private-name.template +/*--- +description: Syntax error if `arguments` used in class field (ClassElementName PrivateName) +esid: sec-class-definitions-static-semantics-early-errors +features: [class, class-fields-public, class-fields-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Static Semantics: Early Errors + + FieldDefinition: + PropertyNameInitializeropt + + - It is a Syntax Error if ContainsArguments of Initializer is true. + + Static Semantics: ContainsArguments + IdentifierReference : Identifier + + 1. If the StringValue of Identifier is "arguments", return true. + ... + For all other grammatical productions, recurse on all nonterminals. If any piece returns true, then return true. Otherwise return false. + +---*/ + + +$DONOTEVALUATE(); + +class C { + #x = arguments; +} diff --git a/js/src/tests/test262/language/statements/class/elements/private-literal-name-init-err-contains-super.js b/js/src/tests/test262/language/statements/class/elements/private-literal-name-init-err-contains-super.js new file mode 100644 index 0000000000..57126d4e80 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-literal-name-init-err-contains-super.js @@ -0,0 +1,28 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/init-err-contains-super.case +// - src/class-elements/initializer-error/cls-decl-fields-private-name.template +/*--- +description: Syntax error if `super()` used in class field (ClassElementName PrivateName) +esid: sec-class-definitions-static-semantics-early-errors +features: [class, class-fields-public, class-fields-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Static Semantics: Early Errors + + FieldDefinition: + PropertyNameInitializeropt + + - It is a Syntax Error if Initializer is present and Initializer Contains SuperCall is true. + +---*/ + + +$DONOTEVALUATE(); + +class C { + #x = super(); +} diff --git a/js/src/tests/test262/language/statements/class/elements/private-method-access-on-inner-arrow-function.js b/js/src/tests/test262/language/statements/class/elements/private-method-access-on-inner-arrow-function.js new file mode 100644 index 0000000000..a0e1670cfa --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-method-access-on-inner-arrow-function.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/private-method-access-on-inner-arrow-function.case +// - src/class-elements/default/cls-decl.template +/*--- +description: PrivateName of private method is visible on inner arrow function of class scope (field definitions in a class declaration) +esid: prod-FieldDefinition +features: [class-methods-private, class] +flags: [generated] +info: | + Updated Productions + + CallExpression[Yield, Await]: + CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await] + SuperCall[?Yield, ?Await] + CallExpression[?Yield, ?Await]Arguments[?Yield, ?Await] + CallExpression[?Yield, ?Await][Expression[+In, ?Yield, ?Await]] + CallExpression[?Yield, ?Await].IdentifierName + CallExpression[?Yield, ?Await]TemplateLiteral[?Yield, ?Await] + CallExpression[?Yield, ?Await].PrivateName + +---*/ + + +class C { + #m() { return 'Test262'; } + + method() { + let arrowFunction = () => { + return this.#m(); + } + + return arrowFunction(); + } +} + +let c = new C(); +assert.sameValue(c.method(), 'Test262'); +let o = {}; +assert.throws(TypeError, function() { + c.method.call(o); +}, 'accessed private method from an ordinary object'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-method-access-on-inner-function.js b/js/src/tests/test262/language/statements/class/elements/private-method-access-on-inner-function.js new file mode 100644 index 0000000000..00d4ba02fe --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-method-access-on-inner-function.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/private-method-access-on-inner-function.case +// - src/class-elements/default/cls-decl.template +/*--- +description: PrivateName of private method is visible on inner function of class scope (field definitions in a class declaration) +esid: prod-FieldDefinition +features: [class-methods-private, class] +flags: [generated] +info: | + Updated Productions + + CallExpression[Yield, Await]: + CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await] + SuperCall[?Yield, ?Await] + CallExpression[?Yield, ?Await]Arguments[?Yield, ?Await] + CallExpression[?Yield, ?Await][Expression[+In, ?Yield, ?Await]] + CallExpression[?Yield, ?Await].IdentifierName + CallExpression[?Yield, ?Await]TemplateLiteral[?Yield, ?Await] + CallExpression[?Yield, ?Await].PrivateName + +---*/ + + +class C { + #m() { return 'Test262'; } + + method() { + let self = this; + function innerFunction() { + return self.#m(); + } + + return innerFunction(); + } +} + +let c = new C(); +assert.sameValue(c.method(), 'Test262'); +let o = {}; +assert.throws(TypeError, function() { + c.method.call(o); +}, 'accessed private method from an ordinary object'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-method-brand-check-multiple-evaluations-of-class.js b/js/src/tests/test262/language/statements/class/elements/private-method-brand-check-multiple-evaluations-of-class.js new file mode 100644 index 0000000000..1a04a5c24f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-method-brand-check-multiple-evaluations-of-class.js @@ -0,0 +1,49 @@ +// Copyright (C) 2019 Caio Lima (Igalia SL). All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Every new evaluation of a class creates a different brand (private method) +esid: sec-privatefieldget +info: | + ClassTail : ClassHeritage { ClassBody } + ... + 11. Let proto be ObjectCreate(protoParent). + ... + 31. If PrivateBoundIdentifiers of ClassBody contains a Private Name P such that the P's [[Kind]] field is either "method" or "accessor", + a. Set F.[[PrivateBrand]] to proto. + ... + + PrivateBrandCheck(O, P) + 1. If O.[[PrivateBrands]] does not contain an entry e such that SameValue(e, P.[[Brand]]) is true, + a. Throw a TypeError exception. +features: [class, class-methods-private] +---*/ + +let createAndInstantiateClass = function () { + class C { + #m() { return 'test262'; } + + access(o) { + return o.#m(); + } + } + + let c = new C(); + return c; +}; + +let c1 = createAndInstantiateClass(); +let c2 = createAndInstantiateClass(); + +assert.sameValue(c1.access(c1), 'test262'); +assert.sameValue(c2.access(c2), 'test262'); + +assert.throws(TypeError, function() { + c1.access(c2); +}, 'invalid access of c1 private method'); + +assert.throws(TypeError, function() { + c2.access(c1); +}, 'invalid access of c2 private method'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-method-brand-check-super-class.js b/js/src/tests/test262/language/statements/class/elements/private-method-brand-check-super-class.js new file mode 100644 index 0000000000..76387409ab --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-method-brand-check-super-class.js @@ -0,0 +1,50 @@ +// Copyright (C) 2019 Caio Lima (Igalia SL). All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Subclass can access private methods of a superclass (private method) +esid: sec-privatefieldget +info: | + SuperCall : super Arguments + ... + 10. Perform ? InitializeInstanceElements(result, F). + ... + + InitializeInstanceFieldsElements ( O, constructor ) + 1. Assert: Type ( O ) is Object. + 2. Assert: Assert constructor is an ECMAScript function object. + 3. If constructor.[[PrivateBrand]] is not undefined, + a. Perform ? PrivateBrandAdd(O, constructor.[[PrivateBrand]]). + 4. Let fieldRecords be the value of constructor's [[Fields]] internal slot. + 5. For each item fieldRecord in order from fieldRecords, + a. Perform ? DefineField(O, fieldRecord). + 6. Return. +features: [class, class-methods-private] +---*/ + +class S { + #method() { return 'super class'; } + + superAccess() { return this.#method(); } +} + +class C extends S { + #method() { return 'test262'; } + + access() { + return this.#method(); + } +} + +let c = new C(); + +assert.sameValue(c.access(), 'test262'); +assert.sameValue(c.superAccess(), 'super class'); + +let s = new S(); +assert.sameValue(s.superAccess(), 'super class'); +assert.throws(TypeError, function() { + c.access.call(s); +}, 'invalid access of C private method'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-method-brand-check.js b/js/src/tests/test262/language/statements/class/elements/private-method-brand-check.js new file mode 100644 index 0000000000..29d0a0ddec --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-method-brand-check.js @@ -0,0 +1,47 @@ +// Copyright (C) 2019 Caio Lima (Igalia SL). All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: PrivateBrandCheck fails when the object O doesn't have P.[[Brand]] (private method) +esid: sec-privatefieldget +info: | + PrivateFieldGet (P, O) + 1. Assert: P is a Private Name. + 2. If O is not an object, throw a TypeError exception. + 3. If P.[[Kind]] is "field", + a. Let entry be PrivateFieldFind(P, O). + b. If entry is empty, throw a TypeError exception. + c. Return entry.[[PrivateFieldValue]]. + 4. Perform ? PrivateBrandCheck(O, P). + 5. If P.[[Kind]] is "method", + a. Return P.[[Value]]. + 6. Else, + a. Assert: P.[[Kind]] is "accessor". + b. If P does not have a [[Get]] field, throw a TypeError exception. + c. Let getter be P.[[Get]]. + d. Return ? Call(getter, O). + + PrivateBrandCheck(O, P) + 1. If O.[[PrivateBrands]] does not contain an entry e such that SameValue(e, P.[[Brand]]) is true, + a. Throw a TypeError exception. +features: [class, class-methods-private] +---*/ + +class C { + #m() { return 'test262'; } + + access(o) { + return o.#m(); + } +} + +let c = new C(); +assert.sameValue(c.access(c), 'test262'); + +let o = {}; +assert.throws(TypeError, function() { + c.access(o); +}, 'invalid access a private method'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-method-comparison-multiple-evaluations-of-class.js b/js/src/tests/test262/language/statements/class/elements/private-method-comparison-multiple-evaluations-of-class.js new file mode 100644 index 0000000000..5e63ac2f19 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-method-comparison-multiple-evaluations-of-class.js @@ -0,0 +1,47 @@ +// Copyright (C) 2019 Caio Lima (Igalia SL). All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Every new evaluation of a class creates a different brand (private getter) +esid: sec-privatefieldget +info: | + PrivateFieldGet (P, O) + 1. Assert: P is a Private Name. + 2. If O is not an object, throw a TypeError exception. + 3. If P.[[Kind]] is "field", + a. Let entry be PrivateFieldFind(P, O). + b. If entry is empty, throw a TypeError exception. + c. Return entry.[[PrivateFieldValue]]. + 4. Perform ? PrivateBrandCheck(O, P). + 5. If P.[[Kind]] is "method", + a. Return P.[[Value]]. + 6. Else, + a. Assert: P.[[Kind]] is "accessor". + b. If P does not have a [[Get]] field, throw a TypeError exception. + c. Let getter be P.[[Get]]. + d. Return ? Call(getter, O). + + PrivateBrandCheck(O, P) + 1. If O.[[PrivateBrands]] does not contain an entry e such that SameValue(e, P.[[Brand]]) is true, + a. Throw a TypeError exception. +features: [class, class-methods-private] +---*/ + +let createAndInstantiateClass = function () { + class C { + #m() { return 'test262'; } + + getPrivateMethod() { + return this.#m; + } + } + + return new C(); +}; + +let c1 = createAndInstantiateClass(); +let c2 = createAndInstantiateClass(); + +assert.notSameValue(c1.getPrivateMethod(), c2.getPrivateMethod()); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-method-comparison.js b/js/src/tests/test262/language/statements/class/elements/private-method-comparison.js new file mode 100644 index 0000000000..94b8d120bb --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-method-comparison.js @@ -0,0 +1,47 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/private-method-comparison.case +// - src/class-elements/default/cls-decl.template +/*--- +description: PrivateFieldGet of a private method returns the same function object to every instance of the same class (field definitions in a class declaration) +esid: prod-FieldDefinition +features: [class, class-methods-private] +flags: [generated] +info: | + PrivateFieldGet (P, O) + 1. Assert: P is a Private Name. + 2. If O is not an object, throw a TypeError exception. + 3. If P.[[Kind]] is "field", + a. Let entry be PrivateFieldFind(P, O). + b. If entry is empty, throw a TypeError exception. + c. Return entry.[[PrivateFieldValue]]. + 4. Perform ? PrivateBrandCheck(O, P). + 5. If P.[[Kind]] is "method", + a. Return P.[[Value]]. + 6. Else, + a. Assert: P.[[Kind]] is "accessor". + b. If P does not have a [[Get]] field, throw a TypeError exception. + c. Let getter be P.[[Get]]. + d. Return ? Call(getter, O). + + PrivateBrandCheck(O, P) + 1. If O.[[PrivateBrands]] does not contain an entry e such that SameValue(e, P.[[Brand]]) is true, + a. Throw a TypeError exception. + +---*/ + + +class C { + #m() { return 'test262'; } + + getPrivateMethod() { + return this.#m; + } + +} + +let c1 = new C(); +let c2 = new C(); + +assert.sameValue(c1.getPrivateMethod(), c2.getPrivateMethod()); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-method-double-initialisation-get-and-set.js b/js/src/tests/test262/language/statements/class/elements/private-method-double-initialisation-get-and-set.js new file mode 100644 index 0000000000..09ab4f46c9 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-method-double-initialisation-get-and-set.js @@ -0,0 +1,37 @@ +// Copyright (C) 2021 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + Throws TypeError when attempting to install private methods multiple times. +esid: sec-privatemethodoraccessoradd +info: | + 7.3.28 PrivateMethodOrAccessorAdd ( method, O ) + 1. Assert: method.[[Kind]] is either method or accessor. + 2. Let entry be ! PrivateElementFind(method.[[Key]], O). + 3. If entry is not empty, throw a TypeError exception. + ... + +features: [class, class-methods-private] +---*/ + +class Base { + constructor(o) { + return o; + } +} + +class C extends Base { + get #p() {} + set #p(x) {} +} + +var obj = {}; + +new C(obj); + +assert.throws(TypeError, function() { + new C(obj); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-method-double-initialisation-get.js b/js/src/tests/test262/language/statements/class/elements/private-method-double-initialisation-get.js new file mode 100644 index 0000000000..7669951721 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-method-double-initialisation-get.js @@ -0,0 +1,36 @@ +// Copyright (C) 2021 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + Throws TypeError when attempting to install private methods multiple times. +esid: sec-privatemethodoraccessoradd +info: | + 7.3.28 PrivateMethodOrAccessorAdd ( method, O ) + 1. Assert: method.[[Kind]] is either method or accessor. + 2. Let entry be ! PrivateElementFind(method.[[Key]], O). + 3. If entry is not empty, throw a TypeError exception. + ... + +features: [class, class-methods-private] +---*/ + +class Base { + constructor(o) { + return o; + } +} + +class C extends Base { + get #p() {} +} + +var obj = {}; + +new C(obj); + +assert.throws(TypeError, function() { + new C(obj); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-method-double-initialisation-set.js b/js/src/tests/test262/language/statements/class/elements/private-method-double-initialisation-set.js new file mode 100644 index 0000000000..41a8f92878 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-method-double-initialisation-set.js @@ -0,0 +1,36 @@ +// Copyright (C) 2021 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + Throws TypeError when attempting to install private methods multiple times. +esid: sec-privatemethodoraccessoradd +info: | + 7.3.28 PrivateMethodOrAccessorAdd ( method, O ) + 1. Assert: method.[[Kind]] is either method or accessor. + 2. Let entry be ! PrivateElementFind(method.[[Key]], O). + 3. If entry is not empty, throw a TypeError exception. + ... + +features: [class, class-methods-private] +---*/ + +class Base { + constructor(o) { + return o; + } +} + +class C extends Base { + set #p(x) {} +} + +var obj = {}; + +new C(obj); + +assert.throws(TypeError, function() { + new C(obj); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-method-double-initialisation.js b/js/src/tests/test262/language/statements/class/elements/private-method-double-initialisation.js new file mode 100644 index 0000000000..cef42e6c13 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-method-double-initialisation.js @@ -0,0 +1,36 @@ +// Copyright (C) 2021 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + Throws TypeError when attempting to install private methods multiple times. +esid: sec-privatemethodoraccessoradd +info: | + 7.3.28 PrivateMethodOrAccessorAdd ( method, O ) + 1. Assert: method.[[Kind]] is either method or accessor. + 2. Let entry be ! PrivateElementFind(method.[[Key]], O). + 3. If entry is not empty, throw a TypeError exception. + ... + +features: [class, class-methods-private] +---*/ + +class Base { + constructor(o) { + return o; + } +} + +class C extends Base { + #m() {} +} + +var obj = {}; + +new C(obj); + +assert.throws(TypeError, function() { + new C(obj); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-method-get-and-call.js b/js/src/tests/test262/language/statements/class/elements/private-method-get-and-call.js new file mode 100644 index 0000000000..863eb31b80 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-method-get-and-call.js @@ -0,0 +1,49 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/private-method-get-and-call.case +// - src/class-elements/default/cls-decl.template +/*--- +description: Function returned by a private method can be called with other values as 'this' (field definitions in a class declaration) +esid: prod-FieldDefinition +features: [class, class-methods-private] +flags: [generated] +info: | + PrivateFieldGet (P, O) + 1. Assert: P is a Private Name. + 2. If O is not an object, throw a TypeError exception. + 3. If P.[[Kind]] is "field", + a. Let entry be PrivateFieldFind(P, O). + b. If entry is empty, throw a TypeError exception. + c. Return entry.[[PrivateFieldValue]]. + 4. Perform ? PrivateBrandCheck(O, P). + 5. If P.[[Kind]] is "method", + a. Return P.[[Value]]. + 6. Else, + a. Assert: P.[[Kind]] is "accessor". + b. If P does not have a [[Get]] field, throw a TypeError exception. + c. Let getter be P.[[Get]]. + d. Return ? Call(getter, O). + + PrivateBrandCheck(O, P) + 1. If O.[[PrivateBrands]] does not contain an entry e such that SameValue(e, P.[[Brand]]) is true, + a. Throw a TypeError exception. + +---*/ + + +class C { + #m() { return this._v; } + + getPrivateMethod() { + return this.#m; + } + +} + +let c = new C(); + +let o1 = {_v: 'test262'}; +let o2 = {_v: 'foo'}; +assert.sameValue(c.getPrivateMethod().call(o1), 'test262'); +assert.sameValue(c.getPrivateMethod().call(o2), 'foo'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-method-is-not-a-own-property.js b/js/src/tests/test262/language/statements/class/elements/private-method-is-not-a-own-property.js new file mode 100644 index 0000000000..1998389348 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-method-is-not-a-own-property.js @@ -0,0 +1,45 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/private-method-is-not-a-own-property.case +// - src/class-elements/default/cls-decl.template +/*--- +description: Private method is not stored as an own property of objects (field definitions in a class declaration) +esid: prod-FieldDefinition +features: [class-methods-private, class] +flags: [generated] +info: | + PrivateFieldGet (P, O) + 1. Assert: P is a Private Name. + 2. If O is not an object, throw a TypeError exception. + 3. If P.[[Kind]] is "field", + a. Let entry be PrivateFieldFind(P, O). + b. If entry is empty, throw a TypeError exception. + c. Return entry.[[PrivateFieldValue]]. + 4. Perform ? PrivateBrandCheck(O, P). + 5. If P.[[Kind]] is "method", + a. Return P.[[Value]]. + 6. Else, + a. Assert: P.[[Kind]] is "accessor". + b. If P does not have a [[Get]] field, throw a TypeError exception. + c. Let getter be P.[[Get]]. + d. Return ? Call(getter, O). + +---*/ + + +class C { + #m() { return "Test262"; } + + checkPrivateMethod() { + assert.sameValue(this.hasOwnProperty("#m"), false); + assert.sameValue("#m" in this, false); + + assert.sameValue(this.#m(), "Test262"); + + return 0; + } +} + +let c = new C(); +assert.sameValue(c.checkPrivateMethod(), 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-method-is-not-clobbered-by-computed-property.js b/js/src/tests/test262/language/statements/class/elements/private-method-is-not-clobbered-by-computed-property.js new file mode 100644 index 0000000000..381b1cd6fb --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-method-is-not-clobbered-by-computed-property.js @@ -0,0 +1,45 @@ +// Copyright (C) 2019 Caio Lima (Igalia SL). All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Private method is not clobbered by computed property +esid: sec-privatefieldget +info: | + PrivateFieldGet (P, O) + 1. Assert: P is a Private Name. + 2. If O is not an object, throw a TypeError exception. + 3. If P.[[Kind]] is "field", + a. Let entry be PrivateFieldFind(P, O). + b. If entry is empty, throw a TypeError exception. + c. Return entry.[[PrivateFieldValue]]. + 4. Perform ? PrivateBrandCheck(O, P). + 5. If P.[[Kind]] is "method", + a. Return P.[[Value]]. + 6. Else, + a. Assert: P.[[Kind]] is "accessor". + b. If P does not have a [[Get]] field, throw a TypeError exception. + c. Let getter be P.[[Get]]. + d. Return ? Call(getter, O). +features: [class-methods-private, class-fields-public, class] +---*/ + +class C { + #m() { return "Test262"; } + ["#m"] = 0; + + checkPrivateMethod() { + assert.sameValue(this.hasOwnProperty("#m"), true); + assert.sameValue("#m" in this, true); + + assert.sameValue(this["#m"], 0); + + assert.sameValue(this.#m(), "Test262"); + + return 0; + } +} + +let c = new C(); +assert.sameValue(c.checkPrivateMethod(), 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-method-is-visible-in-computed-properties.js b/js/src/tests/test262/language/statements/class/elements/private-method-is-visible-in-computed-properties.js new file mode 100644 index 0000000000..2c85c9c7a8 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-method-is-visible-in-computed-properties.js @@ -0,0 +1,34 @@ +// Copyright (C) 2019 Caio Lima (Igalia SL). All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Private method of a class is visible in its ComputetProperty scope +esid: prod-ClassTail +info: | + ClassTail : ClassHeritage { ClassBody } + 1. Let lex be the LexicalEnvironment of the running execution context. + 2. Let classScope be NewDeclarativeEnvironment(lex). + 3. Let classScopeEnvRec be classScope's EnvironmentRecord. + ... + 15. Set the running execution context's LexicalEnvironment to classScope. + 16. Set the running execution context's PrivateEnvironment to classPrivateEnvironment. + ... + 27. For each ClassElement e in order from elements + a. If IsStatic of e is false, then + i. Let field be the result of ClassElementEvaluation for e with arguments proto and false. + ... +features: [class-methods-private, class-fields-public, class] +---*/ + +assert.throws(TypeError, function() { + class C { + #m() { + throw new Test262Error(); + } + + [this.#m()] = 'Test262'; + } +}, 'access to a private method from ordinary object'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-method-length.js b/js/src/tests/test262/language/statements/class/elements/private-method-length.js new file mode 100644 index 0000000000..8e3f61770a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-method-length.js @@ -0,0 +1,49 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/private-method-length.case +// - src/class-elements/default/cls-decl.template +/*--- +description: Private methods have length property properly configured (field definitions in a class declaration) +esid: prod-FieldDefinition +features: [class-methods-private, class] +flags: [generated] +info: | + Updated Productions + + ClassElement : MethodDefinition + 1. Return ClassElementEvaluation of MethodDefinition with arguments ! Get(homeObject, "prototype"),enumerable, and "prototype". + + ClassElement : static MethodDefinition + 1. Return ClassElementEvaluation of MethodDefinition with arguments homeObject, enumerable and "static". + + MethodDefinition : ClassElementName( UniqueFormalParameters ) { FunctionBody } + 1. Let methodDef be DefineMethod of MethodDefinition with argument homeObject. + 2. ReturnIfAbrupt(methodDef). + 3. Perform ? DefineOrdinaryMethod(methodDef.[[Key]], homeObject, methodDef.[[Closure]], _enumerable). + + ClassElement : MethodDefinition + ClassElement : static MethodDefinition + 1. Perform ? PropertyDefinitionEvaluation with parameters object and enumerable. + 2. Return empty. + + MethodDefinition : ClassElementName (UniqueFormalParameters) { FunctionBody } + ... + 8. Let closure be FunctionCreate(kind, UniqueFormalParameters, FunctionBody, scope, privateScope, strict, prototype). + 9. Perform MakeMethod(closure, object). + 10. Return the Record{[[Key]]: propKey, [[Closure]]: closure}. + +---*/ + + +class C { + #method(a) {}; + + getPrivateMethod() { + return this.#method; + } + +} + +let c = new C(); +assert.sameValue(c.getPrivateMethod().length, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-method-not-writable.js b/js/src/tests/test262/language/statements/class/elements/private-method-not-writable.js new file mode 100644 index 0000000000..99346ae098 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-method-not-writable.js @@ -0,0 +1,35 @@ +// Copyright (C) 2021 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + Throws TypeError when attempting to overwrite a private method. +esid: sec-privateset +info: | + 7.3.30 PrivateSet ( P, O, value ) + 1. Let entry be ! PrivateElementFind(P, O). + 2. If entry is empty, throw a TypeError exception. + 3. If entry.[[Kind]] is field, then + ... + 4. Else if entry.[[Kind]] is method, then + a. Throw a TypeError exception. + 5. ... + +features: [class, class-methods-private] +---*/ + +class C { + #m() {} + + assign() { + this.#m = 0; + } +} + +var obj = new C(); + +assert.throws(TypeError, function() { + obj.assign(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-method-on-nested-class.js b/js/src/tests/test262/language/statements/class/elements/private-method-on-nested-class.js new file mode 100644 index 0000000000..c378ce2ad1 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-method-on-nested-class.js @@ -0,0 +1,38 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/private-method-on-nested-class.case +// - src/class-elements/default/cls-decl.template +/*--- +description: PrivateName of private method is available on inner classes (field definitions in a class declaration) +esid: prod-FieldDefinition +features: [class-methods-private, class-fields-public, class] +flags: [generated] +info: | + Updated Productions + + CallExpression[Yield, Await]: + CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await] + SuperCall[?Yield, ?Await] + CallExpression[?Yield, ?Await]Arguments[?Yield, ?Await] + CallExpression[?Yield, ?Await][Expression[+In, ?Yield, ?Await]] + CallExpression[?Yield, ?Await].IdentifierName + CallExpression[?Yield, ?Await]TemplateLiteral[?Yield, ?Await] + CallExpression[?Yield, ?Await].PrivateName + +---*/ + + +class C { + #m() { return 'test262'; } + + B = class { + method(o) { + return o.#m(); + } + } +} + +let c = new C(); +let innerB = new c.B(); +assert.sameValue(innerB.method(c), 'test262'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-method-referenced-from-static-method.js b/js/src/tests/test262/language/statements/class/elements/private-method-referenced-from-static-method.js new file mode 100644 index 0000000000..d7e68cd59a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-method-referenced-from-static-method.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/private-method-referenced-from-static-method.case +// - src/class-elements/default/cls-decl.template +/*--- +description: Private method referenced from a static method (field definitions in a class declaration) +esid: prod-FieldDefinition +features: [class-methods-private, class] +flags: [generated] +info: | + PrivateFieldGet (P, O) + 1. Assert: P is a Private Name. + 2. If O is not an object, throw a TypeError exception. + 3. If P.[[Kind]] is "field", + ... + 4. Perform ? PrivateBrandCheck(O, P). + 5. If P.[[Kind]] is "method", + a. Return P.[[Value]]. + ... + + PrivateBrandCheck(O, P) + 1. If O.[[PrivateBrands]] does not contain an entry e such that SameValue(e, P.[[Brand]]) is true, + a. Throw a TypeError exception. + +---*/ + + +class C { + #f() { return 42; } + static g() { + return this.#f(); + } + +} + +assert.sameValue(C.g.call(new C()), 42); +assert.throws(TypeError, function() { + C.g(); +}, 'Accessed private method from an object which did not contain it'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-method-shadowed-by-field-on-nested-class.js b/js/src/tests/test262/language/statements/class/elements/private-method-shadowed-by-field-on-nested-class.js new file mode 100644 index 0000000000..4e93572bfa --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-method-shadowed-by-field-on-nested-class.js @@ -0,0 +1,46 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/private-method-shadowed-by-field-on-nested-class.case +// - src/class-elements/default/cls-decl.template +/*--- +description: PrivateName of private method can be shadowed on inner classes by a private field (field definitions in a class declaration) +esid: prod-FieldDefinition +features: [class-methods-private, class-fields-private, class-fields-public, class] +flags: [generated] +info: | + Updated Productions + + CallExpression[Yield, Await]: + CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await] + SuperCall[?Yield, ?Await] + CallExpression[?Yield, ?Await]Arguments[?Yield, ?Await] + CallExpression[?Yield, ?Await][Expression[+In, ?Yield, ?Await]] + CallExpression[?Yield, ?Await].IdentifierName + CallExpression[?Yield, ?Await]TemplateLiteral[?Yield, ?Await] + CallExpression[?Yield, ?Await].PrivateName + +---*/ + + +class C { + #m() { return 'outer class'; } + + method() { return this.#m(); } + + B = class { + method(o) { + return o.#m; + } + + #m = 'test262'; + } +} + +let c = new C(); +let innerB = new c.B(); +assert.sameValue(innerB.method(innerB), 'test262'); +assert.sameValue(c.method(), 'outer class'); +assert.throws(TypeError, function() { + innerB.method(c); +}, 'accessed inner class field from an object of outer class'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-method-shadowed-by-getter-on-nested-class.js b/js/src/tests/test262/language/statements/class/elements/private-method-shadowed-by-getter-on-nested-class.js new file mode 100644 index 0000000000..90f322a91c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-method-shadowed-by-getter-on-nested-class.js @@ -0,0 +1,49 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/private-method-shadowed-by-getter-on-nested-class.case +// - src/class-elements/default/cls-decl.template +/*--- +description: PrivateName of private method can be shadowed on inner classes by a private getter (field definitions in a class declaration) +esid: prod-FieldDefinition +features: [class-methods-private, class-fields-public, class] +flags: [generated] +info: | + Updated Productions + + CallExpression[Yield, Await]: + CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await] + SuperCall[?Yield, ?Await] + CallExpression[?Yield, ?Await]Arguments[?Yield, ?Await] + CallExpression[?Yield, ?Await][Expression[+In, ?Yield, ?Await]] + CallExpression[?Yield, ?Await].IdentifierName + CallExpression[?Yield, ?Await]TemplateLiteral[?Yield, ?Await] + CallExpression[?Yield, ?Await].PrivateName + +---*/ + + +class C { + #m() { return 'outer class'; } + + method() { return this.#m(); } + + B = class { + method(o) { + return o.#m; + } + + get #m() { return 'test262'; } + } +} + +let c = new C(); +let innerB = new c.B(); +assert.sameValue(innerB.method(innerB), 'test262'); +assert.sameValue(c.method(), 'outer class'); +assert.throws(TypeError, function() { + innerB.method(c); +}, 'accessed inner class getter from an object of outer class'); +assert.throws(TypeError, function() { + C.prototype.method.call(innerB); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-method-shadowed-by-setter-on-nested-class.js b/js/src/tests/test262/language/statements/class/elements/private-method-shadowed-by-setter-on-nested-class.js new file mode 100644 index 0000000000..80a379e3c6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-method-shadowed-by-setter-on-nested-class.js @@ -0,0 +1,51 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/private-method-shadowed-by-setter-on-nested-class.case +// - src/class-elements/default/cls-decl.template +/*--- +description: PrivateName of private method can be shadowed on inner classes by a private setter (field definitions in a class declaration) +esid: prod-FieldDefinition +features: [class-methods-private, class-fields-public, class] +flags: [generated] +info: | + Updated Productions + + CallExpression[Yield, Await]: + CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await] + SuperCall[?Yield, ?Await] + CallExpression[?Yield, ?Await]Arguments[?Yield, ?Await] + CallExpression[?Yield, ?Await][Expression[+In, ?Yield, ?Await]] + CallExpression[?Yield, ?Await].IdentifierName + CallExpression[?Yield, ?Await]TemplateLiteral[?Yield, ?Await] + CallExpression[?Yield, ?Await].PrivateName + +---*/ + + +class C { + #m() { return 'outer class'; } + + method() { return this.#m(); } + + B = class { + method(o) { + return o.#m; + } + + set #m(v) { this._v = v; } + } +} + +let c = new C(); +let innerB = new c.B(); + +assert.throws(TypeError, function() { + innerB.method(innerB); +}, '[[Get]] operation of an accessor without getter'); + +assert.sameValue(c.method(), 'outer class'); + +assert.throws(TypeError, function() { + innerB.method(c); +}, 'access of inner class accessor from an object of outer class'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-method-shadowed-on-nested-class.js b/js/src/tests/test262/language/statements/class/elements/private-method-shadowed-on-nested-class.js new file mode 100644 index 0000000000..071ab0c649 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-method-shadowed-on-nested-class.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/private-method-shadowed-on-nested-class.case +// - src/class-elements/default/cls-decl.template +/*--- +description: PrivateName of private method can be shadowed by inner class private method (field definitions in a class declaration) +esid: prod-FieldDefinition +features: [class-methods-private, class-fields-public, class] +flags: [generated] +info: | + Updated Productions + + CallExpression[Yield, Await]: + CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await] + SuperCall[?Yield, ?Await] + CallExpression[?Yield, ?Await]Arguments[?Yield, ?Await] + CallExpression[?Yield, ?Await][Expression[+In, ?Yield, ?Await]] + CallExpression[?Yield, ?Await].IdentifierName + CallExpression[?Yield, ?Await]TemplateLiteral[?Yield, ?Await] + CallExpression[?Yield, ?Await].PrivateName + +---*/ + + +class C { + #m() { throw new Test262Error(); } + + B = class { + method() { + return this.#m(); + } + + #m() { return 'test262'; } + } +} + +let c = new C(); +let innerB = new c.B(); +assert.sameValue(innerB.method(), 'test262'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-method-visible-to-direct-eval-on-initializer.js b/js/src/tests/test262/language/statements/class/elements/private-method-visible-to-direct-eval-on-initializer.js new file mode 100644 index 0000000000..a67f1ead92 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-method-visible-to-direct-eval-on-initializer.js @@ -0,0 +1,49 @@ +// Copyright (C) 2019 Caio Lima (Igalia SL). All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Private method is visible on initializer with direct eval +esid: sec-privatefieldget +info: | + PrivateFieldGet (P, O) + 1. Assert: P is a Private Name. + 2. If O is not an object, throw a TypeError exception. + 3. If P.[[Kind]] is "field", + a. Let entry be PrivateFieldFind(P, O). + b. If entry is empty, throw a TypeError exception. + c. Return entry.[[PrivateFieldValue]]. + 4. Perform ? PrivateBrandCheck(O, P). + 5. If P.[[Kind]] is "method", + a. Return P.[[Value]]. + 6. Else, + a. Assert: P.[[Kind]] is "accessor". + b. If P does not have a [[Get]] field, throw a TypeError exception. + c. Let getter be P.[[Get]]. + d. Return ? Call(getter, O). + + ClassElementName : PrivateIdentifier + 1. Let privateIdentifier be StringValue of PrivateIdentifier. + 2. Let privateName be NewPrivateName(privateIdentifier). + 3. Let scope be the running execution context's PrivateEnvironment. + 4. Let scopeEnvRec be scope's EnvironmentRecord. + 5. Perform ! scopeEnvRec.InitializeBinding(privateIdentifier, privateName). + 6. Return privateName. + + MakePrivateReference ( baseValue, privateIdentifier ) + 1. Let env be the running execution context's PrivateEnvironment. + 2. Let privateNameBinding be ? ResolveBinding(privateIdentifier, env). + 3. Let privateName be GetValue(privateNameBinding). + 4. Assert: privateName is a Private Name. + 5. Return a value of type Reference whose base value is baseValue, whose referenced name is privateName, whose strict reference flag is true. +features: [class-methods-private, class-fields-public, class] +---*/ + +class C { + #m() { return "Test262"; }; + v = eval("this.#m()"); +} + +let c = new C(); +assert.sameValue(c.v, "Test262"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-method-visible-to-direct-eval.js b/js/src/tests/test262/language/statements/class/elements/private-method-visible-to-direct-eval.js new file mode 100644 index 0000000000..d1d0a18614 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-method-visible-to-direct-eval.js @@ -0,0 +1,61 @@ +// Copyright (C) 2019 Caio Lima (Igalia SL). All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Private method is visible to direct eval code +esid: sec-privatefieldget +info: | + PrivateFieldGet (P, O) + 1. Assert: P is a Private Name. + 2. If O is not an object, throw a TypeError exception. + 3. If P.[[Kind]] is "field", + a. Let entry be PrivateFieldFind(P, O). + b. If entry is empty, throw a TypeError exception. + c. Return entry.[[PrivateFieldValue]]. + 4. Perform ? PrivateBrandCheck(O, P). + 5. If P.[[Kind]] is "method", + a. Return P.[[Value]]. + 6. Else, + a. Assert: P.[[Kind]] is "accessor". + b. If P does not have a [[Get]] field, throw a TypeError exception. + c. Let getter be P.[[Get]]. + d. Return ? Call(getter, O). + + ClassElementName : PrivateIdentifier + 1. Let privateIdentifier be StringValue of PrivateIdentifier. + 2. Let privateName be NewPrivateName(privateIdentifier). + 3. Let scope be the running execution context's PrivateEnvironment. + 4. Let scopeEnvRec be scope's EnvironmentRecord. + 5. Perform ! scopeEnvRec.InitializeBinding(privateIdentifier, privateName). + 6. Return privateName. + + MakePrivateReference ( baseValue, privateIdentifier ) + 1. Let env be the running execution context's PrivateEnvironment. + 2. Let privateNameBinding be ? ResolveBinding(privateIdentifier, env). + 3. Let privateName be GetValue(privateNameBinding). + 4. Assert: privateName is a Private Name. + 5. Return a value of type Reference whose base value is baseValue, whose referenced name is privateName, whose strict reference flag is true. +features: [class-methods-private, class] +---*/ + +class C { + #m() { return "Test262"; }; + + getWithEval() { + return eval("this.#m()"); + } +} + +class D { + #m() { throw new Test262Error(); }; +} + +let c = new C(); +assert.sameValue(c.getWithEval(), "Test262"); + +let d = new D(); +assert.throws(TypeError, function() { + c.getWithEval.call(d); +}, "invalid access to a private method"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-methods/browser.js b/js/src/tests/test262/language/statements/class/elements/private-methods/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/elements/private-methods/prod-private-async-generator.js b/js/src/tests/test262/language/statements/class/elements/private-methods/prod-private-async-generator.js new file mode 100644 index 0000000000..c703df72d4 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-methods/prod-private-async-generator.js @@ -0,0 +1,134 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/prod-private-async-generator.case +// - src/class-elements/private-methods/cls-decl.template +/*--- +description: Private Async Generator (private method definitions in a class declaration) +esid: prod-MethodDefinition +features: [async-iteration, class, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + ... + ; + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + MethodDefinition : + ClassElementName ( UniqueFormalParameters ) { FunctionBody } + GeneratorMethod + AsyncMethod + AsyncGeneratorMethod + get ClassElementName () { FunctionBody } + set ClassElementName ( PropertySetParameterList ) { FunctionBody } + + GeneratorMethod : + * ClassElementName ( UniqueFormalParameters ){GeneratorBody} + + AsyncMethod : + async [no LineTerminator here] ClassElementName ( UniqueFormalParameters ) { AsyncFunctionBody } + + AsyncGeneratorMethod : + async [no LineTerminator here]* ClassElementName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + --- + + InitializeClassElements ( F, proto ) + + ... + 5. For each item element in order from elements, + a. Assert: If element.[[Placement]] is "prototype" or "static", then element.[[Key]] is not a Private Name. + b. If element.[[Kind]] is "method" and element.[[Placement]] is "static" or "prototype", + i. Let receiver be F if element.[[Placement]] is "static", else let receiver be proto. + ii. Perform ? DefineClassElement(receiver, element). + + InitializeInstanceElements ( O, constructor ) + + ... + 3. Let elements be the value of F's [[Elements]] internal slot. + 4. For each item element in order from elements, + a. If element.[[Placement]] is "own" and element.[[Kind]] is "method", + i. Perform ? DefineClassElement(O, element). + + DefineClassElement (receiver, element) + + ... + 6. If key is a Private Name, + a. Perform ? PrivateFieldDefine(receiver, key, descriptor). + + PrivateFieldDefine (P, O, desc) + + ... + 6. Append { [[PrivateName]]: P, [[PrivateFieldDescriptor]]: desc } to O.[[PrivateFieldDescriptors]]. + +---*/ +var ctorPromise; + + + +/*** template notes + * method should always be #m + * the template provides c.ref() for external reference + */ + +function hasProp(obj, name, expected, msg) { + var hasOwnProperty = Object.prototype.hasOwnProperty.call(obj, name); + assert.sameValue(hasOwnProperty, expected, msg); + + var hasProperty = Reflect.has(obj, name); + assert.sameValue(hasProperty, expected, msg); +} + +class C { + async * #m() { return 42; } + + + get ref() { return this.#m; } + + constructor() { + hasProp(this, '#m', false, 'private methods are defined in an special internal slot and cannot be found as own properties'); + assert.sameValue(typeof this.#m, 'function'); + assert.sameValue(this.ref, this.#m, 'returns the same value'); + assert.sameValue(this.#m, (() => this)().#m, 'memberexpression and call expression forms'); + + var ctorIter = this.#m(); + var p = ctorIter.next(); + ctorPromise = p.then(({ value, done }) => { + assert.sameValue(value, 42, 'return from generator method, inside ctor'); + assert.sameValue(done, true, 'iterator is done, inside ctor'); + }, $DONE); + assert.sameValue(this.#m.name, '#m', 'function name inside constructor'); + + } +} + +var c = new C(); +var other = new C(); + +hasProp(C.prototype, '#m', false, 'method is not defined in the prototype'); +hasProp(C, '#m', false, 'method is not defined in the contructor'); +hasProp(c, '#m', false, 'method cannot be seen outside of the class'); + +/*** + * MethodDefinition : ClassElementName ( UniqueFormalParameters ) { FunctionBody } + * + * 1. Let methodDef be DefineMethod of MethodDefinition with argument homeObject. + * ... + */ +assert.sameValue(c.ref, other.ref, 'The method is defined once, and reused on every new instance'); + +assert.sameValue(c.ref.name, '#m', 'function name is preserved external reference'); +ctorPromise.then(() => { + // gets the returned async iterator from #m + var iter = c.ref(); + return iter.next().then(({ value, done }) => { + assert.sameValue(value, 42, 'return from generator method'); + assert.sameValue(done, true, 'iterator is done'); + }); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/private-methods/prod-private-async-method.js b/js/src/tests/test262/language/statements/class/elements/private-methods/prod-private-async-method.js new file mode 100644 index 0000000000..fa42763d30 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-methods/prod-private-async-method.js @@ -0,0 +1,129 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/prod-private-async-method.case +// - src/class-elements/private-methods/cls-decl.template +/*--- +description: Private Async Method (private method definitions in a class declaration) +esid: prod-MethodDefinition +features: [async-functions, class, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + ... + ; + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + MethodDefinition : + ClassElementName ( UniqueFormalParameters ) { FunctionBody } + GeneratorMethod + AsyncMethod + AsyncGeneratorMethod + get ClassElementName () { FunctionBody } + set ClassElementName ( PropertySetParameterList ) { FunctionBody } + + GeneratorMethod : + * ClassElementName ( UniqueFormalParameters ){GeneratorBody} + + AsyncMethod : + async [no LineTerminator here] ClassElementName ( UniqueFormalParameters ) { AsyncFunctionBody } + + AsyncGeneratorMethod : + async [no LineTerminator here]* ClassElementName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + --- + + InitializeClassElements ( F, proto ) + + ... + 5. For each item element in order from elements, + a. Assert: If element.[[Placement]] is "prototype" or "static", then element.[[Key]] is not a Private Name. + b. If element.[[Kind]] is "method" and element.[[Placement]] is "static" or "prototype", + i. Let receiver be F if element.[[Placement]] is "static", else let receiver be proto. + ii. Perform ? DefineClassElement(receiver, element). + + InitializeInstanceElements ( O, constructor ) + + ... + 3. Let elements be the value of F's [[Elements]] internal slot. + 4. For each item element in order from elements, + a. If element.[[Placement]] is "own" and element.[[Kind]] is "method", + i. Perform ? DefineClassElement(O, element). + + DefineClassElement (receiver, element) + + ... + 6. If key is a Private Name, + a. Perform ? PrivateFieldDefine(receiver, key, descriptor). + + PrivateFieldDefine (P, O, desc) + + ... + 6. Append { [[PrivateName]]: P, [[PrivateFieldDescriptor]]: desc } to O.[[PrivateFieldDescriptors]]. + +---*/ +var ctorPromise; + + + +/*** template notes + * method should always be #m + * the template provides c.ref() for external reference + */ + +function hasProp(obj, name, expected, msg) { + var hasOwnProperty = Object.prototype.hasOwnProperty.call(obj, name); + assert.sameValue(hasOwnProperty, expected, msg); + + var hasProperty = Reflect.has(obj, name); + assert.sameValue(hasProperty, expected, msg); +} + +class C { + async #m() { return 42; } + + + get ref() { return this.#m; } + + constructor() { + hasProp(this, '#m', false, 'private methods are defined in an special internal slot and cannot be found as own properties'); + assert.sameValue(typeof this.#m, 'function'); + assert.sameValue(this.ref, this.#m, 'returns the same value'); + assert.sameValue(this.#m, (() => this)().#m, 'memberexpression and call expression forms'); + + assert.sameValue(this.#m.name, '#m', 'function name inside constructor'); + ctorPromise = this.#m().then(value => { + assert.sameValue(value, 42, 'already defined in the ctor'); + }, $DONE); + + } +} + +var c = new C(); +var other = new C(); + +hasProp(C.prototype, '#m', false, 'method is not defined in the prototype'); +hasProp(C, '#m', false, 'method is not defined in the contructor'); +hasProp(c, '#m', false, 'method cannot be seen outside of the class'); + +/*** + * MethodDefinition : ClassElementName ( UniqueFormalParameters ) { FunctionBody } + * + * 1. Let methodDef be DefineMethod of MethodDefinition with argument homeObject. + * ... + */ +assert.sameValue(c.ref, other.ref, 'The method is defined once, and reused on every new instance'); + +assert.sameValue(c.ref.name, '#m', 'function name is preserved external reference'); +ctorPromise.then(() => { + // gets the returned promise from #m + return c.ref().then(value => { + assert.sameValue(value, 42, 'function return'); + }); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/private-methods/prod-private-generator.js b/js/src/tests/test262/language/statements/class/elements/private-methods/prod-private-generator.js new file mode 100644 index 0000000000..4cd79a852d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-methods/prod-private-generator.js @@ -0,0 +1,126 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/prod-private-generator.case +// - src/class-elements/private-methods/cls-decl.template +/*--- +description: Private Generator (private method definitions in a class declaration) +esid: prod-MethodDefinition +features: [generators, class, class-methods-private] +flags: [generated] +info: | + ClassElement : + MethodDefinition + ... + ; + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + MethodDefinition : + ClassElementName ( UniqueFormalParameters ) { FunctionBody } + GeneratorMethod + AsyncMethod + AsyncGeneratorMethod + get ClassElementName () { FunctionBody } + set ClassElementName ( PropertySetParameterList ) { FunctionBody } + + GeneratorMethod : + * ClassElementName ( UniqueFormalParameters ){GeneratorBody} + + AsyncMethod : + async [no LineTerminator here] ClassElementName ( UniqueFormalParameters ) { AsyncFunctionBody } + + AsyncGeneratorMethod : + async [no LineTerminator here]* ClassElementName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + --- + + InitializeClassElements ( F, proto ) + + ... + 5. For each item element in order from elements, + a. Assert: If element.[[Placement]] is "prototype" or "static", then element.[[Key]] is not a Private Name. + b. If element.[[Kind]] is "method" and element.[[Placement]] is "static" or "prototype", + i. Let receiver be F if element.[[Placement]] is "static", else let receiver be proto. + ii. Perform ? DefineClassElement(receiver, element). + + InitializeInstanceElements ( O, constructor ) + + ... + 3. Let elements be the value of F's [[Elements]] internal slot. + 4. For each item element in order from elements, + a. If element.[[Placement]] is "own" and element.[[Kind]] is "method", + i. Perform ? DefineClassElement(O, element). + + DefineClassElement (receiver, element) + + ... + 6. If key is a Private Name, + a. Perform ? PrivateFieldDefine(receiver, key, descriptor). + + PrivateFieldDefine (P, O, desc) + + ... + 6. Append { [[PrivateName]]: P, [[PrivateFieldDescriptor]]: desc } to O.[[PrivateFieldDescriptors]]. + +---*/ + + +/*** template notes + * method should always be #m + * the template provides c.ref() for external reference + */ + +function hasProp(obj, name, expected, msg) { + var hasOwnProperty = Object.prototype.hasOwnProperty.call(obj, name); + assert.sameValue(hasOwnProperty, expected, msg); + + var hasProperty = Reflect.has(obj, name); + assert.sameValue(hasProperty, expected, msg); +} + +class C { + * #m() { return 42; } + + + get ref() { return this.#m; } + + constructor() { + hasProp(this, '#m', false, 'private methods are defined in an special internal slot and cannot be found as own properties'); + assert.sameValue(typeof this.#m, 'function'); + assert.sameValue(this.ref, this.#m, 'returns the same value'); + assert.sameValue(this.#m, (() => this)().#m, 'memberexpression and call expression forms'); + + var res = this.#m().next(); + assert.sameValue(res.value, 42, 'return from generator method, inside ctor'); + assert.sameValue(res.done, true, 'iterator is done, inside ctor'); + assert.sameValue(this.#m.name, '#m', 'function name inside constructor'); + + } +} + +var c = new C(); +var other = new C(); + +hasProp(C.prototype, '#m', false, 'method is not defined in the prototype'); +hasProp(C, '#m', false, 'method is not defined in the contructor'); +hasProp(c, '#m', false, 'method cannot be seen outside of the class'); + +/*** + * MethodDefinition : ClassElementName ( UniqueFormalParameters ) { FunctionBody } + * + * 1. Let methodDef be DefineMethod of MethodDefinition with argument homeObject. + * ... + */ +assert.sameValue(c.ref, other.ref, 'The method is defined once, and reused on every new instance'); + +// gets the returned iterator from #m +var res = c.ref().next(); +assert.sameValue(res.value, 42, 'return from generator method'); +assert.sameValue(res.done, true, 'iterator is done'); +assert.sameValue(c.ref.name, '#m', 'function name is preserved external reference'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-methods/prod-private-method-initialize-order.js b/js/src/tests/test262/language/statements/class/elements/private-methods/prod-private-method-initialize-order.js new file mode 100644 index 0000000000..a44bf73cd1 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-methods/prod-private-method-initialize-order.js @@ -0,0 +1,141 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/prod-private-method-initialize-order.case +// - src/class-elements/private-methods/cls-decl.template +/*--- +description: Private methods are added before any field initializer is run, even if they appear textually later (private method definitions in a class declaration) +esid: prod-MethodDefinition +features: [class-methods-private, class-fields-private, class-fields-public, class] +flags: [generated] +info: | + ClassElement : + MethodDefinition + ... + ; + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + MethodDefinition : + ClassElementName ( UniqueFormalParameters ) { FunctionBody } + GeneratorMethod + AsyncMethod + AsyncGeneratorMethod + get ClassElementName () { FunctionBody } + set ClassElementName ( PropertySetParameterList ) { FunctionBody } + + GeneratorMethod : + * ClassElementName ( UniqueFormalParameters ){GeneratorBody} + + AsyncMethod : + async [no LineTerminator here] ClassElementName ( UniqueFormalParameters ) { AsyncFunctionBody } + + AsyncGeneratorMethod : + async [no LineTerminator here]* ClassElementName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + --- + + InitializeClassElements ( F, proto ) + + ... + 5. For each item element in order from elements, + a. Assert: If element.[[Placement]] is "prototype" or "static", then element.[[Key]] is not a Private Name. + b. If element.[[Kind]] is "method" and element.[[Placement]] is "static" or "prototype", + i. Let receiver be F if element.[[Placement]] is "static", else let receiver be proto. + ii. Perform ? DefineClassElement(receiver, element). + + InitializeInstanceElements ( O, constructor ) + + ... + 3. Let elements be the value of F's [[Elements]] internal slot. + 4. For each item element in order from elements, + a. If element.[[Placement]] is "own" and element.[[Kind]] is "method", + i. Perform ? DefineClassElement(O, element). + + DefineClassElement (receiver, element) + + ... + 6. If key is a Private Name, + a. Perform ? PrivateFieldDefine(receiver, key, descriptor). + + PrivateFieldDefine (P, O, desc) + + ... + 6. Append { [[PrivateName]]: P, [[PrivateFieldDescriptor]]: desc } to O.[[PrivateFieldDescriptors]]. + + + InitializeInstanceElements ( O, constructor ) + ... + 4. For each item element in order from elements, + a. If element.[[Placement]] is "own" and element.[[Kind]] is "method", + i. Perform ? DefineClassElement(O, element). + 5. For each item element in order from elements, + a. If element.[[Placement]] is "own" and element.[[Kind]] is "field", + i. Assert: element.[[Descriptor]] does not have a [[Value]], [[Get]] or [[Set]] slot. + ii. Perform ? DefineClassElement(O, element). + 6. Return. + + EDITOR'S NOTE: + Value properties are added before initializers so that private methods are visible from all initializers. + +---*/ + + +/*** template notes + * method should always be #m + * the template provides c.ref() for external reference + */ + +function hasProp(obj, name, expected, msg) { + var hasOwnProperty = Object.prototype.hasOwnProperty.call(obj, name); + assert.sameValue(hasOwnProperty, expected, msg); + + var hasProperty = Reflect.has(obj, name); + assert.sameValue(hasProperty, expected, msg); +} + +class C { + a = this.#m(); + + #m() { return 42; } + get bGetter() { return this.#b; } + + #b = this.#m(); + + + get ref() { return this.#m; } + + constructor() { + hasProp(this, '#m', false, 'private methods are defined in an special internal slot and cannot be found as own properties'); + assert.sameValue(typeof this.#m, 'function'); + assert.sameValue(this.ref, this.#m, 'returns the same value'); + assert.sameValue(this.#m, (() => this)().#m, 'memberexpression and call expression forms'); + + assert.sameValue(this.a, 42); + assert.sameValue(this.#b, 42); + + } +} + +var c = new C(); +var other = new C(); + +hasProp(C.prototype, '#m', false, 'method is not defined in the prototype'); +hasProp(C, '#m', false, 'method is not defined in the contructor'); +hasProp(c, '#m', false, 'method cannot be seen outside of the class'); + +/*** + * MethodDefinition : ClassElementName ( UniqueFormalParameters ) { FunctionBody } + * + * 1. Let methodDef be DefineMethod of MethodDefinition with argument homeObject. + * ... + */ +assert.sameValue(c.ref, other.ref, 'The method is defined once, and reused on every new instance'); + +assert.sameValue(c.a, 42); +assert.sameValue(c.bGetter, 42); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-methods/prod-private-method.js b/js/src/tests/test262/language/statements/class/elements/private-methods/prod-private-method.js new file mode 100644 index 0000000000..77c16e2a58 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-methods/prod-private-method.js @@ -0,0 +1,122 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/prod-private-method.case +// - src/class-elements/private-methods/cls-decl.template +/*--- +description: Private Method (private method definitions in a class declaration) +esid: prod-MethodDefinition +features: [class, class-methods-private] +flags: [generated] +info: | + ClassElement : + MethodDefinition + ... + ; + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + MethodDefinition : + ClassElementName ( UniqueFormalParameters ) { FunctionBody } + GeneratorMethod + AsyncMethod + AsyncGeneratorMethod + get ClassElementName () { FunctionBody } + set ClassElementName ( PropertySetParameterList ) { FunctionBody } + + GeneratorMethod : + * ClassElementName ( UniqueFormalParameters ){GeneratorBody} + + AsyncMethod : + async [no LineTerminator here] ClassElementName ( UniqueFormalParameters ) { AsyncFunctionBody } + + AsyncGeneratorMethod : + async [no LineTerminator here]* ClassElementName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + --- + + InitializeClassElements ( F, proto ) + + ... + 5. For each item element in order from elements, + a. Assert: If element.[[Placement]] is "prototype" or "static", then element.[[Key]] is not a Private Name. + b. If element.[[Kind]] is "method" and element.[[Placement]] is "static" or "prototype", + i. Let receiver be F if element.[[Placement]] is "static", else let receiver be proto. + ii. Perform ? DefineClassElement(receiver, element). + + InitializeInstanceElements ( O, constructor ) + + ... + 3. Let elements be the value of F's [[Elements]] internal slot. + 4. For each item element in order from elements, + a. If element.[[Placement]] is "own" and element.[[Kind]] is "method", + i. Perform ? DefineClassElement(O, element). + + DefineClassElement (receiver, element) + + ... + 6. If key is a Private Name, + a. Perform ? PrivateFieldDefine(receiver, key, descriptor). + + PrivateFieldDefine (P, O, desc) + + ... + 6. Append { [[PrivateName]]: P, [[PrivateFieldDescriptor]]: desc } to O.[[PrivateFieldDescriptors]]. + +---*/ + + +/*** template notes + * method should always be #m + * the template provides c.ref() for external reference + */ + +function hasProp(obj, name, expected, msg) { + var hasOwnProperty = Object.prototype.hasOwnProperty.call(obj, name); + assert.sameValue(hasOwnProperty, expected, msg); + + var hasProperty = Reflect.has(obj, name); + assert.sameValue(hasProperty, expected, msg); +} + +class C { + #m() { return 42; } + + + get ref() { return this.#m; } + + constructor() { + hasProp(this, '#m', false, 'private methods are defined in an special internal slot and cannot be found as own properties'); + assert.sameValue(typeof this.#m, 'function'); + assert.sameValue(this.ref, this.#m, 'returns the same value'); + assert.sameValue(this.#m, (() => this)().#m, 'memberexpression and call expression forms'); + + assert.sameValue(this.#m(), 42, 'already defined in the ctor'); + assert.sameValue(this.#m.name, '#m', 'function name inside constructor'); + + } +} + +var c = new C(); +var other = new C(); + +hasProp(C.prototype, '#m', false, 'method is not defined in the prototype'); +hasProp(C, '#m', false, 'method is not defined in the contructor'); +hasProp(c, '#m', false, 'method cannot be seen outside of the class'); + +/*** + * MethodDefinition : ClassElementName ( UniqueFormalParameters ) { FunctionBody } + * + * 1. Let methodDef be DefineMethod of MethodDefinition with argument homeObject. + * ... + */ +assert.sameValue(c.ref, other.ref, 'The method is defined once, and reused on every new instance'); + +// gets the returned value from #m +assert.sameValue(c.ref(), 42, 'function return'); +assert.sameValue(c.ref.name, '#m', 'function name is preserved external reference'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-methods/shell.js b/js/src/tests/test262/language/statements/class/elements/private-methods/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/elements/private-setter-access-on-inner-arrow-function.js b/js/src/tests/test262/language/statements/class/elements/private-setter-access-on-inner-arrow-function.js new file mode 100644 index 0000000000..beaec23a66 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-setter-access-on-inner-arrow-function.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/private-setter-access-on-inner-arrow-function.case +// - src/class-elements/default/cls-decl.template +/*--- +description: PrivateName of private setter is visible on inner arrow function of class scope (field definitions in a class declaration) +esid: prod-FieldDefinition +features: [class-methods-private, class] +flags: [generated] +info: | + Updated Productions + + CallExpression[Yield, Await]: + CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await] + SuperCall[?Yield, ?Await] + CallExpression[?Yield, ?Await]Arguments[?Yield, ?Await] + CallExpression[?Yield, ?Await][Expression[+In, ?Yield, ?Await]] + CallExpression[?Yield, ?Await].IdentifierName + CallExpression[?Yield, ?Await]TemplateLiteral[?Yield, ?Await] + CallExpression[?Yield, ?Await].PrivateName + +---*/ + + +class C { + set #m(v) { this._v = v; } + + method() { + let arrowFunction = () => { + this.#m = 'Test262'; + } + + arrowFunction(); + } +} + +let c = new C(); +c.method(); +assert.sameValue(c._v, 'Test262'); +let o = {}; +assert.throws(TypeError, function() { + c.method.call(o); +}, 'accessed private setter from an ordinary object'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-setter-access-on-inner-function.js b/js/src/tests/test262/language/statements/class/elements/private-setter-access-on-inner-function.js new file mode 100644 index 0000000000..13dcd93871 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-setter-access-on-inner-function.js @@ -0,0 +1,45 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/private-setter-access-on-inner-function.case +// - src/class-elements/default/cls-decl.template +/*--- +description: PrivateName of private setter is visible on inner function of class scope (field definitions in a class declaration) +esid: prod-FieldDefinition +features: [class-methods-private, class] +flags: [generated] +info: | + Updated Productions + + CallExpression[Yield, Await]: + CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await] + SuperCall[?Yield, ?Await] + CallExpression[?Yield, ?Await]Arguments[?Yield, ?Await] + CallExpression[?Yield, ?Await][Expression[+In, ?Yield, ?Await]] + CallExpression[?Yield, ?Await].IdentifierName + CallExpression[?Yield, ?Await]TemplateLiteral[?Yield, ?Await] + CallExpression[?Yield, ?Await].PrivateName + +---*/ + + +class C { + set #m(v) { this._v = v; } + + method() { + let self = this; + function innerFunction() { + self.#m = 'Test262'; + } + + innerFunction(); + } +} + +let c = new C(); +c.method(); +assert.sameValue(c._v, 'Test262'); +let o = {}; +assert.throws(TypeError, function() { + c.method.call(o); +}, 'accessed private setter from an ordinary object'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-setter-brand-check-multiple-evaluations-of-class.js b/js/src/tests/test262/language/statements/class/elements/private-setter-brand-check-multiple-evaluations-of-class.js new file mode 100644 index 0000000000..d4c179fb0e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-setter-brand-check-multiple-evaluations-of-class.js @@ -0,0 +1,51 @@ +// Copyright (C) 2019 Caio Lima (Igalia SL). All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Every new evaluation of a class creates a different brand (private setter) +esid: sec-privatefieldget +info: | + ClassTail : ClassHeritage { ClassBody } + ... + 11. Let proto be ObjectCreate(protoParent). + ... + 31. If PrivateBoundIdentifiers of ClassBody contains a Private Name P such that the P's [[Kind]] field is either "method" or "accessor", + a. Set F.[[PrivateBrand]] to proto. + ... + + PrivateBrandCheck(O, P) + 1. If O.[[PrivateBrands]] does not contain an entry e such that SameValue(e, P.[[Brand]]) is true, + a. Throw a TypeError exception. +features: [class, class-methods-private] +---*/ + +let createAndInstantiateClass = function () { + class C { + set #m(v) { this._v = v; } + + access(o, v) { + o.#m = v; + } + } + + let c = new C(); + return c; +}; + +let c1 = createAndInstantiateClass(); +let c2 = createAndInstantiateClass(); + +c1.access(c1, 'test262'); +assert.sameValue(c1._v, 'test262'); +c2.access(c2, 'test262'); +assert.sameValue(c2._v, 'test262'); + +assert.throws(TypeError, function() { + c1.access(c2, 'foo'); +}, 'invalid access of c1 private method'); + +assert.throws(TypeError, function() { + c2.access(c1, 'foo'); +}, 'invalid access of c2 private method'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-setter-brand-check-super-class.js b/js/src/tests/test262/language/statements/class/elements/private-setter-brand-check-super-class.js new file mode 100644 index 0000000000..87963f8f92 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-setter-brand-check-super-class.js @@ -0,0 +1,55 @@ +// Copyright (C) 2019 Caio Lima (Igalia SL). All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Subclass can access private methods of a superclass (private setter) +esid: sec-privatefieldget +info: | + SuperCall : super Arguments + ... + 10. Perform ? InitializeInstanceElements(result, F). + ... + + InitializeInstanceFieldsElements ( O, constructor ) + 1. Assert: Type ( O ) is Object. + 2. Assert: Assert constructor is an ECMAScript function object. + 3. If constructor.[[PrivateBrand]] is not undefined, + a. Perform ? PrivateBrandAdd(O, constructor.[[PrivateBrand]]). + 4. Let fieldRecords be the value of constructor's [[Fields]] internal slot. + 5. For each item fieldRecord in order from fieldRecords, + a. Perform ? DefineField(O, fieldRecord). + 6. Return. +features: [class, class-methods-private] +---*/ + +class S { + set #m(v) { this._v = v } + + superAccess(v) { this.#m = v; } +} + +class C extends S { + set #m(v) { this._u = v; } + + access(v) { + return this.#m = v; + } +} + +let c = new C(); + +c.access('test262'); +assert.sameValue(c._u, 'test262'); + +c.superAccess('super class'); +assert.sameValue(c._v, 'super class'); + +let s = new S(); +s.superAccess('super class') +assert.sameValue(s._v, 'super class'); + +assert.throws(TypeError, function() { + c.access.call(s, 'foo'); +}, 'invalid access of C private method'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-setter-brand-check.js b/js/src/tests/test262/language/statements/class/elements/private-setter-brand-check.js new file mode 100644 index 0000000000..ba3e5ca66d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-setter-brand-check.js @@ -0,0 +1,48 @@ +// Copyright (C) 2019 Caio Lima (Igalia SL). All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: PrivateBrandCheck fails when the object O doesn't have P.[[Brand]] (private setter) +esid: sec-privatefieldget +info: | + PrivateFieldGet (P, O) + 1. Assert: P is a Private Name. + 2. If O is not an object, throw a TypeError exception. + 3. If P.[[Kind]] is "field", + a. Let entry be PrivateFieldFind(P, O). + b. If entry is empty, throw a TypeError exception. + c. Return entry.[[PrivateFieldValue]]. + 4. Perform ? PrivateBrandCheck(O, P). + 5. If P.[[Kind]] is "method", + a. Return P.[[Value]]. + 6. Else, + a. Assert: P.[[Kind]] is "accessor". + b. If P does not have a [[Get]] field, throw a TypeError exception. + c. Let getter be P.[[Get]]. + d. Return ? Call(getter, O). + + PrivateBrandCheck(O, P) + 1. If O.[[PrivateBrands]] does not contain an entry e such that SameValue(e, P.[[Brand]]) is true, + a. Throw a TypeError exception. +features: [class, class-methods-private] +---*/ + +class C { + set #m(v) { this._v = v; } + + access(o, v) { + return o.#m = v; + } +} + +let c = new C(); +c.access(c, 'test262'); +assert.sameValue(c._v, 'test262'); + +let o = {}; +assert.throws(TypeError, function() { + c.access(o, 'foo'); +}, 'invalid access a private setter'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-setter-is-not-a-own-property.js b/js/src/tests/test262/language/statements/class/elements/private-setter-is-not-a-own-property.js new file mode 100644 index 0000000000..8deba4fe5c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-setter-is-not-a-own-property.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/private-setter-is-not-a-own-property.case +// - src/class-elements/default/cls-decl.template +/*--- +description: Private setter is not stored as an own property of objects (field definitions in a class declaration) +esid: prod-FieldDefinition +features: [class-methods-private, class] +flags: [generated] +info: | + PrivateFieldGet (P, O) + 1. Assert: P is a Private Name. + 2. If O is not an object, throw a TypeError exception. + 3. If P.[[Kind]] is "field", + a. Let entry be PrivateFieldFind(P, O). + b. If entry is empty, throw a TypeError exception. + c. Return entry.[[PrivateFieldValue]]. + 4. Perform ? PrivateBrandCheck(O, P). + 5. If P.[[Kind]] is "method", + a. Return P.[[Value]]. + 6. Else, + a. Assert: P.[[Kind]] is "accessor". + b. If P does not have a [[Get]] field, throw a TypeError exception. + c. Let getter be P.[[Get]]. + d. Return ? Call(getter, O). + +---*/ + + +class C { + set #m(v) { this._v = v; } + + checkPrivateSetter() { + assert.sameValue(this.hasOwnProperty("#m"), false); + assert.sameValue("#m" in this, false); + + assert.sameValue(this.__lookupSetter__("#m"), undefined); + + this.#m = "Test262"; + assert.sameValue(this._v, "Test262"); + + return 0; + } +} + +let c = new C(); +assert.sameValue(c.checkPrivateSetter(), 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-setter-is-not-clobbered-by-computed-property.js b/js/src/tests/test262/language/statements/class/elements/private-setter-is-not-clobbered-by-computed-property.js new file mode 100644 index 0000000000..50943ffbcb --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-setter-is-not-clobbered-by-computed-property.js @@ -0,0 +1,46 @@ +// Copyright (C) 2019 Caio Lima (Igalia SL). All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Private setter is not clobbered by computed property +esid: sec-privatefieldget +info: | + PrivateFieldGet (P, O) + 1. Assert: P is a Private Name. + 2. If O is not an object, throw a TypeError exception. + 3. If P.[[Kind]] is "field", + a. Let entry be PrivateFieldFind(P, O). + b. If entry is empty, throw a TypeError exception. + c. Return entry.[[PrivateFieldValue]]. + 4. Perform ? PrivateBrandCheck(O, P). + 5. If P.[[Kind]] is "method", + a. Return P.[[Value]]. + 6. Else, + a. Assert: P.[[Kind]] is "accessor". + b. If P does not have a [[Get]] field, throw a TypeError exception. + c. Let getter be P.[[Get]]. + d. Return ? Call(getter, O). +features: [class-methods-private, class-fields-public, class] +---*/ + +class C { + set #m(v) { this._v = v; } + ["#m"] = 0; + + checkPrivateSetter() { + assert.sameValue(this.hasOwnProperty("#m"), true); + assert.sameValue("#m" in this, true); + + assert.sameValue(this["#m"], 0); + + this.#m = "Test262"; + assert.sameValue(this._v, "Test262"); + + return 0; + } +} + +let c = new C(); +assert.sameValue(c.checkPrivateSetter(), 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-setter-on-nested-class.js b/js/src/tests/test262/language/statements/class/elements/private-setter-on-nested-class.js new file mode 100644 index 0000000000..c320048fc6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-setter-on-nested-class.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/private-setter-on-nested-class.case +// - src/class-elements/default/cls-decl.template +/*--- +description: PrivateName of private setter is available on inner classes (field definitions in a class declaration) +esid: prod-FieldDefinition +features: [class-methods-private, class-fields-public, class] +flags: [generated] +info: | + Updated Productions + + CallExpression[Yield, Await]: + CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await] + SuperCall[?Yield, ?Await] + CallExpression[?Yield, ?Await]Arguments[?Yield, ?Await] + CallExpression[?Yield, ?Await][Expression[+In, ?Yield, ?Await]] + CallExpression[?Yield, ?Await].IdentifierName + CallExpression[?Yield, ?Await]TemplateLiteral[?Yield, ?Await] + CallExpression[?Yield, ?Await].PrivateName + +---*/ + + +class C { + set #m(v) { this._v = v; } + + B = class { + method(o, v) { + o.#m = v; + } + } +} + +let c = new C(); +let innerB = new c.B(); +innerB.method(c, 'test262'); +assert.sameValue(c._v, 'test262'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-setter-shadowed-by-field-on-nested-class.js b/js/src/tests/test262/language/statements/class/elements/private-setter-shadowed-by-field-on-nested-class.js new file mode 100644 index 0000000000..ac88ecdd4e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-setter-shadowed-by-field-on-nested-class.js @@ -0,0 +1,53 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/private-setter-shadowed-by-field-on-nested-class.case +// - src/class-elements/default/cls-decl.template +/*--- +description: PrivateName of private setter can be shadowed on inner classes by a private field (field definitions in a class declaration) +esid: prod-FieldDefinition +features: [class-methods-private, class-fields-private, class-fields-public, class] +flags: [generated] +info: | + Updated Productions + + CallExpression[Yield, Await]: + CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await] + SuperCall[?Yield, ?Await] + CallExpression[?Yield, ?Await]Arguments[?Yield, ?Await] + CallExpression[?Yield, ?Await][Expression[+In, ?Yield, ?Await]] + CallExpression[?Yield, ?Await].IdentifierName + CallExpression[?Yield, ?Await]TemplateLiteral[?Yield, ?Await] + CallExpression[?Yield, ?Await].PrivateName + +---*/ + + +class C { + set #m(v) { this._v = v; } + + method(v) { this.#m = v; } + + B = class { + method(o, v) { + o.#m = v; + } + + get m() { return this.#m; } + + #m; + } +} + +let c = new C(); +let innerB = new c.B(); + +innerB.method(innerB, 'test262'); +assert.sameValue(innerB.m, 'test262'); + +c.method('outer class'); +assert.sameValue(c._v, 'outer class'); + +assert.throws(TypeError, function() { + innerB.method(c, 'foo'); +}, 'accessed inner class field from an object of outer class'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-setter-shadowed-by-getter-on-nested-class.js b/js/src/tests/test262/language/statements/class/elements/private-setter-shadowed-by-getter-on-nested-class.js new file mode 100644 index 0000000000..b3cfc60c75 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-setter-shadowed-by-getter-on-nested-class.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/private-setter-shadowed-by-getter-on-nested-class.case +// - src/class-elements/default/cls-decl.template +/*--- +description: PrivateName of private setter can be shadowed on inner classes by a private getter (field definitions in a class declaration) +esid: prod-FieldDefinition +features: [class-methods-private, class-fields-public, class] +flags: [generated] +info: | + Updated Productions + + CallExpression[Yield, Await]: + CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await] + SuperCall[?Yield, ?Await] + CallExpression[?Yield, ?Await]Arguments[?Yield, ?Await] + CallExpression[?Yield, ?Await][Expression[+In, ?Yield, ?Await]] + CallExpression[?Yield, ?Await].IdentifierName + CallExpression[?Yield, ?Await]TemplateLiteral[?Yield, ?Await] + CallExpression[?Yield, ?Await].PrivateName + +---*/ + + +class C { + set #m(v) { this._v = v; } + + method(v) { this.#m = v; } + + B = class { + method(o, v) { + o.#m = v; + } + + get #m() { return 'test262'; } + } +} + +let c = new C(); +let innerB = new c.B(); + +assert.throws(TypeError, function() { + innerB.method(innerB); +}, 'invalid [[Set]] of an acessor without setter'); + +c.method('outer class'); +assert.sameValue(c._v, 'outer class'); + +assert.throws(TypeError, function() { + innerB.method(c); +}, 'invalid access of inner class getter from an object of outer class'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-setter-shadowed-by-method-on-nested-class.js b/js/src/tests/test262/language/statements/class/elements/private-setter-shadowed-by-method-on-nested-class.js new file mode 100644 index 0000000000..89d45ebf96 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-setter-shadowed-by-method-on-nested-class.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/private-setter-shadowed-by-method-on-nested-class.case +// - src/class-elements/default/cls-decl.template +/*--- +description: PrivateName of private setter can be shadowed on inner class by a private method (field definitions in a class declaration) +esid: prod-FieldDefinition +features: [class-methods-private, class-fields-public, class] +flags: [generated] +info: | + Updated Productions + + CallExpression[Yield, Await]: + CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await] + SuperCall[?Yield, ?Await] + CallExpression[?Yield, ?Await]Arguments[?Yield, ?Await] + CallExpression[?Yield, ?Await][Expression[+In, ?Yield, ?Await]] + CallExpression[?Yield, ?Await].IdentifierName + CallExpression[?Yield, ?Await]TemplateLiteral[?Yield, ?Await] + CallExpression[?Yield, ?Await].PrivateName + +---*/ + + +class C { + set #m(v) { this._v = v; } + + method(v) { this.#m = v; } + + B = class { + method(o, v) { + o.#m = v; + } + + #m() { return 'test262'; } + } +} + +let c = new C(); +let innerB = new c.B(); + +assert.throws(TypeError, function() { + innerB.method(innerB, 'foo'); +}, 'invalid [[Set]] operation in a private method'); + +c.method('outer class'); +assert.sameValue(c._v, 'outer class'); + +assert.throws(TypeError, function() { + innerB.method(c); +}, 'invalid access of inner class method from an object of outer class'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-setter-shadowed-by-setter-on-nested-class.js b/js/src/tests/test262/language/statements/class/elements/private-setter-shadowed-by-setter-on-nested-class.js new file mode 100644 index 0000000000..45c1e77b82 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-setter-shadowed-by-setter-on-nested-class.js @@ -0,0 +1,51 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/private-setter-shadowed-by-setter-on-nested-class.case +// - src/class-elements/default/cls-decl.template +/*--- +description: PrivateName of private setter can be shadowed on inner classes by a private setter (field definitions in a class declaration) +esid: prod-FieldDefinition +features: [class-methods-private, class-fields-public, class] +flags: [generated] +info: | + Updated Productions + + CallExpression[Yield, Await]: + CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await] + SuperCall[?Yield, ?Await] + CallExpression[?Yield, ?Await]Arguments[?Yield, ?Await] + CallExpression[?Yield, ?Await][Expression[+In, ?Yield, ?Await]] + CallExpression[?Yield, ?Await].IdentifierName + CallExpression[?Yield, ?Await]TemplateLiteral[?Yield, ?Await] + CallExpression[?Yield, ?Await].PrivateName + +---*/ + + +class C { + set #m(v) { this._v = v; } + + method(v) { this.#m = v; } + + B = class { + method(o, v) { + o.#m = v; + } + + set #m(v) { this._v = v; } + } +} + +let c = new C(); +let innerB = new c.B(); + +innerB.method(innerB, 'test262'); +assert.sameValue(innerB._v, 'test262'); + +c.method('outer class'); +assert.sameValue(c._v, 'outer class'); + +assert.throws(TypeError, function() { + innerB.method(c, 'foo'); +}, 'access of inner class accessor from an object of outer class'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-setter-visible-to-direct-eval-on-initializer.js b/js/src/tests/test262/language/statements/class/elements/private-setter-visible-to-direct-eval-on-initializer.js new file mode 100644 index 0000000000..76eaad950f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-setter-visible-to-direct-eval-on-initializer.js @@ -0,0 +1,50 @@ +// Copyright (C) 2019 Caio Lima (Igalia SL). All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Private setter is visible on initializer with direct eval +esid: sec-privatefieldset +info: | + PrivateFieldSet (P, O, value ) + 1. Assert: P is a Private Name. + 2. If O is not an object, throw a TypeError exception. + 3. If P.[[Kind]] is "field", + a. Let entry be PrivateFieldFind(P, O). + b. If entry is empty, throw a TypeError exception. + c. Set entry.[[PrivateFieldValue]] to value. + d. Return. + 4. If P.[[Kind]] is "method", throw a TypeError exception. + 5. Else, + a. Assert: P.[[Kind]] is "accessor". + b. If O.[[PrivateFieldBrands]] does not contain P.[[Brand]], throw a TypeError exception. + c. If P does not have a [[Set]] field, throw a TypeError exception. + d. Let setter be P.[[Set]]. + e. Perform ? Call(setter, O, value). + f. Return. + + ClassElementName : PrivateIdentifier + 1. Let privateIdentifier be StringValue of PrivateIdentifier. + 2. Let privateName be NewPrivateName(privateIdentifier). + 3. Let scope be the running execution context's PrivateEnvironment. + 4. Let scopeEnvRec be scope's EnvironmentRecord. + 5. Perform ! scopeEnvRec.InitializeBinding(privateIdentifier, privateName). + 6. Return privateName. + + MakePrivateReference ( baseValue, privateIdentifier ) + 1. Let env be the running execution context's PrivateEnvironment. + 2. Let privateNameBinding be ? ResolveBinding(privateIdentifier, env). + 3. Let privateName be GetValue(privateNameBinding). + 4. Assert: privateName is a Private Name. + 5. Return a value of type Reference whose base value is baseValue, whose referenced name is privateName, whose strict reference flag is true. +features: [class-fields-public, class-methods-private, class] +---*/ + +class C { + set #m(v) { this._v = v; }; + v = (eval("this.#m = 53"), this._v); +} + +let c = new C(); +assert.sameValue(c.v, 53); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-setter-visible-to-direct-eval.js b/js/src/tests/test262/language/statements/class/elements/private-setter-visible-to-direct-eval.js new file mode 100644 index 0000000000..5a0a24d0e5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-setter-visible-to-direct-eval.js @@ -0,0 +1,63 @@ +// Copyright (C) 2019 Caio Lima (Igalia SL). All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Private setter is visible to direct eval code +esid: sec-privatefieldset +info: | + PrivateFieldSet (P, O, value ) + 1. Assert: P is a Private Name. + 2. If O is not an object, throw a TypeError exception. + 3. If P.[[Kind]] is "field", + a. Let entry be PrivateFieldFind(P, O). + b. If entry is empty, throw a TypeError exception. + c. Set entry.[[PrivateFieldValue]] to value. + d. Return. + 4. If P.[[Kind]] is "method", throw a TypeError exception. + 5. Else, + a. Assert: P.[[Kind]] is "accessor". + b. If O.[[PrivateFieldBrands]] does not contain P.[[Brand]], throw a TypeError exception. + c. If P does not have a [[Set]] field, throw a TypeError exception. + d. Let setter be P.[[Set]]. + e. Perform ? Call(setter, O, value). + f. Return. + + ClassElementName : PrivateIdentifier + 1. Let privateIdentifier be StringValue of PrivateIdentifier. + 2. Let privateName be NewPrivateName(privateIdentifier). + 3. Let scope be the running execution context's PrivateEnvironment. + 4. Let scopeEnvRec be scope's EnvironmentRecord. + 5. Perform ! scopeEnvRec.InitializeBinding(privateIdentifier, privateName). + 6. Return privateName. + + MakePrivateReference ( baseValue, privateIdentifier ) + 1. Let env be the running execution context's PrivateEnvironment. + 2. Let privateNameBinding be ? ResolveBinding(privateIdentifier, env). + 3. Let privateName be GetValue(privateNameBinding). + 4. Assert: privateName is a Private Name. + 5. Return a value of type Reference whose base value is baseValue, whose referenced name is privateName, whose strict reference flag is true. +features: [class-methods-private, class] +---*/ + +class C { + set #m(v) { this._v = v; }; + + setWithEval(v) { + eval("this.#m = v"); + } +} + +class D { + set #m(v) { throw new Test262Error(); }; +} + +let c = new C(); +c.setWithEval("Test262"); +assert.sameValue(c._v, "Test262"); + +let d = new D(); +assert.throws(TypeError, function() { + c.setWithEval.call(d); +}, "invalid access to a private setter"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-static-async-generator-method-name.js b/js/src/tests/test262/language/statements/class/elements/private-static-async-generator-method-name.js new file mode 100644 index 0000000000..3e5e056e36 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-static-async-generator-method-name.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/private-static-async-generator-method-name.case +// - src/class-elements/default/cls-decl.template +/*--- +description: Private static async generator methods have name property properly configured (field definitions in a class declaration) +esid: prod-FieldDefinition +features: [class-static-methods-private, class] +flags: [generated] +info: | + Updated Productions + + ClassElement : MethodDefinition + 1. Return ClassElementEvaluation of MethodDefinition with arguments ! Get(homeObject, "prototype"),enumerable, and "prototype". + + ClassElement : static MethodDefinition + 1. Return ClassElementEvaluation of MethodDefinition with arguments homeObject, enumerable and "static". + + AsyncMethod : async [no LineTerminator here] * ClassElementName (UniqueFormalParameters) { AsyncFunctionBody } + ... + 12. Perform ? DefineOrdinaryMethod(key, homeObject, closure, _enumerable). + + ClassElement : MethodDefinition + ClassElement : static MethodDefinition + 1. Perform ? PropertyDefinitionEvaluation with parameters object and enumerable. + 2. Return empty. + + ClassElementName : PrivateIdentifier + 1. Let bindingName be StringValue of PrivateIdentifier. + ... + 5. If scopeEnvRec's binding for bindingName is uninitialized, + a. Let field be NewPrivateName(bindingName). + b. Perform ! scopeEnvRec.InitializeBinding(bindingName, field). + 6. Otherwise, + a. Let field be scopeEnvRec.GetBindingValue(bindingName). + 7. Assert: field.[[Description]] is bindingName. + 8. Return field. + + DefineOrdinaryMethod(key, homeObject, closure, enumerable) + 1. Perform SetFunctionName(closure, key). + 2. If key is a Private Name, + a. Assert: key does not have a [[Kind]] field. + b. Set key.[[Kind]] to "method". + c. Set key.[[Value]] to closure. + d. Set key.[[Brand]] to homeObject. + 3. Else, + a. Let desc be the PropertyDescriptor{[[Value]]: closure, [[Writable]]: true, [[Enumerable]]: enumerable, [[Configurable]]: true}. + b. Perform ? DefinePropertyOrThrow(homeObject, key, desc). + +---*/ + + +class C { + static async * #method() {}; + + static getPrivateMethod() { + return this.#method; + } +} + +assert.sameValue(C.getPrivateMethod().name, "#method"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-static-async-method-name.js b/js/src/tests/test262/language/statements/class/elements/private-static-async-method-name.js new file mode 100644 index 0000000000..de5464c427 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-static-async-method-name.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/private-static-async-method-name.case +// - src/class-elements/default/cls-decl.template +/*--- +description: Private static async methods have name property properly configured (field definitions in a class declaration) +esid: prod-FieldDefinition +features: [class-static-methods-private, class] +flags: [generated] +info: | + Updated Productions + + ClassElement : MethodDefinition + 1. Return ClassElementEvaluation of MethodDefinition with arguments ! Get(homeObject, "prototype"),enumerable, and "prototype". + + ClassElement : static MethodDefinition + 1. Return ClassElementEvaluation of MethodDefinition with arguments homeObject, enumerable and "static". + + AsyncMethod : async [no LineTerminator here] ClassElementName (UniqueFormalParameters) { AsyncFunctionBody } + ... + 10. Perform ? DefineOrdinaryMethod(key, homeObject, closure, _enumerable). + + ClassElement : MethodDefinition + ClassElement : static MethodDefinition + 1. Perform ? PropertyDefinitionEvaluation with parameters object and enumerable. + 2. Return empty. + + ClassElementName : PrivateIdentifier + 1. Let bindingName be StringValue of PrivateIdentifier. + ... + 5. If scopeEnvRec's binding for bindingName is uninitialized, + a. Let field be NewPrivateName(bindingName). + b. Perform ! scopeEnvRec.InitializeBinding(bindingName, field). + 6. Otherwise, + a. Let field be scopeEnvRec.GetBindingValue(bindingName). + 7. Assert: field.[[Description]] is bindingName. + 8. Return field. + + DefineOrdinaryMethod(key, homeObject, closure, enumerable) + 1. Perform SetFunctionName(closure, key). + 2. If key is a Private Name, + a. Assert: key does not have a [[Kind]] field. + b. Set key.[[Kind]] to "method". + c. Set key.[[Value]] to closure. + d. Set key.[[Brand]] to homeObject. + 3. Else, + a. Let desc be the PropertyDescriptor{[[Value]]: closure, [[Writable]]: true, [[Enumerable]]: enumerable, [[Configurable]]: true}. + b. Perform ? DefinePropertyOrThrow(homeObject, key, desc). + +---*/ + + +class C { + static async #method() {}; + + static getPrivateMethod() { + return this.#method; + } +} + +assert.sameValue(C.getPrivateMethod().name, "#method"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-static-field-shadowed-by-field-on-nested-class.js b/js/src/tests/test262/language/statements/class/elements/private-static-field-shadowed-by-field-on-nested-class.js new file mode 100644 index 0000000000..fe7060c92e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-static-field-shadowed-by-field-on-nested-class.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/private-static-field-shadowed-by-field-on-nested-class.case +// - src/class-elements/default/cls-decl.template +/*--- +description: PrivateName of private static field can be shadowed on inner classes by a private field (field definitions in a class declaration) +esid: prod-FieldDefinition +features: [class-static-fields-private, class-static-fields-public, class-fields-private, class] +flags: [generated] +info: | + Updated Productions + + CallExpression[Yield, Await]: + CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await] + SuperCall[?Yield, ?Await] + CallExpression[?Yield, ?Await]Arguments[?Yield, ?Await] + CallExpression[?Yield, ?Await][Expression[+In, ?Yield, ?Await]] + CallExpression[?Yield, ?Await].IdentifierName + CallExpression[?Yield, ?Await]TemplateLiteral[?Yield, ?Await] + CallExpression[?Yield, ?Await].PrivateIdentifier + + ClassTail : ClassHeritage { ClassBody } + ... + 6. Let classPrivateEnvironment be NewDeclarativeEnvironment(outerPrivateEnvironment). + 7. Let classPrivateEnvRec be classPrivateEnvironment's EnvironmentRecord. + ... + 15. Set the running execution context's LexicalEnvironment to classScope. + 16. Set the running execution context's PrivateEnvironment to classPrivateEnvironment. + ... + 33. If PrivateBoundIdentifiers of ClassBody contains a Private Name P such that P's [[Kind]] field is either "method" or "accessor" and P's [[Brand]] is F, + a. PrivateBrandAdd(F, F). + 34. For each item fieldRecord in order from staticFields, + a. Perform ? DefineField(F, field). + + FieldDefinition : ClassElementName Initializer_opt + 1. Let name be the result of evaluating ClassElementName. + 2. ReturnIfAbrupt(name). + 3. If Initializer_opt is present, + a. Let lex be the Lexical Environment of the running execution context. + b. Let formalParameterList be an instance of the production FormalParameters : [empty]. + c. Let privateScope be the PrivateEnvironment of the running execution context. + d. Let initializer be FunctionCreate(Method, formalParameterList, Initializer, lex, true, privateScope). + e. Perform MakeMethod(initializer, homeObject). + f. Let isAnonymousFunctionDefinition be IsAnonymousFunctionDefinition(Initializer). + 4. Else, + a. Let initializer be empty. + b. Let isAnonymousFunctionDeclaration be false. + 5. Return a Record { [[Name]]: name, [[Initializer]]: initializer, [[IsAnonymousFunctionDefinition]]: isAnonymousFunctionDefinition }. + + MemberExpression : MemberExpression.PrivateIdentifier + 1. Let baseReference be the result of evaluating MemberExpression. + 2. Let baseValue be ? GetValue(baseReference). + 3. Let bv be ? RequireObjectCoercible(baseValue). + 4. Let fieldNameString be the StringValue of PrivateIdentifier. + 5. Return MakePrivateReference(bv, fieldNameString). + + MakePrivateReference(baseValue, privateIdentifier) + 1. Let env be the running execution context's PrivateEnvironment. + 2. Let privateNameBinding be ? ResolveBinding(privateIdentifier, env). + 3. Let privateName be GetValue(privateNameBinding). + 4. Assert: privateName is a Private Name. + 5. Return a value of type Reference whose base value is baseValue, whose referenced name is privateName, whose strict reference flag is true. + +---*/ + + +class C { + static #m = 'outer class'; + + static fieldAccess() { + return this.#m; + } + + static B = class { + #m = 'inner class'; + static fieldAccess(o) { + return o.#m; + } + } +} + +assert.sameValue(C.fieldAccess(), 'outer class'); + +let b = new C.B(); + +assert.sameValue(C.B.fieldAccess(b), 'inner class'); + +assert.throws(TypeError, function() { + C.B.fieldAccess(C); +}, 'accessed private field from an arbritary object'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-static-field-shadowed-by-getter-on-nested-class.js b/js/src/tests/test262/language/statements/class/elements/private-static-field-shadowed-by-getter-on-nested-class.js new file mode 100644 index 0000000000..7e62f99a8f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-static-field-shadowed-by-getter-on-nested-class.js @@ -0,0 +1,92 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/private-static-field-shadowed-by-getter-on-nested-class.case +// - src/class-elements/default/cls-decl.template +/*--- +description: PrivateName of private static field can be shadowed on inner classes by a private getter (field definitions in a class declaration) +esid: prod-FieldDefinition +features: [class-static-fields-private, class-static-fields-public, class-methods-private, class] +flags: [generated] +info: | + Updated Productions + + CallExpression[Yield, Await]: + CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await] + SuperCall[?Yield, ?Await] + CallExpression[?Yield, ?Await]Arguments[?Yield, ?Await] + CallExpression[?Yield, ?Await][Expression[+In, ?Yield, ?Await]] + CallExpression[?Yield, ?Await].IdentifierName + CallExpression[?Yield, ?Await]TemplateLiteral[?Yield, ?Await] + CallExpression[?Yield, ?Await].PrivateIdentifier + + ClassTail : ClassHeritage { ClassBody } + ... + 6. Let classPrivateEnvironment be NewDeclarativeEnvironment(outerPrivateEnvironment). + 7. Let classPrivateEnvRec be classPrivateEnvironment's EnvironmentRecord. + ... + 15. Set the running execution context's LexicalEnvironment to classScope. + 16. Set the running execution context's PrivateEnvironment to classPrivateEnvironment. + ... + 33. If PrivateBoundIdentifiers of ClassBody contains a Private Name P such that P's [[Kind]] field is either "method" or "accessor" and P's [[Brand]] is F, + a. PrivateBrandAdd(F, F). + 34. For each item fieldRecord in order from staticFields, + a. Perform ? DefineField(F, field). + + FieldDefinition : ClassElementName Initializer_opt + 1. Let name be the result of evaluating ClassElementName. + 2. ReturnIfAbrupt(name). + 3. If Initializer_opt is present, + a. Let lex be the Lexical Environment of the running execution context. + b. Let formalParameterList be an instance of the production FormalParameters : [empty]. + c. Let privateScope be the PrivateEnvironment of the running execution context. + d. Let initializer be FunctionCreate(Method, formalParameterList, Initializer, lex, true, privateScope). + e. Perform MakeMethod(initializer, homeObject). + f. Let isAnonymousFunctionDefinition be IsAnonymousFunctionDefinition(Initializer). + 4. Else, + a. Let initializer be empty. + b. Let isAnonymousFunctionDeclaration be false. + 5. Return a Record { [[Name]]: name, [[Initializer]]: initializer, [[IsAnonymousFunctionDefinition]]: isAnonymousFunctionDefinition }. + + MemberExpression : MemberExpression.PrivateIdentifier + 1. Let baseReference be the result of evaluating MemberExpression. + 2. Let baseValue be ? GetValue(baseReference). + 3. Let bv be ? RequireObjectCoercible(baseValue). + 4. Let fieldNameString be the StringValue of PrivateIdentifier. + 5. Return MakePrivateReference(bv, fieldNameString). + + MakePrivateReference(baseValue, privateIdentifier) + 1. Let env be the running execution context's PrivateEnvironment. + 2. Let privateNameBinding be ? ResolveBinding(privateIdentifier, env). + 3. Let privateName be GetValue(privateNameBinding). + 4. Assert: privateName is a Private Name. + 5. Return a value of type Reference whose base value is baseValue, whose referenced name is privateName, whose strict reference flag is true. + +---*/ + + +class C { + static #m = 'outer class'; + + static fieldAccess() { + return this.#m; + } + + static B = class { + get #m() { return 'inner class'; } + + static access(o) { + return o.#m; + } + } +} + +assert.sameValue(C.fieldAccess(), 'outer class'); + +let b = new C.B(); + +assert.sameValue(C.B.access(b), 'inner class'); + +assert.throws(TypeError, function() { + C.B.access(C); +}, 'accessed private getter from an arbritary object'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-static-field-shadowed-by-method-on-nested-class.js b/js/src/tests/test262/language/statements/class/elements/private-static-field-shadowed-by-method-on-nested-class.js new file mode 100644 index 0000000000..a78214d76e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-static-field-shadowed-by-method-on-nested-class.js @@ -0,0 +1,92 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/private-static-field-shadowed-by-method-on-nested-class.case +// - src/class-elements/default/cls-decl.template +/*--- +description: PrivateName of private static field can be shadowed on inner classes by a private method (field definitions in a class declaration) +esid: prod-FieldDefinition +features: [class-static-fields-private, class-static-fields-public, class-methods-private, class] +flags: [generated] +info: | + Updated Productions + + CallExpression[Yield, Await]: + CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await] + SuperCall[?Yield, ?Await] + CallExpression[?Yield, ?Await]Arguments[?Yield, ?Await] + CallExpression[?Yield, ?Await][Expression[+In, ?Yield, ?Await]] + CallExpression[?Yield, ?Await].IdentifierName + CallExpression[?Yield, ?Await]TemplateLiteral[?Yield, ?Await] + CallExpression[?Yield, ?Await].PrivateIdentifier + + ClassTail : ClassHeritage { ClassBody } + ... + 6. Let classPrivateEnvironment be NewDeclarativeEnvironment(outerPrivateEnvironment). + 7. Let classPrivateEnvRec be classPrivateEnvironment's EnvironmentRecord. + ... + 15. Set the running execution context's LexicalEnvironment to classScope. + 16. Set the running execution context's PrivateEnvironment to classPrivateEnvironment. + ... + 33. If PrivateBoundIdentifiers of ClassBody contains a Private Name P such that P's [[Kind]] field is either "method" or "accessor" and P's [[Brand]] is F, + a. PrivateBrandAdd(F, F). + 34. For each item fieldRecord in order from staticFields, + a. Perform ? DefineField(F, field). + + FieldDefinition : ClassElementName Initializer_opt + 1. Let name be the result of evaluating ClassElementName. + 2. ReturnIfAbrupt(name). + 3. If Initializer_opt is present, + a. Let lex be the Lexical Environment of the running execution context. + b. Let formalParameterList be an instance of the production FormalParameters : [empty]. + c. Let privateScope be the PrivateEnvironment of the running execution context. + d. Let initializer be FunctionCreate(Method, formalParameterList, Initializer, lex, true, privateScope). + e. Perform MakeMethod(initializer, homeObject). + f. Let isAnonymousFunctionDefinition be IsAnonymousFunctionDefinition(Initializer). + 4. Else, + a. Let initializer be empty. + b. Let isAnonymousFunctionDeclaration be false. + 5. Return a Record { [[Name]]: name, [[Initializer]]: initializer, [[IsAnonymousFunctionDefinition]]: isAnonymousFunctionDefinition }. + + MemberExpression : MemberExpression.PrivateIdentifier + 1. Let baseReference be the result of evaluating MemberExpression. + 2. Let baseValue be ? GetValue(baseReference). + 3. Let bv be ? RequireObjectCoercible(baseValue). + 4. Let fieldNameString be the StringValue of PrivateIdentifier. + 5. Return MakePrivateReference(bv, fieldNameString). + + MakePrivateReference(baseValue, privateIdentifier) + 1. Let env be the running execution context's PrivateEnvironment. + 2. Let privateNameBinding be ? ResolveBinding(privateIdentifier, env). + 3. Let privateName be GetValue(privateNameBinding). + 4. Assert: privateName is a Private Name. + 5. Return a value of type Reference whose base value is baseValue, whose referenced name is privateName, whose strict reference flag is true. + +---*/ + + +class C { + static #m = () => 'outer class'; + + static fieldAccess() { + return this.#m(); + } + + static B = class { + #m() { return 'inner class'; } + + static access(o) { + return o.#m(); + } + } +} + +assert.sameValue(C.fieldAccess(), 'outer class'); + +let b = new C.B(); + +assert.sameValue(C.B.access(b), 'inner class'); + +assert.throws(TypeError, function() { + C.B.access(C); +}, 'accessed private method from an arbritary object'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-static-field-shadowed-by-setter-on-nested-class.js b/js/src/tests/test262/language/statements/class/elements/private-static-field-shadowed-by-setter-on-nested-class.js new file mode 100644 index 0000000000..f72c5b519e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-static-field-shadowed-by-setter-on-nested-class.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/private-static-field-shadowed-by-setter-on-nested-class.case +// - src/class-elements/default/cls-decl.template +/*--- +description: PrivateName of private static field can be shadowed on inner classes by a private setter (field definitions in a class declaration) +esid: prod-FieldDefinition +features: [class-static-fields-private, class-static-fields-public, class-methods-private, class] +flags: [generated] +info: | + Updated Productions + + CallExpression[Yield, Await]: + CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await] + SuperCall[?Yield, ?Await] + CallExpression[?Yield, ?Await]Arguments[?Yield, ?Await] + CallExpression[?Yield, ?Await][Expression[+In, ?Yield, ?Await]] + CallExpression[?Yield, ?Await].IdentifierName + CallExpression[?Yield, ?Await]TemplateLiteral[?Yield, ?Await] + CallExpression[?Yield, ?Await].PrivateIdentifier + + ClassTail : ClassHeritage { ClassBody } + ... + 6. Let classPrivateEnvironment be NewDeclarativeEnvironment(outerPrivateEnvironment). + 7. Let classPrivateEnvRec be classPrivateEnvironment's EnvironmentRecord. + ... + 15. Set the running execution context's LexicalEnvironment to classScope. + 16. Set the running execution context's PrivateEnvironment to classPrivateEnvironment. + ... + 33. If PrivateBoundIdentifiers of ClassBody contains a Private Name P such that P's [[Kind]] field is either "method" or "accessor" and P's [[Brand]] is F, + a. PrivateBrandAdd(F, F). + 34. For each item fieldRecord in order from staticFields, + a. Perform ? DefineField(F, field). + + FieldDefinition : ClassElementName Initializer_opt + 1. Let name be the result of evaluating ClassElementName. + 2. ReturnIfAbrupt(name). + 3. If Initializer_opt is present, + a. Let lex be the Lexical Environment of the running execution context. + b. Let formalParameterList be an instance of the production FormalParameters : [empty]. + c. Let privateScope be the PrivateEnvironment of the running execution context. + d. Let initializer be FunctionCreate(Method, formalParameterList, Initializer, lex, true, privateScope). + e. Perform MakeMethod(initializer, homeObject). + f. Let isAnonymousFunctionDefinition be IsAnonymousFunctionDefinition(Initializer). + 4. Else, + a. Let initializer be empty. + b. Let isAnonymousFunctionDeclaration be false. + 5. Return a Record { [[Name]]: name, [[Initializer]]: initializer, [[IsAnonymousFunctionDefinition]]: isAnonymousFunctionDefinition }. + + MemberExpression : MemberExpression.PrivateIdentifier + 1. Let baseReference be the result of evaluating MemberExpression. + 2. Let baseValue be ? GetValue(baseReference). + 3. Let bv be ? RequireObjectCoercible(baseValue). + 4. Let fieldNameString be the StringValue of PrivateIdentifier. + 5. Return MakePrivateReference(bv, fieldNameString). + + MakePrivateReference(baseValue, privateIdentifier) + 1. Let env be the running execution context's PrivateEnvironment. + 2. Let privateNameBinding be ? ResolveBinding(privateIdentifier, env). + 3. Let privateName be GetValue(privateNameBinding). + 4. Assert: privateName is a Private Name. + 5. Return a value of type Reference whose base value is baseValue, whose referenced name is privateName, whose strict reference flag is true. + +---*/ + + +class C { + static #m = 'outer class'; + + static fieldAccess() { + return this.#m; + } + + static B = class { + set #m(v) { this._v = v; } + + static access(o) { + o.#m = 'inner class'; + } + } +} + +assert.sameValue(C.fieldAccess(), 'outer class'); + +let b = new C.B(); + +C.B.access(b); +assert.sameValue(b._v, 'inner class'); + +assert.throws(TypeError, function() { + C.B.access(C); +}, 'accessed private setter from an arbritary object'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-static-field-usage-inside-nested-class.js b/js/src/tests/test262/language/statements/class/elements/private-static-field-usage-inside-nested-class.js new file mode 100644 index 0000000000..181a88af67 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-static-field-usage-inside-nested-class.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/private-static-field-usage-inside-nested-class.case +// - src/class-elements/default/cls-decl.template +/*--- +description: PrivateName of private static field is available inside inner classes (field definitions in a class declaration) +esid: prod-FieldDefinition +features: [class-static-fields-private, class-static-fields-public, class] +flags: [generated] +info: | + Updated Productions + + CallExpression[Yield, Await]: + CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await] + SuperCall[?Yield, ?Await] + CallExpression[?Yield, ?Await]Arguments[?Yield, ?Await] + CallExpression[?Yield, ?Await][Expression[+In, ?Yield, ?Await]] + CallExpression[?Yield, ?Await].IdentifierName + CallExpression[?Yield, ?Await]TemplateLiteral[?Yield, ?Await] + CallExpression[?Yield, ?Await].PrivateIdentifier + + ClassTail : ClassHeritage { ClassBody } + ... + 6. Let classPrivateEnvironment be NewDeclarativeEnvironment(outerPrivateEnvironment). + 7. Let classPrivateEnvRec be classPrivateEnvironment's EnvironmentRecord. + ... + 15. Set the running execution context's LexicalEnvironment to classScope. + 16. Set the running execution context's PrivateEnvironment to classPrivateEnvironment. + ... + 33. If PrivateBoundIdentifiers of ClassBody contains a Private Name P such that P's [[Kind]] field is either "method" or "accessor" and P's [[Brand]] is F, + a. PrivateBrandAdd(F, F). + 34. For each item fieldRecord in order from staticFields, + a. Perform ? DefineField(F, field). + + FieldDefinition : ClassElementName Initializer_opt + 1. Let name be the result of evaluating ClassElementName. + 2. ReturnIfAbrupt(name). + 3. If Initializer_opt is present, + a. Let lex be the Lexical Environment of the running execution context. + b. Let formalParameterList be an instance of the production FormalParameters : [empty]. + c. Let privateScope be the PrivateEnvironment of the running execution context. + d. Let initializer be FunctionCreate(Method, formalParameterList, Initializer, lex, true, privateScope). + e. Perform MakeMethod(initializer, homeObject). + f. Let isAnonymousFunctionDefinition be IsAnonymousFunctionDefinition(Initializer). + 4. Else, + a. Let initializer be empty. + b. Let isAnonymousFunctionDeclaration be false. + 5. Return a Record { [[Name]]: name, [[Initializer]]: initializer, [[IsAnonymousFunctionDefinition]]: isAnonymousFunctionDefinition }. + + MemberExpression : MemberExpression.PrivateIdentifier + 1. Let baseReference be the result of evaluating MemberExpression. + 2. Let baseValue be ? GetValue(baseReference). + 3. Let bv be ? RequireObjectCoercible(baseValue). + 4. Let fieldNameString be the StringValue of PrivateIdentifier. + 5. Return MakePrivateReference(bv, fieldNameString). + + MakePrivateReference(baseValue, privateIdentifier) + 1. Let env be the running execution context's PrivateEnvironment. + 2. Let privateNameBinding be ? ResolveBinding(privateIdentifier, env). + 3. Let privateName be GetValue(privateNameBinding). + 4. Assert: privateName is a Private Name. + 5. Return a value of type Reference whose base value is baseValue, whose referenced name is privateName, whose strict reference flag is true. + +---*/ + + +class C { + static #m = 'outer class'; + + static B = class { + static fieldAccess(o) { + return o.#m; + } + } +} + +assert.sameValue(C.B.fieldAccess(C), 'outer class'); +assert.throws(TypeError, function() { + C.B.methodAccess(C.B); +}, 'accessed static private field from an arbritary object'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-static-field-visible-to-direct-eval.js b/js/src/tests/test262/language/statements/class/elements/private-static-field-visible-to-direct-eval.js new file mode 100644 index 0000000000..68a0debf28 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-static-field-visible-to-direct-eval.js @@ -0,0 +1,59 @@ +// Copyright (C) 2019 Caio Lima (Igalia SL). All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Private static field is visible to direct eval code +esid: sec-privatefieldget +info: | + PrivateFieldGet (P, O) + 1. Assert: P is a Private Name. + 2. If O is not an object, throw a TypeError exception. + 3. If P.[[Kind]] is "field", + a. Let entry be PrivateFieldFind(P, O). + b. If entry is empty, throw a TypeError exception. + c. Return entry.[[PrivateFieldValue]]. + 4. Perform ? PrivateBrandCheck(O, P). + 5. If P.[[Kind]] is "method", + a. Return P.[[Value]]. + 6. Else, + a. Assert: P.[[Kind]] is "accessor". + b. If P does not have a [[Get]] field, throw a TypeError exception. + c. Let getter be P.[[Get]]. + d. Return ? Call(getter, O). + + ClassElementName : PrivateIdentifier + 1. Let privateIdentifier be StringValue of PrivateIdentifier. + 2. Let privateName be NewPrivateName(privateIdentifier). + 3. Let scope be the running execution context's PrivateEnvironment. + 4. Let scopeEnvRec be scope's EnvironmentRecord. + 5. Perform ! scopeEnvRec.InitializeBinding(privateIdentifier, privateName). + 6. Return privateName. + + MakePrivateReference ( baseValue, privateIdentifier ) + 1. Let env be the running execution context's PrivateEnvironment. + 2. Let privateNameBinding be ? ResolveBinding(privateIdentifier, env). + 3. Let privateName be GetValue(privateNameBinding). + 4. Assert: privateName is a Private Name. + 5. Return a value of type Reference whose base value is baseValue, whose referenced name is privateName, whose strict reference flag is true. +features: [class-static-fields-private, class] +---*/ + +class C { + static #m = 44; + + static getWithEval() { + return eval("this.#m"); + } +} + +class D { + static #m = 44; +} + +assert.sameValue(C.getWithEval(), 44); + +assert.throws(TypeError, function() { + C.getWithEval.call(D); +}, "invalid access to a private field"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-static-generator-method-name.js b/js/src/tests/test262/language/statements/class/elements/private-static-generator-method-name.js new file mode 100644 index 0000000000..8fd8d86c02 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-static-generator-method-name.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/private-static-generator-method-name.case +// - src/class-elements/default/cls-decl.template +/*--- +description: Private static generator methods have name property properly configured (field definitions in a class declaration) +esid: prod-FieldDefinition +features: [class-static-methods-private, class] +flags: [generated] +info: | + Updated Productions + + ClassElement : MethodDefinition + 1. Return ClassElementEvaluation of MethodDefinition with arguments ! Get(homeObject, "prototype"),enumerable, and "prototype". + + ClassElement : static MethodDefinition + 1. Return ClassElementEvaluation of MethodDefinition with arguments homeObject, enumerable and "static". + + GeneratorMethod : * ClassElementName (UniqueFormalParameters) { GeneratorBody } + ... + 12. Perform ? DefineOrdinaryMethod(key, homeObject, closure, _enumerable). + + ClassElement : MethodDefinition + ClassElement : static MethodDefinition + 1. Perform ? PropertyDefinitionEvaluation with parameters object and enumerable. + 2. Return empty. + + ClassElementName : PrivateIdentifier + 1. Let bindingName be StringValue of PrivateIdentifier. + ... + 5. If scopeEnvRec's binding for bindingName is uninitialized, + a. Let field be NewPrivateName(bindingName). + b. Perform ! scopeEnvRec.InitializeBinding(bindingName, field). + 6. Otherwise, + a. Let field be scopeEnvRec.GetBindingValue(bindingName). + 7. Assert: field.[[Description]] is bindingName. + 8. Return field. + + DefineOrdinaryMethod(key, homeObject, closure, enumerable) + 1. Perform SetFunctionName(closure, key). + 2. If key is a Private Name, + a. Assert: key does not have a [[Kind]] field. + b. Set key.[[Kind]] to "method". + c. Set key.[[Value]] to closure. + d. Set key.[[Brand]] to homeObject. + 3. Else, + a. Let desc be the PropertyDescriptor{[[Value]]: closure, [[Writable]]: true, [[Enumerable]]: enumerable, [[Configurable]]: true}. + b. Perform ? DefinePropertyOrThrow(homeObject, key, desc). + +---*/ + + +class C { + static * #method() {}; + + static getPrivateMethod() { + return this.#method; + } +} + +assert.sameValue(C.getPrivateMethod().name, "#method"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-static-getter-abrupt-completition.js b/js/src/tests/test262/language/statements/class/elements/private-static-getter-abrupt-completition.js new file mode 100644 index 0000000000..fc0b9f42dc --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-static-getter-abrupt-completition.js @@ -0,0 +1,41 @@ +// Copyright (C) 2019 Caio Lima (Igalia SL). All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: PrivateFieldGet should return an abrupt completion +esid: sec-privatefieldget +info: | + PrivateFieldGet (P, O) + 1. Assert: P is a Private Name. + 2. If O is not an object, throw a TypeError exception. + 3. If P.[[Kind]] is "field", + a. Let entry be PrivateFieldFind(P, O). + b. If entry is empty, throw a TypeError exception. + c. Return entry.[[PrivateFieldValue]]. + 4. Perform ? PrivateBrandCheck(O, P). + 5. If P.[[Kind]] is "method", + a. Return P.[[Value]]. + 6. Else, + a. Assert: P.[[Kind]] is "accessor". + b. If P does not have a [[Get]] field, throw a TypeError exception. + c. Let getter be P.[[Get]]. + d. Return ? Call(getter, O). +features: [class-methods-private, class] +---*/ + +class C { + get #m() { + throw new Test262Error(); + } + + access() { + this.#m; + } +} + +let c = new C(); +assert.throws(Test262Error, function() { + c.access(); +}, 'private getter should have abrupt completion'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-static-getter-visible-to-direct-eval.js b/js/src/tests/test262/language/statements/class/elements/private-static-getter-visible-to-direct-eval.js new file mode 100644 index 0000000000..180d624623 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-static-getter-visible-to-direct-eval.js @@ -0,0 +1,63 @@ +// Copyright (C) 2019 Caio Lima (Igalia SL). All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Private static getter is visible to direct eval code +esid: sec-privatefieldget +info: | + PrivateFieldGet (P, O) + 1. Assert: P is a Private Name. + 2. If O is not an object, throw a TypeError exception. + 3. If P.[[Kind]] is "field", + a. Let entry be PrivateFieldFind(P, O). + b. If entry is empty, throw a TypeError exception. + c. Return entry.[[PrivateFieldValue]]. + 4. Perform ? PrivateBrandCheck(O, P). + 5. If P.[[Kind]] is "method", + a. Return P.[[Value]]. + 6. Else, + a. Assert: P.[[Kind]] is "accessor". + b. If P does not have a [[Get]] field, throw a TypeError exception. + c. Let getter be P.[[Get]]. + d. Return ? Call(getter, O). + + ClassElementName : PrivateIdentifier + 1. Let privateIdentifier be StringValue of PrivateIdentifier. + 2. Let privateName be NewPrivateName(privateIdentifier). + 3. Let scope be the running execution context's PrivateEnvironment. + 4. Let scopeEnvRec be scope's EnvironmentRecord. + 5. Perform ! scopeEnvRec.InitializeBinding(privateIdentifier, privateName). + 6. Return privateName. + + MakePrivateReference ( baseValue, privateIdentifier ) + 1. Let env be the running execution context's PrivateEnvironment. + 2. Let privateNameBinding be ? ResolveBinding(privateIdentifier, env). + 3. Let privateName be GetValue(privateNameBinding). + 4. Assert: privateName is a Private Name. + 5. Return a value of type Reference whose base value is baseValue, whose referenced name is privateName, whose strict reference flag is true. +features: [class-static-methods-private, class] +---*/ + +class C { + static get #m() { + return 'Test262'; + } + + static getWithEval() { + return eval('this.#m'); + } +} + +class D { + static get #m() { + throw new Test262Error('should never be executed'); + } +} + +assert.sameValue(C.getWithEval(), 'Test262'); + +assert.throws(TypeError, function() { + C.getWithEval.call(D); +}, 'invalid access to a static private getter'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-static-method-length.js b/js/src/tests/test262/language/statements/class/elements/private-static-method-length.js new file mode 100644 index 0000000000..b18f48e6ba --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-static-method-length.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/private-static-method-length.case +// - src/class-elements/default/cls-decl.template +/*--- +description: Private static methods have length property properly configured (field definitions in a class declaration) +esid: prod-FieldDefinition +features: [class-static-methods-private, class] +flags: [generated] +info: | + Updated Productions + + ClassElement : MethodDefinition + 1. Return ClassElementEvaluation of MethodDefinition with arguments ! Get(homeObject, "prototype"),enumerable, and "prototype". + + ClassElement : static MethodDefinition + 1. Return ClassElementEvaluation of MethodDefinition with arguments homeObject, enumerable and "static". + + MethodDefinition : ClassElementName( UniqueFormalParameters ) { FunctionBody } + 1. Let methodDef be DefineMethod of MethodDefinition with argument homeObject. + 2. ReturnIfAbrupt(methodDef). + 3. Perform ? DefineOrdinaryMethod(methodDef.[[Key]], homeObject, methodDef.[[Closure]], _enumerable). + + ClassElement : MethodDefinition + ClassElement : static MethodDefinition + 1. Perform ? PropertyDefinitionEvaluation with parameters object and enumerable. + 2. Return empty. + + MethodDefinition : ClassElementName (UniqueFormalParameters) { FunctionBody } + ... + 8. Let closure be FunctionCreate(kind, UniqueFormalParameters, FunctionBody, scope, privateScope, strict, prototype). + 9. Perform MakeMethod(closure, object). + 10. Return the Record{[[Key]]: propKey, [[Closure]]: closure}. + +---*/ + + +class C { + static #method(a, b, c) {}; + + static getPrivateMethod() { + return this.#method; + } + +} + +assert.sameValue(C.getPrivateMethod().length, 3); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-static-method-name.js b/js/src/tests/test262/language/statements/class/elements/private-static-method-name.js new file mode 100644 index 0000000000..cafb88ff0d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-static-method-name.js @@ -0,0 +1,73 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/private-static-method-name.case +// - src/class-elements/default/cls-decl.template +/*--- +description: Private static methods have name property properly configured (field definitions in a class declaration) +esid: prod-FieldDefinition +features: [class-static-methods-private, class] +flags: [generated] +info: | + Updated Productions + + ClassElement : MethodDefinition + 1. Return ClassElementEvaluation of MethodDefinition with arguments ! Get(homeObject, "prototype"),enumerable, and "prototype". + + ClassElement : static MethodDefinition + 1. Return ClassElementEvaluation of MethodDefinition with arguments homeObject, enumerable and "static". + + MethodDefinition : ClassElementName( UniqueFormalParameters ) { FunctionBody } + 1. Let methodDef be DefineMethod of MethodDefinition with argument homeObject. + 2. ReturnIfAbrupt(methodDef). + 3. Perform ? DefineOrdinaryMethod(methodDef.[[Key]], homeObject, methodDef.[[Closure]], _enumerable). + + ClassElement : MethodDefinition + ClassElement : static MethodDefinition + 1. Perform ? PropertyDefinitionEvaluation with parameters object and enumerable. + 2. Return empty. + + MethodDefinition : ClassElementName (UniqueFormalParameters) { FunctionBody } + 1. Let propKey be the result of evaluating ClassElementName. + ... + 8. Let closure be FunctionCreate(kind, UniqueFormalParameters, FunctionBody, scope, privateScope, strict, prototype). + 9. Perform MakeMethod(closure, object). + 10. Return the Record{[[Key]]: propKey, [[Closure]]: closure}. + + ClassElementName : PrivateIdentifier + 1. Let bindingName be StringValue of PrivateIdentifier. + ... + 5. If scopeEnvRec's binding for bindingName is uninitialized, + a. Let field be NewPrivateName(bindingName). + b. Perform ! scopeEnvRec.InitializeBinding(bindingName, field). + 6. Otherwise, + a. Let field be scopeEnvRec.GetBindingValue(bindingName). + 7. Assert: field.[[Description]] is bindingName. + 8. Return field. + + DefineOrdinaryMethod(key, homeObject, closure, enumerable) + 1. Perform SetFunctionName(closure, key). + 2. If key is a Private Name, + a. Assert: key does not have a [[Kind]] field. + b. Set key.[[Kind]] to "method". + c. Set key.[[Value]] to closure. + d. Set key.[[Brand]] to homeObject. + 3. Else, + a. Let desc be the PropertyDescriptor{[[Value]]: closure, [[Writable]]: true, [[Enumerable]]: enumerable, [[Configurable]]: true}. + b. Perform ? DefinePropertyOrThrow(homeObject, key, desc). + +---*/ + + +class C { + static #method() { + return 'Test262'; + }; + + static getPrivateMethod() { + return this.#method; + } + +} + +assert.sameValue(C.getPrivateMethod().name, "#method"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-static-method-not-writable.js b/js/src/tests/test262/language/statements/class/elements/private-static-method-not-writable.js new file mode 100644 index 0000000000..ce0d1f9cd1 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-static-method-not-writable.js @@ -0,0 +1,33 @@ +// Copyright (C) 2021 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + Throws TypeError when attempting to overwrite a private static method. +esid: sec-privateset +info: | + 7.3.30 PrivateSet ( P, O, value ) + 1. Let entry be ! PrivateElementFind(P, O). + 2. If entry is empty, throw a TypeError exception. + 3. If entry.[[Kind]] is field, then + ... + 4. Else if entry.[[Kind]] is method, then + a. Throw a TypeError exception. + 5. ... + +features: [class, class-static-methods-private] +---*/ + +class C { + static #m() {} + + static assign() { + this.#m = 0; + } +} + +assert.throws(TypeError, function() { + C.assign(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-static-method-shadowed-by-field-on-nested-class.js b/js/src/tests/test262/language/statements/class/elements/private-static-method-shadowed-by-field-on-nested-class.js new file mode 100644 index 0000000000..53efd583e5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-static-method-shadowed-by-field-on-nested-class.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/private-static-method-shadowed-by-field-on-nested-class.case +// - src/class-elements/default/cls-decl.template +/*--- +description: PrivateName of private static method can be shadowed on inner classes by a private field (field definitions in a class declaration) +esid: prod-FieldDefinition +features: [class-static-methods-private, class-static-fields-public, class-fields-private, class] +flags: [generated] +info: | + Updated Productions + + CallExpression[Yield, Await]: + CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await] + SuperCall[?Yield, ?Await] + CallExpression[?Yield, ?Await]Arguments[?Yield, ?Await] + CallExpression[?Yield, ?Await][Expression[+In, ?Yield, ?Await]] + CallExpression[?Yield, ?Await].IdentifierName + CallExpression[?Yield, ?Await]TemplateLiteral[?Yield, ?Await] + CallExpression[?Yield, ?Await].PrivateIdentifier + + ClassTail : ClassHeritage { ClassBody } + ... + 6. Let classPrivateEnvironment be NewDeclarativeEnvironment(outerPrivateEnvironment). + 7. Let classPrivateEnvRec be classPrivateEnvironment's EnvironmentRecord. + ... + 15. Set the running execution context's LexicalEnvironment to classScope. + 16. Set the running execution context's PrivateEnvironment to classPrivateEnvironment. + ... + 33. If PrivateBoundIdentifiers of ClassBody contains a Private Name P such that P's [[Kind]] field is either "method" or "accessor" and P's [[Brand]] is F, + a. PrivateBrandAdd(F, F). + 34. For each item fieldRecord in order from staticFields, + a. Perform ? DefineField(F, field). + + FieldDefinition : ClassElementName Initializer_opt + 1. Let name be the result of evaluating ClassElementName. + 2. ReturnIfAbrupt(name). + 3. If Initializer_opt is present, + a. Let lex be the Lexical Environment of the running execution context. + b. Let formalParameterList be an instance of the production FormalParameters : [empty]. + c. Let privateScope be the PrivateEnvironment of the running execution context. + d. Let initializer be FunctionCreate(Method, formalParameterList, Initializer, lex, true, privateScope). + e. Perform MakeMethod(initializer, homeObject). + f. Let isAnonymousFunctionDefinition be IsAnonymousFunctionDefinition(Initializer). + 4. Else, + a. Let initializer be empty. + b. Let isAnonymousFunctionDeclaration be false. + 5. Return a Record { [[Name]]: name, [[Initializer]]: initializer, [[IsAnonymousFunctionDefinition]]: isAnonymousFunctionDefinition }. + + MemberExpression : MemberExpression.PrivateIdentifier + 1. Let baseReference be the result of evaluating MemberExpression. + 2. Let baseValue be ? GetValue(baseReference). + 3. Let bv be ? RequireObjectCoercible(baseValue). + 4. Let fieldNameString be the StringValue of PrivateIdentifier. + 5. Return MakePrivateReference(bv, fieldNameString). + + MakePrivateReference(baseValue, privateIdentifier) + 1. Let env be the running execution context's PrivateEnvironment. + 2. Let privateNameBinding be ? ResolveBinding(privateIdentifier, env). + 3. Let privateName be GetValue(privateNameBinding). + 4. Assert: privateName is a Private Name. + 5. Return a value of type Reference whose base value is baseValue, whose referenced name is privateName, whose strict reference flag is true. + +---*/ + + +class C { + static #m() { return 'outer class'; } + + static methodAccess() { + return this.#m(); + } + + static B = class { + #m = 'inner class'; + static fieldAccess(o) { + return o.#m; + } + } +} + +assert.sameValue(C.methodAccess(), 'outer class'); + +let b = new C.B(); + +assert.sameValue(C.B.fieldAccess(b), 'inner class'); + +assert.throws(TypeError, function() { + C.B.fieldAccess(C); +}, 'accessed private field from an arbritary object'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-static-method-shadowed-by-getter-on-nested-class.js b/js/src/tests/test262/language/statements/class/elements/private-static-method-shadowed-by-getter-on-nested-class.js new file mode 100644 index 0000000000..f7ad4de011 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-static-method-shadowed-by-getter-on-nested-class.js @@ -0,0 +1,92 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/private-static-method-shadowed-by-getter-on-nested-class.case +// - src/class-elements/default/cls-decl.template +/*--- +description: PrivateName of private static method can be shadowed on inner classes by a private getter (field definitions in a class declaration) +esid: prod-FieldDefinition +features: [class-static-methods-private, class-static-fields-public, class-methods-private, class] +flags: [generated] +info: | + Updated Productions + + CallExpression[Yield, Await]: + CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await] + SuperCall[?Yield, ?Await] + CallExpression[?Yield, ?Await]Arguments[?Yield, ?Await] + CallExpression[?Yield, ?Await][Expression[+In, ?Yield, ?Await]] + CallExpression[?Yield, ?Await].IdentifierName + CallExpression[?Yield, ?Await]TemplateLiteral[?Yield, ?Await] + CallExpression[?Yield, ?Await].PrivateIdentifier + + ClassTail : ClassHeritage { ClassBody } + ... + 6. Let classPrivateEnvironment be NewDeclarativeEnvironment(outerPrivateEnvironment). + 7. Let classPrivateEnvRec be classPrivateEnvironment's EnvironmentRecord. + ... + 15. Set the running execution context's LexicalEnvironment to classScope. + 16. Set the running execution context's PrivateEnvironment to classPrivateEnvironment. + ... + 33. If PrivateBoundIdentifiers of ClassBody contains a Private Name P such that P's [[Kind]] field is either "method" or "accessor" and P's [[Brand]] is F, + a. PrivateBrandAdd(F, F). + 34. For each item fieldRecord in order from staticFields, + a. Perform ? DefineField(F, field). + + FieldDefinition : ClassElementName Initializer_opt + 1. Let name be the result of evaluating ClassElementName. + 2. ReturnIfAbrupt(name). + 3. If Initializer_opt is present, + a. Let lex be the Lexical Environment of the running execution context. + b. Let formalParameterList be an instance of the production FormalParameters : [empty]. + c. Let privateScope be the PrivateEnvironment of the running execution context. + d. Let initializer be FunctionCreate(Method, formalParameterList, Initializer, lex, true, privateScope). + e. Perform MakeMethod(initializer, homeObject). + f. Let isAnonymousFunctionDefinition be IsAnonymousFunctionDefinition(Initializer). + 4. Else, + a. Let initializer be empty. + b. Let isAnonymousFunctionDeclaration be false. + 5. Return a Record { [[Name]]: name, [[Initializer]]: initializer, [[IsAnonymousFunctionDefinition]]: isAnonymousFunctionDefinition }. + + MemberExpression : MemberExpression.PrivateIdentifier + 1. Let baseReference be the result of evaluating MemberExpression. + 2. Let baseValue be ? GetValue(baseReference). + 3. Let bv be ? RequireObjectCoercible(baseValue). + 4. Let fieldNameString be the StringValue of PrivateIdentifier. + 5. Return MakePrivateReference(bv, fieldNameString). + + MakePrivateReference(baseValue, privateIdentifier) + 1. Let env be the running execution context's PrivateEnvironment. + 2. Let privateNameBinding be ? ResolveBinding(privateIdentifier, env). + 3. Let privateName be GetValue(privateNameBinding). + 4. Assert: privateName is a Private Name. + 5. Return a value of type Reference whose base value is baseValue, whose referenced name is privateName, whose strict reference flag is true. + +---*/ + + +class C { + static #m() { return 'outer class'; } + + static methodAccess() { + return this.#m(); + } + + static B = class { + get #m() { return 'inner class'; } + + static access(o) { + return o.#m; + } + } +} + +assert.sameValue(C.methodAccess(), 'outer class'); + +let b = new C.B(); + +assert.sameValue(C.B.access(b), 'inner class'); + +assert.throws(TypeError, function() { + C.B.access(C); +}, 'accessed private getter from an arbritary object'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-static-method-shadowed-by-method-on-nested-class.js b/js/src/tests/test262/language/statements/class/elements/private-static-method-shadowed-by-method-on-nested-class.js new file mode 100644 index 0000000000..6f48d6514e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-static-method-shadowed-by-method-on-nested-class.js @@ -0,0 +1,92 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/private-static-method-shadowed-by-method-on-nested-class.case +// - src/class-elements/default/cls-decl.template +/*--- +description: PrivateName of private static method can be shadowed on inner classes by a private method (field definitions in a class declaration) +esid: prod-FieldDefinition +features: [class-static-methods-private, class-static-fields-public, class-methods-private, class] +flags: [generated] +info: | + Updated Productions + + CallExpression[Yield, Await]: + CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await] + SuperCall[?Yield, ?Await] + CallExpression[?Yield, ?Await]Arguments[?Yield, ?Await] + CallExpression[?Yield, ?Await][Expression[+In, ?Yield, ?Await]] + CallExpression[?Yield, ?Await].IdentifierName + CallExpression[?Yield, ?Await]TemplateLiteral[?Yield, ?Await] + CallExpression[?Yield, ?Await].PrivateIdentifier + + ClassTail : ClassHeritage { ClassBody } + ... + 6. Let classPrivateEnvironment be NewDeclarativeEnvironment(outerPrivateEnvironment). + 7. Let classPrivateEnvRec be classPrivateEnvironment's EnvironmentRecord. + ... + 15. Set the running execution context's LexicalEnvironment to classScope. + 16. Set the running execution context's PrivateEnvironment to classPrivateEnvironment. + ... + 33. If PrivateBoundIdentifiers of ClassBody contains a Private Name P such that P's [[Kind]] field is either "method" or "accessor" and P's [[Brand]] is F, + a. PrivateBrandAdd(F, F). + 34. For each item fieldRecord in order from staticFields, + a. Perform ? DefineField(F, field). + + FieldDefinition : ClassElementName Initializer_opt + 1. Let name be the result of evaluating ClassElementName. + 2. ReturnIfAbrupt(name). + 3. If Initializer_opt is present, + a. Let lex be the Lexical Environment of the running execution context. + b. Let formalParameterList be an instance of the production FormalParameters : [empty]. + c. Let privateScope be the PrivateEnvironment of the running execution context. + d. Let initializer be FunctionCreate(Method, formalParameterList, Initializer, lex, true, privateScope). + e. Perform MakeMethod(initializer, homeObject). + f. Let isAnonymousFunctionDefinition be IsAnonymousFunctionDefinition(Initializer). + 4. Else, + a. Let initializer be empty. + b. Let isAnonymousFunctionDeclaration be false. + 5. Return a Record { [[Name]]: name, [[Initializer]]: initializer, [[IsAnonymousFunctionDefinition]]: isAnonymousFunctionDefinition }. + + MemberExpression : MemberExpression.PrivateIdentifier + 1. Let baseReference be the result of evaluating MemberExpression. + 2. Let baseValue be ? GetValue(baseReference). + 3. Let bv be ? RequireObjectCoercible(baseValue). + 4. Let fieldNameString be the StringValue of PrivateIdentifier. + 5. Return MakePrivateReference(bv, fieldNameString). + + MakePrivateReference(baseValue, privateIdentifier) + 1. Let env be the running execution context's PrivateEnvironment. + 2. Let privateNameBinding be ? ResolveBinding(privateIdentifier, env). + 3. Let privateName be GetValue(privateNameBinding). + 4. Assert: privateName is a Private Name. + 5. Return a value of type Reference whose base value is baseValue, whose referenced name is privateName, whose strict reference flag is true. + +---*/ + + +class C { + static #m() { return 'outer class'; } + + static methodAccess() { + return this.#m(); + } + + static B = class { + #m() { return 'inner class'; } + + static access(o) { + return o.#m(); + } + } +} + +assert.sameValue(C.methodAccess(), 'outer class'); + +let b = new C.B(); + +assert.sameValue(C.B.access(b), 'inner class'); + +assert.throws(TypeError, function() { + C.B.access(C); +}, 'accessed private method from an arbritary object'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-static-method-shadowed-by-setter-on-nested-class.js b/js/src/tests/test262/language/statements/class/elements/private-static-method-shadowed-by-setter-on-nested-class.js new file mode 100644 index 0000000000..47497485d2 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-static-method-shadowed-by-setter-on-nested-class.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/private-static-method-shadowed-by-setter-on-nested-class.case +// - src/class-elements/default/cls-decl.template +/*--- +description: PrivateName of private static method can be shadowed on inner classes by a private setter (field definitions in a class declaration) +esid: prod-FieldDefinition +features: [class-static-methods-private, class-static-fields-public, class-methods-private, class] +flags: [generated] +info: | + Updated Productions + + CallExpression[Yield, Await]: + CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await] + SuperCall[?Yield, ?Await] + CallExpression[?Yield, ?Await]Arguments[?Yield, ?Await] + CallExpression[?Yield, ?Await][Expression[+In, ?Yield, ?Await]] + CallExpression[?Yield, ?Await].IdentifierName + CallExpression[?Yield, ?Await]TemplateLiteral[?Yield, ?Await] + CallExpression[?Yield, ?Await].PrivateIdentifier + + ClassTail : ClassHeritage { ClassBody } + ... + 6. Let classPrivateEnvironment be NewDeclarativeEnvironment(outerPrivateEnvironment). + 7. Let classPrivateEnvRec be classPrivateEnvironment's EnvironmentRecord. + ... + 15. Set the running execution context's LexicalEnvironment to classScope. + 16. Set the running execution context's PrivateEnvironment to classPrivateEnvironment. + ... + 33. If PrivateBoundIdentifiers of ClassBody contains a Private Name P such that P's [[Kind]] field is either "method" or "accessor" and P's [[Brand]] is F, + a. PrivateBrandAdd(F, F). + 34. For each item fieldRecord in order from staticFields, + a. Perform ? DefineField(F, field). + + FieldDefinition : ClassElementName Initializer_opt + 1. Let name be the result of evaluating ClassElementName. + 2. ReturnIfAbrupt(name). + 3. If Initializer_opt is present, + a. Let lex be the Lexical Environment of the running execution context. + b. Let formalParameterList be an instance of the production FormalParameters : [empty]. + c. Let privateScope be the PrivateEnvironment of the running execution context. + d. Let initializer be FunctionCreate(Method, formalParameterList, Initializer, lex, true, privateScope). + e. Perform MakeMethod(initializer, homeObject). + f. Let isAnonymousFunctionDefinition be IsAnonymousFunctionDefinition(Initializer). + 4. Else, + a. Let initializer be empty. + b. Let isAnonymousFunctionDeclaration be false. + 5. Return a Record { [[Name]]: name, [[Initializer]]: initializer, [[IsAnonymousFunctionDefinition]]: isAnonymousFunctionDefinition }. + + MemberExpression : MemberExpression.PrivateIdentifier + 1. Let baseReference be the result of evaluating MemberExpression. + 2. Let baseValue be ? GetValue(baseReference). + 3. Let bv be ? RequireObjectCoercible(baseValue). + 4. Let fieldNameString be the StringValue of PrivateIdentifier. + 5. Return MakePrivateReference(bv, fieldNameString). + + MakePrivateReference(baseValue, privateIdentifier) + 1. Let env be the running execution context's PrivateEnvironment. + 2. Let privateNameBinding be ? ResolveBinding(privateIdentifier, env). + 3. Let privateName be GetValue(privateNameBinding). + 4. Assert: privateName is a Private Name. + 5. Return a value of type Reference whose base value is baseValue, whose referenced name is privateName, whose strict reference flag is true. + +---*/ + + +class C { + static #m() { return 'outer class'; } + + static methodAccess() { + return this.#m(); + } + + static B = class { + set #m(v) { this._v = v; } + + static access(o) { + o.#m = 'inner class'; + } + } +} + +assert.sameValue(C.methodAccess(), 'outer class'); + +let b = new C.B(); + +C.B.access(b); +assert.sameValue(b._v, 'inner class'); + +assert.throws(TypeError, function() { + C.B.access(C); +}, 'accessed private setter from an arbritary object'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-static-method-usage-inside-nested-class.js b/js/src/tests/test262/language/statements/class/elements/private-static-method-usage-inside-nested-class.js new file mode 100644 index 0000000000..3bbf3d5462 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-static-method-usage-inside-nested-class.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/private-static-method-usage-inside-nested-class.case +// - src/class-elements/default/cls-decl.template +/*--- +description: PrivateName of private static method is available inside inner classes (field definitions in a class declaration) +esid: prod-FieldDefinition +features: [class-static-methods-private, class-static-fields-public, class] +flags: [generated] +info: | + Updated Productions + + CallExpression[Yield, Await]: + CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await] + SuperCall[?Yield, ?Await] + CallExpression[?Yield, ?Await]Arguments[?Yield, ?Await] + CallExpression[?Yield, ?Await][Expression[+In, ?Yield, ?Await]] + CallExpression[?Yield, ?Await].IdentifierName + CallExpression[?Yield, ?Await]TemplateLiteral[?Yield, ?Await] + CallExpression[?Yield, ?Await].PrivateIdentifier + + ClassTail : ClassHeritage { ClassBody } + ... + 6. Let classPrivateEnvironment be NewDeclarativeEnvironment(outerPrivateEnvironment). + 7. Let classPrivateEnvRec be classPrivateEnvironment's EnvironmentRecord. + ... + 15. Set the running execution context's LexicalEnvironment to classScope. + 16. Set the running execution context's PrivateEnvironment to classPrivateEnvironment. + ... + 33. If PrivateBoundIdentifiers of ClassBody contains a Private Name P such that P's [[Kind]] field is either "method" or "accessor" and P's [[Brand]] is F, + a. PrivateBrandAdd(F, F). + 34. For each item fieldRecord in order from staticFields, + a. Perform ? DefineField(F, field). + + FieldDefinition : ClassElementName Initializer_opt + 1. Let name be the result of evaluating ClassElementName. + 2. ReturnIfAbrupt(name). + 3. If Initializer_opt is present, + a. Let lex be the Lexical Environment of the running execution context. + b. Let formalParameterList be an instance of the production FormalParameters : [empty]. + c. Let privateScope be the PrivateEnvironment of the running execution context. + d. Let initializer be FunctionCreate(Method, formalParameterList, Initializer, lex, true, privateScope). + e. Perform MakeMethod(initializer, homeObject). + f. Let isAnonymousFunctionDefinition be IsAnonymousFunctionDefinition(Initializer). + 4. Else, + a. Let initializer be empty. + b. Let isAnonymousFunctionDeclaration be false. + 5. Return a Record { [[Name]]: name, [[Initializer]]: initializer, [[IsAnonymousFunctionDefinition]]: isAnonymousFunctionDefinition }. + + MemberExpression : MemberExpression.PrivateIdentifier + 1. Let baseReference be the result of evaluating MemberExpression. + 2. Let baseValue be ? GetValue(baseReference). + 3. Let bv be ? RequireObjectCoercible(baseValue). + 4. Let fieldNameString be the StringValue of PrivateIdentifier. + 5. Return MakePrivateReference(bv, fieldNameString). + + MakePrivateReference(baseValue, privateIdentifier) + 1. Let env be the running execution context's PrivateEnvironment. + 2. Let privateNameBinding be ? ResolveBinding(privateIdentifier, env). + 3. Let privateName be GetValue(privateNameBinding). + 4. Assert: privateName is a Private Name. + 5. Return a value of type Reference whose base value is baseValue, whose referenced name is privateName, whose strict reference flag is true. + +---*/ + + +class C { + static #m() { + return 'outer class'; + } + + static B = class { + static methodAccess(o) { + return o.#m(); + } + } +} + +assert.sameValue(C.B.methodAccess(C), 'outer class'); +assert.throws(TypeError, function() { + C.B.methodAccess(C.B); +}, 'accessed static private method from an arbritary object'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-static-method-visible-to-direct-eval.js b/js/src/tests/test262/language/statements/class/elements/private-static-method-visible-to-direct-eval.js new file mode 100644 index 0000000000..01d010c80f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-static-method-visible-to-direct-eval.js @@ -0,0 +1,63 @@ +// Copyright (C) 2019 Caio Lima (Igalia SL). All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Private static method is visible to direct eval code +esid: sec-privatefieldget +info: | + PrivateFieldGet (P, O) + 1. Assert: P is a Private Name. + 2. If O is not an object, throw a TypeError exception. + 3. If P.[[Kind]] is "field", + a. Let entry be PrivateFieldFind(P, O). + b. If entry is empty, throw a TypeError exception. + c. Return entry.[[PrivateFieldValue]]. + 4. Perform ? PrivateBrandCheck(O, P). + 5. If P.[[Kind]] is "method", + a. Return P.[[Value]]. + 6. Else, + a. Assert: P.[[Kind]] is "accessor". + b. If P does not have a [[Get]] field, throw a TypeError exception. + c. Let getter be P.[[Get]]. + d. Return ? Call(getter, O). + + ClassElementName : PrivateIdentifier + 1. Let privateIdentifier be StringValue of PrivateIdentifier. + 2. Let privateName be NewPrivateName(privateIdentifier). + 3. Let scope be the running execution context's PrivateEnvironment. + 4. Let scopeEnvRec be scope's EnvironmentRecord. + 5. Perform ! scopeEnvRec.InitializeBinding(privateIdentifier, privateName). + 6. Return privateName. + + MakePrivateReference ( baseValue, privateIdentifier ) + 1. Let env be the running execution context's PrivateEnvironment. + 2. Let privateNameBinding be ? ResolveBinding(privateIdentifier, env). + 3. Let privateName be GetValue(privateNameBinding). + 4. Assert: privateName is a Private Name. + 5. Return a value of type Reference whose base value is baseValue, whose referenced name is privateName, whose strict reference flag is true. +features: [class-static-methods-private, class] +---*/ + +class C { + static #m() { + return "Test262"; + } + + static accessWithEval() { + return eval("this.#m()"); + } +} + +class D { + static #m() { + throw new Test262Error(); + } +} + +assert.sameValue(C.accessWithEval(), "Test262"); + +assert.throws(TypeError, function() { + C.accessWithEval.call(D); +}, "invalid access to a private field"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-static-setter-abrupt-completition.js b/js/src/tests/test262/language/statements/class/elements/private-static-setter-abrupt-completition.js new file mode 100644 index 0000000000..14afc2640f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-static-setter-abrupt-completition.js @@ -0,0 +1,42 @@ +// Copyright (C) 2019 Caio Lima (Igalia SL). All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: PrivateFieldSet should return an abrupt completion +esid: sec-privatefieldset +info: | + PrivateFieldSet (P, O, value) + 1. Assert: P is a Private Name. + 2. If O is not an object, throw a TypeError exception. + 3. If P.[[Kind]] is "field", + a. Let entry be PrivateFieldFind(P, O). + b. If entry is empty, throw a TypeError exception. + c. Set entry.[[PrivateFieldValue]] to value. + d. Return. + 4. If P.[[Kind]] is "method", throw a TypeError exception. + 5. Else, + a. Assert: P.[[Kind]] is "accessor". + b. If O.[[PrivateFieldBrands]] does not contain P.[[Brand]], throw a TypeError exception. + c. If P does not have a [[Set]] field, throw a TypeError exception. + d. Let setter be P.[[Set]]. + e. Perform ? Call(setter, O, value). + f. Return. +features: [class-methods-private, class] +---*/ + +class C { + set #m(_) { + throw new Test262Error(); + } + + access() { + this.#m = 'Test262'; + } +} + +let c = new C(); +assert.throws(Test262Error, function() { + c.access(); +}, 'private setter should have abrupt completion'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-static-setter-visible-to-direct-eval.js b/js/src/tests/test262/language/statements/class/elements/private-static-setter-visible-to-direct-eval.js new file mode 100644 index 0000000000..e4205b729d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-static-setter-visible-to-direct-eval.js @@ -0,0 +1,64 @@ +// Copyright (C) 2019 Caio Lima (Igalia SL). All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Private static setter is visible to direct eval code +esid: sec-privatefieldget +info: | + PrivateFieldGet (P, O) + 1. Assert: P is a Private Name. + 2. If O is not an object, throw a TypeError exception. + 3. If P.[[Kind]] is "field", + a. Let entry be PrivateFieldFind(P, O). + b. If entry is empty, throw a TypeError exception. + c. Return entry.[[PrivateFieldValue]]. + 4. Perform ? PrivateBrandCheck(O, P). + 5. If P.[[Kind]] is "method", + a. Return P.[[Value]]. + 6. Else, + a. Assert: P.[[Kind]] is "accessor". + b. If P does not have a [[Get]] field, throw a TypeError exception. + c. Let getter be P.[[Get]]. + d. Return ? Call(getter, O). + + ClassElementName : PrivateIdentifier + 1. Let privateIdentifier be StringValue of PrivateIdentifier. + 2. Let privateName be NewPrivateName(privateIdentifier). + 3. Let scope be the running execution context's PrivateEnvironment. + 4. Let scopeEnvRec be scope's EnvironmentRecord. + 5. Perform ! scopeEnvRec.InitializeBinding(privateIdentifier, privateName). + 6. Return privateName. + + MakePrivateReference ( baseValue, privateIdentifier ) + 1. Let env be the running execution context's PrivateEnvironment. + 2. Let privateNameBinding be ? ResolveBinding(privateIdentifier, env). + 3. Let privateName be GetValue(privateNameBinding). + 4. Assert: privateName is a Private Name. + 5. Return a value of type Reference whose base value is baseValue, whose referenced name is privateName, whose strict reference flag is true. +features: [class-static-methods-private, class] +---*/ + +class C { + static set #m(v) { + this._v = v; + } + + static setWithEval() { + eval('this.#m = "Test262"'); + } +} + +class D { + static set #m(v) { + throw new Test262Error('should never be called'); + } +} + +C.setWithEval(); +assert.sameValue(C._v, 'Test262'); + +assert.throws(TypeError, function() { + C.getWithEval.call(D); +}, 'invalid access to a static private getter'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/private-ternary-init-err-contains-arguments.js b/js/src/tests/test262/language/statements/class/elements/private-ternary-init-err-contains-arguments.js new file mode 100644 index 0000000000..3d409fceb2 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-ternary-init-err-contains-arguments.js @@ -0,0 +1,35 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/init-err-contains-arguments.case +// - src/class-elements/initializer-error/cls-decl-fields-private-ternary.template +/*--- +description: Syntax error if `arguments` used in class field (private field, ternary expression) +esid: sec-class-definitions-static-semantics-early-errors +features: [class, class-fields-public, class-fields-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Static Semantics: Early Errors + + FieldDefinition: + PropertyNameInitializeropt + + - It is a Syntax Error if ContainsArguments of Initializer is true. + + Static Semantics: ContainsArguments + IdentifierReference : Identifier + + 1. If the StringValue of Identifier is "arguments", return true. + ... + For all other grammatical productions, recurse on all nonterminals. If any piece returns true, then return true. Otherwise return false. + +---*/ + + +$DONOTEVALUATE(); + +class C { + #x = false ? {} : arguments; +} diff --git a/js/src/tests/test262/language/statements/class/elements/private-ternary-init-err-contains-super.js b/js/src/tests/test262/language/statements/class/elements/private-ternary-init-err-contains-super.js new file mode 100644 index 0000000000..4f82a572ae --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-ternary-init-err-contains-super.js @@ -0,0 +1,28 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/init-err-contains-super.case +// - src/class-elements/initializer-error/cls-decl-fields-private-ternary.template +/*--- +description: Syntax error if `super()` used in class field (private field, ternary expression) +esid: sec-class-definitions-static-semantics-early-errors +features: [class, class-fields-public, class-fields-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Static Semantics: Early Errors + + FieldDefinition: + PropertyNameInitializeropt + + - It is a Syntax Error if Initializer is present and Initializer Contains SuperCall is true. + +---*/ + + +$DONOTEVALUATE(); + +class C { + #x = false ? {} : super(); +} diff --git a/js/src/tests/test262/language/statements/class/elements/private-typeof-init-err-contains-arguments.js b/js/src/tests/test262/language/statements/class/elements/private-typeof-init-err-contains-arguments.js new file mode 100644 index 0000000000..b2a0a1fe0e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-typeof-init-err-contains-arguments.js @@ -0,0 +1,35 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/init-err-contains-arguments.case +// - src/class-elements/initializer-error/cls-decl-fields-private-typeof.template +/*--- +description: Syntax error if `arguments` used in class field (private field, typeof expression) +esid: sec-class-definitions-static-semantics-early-errors +features: [class, class-fields-public, class-fields-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Static Semantics: Early Errors + + FieldDefinition: + PropertyNameInitializeropt + + - It is a Syntax Error if ContainsArguments of Initializer is true. + + Static Semantics: ContainsArguments + IdentifierReference : Identifier + + 1. If the StringValue of Identifier is "arguments", return true. + ... + For all other grammatical productions, recurse on all nonterminals. If any piece returns true, then return true. Otherwise return false. + +---*/ + + +$DONOTEVALUATE(); + +class C { + #x = typeof arguments; +} diff --git a/js/src/tests/test262/language/statements/class/elements/private-typeof-init-err-contains-super.js b/js/src/tests/test262/language/statements/class/elements/private-typeof-init-err-contains-super.js new file mode 100644 index 0000000000..d3ab2de187 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/private-typeof-init-err-contains-super.js @@ -0,0 +1,28 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/init-err-contains-super.case +// - src/class-elements/initializer-error/cls-decl-fields-private-typeof.template +/*--- +description: Syntax error if `super()` used in class field (private field, typeof expression) +esid: sec-class-definitions-static-semantics-early-errors +features: [class, class-fields-public, class-fields-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Static Semantics: Early Errors + + FieldDefinition: + PropertyNameInitializeropt + + - It is a Syntax Error if Initializer is present and Initializer Contains SuperCall is true. + +---*/ + + +$DONOTEVALUATE(); + +class C { + #x = typeof super(); +} diff --git a/js/src/tests/test262/language/statements/class/elements/privatefield-on-proxy.js b/js/src/tests/test262/language/statements/class/elements/privatefield-on-proxy.js new file mode 100644 index 0000000000..0fa28efac7 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/privatefield-on-proxy.js @@ -0,0 +1,55 @@ +// Copyright (C) 2019 Caio Lima. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Sucessyfully get private reference without using [[Get]] +esid: sec-getvalue +info: | + GetValue(V) + ... + 5. If IsPropertyReference(V), then + ... + b. If IsPrivateReference(V), then + i. Let env be the running execution context's PrivateNameEnvironment. + ii. Let field be ? ResolveBinding(GetReferencedName(V), env). + iii. Assert: field is a Private Name. + iv. Return ? PrivateFieldGet(field, base). + c. Return ? base.[[Get]](GetReferencedName(V), GetThisValue(V)). + PrivateFieldGet(P, O) + 1. Assert: P is a Private Name value. + 2. If O is not an object, throw a TypeError exception. + 3. Let entry be PrivateFieldFind(P, O). + 4. If entry is empty, throw a TypeError exception. + 5. Return entry.[[PrivateFieldValue]]. +includes: [compareArray.js] +features: [class, class-fields-private, Proxy] +---*/ + +let arr = []; + +class ProxyBase { + constructor() { + return new Proxy(this, { + get: function (obj, prop) { + arr.push(prop); + return obj[prop]; + } + }); + } +} + +class Test extends ProxyBase { + #f = 3; + method() { + return this.#f; + } +} + +let t = new Test(); +let r = t.method(); +assert.sameValue(r, 3); + +assert.compareArray(arr, ['method']); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/privatefieldadd-typeerror.js b/js/src/tests/test262/language/statements/class/elements/privatefieldadd-typeerror.js new file mode 100644 index 0000000000..6bd7feb092 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/privatefieldadd-typeerror.js @@ -0,0 +1,63 @@ +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Class construction should error if attempting to add private field twice +esid: sec-ecmascript-function-objects-construct-argumentslist-newtarget +info: | + [[Construct]] ( argumentsList, newTarget) + ... + 8. If kind is "base", then + a. Perform OrdinaryCallBindThis(F, calleeContext, thisArgument). + b. Let result be InitializeInstanceFields(thisArgument, F). + c. If result is an abrupt completion, then + i. Remove calleeContext from execution context stack and restore callerContext as the running execution context. + ii. Return Completion(result). + + InitializeInstanceFields ( O, constructor ) + 1. Assert: Type ( O ) is Object. + 2. Assert: Assert constructor is an ECMAScript function object. + 3. Let fieldRecords be the value of constructor's [[Fields]] internal slot. + 4. For each item fieldRecord in order from fieldRecords, + a. Perform ? DefineField(O, fieldRecord). + 5. Return. + + DefineField(receiver, fieldRecord) + ... + 8. If fieldName is a Private Name, + a. Perform ? PrivateFieldAdd(fieldName, receiver, initValue). + + PrivateFieldAdd (P, O, value) + 1. Assert: P is a Private Name value. + 2. If O is not an object, throw a TypeError exception. + 3. Let entry be PrivateFieldFind(P, O). + 4. If entry is not empty, throw a TypeError exception. + ... + +features: [class, class-fields-private] +---*/ + + +class A { + constructor(arg) { + return arg; + } +} + +class C extends A { + #x; + + constructor(arg) { + super(arg); + } +} + +var containsprivatex = new C(); + +assert.throws(TypeError, function() { + // After the super call in C's constructor, the `this` value in C will + // already have "#x" in it's [[PrivateFieldValues]] + new C(containsprivatex); +}) + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/privatefieldget-primitive-receiver.js b/js/src/tests/test262/language/statements/class/elements/privatefieldget-primitive-receiver.js new file mode 100644 index 0000000000..2b56307e8c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/privatefieldget-primitive-receiver.js @@ -0,0 +1,78 @@ +// Copyright (C) 2020 Caio Lima (Igalia S.L). All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: PrivateField calls ToObject when receiver is a primitive +esid: sec-getvalue +info: | + GetValue ( V ) + ... + 5. If IsPropertyReference(V), then + a. If HasPrimitiveBase(V), then + i. Assert: In this case, base will never be null or undefined. + ii. Let base be ToObject(base). + b. If IsPrivateReference(V), then + i. Return ? PrivateFieldGet(field, base). + ... + + PrivateFieldGet (P, O ) + 1. Assert: P is a Private Name value. + 2. If O is not an object, throw a TypeError exception. + 3. Let entry be PrivateFieldFind(P, O). + 4. If entry is empty, throw a TypeError exception. + 5. Return entry.[[PrivateFieldValue]]. + +features: [class, class-fields-private, BigInt] +---*/ + +let count = 0; + +class C { + #p = 1; + + method() { + count++; + try { + count++; + this.#p; + } catch (e) { + count++; + if (e instanceof TypeError) { + throw new Test262Error(); + } + } + } +} + +assert.throws(Test262Error, () => { + new C().method.call(15); +}); +assert.sameValue(count, 3); + +assert.throws(Test262Error, () => { + new C().method.call('Test262'); +}); +assert.sameValue(count, 6); + +assert.throws(Test262Error, () => { + new C().method.call(Symbol('Test262')); +}); +assert.sameValue(count, 9); + +assert.throws(Test262Error, () => { + new C().method.call(15n); +}); +assert.sameValue(count, 12); + +assert.throws(Test262Error, () => { + new C().method.call(null); +}); +assert.sameValue(count, 15); + +assert.throws(Test262Error, () => { + new C().method.call(undefined); +}); +assert.sameValue(count, 18); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/privatefieldget-success-1.js b/js/src/tests/test262/language/statements/class/elements/privatefieldget-success-1.js new file mode 100644 index 0000000000..c53b93740c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/privatefieldget-success-1.js @@ -0,0 +1,48 @@ +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Successfully access private field +esid: sec-getvalue +info: | + GetValue ( V ) + ... + 5. If IsPropertyReference(V), then + ... + b. If IsPrivateReference(V), then + i. Let env be the running execution context's PrivateNameEnvironment. + ii. Let field be ? ResolveBinding(GetReferencedName(V), env). + iii. Assert: field is a Private Name. + iv. Return ? PrivateFieldGet(field, base). + + PrivateFieldGet (P, O ) + 1. Assert: P is a Private Name value. + 2. If O is not an object, throw a TypeError exception. + 3. Let entry be PrivateFieldFind(P, O). + 4. If entry is empty, throw a TypeError exception. + 5. Return entry.[[PrivateFieldValue]]. + +features: [class, class-fields-private] +---*/ + +class Outer { + #x = 42; + + innerclass() { + var self = this; + + return class extends Outer { + f() { + return self.#x; + } + } + } +} + +var Inner = new Outer().innerclass(); +var i = new Inner(); +var value = i.f(); + +assert.sameValue(value, 42) + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/privatefieldget-success-2.js b/js/src/tests/test262/language/statements/class/elements/privatefieldget-success-2.js new file mode 100644 index 0000000000..e839d3594e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/privatefieldget-success-2.js @@ -0,0 +1,46 @@ +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Successfully access private field +esid: sec-getvalue +info: | + GetValue ( V ) + ... + 5. If IsPropertyReference(V), then + ... + b. If IsPrivateReference(V), then + i. Let env be the running execution context's PrivateNameEnvironment. + ii. Let field be ? ResolveBinding(GetReferencedName(V), env). + iii. Assert: field is a Private Name. + iv. Return ? PrivateFieldGet(field, base). + + PrivateFieldGet (P, O ) + 1. Assert: P is a Private Name value. + 2. If O is not an object, throw a TypeError exception. + 3. Let entry be PrivateFieldFind(P, O). + 4. If entry is empty, throw a TypeError exception. + 5. Return entry.[[PrivateFieldValue]]. + +features: [class, class-fields-private] +---*/ + + +class A { + #x = 'Avalue'; + x() { + return this.#x; + } +} +class B extends A { + #x = 'Bvalue'; + x() { + return this.#x; + } +} + +var b = new B(); + +assert.sameValue(b.x(), 'Bvalue') + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/privatefieldget-success-3.js b/js/src/tests/test262/language/statements/class/elements/privatefieldget-success-3.js new file mode 100644 index 0000000000..73bcffa0cf --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/privatefieldget-success-3.js @@ -0,0 +1,43 @@ +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Successfully access private field +esid: sec-getvalue +info: | + GetValue ( V ) + ... + 5. If IsPropertyReference(V), then + ... + b. If IsPrivateReference(V), then + i. Let env be the running execution context's PrivateNameEnvironment. + ii. Let field be ? ResolveBinding(GetReferencedName(V), env). + iii. Assert: field is a Private Name. + iv. Return ? PrivateFieldGet(field, base). + + PrivateFieldGet (P, O ) + 1. Assert: P is a Private Name value. + 2. If O is not an object, throw a TypeError exception. + 3. Let entry be PrivateFieldFind(P, O). + 4. If entry is empty, throw a TypeError exception. + 5. Return entry.[[PrivateFieldValue]]. + +features: [class, class-fields-private] +---*/ + + +class A { + #x = 'Avalue'; + x() { + return this.#x; + } +} +class B extends A { + #x = 'Bvalue'; +} + +var b = new B(); + +assert.sameValue(b.x(), 'Avalue') + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/privatefieldget-success-4.js b/js/src/tests/test262/language/statements/class/elements/privatefieldget-success-4.js new file mode 100644 index 0000000000..9ba095942e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/privatefieldget-success-4.js @@ -0,0 +1,42 @@ +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Successfully access private field +esid: sec-getvalue +info: | + GetValue ( V ) + ... + 5. If IsPropertyReference(V), then + ... + b. If IsPrivateReference(V), then + i. Let env be the running execution context's PrivateNameEnvironment. + ii. Let field be ? ResolveBinding(GetReferencedName(V), env). + iii. Assert: field is a Private Name. + iv. Return ? PrivateFieldGet(field, base). + + PrivateFieldGet (P, O ) + 1. Assert: P is a Private Name value. + 2. If O is not an object, throw a TypeError exception. + 3. Let entry be PrivateFieldFind(P, O). + 4. If entry is empty, throw a TypeError exception. + 5. Return entry.[[PrivateFieldValue]]. + +features: [class, class-fields-private] +---*/ + + +class A { + #x = 'Avalue'; + x() { + return this.#x; + } +} +class B extends A { +} + +var b = new B(); + +assert.sameValue(b.x(), 'Avalue') + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/privatefieldget-success-5.js b/js/src/tests/test262/language/statements/class/elements/privatefieldget-success-5.js new file mode 100644 index 0000000000..3863cefd40 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/privatefieldget-success-5.js @@ -0,0 +1,42 @@ +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Successfully access private field +esid: sec-getvalue +info: | + GetValue ( V ) + ... + 5. If IsPropertyReference(V), then + ... + b. If IsPrivateReference(V), then + i. Let env be the running execution context's PrivateNameEnvironment. + ii. Let field be ? ResolveBinding(GetReferencedName(V), env). + iii. Assert: field is a Private Name. + iv. Return ? PrivateFieldGet(field, base). + + PrivateFieldGet (P, O ) + 1. Assert: P is a Private Name value. + 2. If O is not an object, throw a TypeError exception. + 3. Let entry be PrivateFieldFind(P, O). + 4. If entry is empty, throw a TypeError exception. + 5. Return entry.[[PrivateFieldValue]]. + +features: [class, class-fields-private] +---*/ + + +class C { + #x = 42; + f() { + return this.#x; + } +} + +var c1 = new C(); +var c2 = new C(); +var value = c2.f.call(c1); + +assert.sameValue(value, 42); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/privatefieldget-typeerror-1.js b/js/src/tests/test262/language/statements/class/elements/privatefieldget-typeerror-1.js new file mode 100644 index 0000000000..69f6e48525 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/privatefieldget-typeerror-1.js @@ -0,0 +1,41 @@ +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Cannot access private field before the entry was added to [[PrivateFieldValues]] +esid: sec-getvalue +info: | + GetValue ( V ) + ... + 5. If IsPropertyReference(V), then + ... + b. If IsPrivateReference(V), then + i. Let env be the running execution context's PrivateNameEnvironment. + ii. Let field be ? ResolveBinding(GetReferencedName(V), env). + iii. Assert: field is a Private Name. + iv. Return ? PrivateFieldGet(field, base). + + PrivateFieldGet (P, O ) + 1. Assert: P is a Private Name value. + 2. If O is not an object, throw a TypeError exception. + 3. Let entry be PrivateFieldFind(P, O). + 4. If entry is empty, throw a TypeError exception. + + PrivateFieldFind (P, O) + 1. Assert: P is a Private Name value. + 2. Assert: O is an object with a [[PrivateFieldValues]] internal slot. + 3. For each element entry in O.[[PrivateFieldValues]], + a. If entry.[[PrivateName]] is P, return entry. + 4. Return empty. + +features: [class, class-fields-private, class-fields-public] +---*/ + +class C { + y = this.#x; + #x; +} + +assert.throws(TypeError, function() { new C(); }) + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/privatefieldget-typeerror-2.js b/js/src/tests/test262/language/statements/class/elements/privatefieldget-typeerror-2.js new file mode 100644 index 0000000000..1a36416cfa --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/privatefieldget-typeerror-2.js @@ -0,0 +1,57 @@ +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: TypeError when referenced private field cannot be found in `this`'s [[PrivateFieldValues]] +esid: sec-getvalue +info: | + GetValue ( V ) + ... + 5. If IsPropertyReference(V), then + ... + b. If IsPrivateReference(V), then + i. Let env be the running execution context's PrivateNameEnvironment. + ii. Let field be ? ResolveBinding(GetReferencedName(V), env). + iii. Assert: field is a Private Name. + iv. Return ? PrivateFieldGet(field, base). + + PrivateFieldGet (P, O ) + 1. Assert: P is a Private Name value. + 2. If O is not an object, throw a TypeError exception. + 3. Let entry be PrivateFieldFind(P, O). + 4. If entry is empty, throw a TypeError exception. + + PrivateFieldFind (P, O) + 1. Assert: P is a Private Name value. + 2. Assert: O is an object with a [[PrivateFieldValues]] internal slot. + 3. For each element entry in O.[[PrivateFieldValues]], + a. If entry.[[PrivateName]] is P, return entry. + 4. Return empty. + +features: [class, class-fields-private] +---*/ + +class Outer { + #x = 42; + + innerclass() { + + // create class within in Outerclass -- the PrivateNameEnvironment binding for + // private field `#x` is resolvable. + return class { + f() { + return this.#x; + } + } + } +} + +var Inner = new Outer().innerclass(); +var i = new Inner(); + +assert.throws(TypeError, function() { + // when f() is called, the private field will not be found in Inner's `this` + i.f(); +}) + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/privatefieldget-typeerror-3.js b/js/src/tests/test262/language/statements/class/elements/privatefieldget-typeerror-3.js new file mode 100644 index 0000000000..979a4c263a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/privatefieldget-typeerror-3.js @@ -0,0 +1,55 @@ +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + Referenced lexically scoped private field found in `this`'s [[PrivateFieldValues]] +esid: sec-getvalue +info: | + GetValue ( V ) + ... + 5. If IsPropertyReference(V), then + ... + b. If IsPrivateReference(V), then + i. Let env be the running execution context's PrivateNameEnvironment. + ii. Let field be ? ResolveBinding(GetReferencedName(V), env). + iii. Assert: field is a Private Name. + iv. Return ? PrivateFieldGet(field, base). + + PrivateFieldGet (P, O ) + 1. Assert: P is a Private Name value. + 2. If O is not an object, throw a TypeError exception. + 3. Let entry be PrivateFieldFind(P, O). + 4. If entry is empty, throw a TypeError exception. + + PrivateFieldFind (P, O) + 1. Assert: P is a Private Name value. + 2. Assert: O is an object with a [[PrivateFieldValues]] internal slot. + 3. For each element entry in O.[[PrivateFieldValues]], + a. If entry.[[PrivateName]] is P, return entry. + 4. Return empty. + +features: [class, class-fields-private] +---*/ + +class Outer { + #x = 42; + + innerclass() { + + // create class within in Outerclass -- the PrivateNameEnvironment binding for + // private field `#x` is resolvable. + return class extends Outer { + f() { + return this.#x; + } + } + } +} + +var Inner = new Outer().innerclass(); +var i = new Inner(); + +assert.sameValue(i.f(), 42); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/privatefieldget-typeerror-4.js b/js/src/tests/test262/language/statements/class/elements/privatefieldget-typeerror-4.js new file mode 100644 index 0000000000..878296ac4c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/privatefieldget-typeerror-4.js @@ -0,0 +1,55 @@ +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: TypeError when referenced private field cannot be found in `this`'s [[PrivateFieldValues]] +esid: sec-getvalue +info: | + GetValue ( V ) + ... + 5. If IsPropertyReference(V), then + ... + b. If IsPrivateReference(V), then + i. Let env be the running execution context's PrivateNameEnvironment. + ii. Let field be ? ResolveBinding(GetReferencedName(V), env). + iii. Assert: field is a Private Name. + iv. Return ? PrivateFieldGet(field, base). + + PrivateFieldGet (P, O ) + 1. Assert: P is a Private Name value. + 2. If O is not an object, throw a TypeError exception. + 3. Let entry be PrivateFieldFind(P, O). + 4. If entry is empty, throw a TypeError exception. + + PrivateFieldFind (P, O) + 1. Assert: P is a Private Name value. + 2. Assert: O is an object with a [[PrivateFieldValues]] internal slot. + 3. For each element entry in O.[[PrivateFieldValues]], + a. If entry.[[PrivateName]] is P, return entry. + 4. Return empty. + +features: [class, class-fields-private] +---*/ + +function classfactory() { + return class { + #x; + f() { + this.#x; + } + } +} + +var C1 = classfactory(); +var C2 = classfactory(); + +var c1 = new C1(); +var c2 = new C2(); + +assert.throws(TypeError, function() { + // when f() is called in class C1, the Private Name binding for #x in C1 will + // not found in C2's [[PrivateNameValues]] + c1.f.call(c2); +}) + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/privatefieldget-typeerror-5.js b/js/src/tests/test262/language/statements/class/elements/privatefieldget-typeerror-5.js new file mode 100644 index 0000000000..11eb32250d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/privatefieldget-typeerror-5.js @@ -0,0 +1,60 @@ +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: TypeError when referenced private field cannot be found in `this`'s [[PrivateFieldValues]] +esid: sec-getvalue +info: | + GetValue ( V ) + ... + 5. If IsPropertyReference(V), then + ... + b. If IsPrivateReference(V), then + i. Let env be the running execution context's PrivateNameEnvironment. + ii. Let field be ? ResolveBinding(GetReferencedName(V), env). + iii. Assert: field is a Private Name. + iv. Return ? PrivateFieldGet(field, base). + + PrivateFieldGet (P, O ) + 1. Assert: P is a Private Name value. + 2. If O is not an object, throw a TypeError exception. + 3. Let entry be PrivateFieldFind(P, O). + 4. If entry is empty, throw a TypeError exception. + + PrivateFieldFind (P, O) + 1. Assert: P is a Private Name value. + 2. Assert: O is an object with a [[PrivateFieldValues]] internal slot. + 3. For each element entry in O.[[PrivateFieldValues]], + a. If entry.[[PrivateName]] is P, return entry. + 4. Return empty. + +features: [class, class-fields-private] +---*/ + +class Outer { + #x = 42; + + innerclass() { + var self = this; + + return class extends Outer { + #x = 'not42'; + f() { + return self.#x; + } + } + } +} + +var Inner = new Outer().innerclass(); +var i = new Inner(); + +assert.throws(TypeError, function() { + // when f() is called, the entry in the PrivateNameEnironment's environment + // record for '#x' will contain the Inner class's Private Name for '#x'. + // When this Private Name is used for lookup on the `self` object, it + // will not be found (as the `self` object has the Outer's Private Name for #x) + i.f(); +}) + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/privatefieldput-primitive-receiver.js b/js/src/tests/test262/language/statements/class/elements/privatefieldput-primitive-receiver.js new file mode 100644 index 0000000000..13f25a19b4 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/privatefieldput-primitive-receiver.js @@ -0,0 +1,78 @@ +// Copyright (C) 2020 Caio Lima (Igalia S.L). All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: PrivateField calls ToObject when receiver is a primitive +esid: sec-putvalue +info: | + PutValue ( V, W ) + ... + 6. If IsPropertyReference(V), then + a. If HasPrimitiveBase(V), then + i. Assert: In this case, base will never be null or undefined. + ii. Let base be ToObject(base). + b. If IsPrivateReference(V), then + i. Return ? PrivateFieldSet(field, base, W). + ... + + PrivateFieldSet (P, O, value ) + 1. Assert: P is a Private Name. + 2. Assert: Type(O) is Object. + 3. Let entry be PrivateFieldFind(P, O). + 4. If entry is empty, throw a TypeError exception. + 5. Set entry.[[PrivateFieldValue]] to value. + +features: [class, class-fields-private, BigInt] +---*/ + +let count = 0; + +class C { + #p = 1; + + method(v) { + count++; + try { + count++; + this.#p = v; + } catch (e) { + count++; + if (e instanceof TypeError) { + throw new Test262Error(); + } + } + } +} + +assert.throws(Test262Error, () => { + new C().method.call(15, 0); +}); +assert.sameValue(count, 3); + +assert.throws(Test262Error, () => { + new C().method.call('Test262', 0); +}); +assert.sameValue(count, 6); + +assert.throws(Test262Error, () => { + new C().method.call(Symbol('Test262'), 0); +}); +assert.sameValue(count, 9); + +assert.throws(Test262Error, () => { + new C().method.call(15n, 0); +}); +assert.sameValue(count, 12); + +assert.throws(Test262Error, () => { + new C().method.call(null, 0); +}); +assert.sameValue(count, 15); + +assert.throws(Test262Error, () => { + new C().method.call(undefined, 0); +}); +assert.sameValue(count, 18); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/privatefieldset-evaluation-order-1.js b/js/src/tests/test262/language/statements/class/elements/privatefieldset-evaluation-order-1.js new file mode 100644 index 0000000000..b9d1a0944f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/privatefieldset-evaluation-order-1.js @@ -0,0 +1,45 @@ +// Copyright (C) 2021 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + Evaluation order when resolving private fields. +esid: sec-runtime-semantics-keyeddestructuringassignmentevaluation +info: | + 13.15.5.6 Runtime Semantics: KeyedDestructuringAssignmentEvaluation + 1. If DestructuringAssignmentTarget is neither an ObjectLiteral nor an ArrayLiteral, then + a. Let lref be the result of evaluating DestructuringAssignmentTarget. + b. ReturnIfAbrupt(lref). + 2. ... + + 9.1.1.3.4 GetThisBinding ( ) + 1. Assert: envRec.[[ThisBindingStatus]] is not lexical. + 2. If envRec.[[ThisBindingStatus]] is uninitialized, throw a ReferenceError exception. + 3. ... + +features: [class, class-fields-private] +---*/ + +class C extends class {} { + #field; + + constructor() { + var init = () => super(); + + var object = { + get a() { + init(); + } + }; + + // Accessing |this| should throw a ReferenceError before there's an attempt + // to invoke the getter. + ({a: this.#field} = object); + } +} + +assert.throws(ReferenceError, function() { + new C(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/privatefieldset-evaluation-order-2.js b/js/src/tests/test262/language/statements/class/elements/privatefieldset-evaluation-order-2.js new file mode 100644 index 0000000000..adacf20da5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/privatefieldset-evaluation-order-2.js @@ -0,0 +1,38 @@ +// Copyright (C) 2021 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + Evaluation order when resolving private fields. +esid: sec-runtime-semantics-keyeddestructuringassignmentevaluation +info: | + 13.15.5.6 Runtime Semantics: KeyedDestructuringAssignmentEvaluation + 1. If DestructuringAssignmentTarget is neither an ObjectLiteral nor an ArrayLiteral, then + a. Let lref be the result of evaluating DestructuringAssignmentTarget. + b. ReturnIfAbrupt(lref). + 2. Let v be ? GetV(value, propertyName). + 3. ... + +features: [class, class-fields-private] +---*/ + +class C { + #field; + + m() { + var object = { + get a() { + throw new Test262Error(); + } + }; + + // The getter is executed before the check if the private field is present. + ({a: this.#field} = object); + } +} + +assert.throws(Test262Error, function() { + C.prototype.m.call({}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/privatefieldset-evaluation-order-3.js b/js/src/tests/test262/language/statements/class/elements/privatefieldset-evaluation-order-3.js new file mode 100644 index 0000000000..8a56632f36 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/privatefieldset-evaluation-order-3.js @@ -0,0 +1,47 @@ +// Copyright (C) 2021 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + Evaluation order when resolving private fields. +esid: sec-runtime-semantics-keyeddestructuringassignmentevaluation +info: | + 13.15.5.6 Runtime Semantics: KeyedDestructuringAssignmentEvaluation + 1. If DestructuringAssignmentTarget is neither an ObjectLiteral nor an ArrayLiteral, then + a. Let lref be the result of evaluating DestructuringAssignmentTarget. + b. ReturnIfAbrupt(lref). + 2. Let v be ? GetV(value, propertyName). + 3. ... + +features: [class, class-fields-private] +---*/ + +class Base { + constructor(o) { + return o; + } +} + +class C extends Base { + #field; + + m() { + var init = () => new C(this); + + var object = { + get a() { + init(); + + return "pass"; + } + }; + + ({a: this.#field} = object); + + assert.sameValue(this.#field, "pass"); + } +} + +C.prototype.m.call({}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/privatefieldset-typeerror-1.js b/js/src/tests/test262/language/statements/class/elements/privatefieldset-typeerror-1.js new file mode 100644 index 0000000000..1bcbb433ef --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/privatefieldset-typeerror-1.js @@ -0,0 +1,41 @@ +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: TypeError when setting private field before the entry was added to [[PrivateFieldValues]] +esid: sec-putvalue +info: | + PutValue ( V, W ) + ... + 6. Else if IsPropertyReference(V), then + ... + b. If IsPrivateReference(V), then + i. Let env be the running execution context's PrivateNameEnvironment. + ii. Let field be ? ResolveBinding(GetReferencedName(V), env). + iii. Assert: field is a Private Name. + iv. Perform ? PrivateFieldSet(field, base, W). + + PrivateFieldSet (P, O, value ) + 1. Assert: P is a Private Name value. + 2. If O is not an object, throw a TypeError exception. + 3. Let entry be PrivateFieldFind(P, O). + 4. If entry is empty, throw a TypeError exception. + + PrivateFieldFind (P, O) + 1. Assert: P is a Private Name value. + 2. Assert: O is an object with a [[PrivateFieldValues]] internal slot. + 3. For each element entry in O.[[PrivateFieldValues]], + a. If entry.[[PrivateName]] is P, return entry. + 4. Return empty. + +features: [class, class-fields-private, class-fields-public] +---*/ + +class C { + y = this.#x = 1; + #x; +} + +assert.throws(TypeError, function() { new C(); }) + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/privatefieldset-typeerror-10.js b/js/src/tests/test262/language/statements/class/elements/privatefieldset-typeerror-10.js new file mode 100644 index 0000000000..4057039735 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/privatefieldset-typeerror-10.js @@ -0,0 +1,47 @@ +// Copyright (C) 2021 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + TypeError when setting private field not in `this`'s [[PrivateFieldValues]] +esid: sec-putvalue +info: | + PutValue ( V, W ) + ... + 6. Else if IsPropertyReference(V), then + ... + b. If IsPrivateReference(V), then + i. Let env be the running execution context's PrivateNameEnvironment. + ii. Let field be ? ResolveBinding(GetReferencedName(V), env). + iii. Assert: field is a Private Name. + iv. Perform ? PrivateFieldSet(field, base, W). + + PrivateFieldSet (P, O, value ) + 1. Assert: P is a Private Name value. + 2. If O is not an object, throw a TypeError exception. + 3. Let entry be PrivateFieldFind(P, O). + 4. If entry is empty, throw a TypeError exception. + + PrivateFieldFind (P, O) + 1. Assert: P is a Private Name value. + 2. Assert: O is an object with a [[PrivateFieldValues]] internal slot. + 3. For each element entry in O.[[PrivateFieldValues]], + a. If entry.[[PrivateName]] is P, return entry. + 4. Return empty. + +features: [class, class-fields-private] +---*/ + +class C { + #field; + + m() { + [...this.#field] = []; + } +} + +assert.throws(TypeError, function() { + C.prototype.m.call({}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/privatefieldset-typeerror-11.js b/js/src/tests/test262/language/statements/class/elements/privatefieldset-typeerror-11.js new file mode 100644 index 0000000000..2ce9e2b796 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/privatefieldset-typeerror-11.js @@ -0,0 +1,47 @@ +// Copyright (C) 2021 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + TypeError when setting private field not in `this`'s [[PrivateFieldValues]] +esid: sec-putvalue +info: | + PutValue ( V, W ) + ... + 6. Else if IsPropertyReference(V), then + ... + b. If IsPrivateReference(V), then + i. Let env be the running execution context's PrivateNameEnvironment. + ii. Let field be ? ResolveBinding(GetReferencedName(V), env). + iii. Assert: field is a Private Name. + iv. Perform ? PrivateFieldSet(field, base, W). + + PrivateFieldSet (P, O, value ) + 1. Assert: P is a Private Name value. + 2. If O is not an object, throw a TypeError exception. + 3. Let entry be PrivateFieldFind(P, O). + 4. If entry is empty, throw a TypeError exception. + + PrivateFieldFind (P, O) + 1. Assert: P is a Private Name value. + 2. Assert: O is an object with a [[PrivateFieldValues]] internal slot. + 3. For each element entry in O.[[PrivateFieldValues]], + a. If entry.[[PrivateName]] is P, return entry. + 4. Return empty. + +features: [class, class-fields-private] +---*/ + +class C { + #field; + + m() { + ({...this.#field} = {}); + } +} + +assert.throws(TypeError, function() { + C.prototype.m.call({}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/privatefieldset-typeerror-2.js b/js/src/tests/test262/language/statements/class/elements/privatefieldset-typeerror-2.js new file mode 100644 index 0000000000..f1e389ef3e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/privatefieldset-typeerror-2.js @@ -0,0 +1,57 @@ +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: TypeError when setting private field not in `this`'s [[PrivateFieldValues]] +esid: sec-putvalue +info: | + PutValue ( V, W ) + ... + 6. Else if IsPropertyReference(V), then + ... + b. If IsPrivateReference(V), then + i. Let env be the running execution context's PrivateNameEnvironment. + ii. Let field be ? ResolveBinding(GetReferencedName(V), env). + iii. Assert: field is a Private Name. + iv. Perform ? PrivateFieldSet(field, base, W). + + PrivateFieldSet (P, O, value ) + 1. Assert: P is a Private Name value. + 2. If O is not an object, throw a TypeError exception. + 3. Let entry be PrivateFieldFind(P, O). + 4. If entry is empty, throw a TypeError exception. + + PrivateFieldFind (P, O) + 1. Assert: P is a Private Name value. + 2. Assert: O is an object with a [[PrivateFieldValues]] internal slot. + 3. For each element entry in O.[[PrivateFieldValues]], + a. If entry.[[PrivateName]] is P, return entry. + 4. Return empty. + +features: [class, class-fields-private] +---*/ + +class Outer { + #x = 42; + + innerclass() { + + // create class within in Outerclass -- the PrivateNameEnvironment binding for + // private field `#x` is resolvable. + return class { + f() { + this.#x = 1; + } + } + } +} + +var Inner = new Outer().innerclass(); +var i = new Inner(); + +assert.throws(TypeError, function() { + // when f() is called, the private field will not be found in Inner's `this` + i.f(); +}) + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/privatefieldset-typeerror-3.js b/js/src/tests/test262/language/statements/class/elements/privatefieldset-typeerror-3.js new file mode 100644 index 0000000000..600c76567e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/privatefieldset-typeerror-3.js @@ -0,0 +1,66 @@ +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + Referenced lexically scoped private field found in `this`'s [[PrivateFieldValues]] +esid: sec-putvalue +info: | + PutValue ( V, W ) + ... + 6. Else if IsPropertyReference(V), then + ... + b. If IsPrivateReference(V), then + i. Let env be the running execution context's PrivateNameEnvironment. + ii. Let field be ? ResolveBinding(GetReferencedName(V), env). + iii. Assert: field is a Private Name. + iv. Perform ? PrivateFieldSet(field, base, W). + + PrivateFieldSet (P, O, value ) + 1. Assert: P is a Private Name value. + 2. If O is not an object, throw a TypeError exception. + 3. Let entry be PrivateFieldFind(P, O). + 4. If entry is empty, throw a TypeError exception. + + PrivateFieldFind (P, O) + 1. Assert: P is a Private Name value. + 2. Assert: O is an object with a [[PrivateFieldValues]] internal slot. + 3. For each element entry in O.[[PrivateFieldValues]], + a. If entry.[[PrivateName]] is P, return entry. + 4. Return empty. + +features: [class, class-fields-private] +---*/ + +class Outer { + #x = 42; + + innerclass() { + + // create class within in Outerclass -- the PrivateNameEnvironment binding for + // private field `#x` is resolvable. + return class extends Outer { + f() { + this.#x = 1; + } + } + } + + value() { + return this.#x; + } +} + +var outer = new Outer(); +var Inner = outer.innerclass(); +var i = new Inner(); + +assert.sameValue(outer.value(), 42); +assert.sameValue(i.value(), 42); + +i.f(); + +assert.sameValue(outer.value(), 42, "value is set on inner class instance only"); +assert.sameValue(i.value(), 1, "value is set from inner class instance"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/privatefieldset-typeerror-4.js b/js/src/tests/test262/language/statements/class/elements/privatefieldset-typeerror-4.js new file mode 100644 index 0000000000..5041bf15df --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/privatefieldset-typeerror-4.js @@ -0,0 +1,55 @@ +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: TypeError when setting private field not in `this`'s [[PrivateFieldValues]] +esid: sec-putvalue +info: | + PutValue ( V, W ) + ... + 6. Else if IsPropertyReference(V), then + ... + b. If IsPrivateReference(V), then + i. Let env be the running execution context's PrivateNameEnvironment. + ii. Let field be ? ResolveBinding(GetReferencedName(V), env). + iii. Assert: field is a Private Name. + iv. Perform ? PrivateFieldSet(field, base, W). + + PrivateFieldSet (P, O, value ) + 1. Assert: P is a Private Name value. + 2. If O is not an object, throw a TypeError exception. + 3. Let entry be PrivateFieldFind(P, O). + 4. If entry is empty, throw a TypeError exception. + + PrivateFieldFind (P, O) + 1. Assert: P is a Private Name value. + 2. Assert: O is an object with a [[PrivateFieldValues]] internal slot. + 3. For each element entry in O.[[PrivateFieldValues]], + a. If entry.[[PrivateName]] is P, return entry. + 4. Return empty. + +features: [class, class-fields-private] +---*/ + +function classfactory() { + return class { + #x; + f() { + this.#x = 1; + } + } +} + +var C1 = classfactory(); +var C2 = classfactory(); + +var c1 = new C1(); +var c2 = new C2(); + +assert.throws(TypeError, function() { + // when f() is called in class C1, the Private Name binding for #x in C1 will + // not found in C2's [[PrivateNameValues]] + c1.f.call(c2); +}) + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/privatefieldset-typeerror-5.js b/js/src/tests/test262/language/statements/class/elements/privatefieldset-typeerror-5.js new file mode 100644 index 0000000000..17d27ecbf4 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/privatefieldset-typeerror-5.js @@ -0,0 +1,61 @@ +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: TypeError when setting private field not in `this`'s [[PrivateFieldValues]] +esid: sec-putvalue +info: | + PutValue ( V, W ) + ... + 6. Else if IsPropertyReference(V), then + ... + b. If IsPrivateReference(V), then + i. Let env be the running execution context's PrivateNameEnvironment. + ii. Let field be ? ResolveBinding(GetReferencedName(V), env). + iii. Assert: field is a Private Name. + iv. Perform ? PrivateFieldSet(field, base, W). + + PrivateFieldSet (P, O, value ) + 1. Assert: P is a Private Name value. + 2. If O is not an object, throw a TypeError exception. + 3. Let entry be PrivateFieldFind(P, O). + 4. If entry is empty, throw a TypeError exception. + + PrivateFieldFind (P, O) + 1. Assert: P is a Private Name value. + 2. Assert: O is an object with a [[PrivateFieldValues]] internal slot. + 3. For each element entry in O.[[PrivateFieldValues]], + a. If entry.[[PrivateName]] is P, return entry. + 4. Return empty. + +features: [class, class-fields-private] +---*/ + + +class Outer { + #x = 42; + + innerclass() { + var self = this; + + return class extends Outer { + #x = 'not42'; + f() { + self.#x = 1; + } + } + } +} + +var Inner = new Outer().innerclass(); +var i = new Inner(); + +assert.throws(TypeError, function() { + // when f() is called, the entry in the PrivateNameEnironment's environment + // record for '#x' will contain the Inner class's Private Name for '#x'. + // When this Private Name is used for lookup on the `self` object, it + // will not be found (as the `self` object has the Outer's Private Name for #x) + i.f(); +}) + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/privatefieldset-typeerror-6.js b/js/src/tests/test262/language/statements/class/elements/privatefieldset-typeerror-6.js new file mode 100644 index 0000000000..49d531ee7c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/privatefieldset-typeerror-6.js @@ -0,0 +1,47 @@ +// Copyright (C) 2021 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + TypeError when setting private field not in `this`'s [[PrivateFieldValues]] +esid: sec-putvalue +info: | + PutValue ( V, W ) + ... + 6. Else if IsPropertyReference(V), then + ... + b. If IsPrivateReference(V), then + i. Let env be the running execution context's PrivateNameEnvironment. + ii. Let field be ? ResolveBinding(GetReferencedName(V), env). + iii. Assert: field is a Private Name. + iv. Perform ? PrivateFieldSet(field, base, W). + + PrivateFieldSet (P, O, value ) + 1. Assert: P is a Private Name value. + 2. If O is not an object, throw a TypeError exception. + 3. Let entry be PrivateFieldFind(P, O). + 4. If entry is empty, throw a TypeError exception. + + PrivateFieldFind (P, O) + 1. Assert: P is a Private Name value. + 2. Assert: O is an object with a [[PrivateFieldValues]] internal slot. + 3. For each element entry in O.[[PrivateFieldValues]], + a. If entry.[[PrivateName]] is P, return entry. + 4. Return empty. + +features: [class, class-fields-private] +---*/ + +class C { + #field; + + m() { + for (this.#field of [1]) ; + } +} + +assert.throws(TypeError, function() { + C.prototype.m.call({}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/privatefieldset-typeerror-7.js b/js/src/tests/test262/language/statements/class/elements/privatefieldset-typeerror-7.js new file mode 100644 index 0000000000..e2c0921bb6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/privatefieldset-typeerror-7.js @@ -0,0 +1,47 @@ +// Copyright (C) 2021 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + TypeError when setting private field not in `this`'s [[PrivateFieldValues]] +esid: sec-putvalue +info: | + PutValue ( V, W ) + ... + 6. Else if IsPropertyReference(V), then + ... + b. If IsPrivateReference(V), then + i. Let env be the running execution context's PrivateNameEnvironment. + ii. Let field be ? ResolveBinding(GetReferencedName(V), env). + iii. Assert: field is a Private Name. + iv. Perform ? PrivateFieldSet(field, base, W). + + PrivateFieldSet (P, O, value ) + 1. Assert: P is a Private Name value. + 2. If O is not an object, throw a TypeError exception. + 3. Let entry be PrivateFieldFind(P, O). + 4. If entry is empty, throw a TypeError exception. + + PrivateFieldFind (P, O) + 1. Assert: P is a Private Name value. + 2. Assert: O is an object with a [[PrivateFieldValues]] internal slot. + 3. For each element entry in O.[[PrivateFieldValues]], + a. If entry.[[PrivateName]] is P, return entry. + 4. Return empty. + +features: [class, class-fields-private] +---*/ + +class C { + #field; + + m() { + for (this.#field in {a: 0}) ; + } +} + +assert.throws(TypeError, function() { + C.prototype.m.call({}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/privatefieldset-typeerror-8.js b/js/src/tests/test262/language/statements/class/elements/privatefieldset-typeerror-8.js new file mode 100644 index 0000000000..309e31663d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/privatefieldset-typeerror-8.js @@ -0,0 +1,47 @@ +// Copyright (C) 2021 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + TypeError when setting private field not in `this`'s [[PrivateFieldValues]] +esid: sec-putvalue +info: | + PutValue ( V, W ) + ... + 6. Else if IsPropertyReference(V), then + ... + b. If IsPrivateReference(V), then + i. Let env be the running execution context's PrivateNameEnvironment. + ii. Let field be ? ResolveBinding(GetReferencedName(V), env). + iii. Assert: field is a Private Name. + iv. Perform ? PrivateFieldSet(field, base, W). + + PrivateFieldSet (P, O, value ) + 1. Assert: P is a Private Name value. + 2. If O is not an object, throw a TypeError exception. + 3. Let entry be PrivateFieldFind(P, O). + 4. If entry is empty, throw a TypeError exception. + + PrivateFieldFind (P, O) + 1. Assert: P is a Private Name value. + 2. Assert: O is an object with a [[PrivateFieldValues]] internal slot. + 3. For each element entry in O.[[PrivateFieldValues]], + a. If entry.[[PrivateName]] is P, return entry. + 4. Return empty. + +features: [class, class-fields-private] +---*/ + +class C { + #field; + + m() { + [this.#field] = [1]; + } +} + +assert.throws(TypeError, function() { + C.prototype.m.call({}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/privatefieldset-typeerror-9.js b/js/src/tests/test262/language/statements/class/elements/privatefieldset-typeerror-9.js new file mode 100644 index 0000000000..b39c3fc6a8 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/privatefieldset-typeerror-9.js @@ -0,0 +1,47 @@ +// Copyright (C) 2021 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + TypeError when setting private field not in `this`'s [[PrivateFieldValues]] +esid: sec-putvalue +info: | + PutValue ( V, W ) + ... + 6. Else if IsPropertyReference(V), then + ... + b. If IsPrivateReference(V), then + i. Let env be the running execution context's PrivateNameEnvironment. + ii. Let field be ? ResolveBinding(GetReferencedName(V), env). + iii. Assert: field is a Private Name. + iv. Perform ? PrivateFieldSet(field, base, W). + + PrivateFieldSet (P, O, value ) + 1. Assert: P is a Private Name value. + 2. If O is not an object, throw a TypeError exception. + 3. Let entry be PrivateFieldFind(P, O). + 4. If entry is empty, throw a TypeError exception. + + PrivateFieldFind (P, O) + 1. Assert: P is a Private Name value. + 2. Assert: O is an object with a [[PrivateFieldValues]] internal slot. + 3. For each element entry in O.[[PrivateFieldValues]], + a. If entry.[[PrivateName]] is P, return entry. + 4. Return empty. + +features: [class, class-fields-private] +---*/ + +class C { + #field; + + m() { + ({a: this.#field} = {a: 0}); + } +} + +assert.throws(TypeError, function() { + C.prototype.m.call({}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/privategetter-on-proxy.js b/js/src/tests/test262/language/statements/class/elements/privategetter-on-proxy.js new file mode 100644 index 0000000000..4ea77939f1 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/privategetter-on-proxy.js @@ -0,0 +1,61 @@ +// Copyright (C) 2019 Caio Lima. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Successfully access private getter on Proxy objects without using [[Get]] +esid: sec-getvalue +info: | + GetValue(V) + ... + 5. If IsPropertyReference(V), then + ... + b. If IsPrivateReference(V), then + i. Let env be the running execution context's PrivateNameEnvironment. + ii. Let field be ? ResolveBinding(GetReferencedName(V), env). + iii. Assert: field is a Private Name. + iv. Return ? PrivateFieldGet(field, base). + c. Return ? base.[[Get]](GetReferencedName(V), GetThisValue(V)). + PrivateFieldGet(P, O) + ... + 4. Perform ? PrivateBrandCheck(O, P). + 5. If P.[[Kind]] is "method", + ... + 6. Else, + a. Assert: P.[[Kind]] is "accessor". + b. If P does not have a [[Get]] field, throw a TypeError exception. + c. Let getter be P.[[Get]]. + d. Return ? Call(getter, O). +includes: [compareArray.js] +features: [class, class-methods-private, Proxy] +---*/ + +let arr = []; + +class ProxyBase { + constructor() { + return new Proxy(this, { + get: function (obj, prop) { + arr.push(prop); + return obj[prop]; + } + }); + } +} + +class Test extends ProxyBase { + get #f() { + return 3; + } + method() { + return this.#f; + } +} + +let t = new Test(); +let r = t.method(); +assert.sameValue(r, 3); + +assert.compareArray(arr, ['method']); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/privatemethods-on-proxy.js b/js/src/tests/test262/language/statements/class/elements/privatemethods-on-proxy.js new file mode 100644 index 0000000000..d6aaabba64 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/privatemethods-on-proxy.js @@ -0,0 +1,57 @@ +// Copyright (C) 2019 Caio Lima. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Successfully access private method on Proxy objects without using [[Get]] +esid: sec-getvalue +info: | + GetValue(V) + ... + 5. If IsPropertyReference(V), then + ... + b. If IsPrivateReference(V), then + i. Let env be the running execution context's PrivateNameEnvironment. + ii. Let field be ? ResolveBinding(GetReferencedName(V), env). + iii. Assert: field is a Private Name. + iv. Return ? PrivateFieldGet(field, base). + c. Return ? base.[[Get]](GetReferencedName(V), GetThisValue(V)). + PrivateFieldGet(P, O) + ... + 4. Perform ? PrivateBrandCheck(O, P). + 5. If P.[[Kind]] is "method", + a. Return P.[[Value]]. + ... +includes: [compareArray.js] +features: [class, class-methods-private, Proxy] +---*/ + +let arr = []; + +class ProxyBase { + constructor() { + return new Proxy(this, { + get: function (obj, prop) { + arr.push(prop); + return obj[prop]; + } + }); + } +} + +class Test extends ProxyBase { + #f() { + return 3; + } + method() { + return this.#f(); + } +} + +let t = new Test(); +let r = t.method(); +assert.sameValue(r, 3); + +assert.compareArray(arr, ['method']); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/privatename-not-valid-earlyerr-script-1.js b/js/src/tests/test262/language/statements/class/elements/privatename-not-valid-earlyerr-script-1.js new file mode 100644 index 0000000000..9e13a856da --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/privatename-not-valid-earlyerr-script-1.js @@ -0,0 +1,25 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-scripts-static-semantics-early-errors +description: Early error when referencing privatename in constructor without being declared in class fields +info: | + Static Semantics: Early Errors + ScriptBody : StatementList + + It is a Syntax Error if AllPrivateNamesValid of StatementList with an empty List as an argument is false unless the source code is eval code that is being processed by a direct eval. + +features: [class, class-fields-private] +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +class C { + constructor() { + this.#x; + } +} diff --git a/js/src/tests/test262/language/statements/class/elements/privatename-not-valid-earlyerr-script-2.js b/js/src/tests/test262/language/statements/class/elements/privatename-not-valid-earlyerr-script-2.js new file mode 100644 index 0000000000..415cd95d52 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/privatename-not-valid-earlyerr-script-2.js @@ -0,0 +1,25 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-scripts-static-semantics-early-errors +description: Early error when referencing privatename in function in class without declaring in field +info: | + Static Semantics: Early Errors + ScriptBody : StatementList + + It is a Syntax Error if AllPrivateNamesValid of StatementList with an empty List as an argument is false unless the source code is eval code that is being processed by a direct eval. + +features: [class, class-fields-private] +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +class C { + f() { + this.#x; + } +} diff --git a/js/src/tests/test262/language/statements/class/elements/privatename-not-valid-earlyerr-script-3.js b/js/src/tests/test262/language/statements/class/elements/privatename-not-valid-earlyerr-script-3.js new file mode 100644 index 0000000000..4eef9588c7 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/privatename-not-valid-earlyerr-script-3.js @@ -0,0 +1,23 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-scripts-static-semantics-early-errors +description: Early error when referencing privatename that has not been declared in class. +info: | + Static Semantics: Early Errors + ScriptBody : StatementList + + It is a Syntax Error if AllPrivateNamesValid of StatementList with an empty List as an argument is false unless the source code is eval code that is being processed by a direct eval. + +features: [class, class-fields-private, class-fields-public] +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +class C { + y = this.#x; +} diff --git a/js/src/tests/test262/language/statements/class/elements/privatename-not-valid-earlyerr-script-4.js b/js/src/tests/test262/language/statements/class/elements/privatename-not-valid-earlyerr-script-4.js new file mode 100644 index 0000000000..6057d7051a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/privatename-not-valid-earlyerr-script-4.js @@ -0,0 +1,28 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-scripts-static-semantics-early-errors +description: Early error when referencing privatename that has not been declared in class. +info: | + Static Semantics: Early Errors + ScriptBody : StatementList + + It is a Syntax Error if AllPrivateNamesValid of StatementList with an empty List as an argument is false unless the source code is eval code that is being processed by a direct eval. + +features: [class, class-fields-private] +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +class C { + f() { + this.#x; + class D extends C { + #x; + } + } +} diff --git a/js/src/tests/test262/language/statements/class/elements/privatename-not-valid-earlyerr-script-5.js b/js/src/tests/test262/language/statements/class/elements/privatename-not-valid-earlyerr-script-5.js new file mode 100644 index 0000000000..2c0120fc1e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/privatename-not-valid-earlyerr-script-5.js @@ -0,0 +1,25 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-scripts-static-semantics-early-errors +description: Early error when referencing privatename outside of class +info: | + Static Semantics: Early Errors + ScriptBody : StatementList + + It is a Syntax Error if AllPrivateNamesValid of StatementList with an empty List as an argument is false unless the source code is eval code that is being processed by a direct eval. + +features: [class, class-fields-private] +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +class C { + #x; +} + +new C().#x; diff --git a/js/src/tests/test262/language/statements/class/elements/privatename-not-valid-earlyerr-script-6.js b/js/src/tests/test262/language/statements/class/elements/privatename-not-valid-earlyerr-script-6.js new file mode 100644 index 0000000000..833606797f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/privatename-not-valid-earlyerr-script-6.js @@ -0,0 +1,23 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-scripts-static-semantics-early-errors +description: Early error when referencing privatename outside of class. +info: | + Static Semantics: Early Errors + ScriptBody : StatementList + + It is a Syntax Error if AllPrivateNamesValid of StatementList with an empty List as an argument is false unless the source code is eval code that is being processed by a direct eval. + +features: [class, class-fields-private] +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +class C {} + +new C().#x; diff --git a/js/src/tests/test262/language/statements/class/elements/privatename-not-valid-earlyerr-script-7.js b/js/src/tests/test262/language/statements/class/elements/privatename-not-valid-earlyerr-script-7.js new file mode 100644 index 0000000000..3b9aededd1 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/privatename-not-valid-earlyerr-script-7.js @@ -0,0 +1,23 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-scripts-static-semantics-early-errors +description: Early error when referencing privatename on object, outside of class. +info: | + Static Semantics: Early Errors + ScriptBody : StatementList + + It is a Syntax Error if AllPrivateNamesValid of StatementList with an empty List as an argument is false unless the source code is eval code that is being processed by a direct eval. + +features: [class, class-fields-private] +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +obj = {}; + +obj.#x; diff --git a/js/src/tests/test262/language/statements/class/elements/privatename-not-valid-earlyerr-script-8.js b/js/src/tests/test262/language/statements/class/elements/privatename-not-valid-earlyerr-script-8.js new file mode 100644 index 0000000000..8b76cafa0f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/privatename-not-valid-earlyerr-script-8.js @@ -0,0 +1,23 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-scripts-static-semantics-early-errors +description: Early error when referencing privatename on object, outside of class. +info: | + Static Semantics: Early Errors + ScriptBody : StatementList + + It is a Syntax Error if AllPrivateNamesValid of StatementList with an empty List as an argument is false unless the source code is eval code that is being processed by a direct eval. + +features: [class, class-fields-private] +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +function f() { + this.#x; +} diff --git a/js/src/tests/test262/language/statements/class/elements/privatename-not-valid-eval-earlyerr-1.js b/js/src/tests/test262/language/statements/class/elements/privatename-not-valid-eval-earlyerr-1.js new file mode 100644 index 0000000000..64623554fb --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/privatename-not-valid-eval-earlyerr-1.js @@ -0,0 +1,29 @@ +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-scripts-static-semantics-early-errors +description: Early error when referencing privatename in constructor without being declared in class fields +info: | + Static Semantics: Early Errors + ScriptBody : StatementList + + It is a Syntax Error if AllPrivateNamesValid of StatementList with an empty List as an argument is false unless the source code is eval code that is being processed by a direct eval. + +features: [class, class-fields-private] +---*/ + +var executed = false; + +class C { + constructor() { + eval("executed = true; this.#x;"); + } +} + +assert.throws(SyntaxError, function() { + new C(); +}); + +assert.sameValue(executed, false); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/privatename-not-valid-eval-earlyerr-2.js b/js/src/tests/test262/language/statements/class/elements/privatename-not-valid-eval-earlyerr-2.js new file mode 100644 index 0000000000..b3502625b7 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/privatename-not-valid-eval-earlyerr-2.js @@ -0,0 +1,29 @@ +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-scripts-static-semantics-early-errors +description: Early error when referencing privatename in function in class without declaring in field +info: | + Static Semantics: Early Errors + ScriptBody : StatementList + + It is a Syntax Error if AllPrivateNamesValid of StatementList with an empty List as an argument is false unless the source code is eval code that is being processed by a direct eval. + +features: [class, class-fields-private] +---*/ + +var executed = false; + +class C { + f() { + eval("executed = true; this.#x;"); + } +} + +assert.throws(SyntaxError, function() { + new C().f(); +}); + +assert.sameValue(executed, false); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/privatename-not-valid-eval-earlyerr-3.js b/js/src/tests/test262/language/statements/class/elements/privatename-not-valid-eval-earlyerr-3.js new file mode 100644 index 0000000000..1275505b59 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/privatename-not-valid-eval-earlyerr-3.js @@ -0,0 +1,27 @@ +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-scripts-static-semantics-early-errors +description: Early error when referencing privatename that has not been declared in class. +info: | + Static Semantics: Early Errors + ScriptBody : StatementList + + It is a Syntax Error if AllPrivateNamesValid of StatementList with an empty List as an argument is false unless the source code is eval code that is being processed by a direct eval. + +features: [class, class-fields-private, class-fields-public] +---*/ + +var executed = false; + +class C { + y = eval("executed = true; this.#x;") +} + +assert.throws(SyntaxError, function() { + new C(); +}); + +assert.sameValue(executed, false); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/privatename-not-valid-eval-earlyerr-4.js b/js/src/tests/test262/language/statements/class/elements/privatename-not-valid-eval-earlyerr-4.js new file mode 100644 index 0000000000..af441ae724 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/privatename-not-valid-eval-earlyerr-4.js @@ -0,0 +1,32 @@ +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-scripts-static-semantics-early-errors +description: Early error when referencing privatename that has not been declared in class. +info: | + Static Semantics: Early Errors + ScriptBody : StatementList + + It is a Syntax Error if AllPrivateNamesValid of StatementList with an empty List as an argument is false unless the source code is eval code that is being processed by a direct eval. + +features: [class, class-fields-private] +---*/ + +var executed = false; + +class C { + f() { + eval("executed = true; this.#x;"); + class D extends C { + #x; + } + } +} + +assert.throws(SyntaxError, function() { + new C().f(); +}); + +assert.sameValue(executed, false); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/privatename-not-valid-eval-earlyerr-5.js b/js/src/tests/test262/language/statements/class/elements/privatename-not-valid-eval-earlyerr-5.js new file mode 100644 index 0000000000..ed05abfd60 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/privatename-not-valid-eval-earlyerr-5.js @@ -0,0 +1,27 @@ +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-scripts-static-semantics-early-errors +description: Early error when referencing privatename outside of class +info: | + Static Semantics: Early Errors + ScriptBody : StatementList + + It is a Syntax Error if AllPrivateNamesValid of StatementList with an empty List as an argument is false unless the source code is eval code that is being processed by a direct eval. + +features: [class, class-fields-private] +---*/ + +var executed = false; + +class C { + #x; +} + +assert.throws(SyntaxError, function() { + eval("executed = true; new C().#x"); +}); + +assert.sameValue(executed, false); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/privatename-not-valid-eval-earlyerr-6.js b/js/src/tests/test262/language/statements/class/elements/privatename-not-valid-eval-earlyerr-6.js new file mode 100644 index 0000000000..54fa2cdc03 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/privatename-not-valid-eval-earlyerr-6.js @@ -0,0 +1,24 @@ +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-scripts-static-semantics-early-errors +description: Early error when referencing privatename outside of class. +info: | + Static Semantics: Early Errors + ScriptBody : StatementList + + It is a Syntax Error if AllPrivateNamesValid of StatementList with an empty List as an argument is false unless the source code is eval code that is being processed by a direct eval. + +features: [class, class-fields-private] +---*/ + +var executed = false; +class C {} + +assert.throws(SyntaxError, function() { + eval("executed = true; new C().#x"); +}); + +assert.sameValue(executed, false); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/privatename-not-valid-eval-earlyerr-7.js b/js/src/tests/test262/language/statements/class/elements/privatename-not-valid-eval-earlyerr-7.js new file mode 100644 index 0000000000..879bcf646f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/privatename-not-valid-eval-earlyerr-7.js @@ -0,0 +1,24 @@ +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-scripts-static-semantics-early-errors +description: Early error when referencing privatename on object, outside of class. +info: | + Static Semantics: Early Errors + ScriptBody : StatementList + + It is a Syntax Error if AllPrivateNamesValid of StatementList with an empty List as an argument is false unless the source code is eval code that is being processed by a direct eval. + +features: [class-fields-private] +---*/ + +var executed = false; +var obj = {}; + +assert.throws(SyntaxError, function() { + eval("executed = true; obj.#x;"); +}); + +assert.sameValue(executed, false); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/privatename-not-valid-eval-earlyerr-8.js b/js/src/tests/test262/language/statements/class/elements/privatename-not-valid-eval-earlyerr-8.js new file mode 100644 index 0000000000..bb89e9ea39 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/privatename-not-valid-eval-earlyerr-8.js @@ -0,0 +1,28 @@ +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-scripts-static-semantics-early-errors +description: Early error when referencing privatename on object, outside of class. +info: | + Static Semantics: Early Errors + ScriptBody : StatementList + + It is a Syntax Error if AllPrivateNamesValid of StatementList with an empty List as an argument is false unless the source code is eval code that is being processed by a direct eval. + +features: [class-fields-private] +---*/ + +var executed = false; + +function f() { + eval("executed = true; this.#x;"); +} + +assert.throws(SyntaxError, function() { + f(); +}); + +assert.sameValue(executed, false); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/privatename-valid-no-earlyerr.js b/js/src/tests/test262/language/statements/class/elements/privatename-valid-no-earlyerr.js new file mode 100644 index 0000000000..4a63961a6b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/privatename-valid-no-earlyerr.js @@ -0,0 +1,46 @@ +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-all-private-names-valid +description: Referencing privatename in class within class does not error. +info: | + Static Semantics: AllPrivateNamesValid + + AllPrivateNamesValid is an abstract operation which takes names as an argument. + + MemberExpression : MemberExpression . PrivateName + 1. If StringValue of PrivateName is in names, return true. + 2. Return false. + + CallExpression : CallExpression . PrivateName + 1. If StringValue of PrivateName is in names, return true. + 2. Return false. + + ClassBody : ClassElementList + 1. Let newNames be the concatenation of names with PrivateBoundNames of ClassBody. + 2. Return AllPrivateNamesValid of ClassElementList with the argument newNames. + + For all other grammatical productions, recurse on subexpressions/substatements, passing in the names of the caller. If all pieces return true, then return true. If any returns false, return false. + +features: [class, class-fields-private] +---*/ + +class outer { + #x = 42; + + f() { + var self = this; + return class inner { + g() { + return self.#x; + } + } + } +} + +var innerclass = new outer().f(); +var test = new innerclass().g(); + +assert.sameValue(test, 42); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/prod-private-getter-before-super-return-in-constructor.js b/js/src/tests/test262/language/statements/class/elements/prod-private-getter-before-super-return-in-constructor.js new file mode 100644 index 0000000000..00e7377707 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/prod-private-getter-before-super-return-in-constructor.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/prod-private-getter-before-super-return-in-constructor.case +// - src/class-elements/default/cls-decl.template +/*--- +description: Private getters are installed "when super returns" and no earlier (call in constructor) (field definitions in a class declaration) +esid: prod-FieldDefinition +features: [class-methods-private, class] +flags: [generated] +info: | + SuperCall: super Arguments + 1. Let newTarget be GetNewTarget(). + 2. If newTarget is undefined, throw a ReferenceError exception. + 3. Let func be ? GetSuperConstructor(). + 4. Let argList be ArgumentListEvaluation of Arguments. + 5. ReturnIfAbrupt(argList). + 6. Let result be ? Construct(func, argList, newTarget). + 7. Let thisER be GetThisEnvironment( ). + 8. Let F be thisER.[[FunctionObject]]. + 9. Assert: F is an ECMAScript function object. + 10. Perform ? InitializeInstanceElements(result, F). + + EDITOR'S NOTE: + Private fields are added to the object one by one, interspersed with + evaluation of the initializers, following the construction of the + receiver. These semantics allow for a later initializer to refer to + a previous private field. + +---*/ + + +class C { + constructor() { + this.f(); + } + +} + +class D extends C { + f() { this.#m; } + get #m() { return 42; } +} + +assert(D.prototype.hasOwnProperty('f')); +assert.throws(TypeError, function() { + var d = new D(); +}, 'private getters are not installed before super returns'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/prod-private-getter-before-super-return-in-field-initializer.js b/js/src/tests/test262/language/statements/class/elements/prod-private-getter-before-super-return-in-field-initializer.js new file mode 100644 index 0000000000..65725972ca --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/prod-private-getter-before-super-return-in-field-initializer.js @@ -0,0 +1,46 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/prod-private-getter-before-super-return-in-field-initializer.case +// - src/class-elements/default/cls-decl.template +/*--- +description: Private getters are installed "when super returns" and no earlier (call in field initializer) (field definitions in a class declaration) +esid: prod-FieldDefinition +features: [class-methods-private, class-fields-public, class] +flags: [generated] +info: | + SuperCall: super Arguments + 1. Let newTarget be GetNewTarget(). + 2. If newTarget is undefined, throw a ReferenceError exception. + 3. Let func be ? GetSuperConstructor(). + 4. Let argList be ArgumentListEvaluation of Arguments. + 5. ReturnIfAbrupt(argList). + 6. Let result be ? Construct(func, argList, newTarget). + 7. Let thisER be GetThisEnvironment( ). + 8. Let F be thisER.[[FunctionObject]]. + 9. Assert: F is an ECMAScript function object. + 10. Perform ? InitializeInstanceElements(result, F). + + EDITOR'S NOTE: + Private fields are added to the object one by one, interspersed with + evaluation of the initializers, following the construction of the + receiver. These semantics allow for a later initializer to refer to + a previous private field. + +---*/ + + +class C { + f = this.g(); + +} + +class D extends C { + g() { this.#m; } + get #m() { return 42; } +} + +assert(D.prototype.hasOwnProperty('g')); +assert.throws(TypeError, function() { + var d = new D(); +}, 'private getters are not installed before super returns'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/prod-private-method-before-super-return-in-constructor.js b/js/src/tests/test262/language/statements/class/elements/prod-private-method-before-super-return-in-constructor.js new file mode 100644 index 0000000000..b3d9c28436 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/prod-private-method-before-super-return-in-constructor.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/prod-private-method-before-super-return-in-constructor.case +// - src/class-elements/default/cls-decl.template +/*--- +description: Private methods are installed "when super returns" and no earlier (call in constructor) (field definitions in a class declaration) +esid: prod-FieldDefinition +features: [class-methods-private, class] +flags: [generated] +info: | + SuperCall: super Arguments + 1. Let newTarget be GetNewTarget(). + 2. If newTarget is undefined, throw a ReferenceError exception. + 3. Let func be ? GetSuperConstructor(). + 4. Let argList be ArgumentListEvaluation of Arguments. + 5. ReturnIfAbrupt(argList). + 6. Let result be ? Construct(func, argList, newTarget). + 7. Let thisER be GetThisEnvironment( ). + 8. Let F be thisER.[[FunctionObject]]. + 9. Assert: F is an ECMAScript function object. + 10. Perform ? InitializeInstanceElements(result, F). + + EDITOR'S NOTE: + Private fields are added to the object one by one, interspersed with + evaluation of the initializers, following the construction of the + receiver. These semantics allow for a later initializer to refer to + a previous private field. + +---*/ + + +class C { + constructor() { + this.f(); + } + +} + +class D extends C { + f() { this.#m(); } + #m() { return 42; } +} + +assert(D.prototype.hasOwnProperty('f')); +assert.throws(TypeError, function() { + var d = new D(); +}, 'private methods are not installed before super returns'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/prod-private-method-before-super-return-in-field-initializer.js b/js/src/tests/test262/language/statements/class/elements/prod-private-method-before-super-return-in-field-initializer.js new file mode 100644 index 0000000000..18bd4f8a82 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/prod-private-method-before-super-return-in-field-initializer.js @@ -0,0 +1,46 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/prod-private-method-before-super-return-in-field-initializer.case +// - src/class-elements/default/cls-decl.template +/*--- +description: Private methods are installed "when super returns" and no earlier (call in field initializer) (field definitions in a class declaration) +esid: prod-FieldDefinition +features: [class-methods-private, class-fields-public, class] +flags: [generated] +info: | + SuperCall: super Arguments + 1. Let newTarget be GetNewTarget(). + 2. If newTarget is undefined, throw a ReferenceError exception. + 3. Let func be ? GetSuperConstructor(). + 4. Let argList be ArgumentListEvaluation of Arguments. + 5. ReturnIfAbrupt(argList). + 6. Let result be ? Construct(func, argList, newTarget). + 7. Let thisER be GetThisEnvironment( ). + 8. Let F be thisER.[[FunctionObject]]. + 9. Assert: F is an ECMAScript function object. + 10. Perform ? InitializeInstanceElements(result, F). + + EDITOR'S NOTE: + Private fields are added to the object one by one, interspersed with + evaluation of the initializers, following the construction of the + receiver. These semantics allow for a later initializer to refer to + a previous private field. + +---*/ + + +class C { + f = this.g(); + +} + +class D extends C { + g() { this.#m(); } + #m() { return 42; } +} + +assert(D.prototype.hasOwnProperty('g')); +assert.throws(TypeError, function() { + var d = new D(); +}, 'private methods are not installed before super returns'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/prod-private-setter-before-super-return-in-constructor.js b/js/src/tests/test262/language/statements/class/elements/prod-private-setter-before-super-return-in-constructor.js new file mode 100644 index 0000000000..9ff167a991 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/prod-private-setter-before-super-return-in-constructor.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/prod-private-setter-before-super-return-in-constructor.case +// - src/class-elements/default/cls-decl.template +/*--- +description: Private setters are installed "when super returns" and no earlier (call in constructor) (field definitions in a class declaration) +esid: prod-FieldDefinition +features: [class-methods-private, class] +flags: [generated] +info: | + SuperCall: super Arguments + 1. Let newTarget be GetNewTarget(). + 2. If newTarget is undefined, throw a ReferenceError exception. + 3. Let func be ? GetSuperConstructor(). + 4. Let argList be ArgumentListEvaluation of Arguments. + 5. ReturnIfAbrupt(argList). + 6. Let result be ? Construct(func, argList, newTarget). + 7. Let thisER be GetThisEnvironment( ). + 8. Let F be thisER.[[FunctionObject]]. + 9. Assert: F is an ECMAScript function object. + 10. Perform ? InitializeInstanceElements(result, F). + + EDITOR'S NOTE: + Private fields are added to the object one by one, interspersed with + evaluation of the initializers, following the construction of the + receiver. These semantics allow for a later initializer to refer to + a previous private field. + +---*/ + + +class C { + constructor() { + this.f(); + } + +} + +class D extends C { + f() { this.#m = 42; } + set #m(val) {} +} + +assert(D.prototype.hasOwnProperty('f')); +assert.throws(TypeError, function() { + var d = new D(); +}, 'private setters are not installed before super returns'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/prod-private-setter-before-super-return-in-field-initializer.js b/js/src/tests/test262/language/statements/class/elements/prod-private-setter-before-super-return-in-field-initializer.js new file mode 100644 index 0000000000..514e777881 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/prod-private-setter-before-super-return-in-field-initializer.js @@ -0,0 +1,46 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/prod-private-setter-before-super-return-in-field-initializer.case +// - src/class-elements/default/cls-decl.template +/*--- +description: Private settters are installed "when super returns" and no earlier (call in field initializer) (field definitions in a class declaration) +esid: prod-FieldDefinition +features: [class-methods-private, class-fields-public, class] +flags: [generated] +info: | + SuperCall: super Arguments + 1. Let newTarget be GetNewTarget(). + 2. If newTarget is undefined, throw a ReferenceError exception. + 3. Let func be ? GetSuperConstructor(). + 4. Let argList be ArgumentListEvaluation of Arguments. + 5. ReturnIfAbrupt(argList). + 6. Let result be ? Construct(func, argList, newTarget). + 7. Let thisER be GetThisEnvironment( ). + 8. Let F be thisER.[[FunctionObject]]. + 9. Assert: F is an ECMAScript function object. + 10. Perform ? InitializeInstanceElements(result, F). + + EDITOR'S NOTE: + Private fields are added to the object one by one, interspersed with + evaluation of the initializers, following the construction of the + receiver. These semantics allow for a later initializer to refer to + a previous private field. + +---*/ + + +class C { + f = this.g(); + +} + +class D extends C { + g() { this.#m = 42; } + set #m(val) {} +} + +assert(D.prototype.hasOwnProperty('g')); +assert.throws(TypeError, function() { + var d = new D(); +}, 'private setters are not installed before super returns'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/public-class-field-initialization-is-visible-to-proxy.js b/js/src/tests/test262/language/statements/class/elements/public-class-field-initialization-is-visible-to-proxy.js new file mode 100644 index 0000000000..47d1459d11 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/public-class-field-initialization-is-visible-to-proxy.js @@ -0,0 +1,33 @@ +// Copyright (C) 2019 Caio Lima. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Public class field initialization calls [[DefineOwnProperty]] and can be observed by Proxies +esid: sec-define-field +info: | + DefineField(receiver, fieldRecord) + ... + 8. If fieldName is a Private Name, + a. Perform ? PrivateFieldAdd(fieldName, receiver, initValue). + 9. Else, + a. Assert: IsPropertyKey(fieldName) is true. + b. Perform ? CreateDataPropertyOrThrow(receiver, fieldName, initValue). + 10. Return. +features: [class, class-fields-public] +---*/ + +function ProxyBase() { + return new Proxy(this, { + defineProperty: function (target, key, descriptor) { + throw new Test262Error(); + } + }); +} + +class Base extends ProxyBase { + f = "Test262"; +} + +assert.throws(Test262Error, () => { new Base(); }); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/public-class-field-initialization-on-super-class-with-setter.js b/js/src/tests/test262/language/statements/class/elements/public-class-field-initialization-on-super-class-with-setter.js new file mode 100644 index 0000000000..ead5887638 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/public-class-field-initialization-on-super-class-with-setter.js @@ -0,0 +1,39 @@ +// Copyright (C) 2019 Caio Lima. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Public class field initialization calls [[DefineOwnProperty]] and don't execute super's getter +esid: sec-define-field +info: | + DefineField(receiver, fieldRecord) + ... + 8. If fieldName is a Private Name, + a. Perform ? PrivateFieldAdd(fieldName, receiver, initValue). + 9. Else, + a. Assert: IsPropertyKey(fieldName) is true. + b. Perform ? CreateDataPropertyOrThrow(receiver, fieldName, initValue). + 10. Return. +includes: [propertyHelper.js] +features: [class, class-fields-public] +---*/ + +class Super { + set f(v) { + throw new Test262Error(); + } +} + +class Base extends Super { + f = "Test262"; +} + +let o = new Base(); + +verifyProperty(o, "f", { + value: "Test262", + enumerable: true, + writable: true, + configurable: true, +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/redeclaration-symbol.js b/js/src/tests/test262/language/statements/class/elements/redeclaration-symbol.js new file mode 100644 index 0000000000..84fcf66da1 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/redeclaration-symbol.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/redeclaration-symbol.case +// - src/class-elements/default/cls-decl.template +/*--- +description: Redeclaration of public fields with the same name (field definitions in a class declaration) +esid: prod-FieldDefinition +features: [class-fields-public, class] +flags: [generated] +includes: [propertyHelper.js, compareArray.js] +info: | + 2.13.2 Runtime Semantics: ClassDefinitionEvaluation + + ... + 30. Set the value of F's [[Fields]] internal slot to fieldRecords. + ... + + 2.14 [[Construct]] ( argumentsList, newTarget) + + ... + 8. If kind is "base", then + ... + b. Let result be InitializeInstanceFields(thisArgument, F). + ... + + 2.9 InitializeInstanceFields ( O, constructor ) + + 3. Let fieldRecords be the value of constructor's [[Fields]] internal slot. + 4. For each item fieldRecord in order from fieldRecords, + a. If fieldRecord.[[static]] is false, then + i. Perform ? DefineField(O, fieldRecord). + +---*/ +var x = []; +var y = Symbol(); + + +class C { + [y] = (x.push("a"), "old_value"); + [y] = (x.push("b"), "same_value"); + [y] = (x.push("c"), "same_value"); +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, y), + "y does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, y), + "y does not appear as an own property on C constructor" +); + +verifyProperty(c, y, { + value: "same_value", + enumerable: true, + writable: true, + configurable: true +}); + +assert.compareArray(x, ["a", "b", "c"]); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/redeclaration.js b/js/src/tests/test262/language/statements/class/elements/redeclaration.js new file mode 100644 index 0000000000..adefc1b2ac --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/redeclaration.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/redeclaration.case +// - src/class-elements/default/cls-decl.template +/*--- +description: Redeclaration of public fields with the same name (field definitions in a class declaration) +esid: prod-FieldDefinition +features: [class-fields-public, computed-property-names, class] +flags: [generated] +includes: [propertyHelper.js, compareArray.js] +info: | + 2.13.2 Runtime Semantics: ClassDefinitionEvaluation + + ... + 30. Set the value of F's [[Fields]] internal slot to fieldRecords. + ... + + 2.14 [[Construct]] ( argumentsList, newTarget) + + ... + 8. If kind is "base", then + ... + b. Let result be InitializeInstanceFields(thisArgument, F). + ... + + 2.9 InitializeInstanceFields ( O, constructor ) + + 3. Let fieldRecords be the value of constructor's [[Fields]] internal slot. + 4. For each item fieldRecord in order from fieldRecords, + a. If fieldRecord.[[static]] is false, then + i. Perform ? DefineField(O, fieldRecord). + +---*/ +var x = []; + + +class C { + y = (x.push("a"), "old_value"); + ["y"] = (x.push("b"), "another_value"); + "y" = (x.push("c"), "same_value"); + y = (x.push("d"), "same_value"); +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "y"), + "y does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "y"), + "y does not appear as an own property on C constructor" +); + +verifyProperty(c, "y", { + value: "same_value", + enumerable: true, + writable: true, + configurable: true +}); + +assert.compareArray(x, ["a", "b", "c", "d"]); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/regular-definitions-computed-names.js b/js/src/tests/test262/language/statements/class/elements/regular-definitions-computed-names.js new file mode 100644 index 0000000000..804d5547d6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/regular-definitions-computed-names.js @@ -0,0 +1,94 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/computed-names.case +// - src/class-elements/productions/cls-decl-regular-definitions.template +/*--- +description: Computed property names (regular fields defintion) +esid: prod-FieldDefinition +features: [class-fields-public, computed-property-names, class] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PropertyName + +---*/ +var x = "b"; + + + +class C { + [x] = 42; [10] = "meep"; ["not initialized"] + +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "b"), + "b doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "b"), + "b doesn't appear as an own property on C constructor" +); + +verifyProperty(c, "b", { + value: 42, + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "x"), + "x doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "x"), + "x doesn't appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "x"), + "x doesn't appear as an own property on C instance" +); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "10"), + "10 doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "10"), + "10 doesn't appear as an own property on C constructor" +); + +verifyProperty(c, "10", { + value: "meep", + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "not initialized"), + "'not initialized' doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "not initialized"), + "'not initialized' doesn't appear as an own property on C constructor" +); + +verifyProperty(c, "not initialized", { + value: undefined, + enumerable: true, + writable: true, + configurable: true +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/regular-definitions-computed-symbol-names.js b/js/src/tests/test262/language/statements/class/elements/regular-definitions-computed-symbol-names.js new file mode 100644 index 0000000000..4c92e0626f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/regular-definitions-computed-symbol-names.js @@ -0,0 +1,92 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/computed-symbol-names.case +// - src/class-elements/productions/cls-decl-regular-definitions.template +/*--- +description: Computed property symbol names (regular fields defintion) +esid: prod-FieldDefinition +features: [class-fields-public, Symbol, computed-property-names, class] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PropertyName + +---*/ +var x = Symbol(); +var y = Symbol(); + + + +class C { + [x]; [y] = 42 + +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, x), + "Symbol x doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, x), + "Symbol x doesn't appear as an own property on C constructor" +); + +verifyProperty(c, x, { + value: undefined, + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, y), + "Symbol y doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, y), + "Symbol y doesn't appear as an own property on C constructor" +); + +verifyProperty(c, y, { + value: 42, + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "x"), + "x doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "x"), + "x doesn't appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "x"), + "x doesn't appear as an own property on C instance" +); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "y"), + "y doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "y"), + "y doesn't appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "y"), + "y doesn't appear as an own property on C instance" +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/regular-definitions-grammar-privatename-identifier-semantics-stringvalue.js b/js/src/tests/test262/language/statements/class/elements/regular-definitions-grammar-privatename-identifier-semantics-stringvalue.js new file mode 100644 index 0000000000..80fa60ad31 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/regular-definitions-grammar-privatename-identifier-semantics-stringvalue.js @@ -0,0 +1,95 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-privatename-identifier-semantics-stringvalue.case +// - src/class-elements/productions/cls-decl-regular-definitions.template +/*--- +description: PrivateName Static Semantics, StringValue (regular fields defintion) +esid: prod-FieldDefinition +features: [class-fields-private, class, class-fields-public] +flags: [generated] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + + + 1. Return the String value consisting of the sequence of code + units corresponding to PrivateName. In determining the sequence + any occurrences of \ UnicodeEscapeSequence are first replaced + with the code point represented by the UnicodeEscapeSequence + and then the code points of the entire PrivateName are converted + to code units by UTF16Encoding (10.1.1) each code point. + +---*/ + + +class C { + #\u{6F}; + #\u2118; + #ZW_\u200C_NJ; + #ZW_\u200D_J; + o(value) { + this.#o = value; + return this.#o; + } + ℘(value) { + this.#℘ = value; + return this.#℘; + } + ZW_‌_NJ(value) { // DO NOT CHANGE THE NAME OF THIS METHOD + this.#ZW_‌_NJ = value; + return this.#ZW_‌_NJ; + } + ZW_‍_J(value) { // DO NOT CHANGE THE NAME OF THIS METHOD + this.#ZW_‍_J = value; + return this.#ZW_‍_J; + } +} + +var c = new C(); + +assert.sameValue(c.o(1), 1); +assert.sameValue(c.℘(1), 1); +assert.sameValue(c.ZW_‌_NJ(1), 1); +assert.sameValue(c.ZW_‍_J(1), 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/regular-definitions-literal-names-asi.js b/js/src/tests/test262/language/statements/class/elements/regular-definitions-literal-names-asi.js new file mode 100644 index 0000000000..c3e40e0527 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/regular-definitions-literal-names-asi.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/literal-names-asi.case +// - src/class-elements/productions/cls-decl-regular-definitions.template +/*--- +description: Literal property names with ASI (regular fields defintion) +esid: prod-FieldDefinition +features: [class-fields-public, class] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PropertyName + +---*/ + + +class C { + a + b = 42; + +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "a"), + "a doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "a"), + "a doesn't appear as an own property on C constructor" +); + +verifyProperty(c, "a", { + value: undefined, + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "b"), + "b doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "b"), + "b doesn't appear as an own property on C constructor" +); + +verifyProperty(c, "b", { + value: 42, + enumerable: true, + writable: true, + configurable: true +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/regular-definitions-literal-names.js b/js/src/tests/test262/language/statements/class/elements/regular-definitions-literal-names.js new file mode 100644 index 0000000000..26d73e8e17 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/regular-definitions-literal-names.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/literal-names.case +// - src/class-elements/productions/cls-decl-regular-definitions.template +/*--- +description: Literal property names (regular fields defintion) +esid: prod-FieldDefinition +features: [class-fields-public, class] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PropertyName + +---*/ +const fn = function() {} + + + +class C { + a; b = 42; + c = fn + +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "a"), + "a doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "a"), + "a doesn't appear as an own property on C constructor" +); + +verifyProperty(c, "a", { + value: undefined, + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "b"), + "b doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "b"), + "b doesn't appear as an own property on C constructor" +); + +verifyProperty(c, "b", { + value: 42, + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "c"), + "c doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "c"), + "c doesn't appear as an own property on C constructor" +); + +verifyProperty(c, "c", { + value: fn, + enumerable: true, + writable: true, + configurable: true +}); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/regular-definitions-private-field-usage.js b/js/src/tests/test262/language/statements/class/elements/regular-definitions-private-field-usage.js new file mode 100644 index 0000000000..d8383f1c25 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/regular-definitions-private-field-usage.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/private-field-usage.case +// - src/class-elements/productions/cls-decl-regular-definitions.template +/*--- +description: PrivateName CallExpression usage (private field) (regular fields defintion) +esid: prod-FieldDefinition +features: [class-fields-private, class, class-fields-public] +flags: [generated] +info: | + Updated Productions + + CallExpression[Yield, Await]: + CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await] + SuperCall[?Yield, ?Await] + CallExpression[?Yield, ?Await]Arguments[?Yield, ?Await] + CallExpression[?Yield, ?Await][Expression[+In, ?Yield, ?Await]] + CallExpression[?Yield, ?Await].IdentifierName + CallExpression[?Yield, ?Await]TemplateLiteral[?Yield, ?Await] + CallExpression[?Yield, ?Await].PrivateName + +---*/ + + +class C { + #m = 'test262'; + method() { + return this.#m; + } +} + +var c = new C(); + +assert.sameValue(c.method(), 'test262'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/regular-definitions-private-method-getter-usage.js b/js/src/tests/test262/language/statements/class/elements/regular-definitions-private-method-getter-usage.js new file mode 100644 index 0000000000..e193a0f685 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/regular-definitions-private-method-getter-usage.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/private-method-getter-usage.case +// - src/class-elements/productions/cls-decl-regular-definitions.template +/*--- +description: PrivateName CallExpression usage (Accesor get method) (regular fields defintion) +esid: prod-FieldDefinition +features: [class-methods-private, class, class-fields-public] +flags: [generated] +info: | + Updated Productions + + CallExpression[Yield, Await]: + CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await] + SuperCall[?Yield, ?Await] + CallExpression[?Yield, ?Await]Arguments[?Yield, ?Await] + CallExpression[?Yield, ?Await][Expression[+In, ?Yield, ?Await]] + CallExpression[?Yield, ?Await].IdentifierName + CallExpression[?Yield, ?Await]TemplateLiteral[?Yield, ?Await] + CallExpression[?Yield, ?Await].PrivateName + +---*/ + + +class C { + get #m() { return 'test262'; } + method() { + return this.#m; + } +} + +var c = new C(); + +assert.sameValue(c.method(), 'test262'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/regular-definitions-private-method-usage.js b/js/src/tests/test262/language/statements/class/elements/regular-definitions-private-method-usage.js new file mode 100644 index 0000000000..414c3f0fbe --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/regular-definitions-private-method-usage.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/private-method-usage.case +// - src/class-elements/productions/cls-decl-regular-definitions.template +/*--- +description: PrivateName CallExpression usage (private method) (regular fields defintion) +esid: prod-FieldDefinition +features: [class-methods-private, class, class-fields-public] +flags: [generated] +info: | + Updated Productions + + CallExpression[Yield, Await]: + CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await] + SuperCall[?Yield, ?Await] + CallExpression[?Yield, ?Await]Arguments[?Yield, ?Await] + CallExpression[?Yield, ?Await][Expression[+In, ?Yield, ?Await]] + CallExpression[?Yield, ?Await].IdentifierName + CallExpression[?Yield, ?Await]TemplateLiteral[?Yield, ?Await] + CallExpression[?Yield, ?Await].PrivateName + +---*/ + + +class C { + #m() { return 'test262'; } + method() { + return this.#m(); + } +} + +var c = new C(); + +assert.sameValue(c.method(), 'test262'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/regular-definitions-private-names.js b/js/src/tests/test262/language/statements/class/elements/regular-definitions-private-names.js new file mode 100644 index 0000000000..e0033fde71 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/regular-definitions-private-names.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/private-names.case +// - src/class-elements/productions/cls-decl-regular-definitions.template +/*--- +description: private names (regular fields defintion) +esid: prod-FieldDefinition +features: [class-fields-private, class, class-fields-public] +flags: [generated] +info: | + ClassElement : + ... + FieldDefinition ; + + FieldDefinition : + ClassElementName Initializer_opt + + ClassElementName : + PrivateName + + PrivateName : + # IdentifierName + +---*/ + + +class C { + #x; #y + x() { + this.#x = 42; + return this.#x; + } + y() { + this.#y = 43; + return this.#y; + } +} + +var c = new C(); + +// Test the private fields do not appear as properties before set to value +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#x"), "test 1"); +assert(!Object.prototype.hasOwnProperty.call(C, "#x"), "test 2"); +assert(!Object.prototype.hasOwnProperty.call(c, "#x"), "test 3"); + +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#y"), "test 4"); +assert(!Object.prototype.hasOwnProperty.call(C, "#y"), "test 5"); +assert(!Object.prototype.hasOwnProperty.call(c, "#y"), "test 6"); + +// Test if private fields can be sucessfully accessed and set to value +assert.sameValue(c.x(), 42, "test 7"); +assert.sameValue(c.y(), 43, "test 8"); + +// Test the private fields do not appear as properties before after set to value +assert(!Object.prototype.hasOwnProperty.call(c, "#x"), "test 9"); +assert(!Object.prototype.hasOwnProperty.call(c, "#y"), "test 10"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/regular-definitions-rs-field-identifier-initializer.js b/js/src/tests/test262/language/statements/class/elements/regular-definitions-rs-field-identifier-initializer.js new file mode 100644 index 0000000000..90d7c9c884 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/regular-definitions-rs-field-identifier-initializer.js @@ -0,0 +1,73 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-field-identifier-initializer.case +// - src/class-elements/productions/cls-decl-regular-definitions.template +/*--- +description: Valid FieldDefinition (regular fields defintion) +esid: prod-FieldDefinition +features: [class-fields-public, class] +flags: [generated] +info: | + ClassElement : + ... + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + + PropertyName : + LiteralPropertyName + ComputedPropertyName + + LiteralPropertyName : + IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + $ = 1; _ = 1; \u{6F} = 1; \u2118 = 1; ZW_\u200C_NJ = 1; ZW_\u200D_J = 1 + +} + +var c = new C(); + +assert.sameValue(c.$, 1); +assert.sameValue(c._, 1); +assert.sameValue(c.\u{6F}, 1); +assert.sameValue(c.\u2118, 1); +assert.sameValue(c.ZW_\u200C_NJ, 1); +assert.sameValue(c.ZW_\u200D_J, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/regular-definitions-rs-field-identifier.js b/js/src/tests/test262/language/statements/class/elements/regular-definitions-rs-field-identifier.js new file mode 100644 index 0000000000..9c1eeb88c8 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/regular-definitions-rs-field-identifier.js @@ -0,0 +1,80 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-field-identifier.case +// - src/class-elements/productions/cls-decl-regular-definitions.template +/*--- +description: Valid FieldDefinition (regular fields defintion) +esid: prod-FieldDefinition +features: [class-fields-public, class] +flags: [generated] +info: | + ClassElement : + ... + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + + PropertyName : + LiteralPropertyName + ComputedPropertyName + + LiteralPropertyName : + IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + $; _; \u{6F}; \u2118; ZW_\u200C_NJ; ZW_\u200D_J + +} + +var c = new C(); + +c.$ = 1; +c._ = 1; +c.\u{6F} = 1; +c.\u2118 = 1; +c.ZW_\u200C_NJ = 1; +c.ZW_\u200D_J = 1; + +assert.sameValue(c.$, 1); +assert.sameValue(c._, 1); +assert.sameValue(c.\u{6F}, 1); +assert.sameValue(c.\u2118, 1); +assert.sameValue(c.ZW_\u200C_NJ, 1); +assert.sameValue(c.ZW_\u200D_J, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/regular-definitions-rs-private-getter-alt.js b/js/src/tests/test262/language/statements/class/elements/regular-definitions-rs-private-getter-alt.js new file mode 100644 index 0000000000..7a74aa71d6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/regular-definitions-rs-private-getter-alt.js @@ -0,0 +1,114 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-private-getter-alt.case +// - src/class-elements/productions/cls-decl-regular-definitions.template +/*--- +description: Valid PrivateName as private getter (regular fields defintion) +esid: prod-FieldDefinition +features: [class-methods-private, class-fields-private, class, class-fields-public] +flags: [generated] +info: | + ClassElement : + MethodDefinition + ... + ; + + MethodDefinition : + ... + get ClassElementName ( ){ FunctionBody } + ... + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + #$_; #__; #\u{6F}_; #℘_; #ZW_‌_NJ_; #ZW_‍_J_; + get #$() { + return this.#$_; + } + get #_() { + return this.#__; + } + get #\u{6F}() { + return this.#\u{6F}_; + } + get #℘() { + return this.#℘_; + } + get #ZW_‌_NJ() { + return this.#ZW_‌_NJ_; + } + get #ZW_‍_J() { + return this.#ZW_‍_J_; + } + + $(value) { + this.#$_ = value; + return this.#$; + } + _(value) { + this.#__ = value; + return this.#_; + } + \u{6F}(value) { + this.#\u{6F}_ = value; + return this.#\u{6F}; + } + ℘(value) { + this.#℘_ = value; + return this.#℘; + } + ZW_‌_NJ(value) { + this.#ZW_‌_NJ_ = value; + return this.#ZW_‌_NJ; + } + ZW_‍_J(value) { + this.#ZW_‍_J_ = value; + return this.#ZW_‍_J; + } + +} + +var c = new C(); + +assert.sameValue(c.$(1), 1); +assert.sameValue(c._(1), 1); +assert.sameValue(c.\u{6F}(1), 1); +assert.sameValue(c.℘(1), 1); +assert.sameValue(c.ZW_‌_NJ(1), 1); +assert.sameValue(c.ZW_‍_J(1), 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/regular-definitions-rs-private-getter.js b/js/src/tests/test262/language/statements/class/elements/regular-definitions-rs-private-getter.js new file mode 100644 index 0000000000..64370e9bea --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/regular-definitions-rs-private-getter.js @@ -0,0 +1,114 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-private-getter.case +// - src/class-elements/productions/cls-decl-regular-definitions.template +/*--- +description: Valid PrivateName as private getter (regular fields defintion) +esid: prod-FieldDefinition +features: [class-methods-private, class-fields-private, class, class-fields-public] +flags: [generated] +info: | + ClassElement : + MethodDefinition + ... + ; + + MethodDefinition : + ... + get ClassElementName ( ){ FunctionBody } + ... + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + #$_; #__; #\u{6F}_; #\u2118_; #ZW_\u200C_NJ_; #ZW_\u200D_J_; + get #$() { + return this.#$_; + } + get #_() { + return this.#__; + } + get #\u{6F}() { + return this.#\u{6F}_; + } + get #\u2118() { + return this.#\u2118_; + } + get #ZW_\u200C_NJ() { + return this.#ZW_\u200C_NJ_; + } + get #ZW_\u200D_J() { + return this.#ZW_\u200D_J_; + } + + $(value) { + this.#$_ = value; + return this.#$; + } + _(value) { + this.#__ = value; + return this.#_; + } + \u{6F}(value) { + this.#\u{6F}_ = value; + return this.#\u{6F}; + } + \u2118(value) { + this.#\u2118_ = value; + return this.#\u2118; + } + ZW_\u200C_NJ(value) { + this.#ZW_\u200C_NJ_ = value; + return this.#ZW_\u200C_NJ; + } + ZW_\u200D_J(value) { + this.#ZW_\u200D_J_ = value; + return this.#ZW_\u200D_J; + } + +} + +var c = new C(); + +assert.sameValue(c.$(1), 1); +assert.sameValue(c._(1), 1); +assert.sameValue(c.\u{6F}(1), 1); +assert.sameValue(c.\u2118(1), 1); +assert.sameValue(c.ZW_\u200C_NJ(1), 1); +assert.sameValue(c.ZW_\u200D_J(1), 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/regular-definitions-rs-private-method-alt.js b/js/src/tests/test262/language/statements/class/elements/regular-definitions-rs-private-method-alt.js new file mode 100644 index 0000000000..ca1d7342d2 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/regular-definitions-rs-private-method-alt.js @@ -0,0 +1,113 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-private-method-alt.case +// - src/class-elements/productions/cls-decl-regular-definitions.template +/*--- +description: Valid PrivateName as private method (regular fields defintion) +esid: prod-FieldDefinition +features: [class-methods-private, class-fields-private, class, class-fields-public] +flags: [generated] +info: | + ClassElement : + MethodDefinition + ... + ; + + MethodDefinition : + ClassElementName ( UniqueFormalParameters ) { FunctionBody } + ... + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + #$_; #__; #\u{6F}_; #℘_; #ZW_‌_NJ_; #ZW_‍_J_; + #$() { + return this.#$_; + } + #_() { + return this.#__; + } + #\u{6F}() { + return this.#\u{6F}_; + } + #℘() { + return this.#℘_; + } + #ZW_‌_NJ() { + return this.#ZW_‌_NJ_; + } + #ZW_‍_J() { + return this.#ZW_‍_J_; + } + + $(value) { + this.#$_ = value; + return this.#$(); + } + _(value) { + this.#__ = value; + return this.#_(); + } + \u{6F}(value) { + this.#\u{6F}_ = value; + return this.#\u{6F}(); + } + ℘(value) { + this.#℘_ = value; + return this.#℘(); + } + ZW_‌_NJ(value) { + this.#ZW_‌_NJ_ = value; + return this.#ZW_‌_NJ(); + } + ZW_‍_J(value) { + this.#ZW_‍_J_ = value; + return this.#ZW_‍_J(); + } + +} + +var c = new C(); + +assert.sameValue(c.$(1), 1); +assert.sameValue(c._(1), 1); +assert.sameValue(c.\u{6F}(1), 1); +assert.sameValue(c.℘(1), 1); +assert.sameValue(c.ZW_‌_NJ(1), 1); +assert.sameValue(c.ZW_‍_J(1), 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/regular-definitions-rs-private-method.js b/js/src/tests/test262/language/statements/class/elements/regular-definitions-rs-private-method.js new file mode 100644 index 0000000000..9ab249e21a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/regular-definitions-rs-private-method.js @@ -0,0 +1,113 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-private-method.case +// - src/class-elements/productions/cls-decl-regular-definitions.template +/*--- +description: Valid PrivateName as private method (regular fields defintion) +esid: prod-FieldDefinition +features: [class-methods-private, class-fields-private, class, class-fields-public] +flags: [generated] +info: | + ClassElement : + MethodDefinition + ... + ; + + MethodDefinition : + ClassElementName ( UniqueFormalParameters ) { FunctionBody } + ... + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + #$_; #__; #\u{6F}_; #\u2118_; #ZW_\u200C_NJ_; #ZW_\u200D_J_; + #$() { + return this.#$_; + } + #_() { + return this.#__; + } + #\u{6F}() { + return this.#\u{6F}_; + } + #\u2118() { + return this.#\u2118_; + } + #ZW_\u200C_NJ() { + return this.#ZW_\u200C_NJ_; + } + #ZW_\u200D_J() { + return this.#ZW_\u200D_J_; + } + + $(value) { + this.#$_ = value; + return this.#$(); + } + _(value) { + this.#__ = value; + return this.#_(); + } + \u{6F}(value) { + this.#\u{6F}_ = value; + return this.#\u{6F}(); + } + \u2118(value) { + this.#\u2118_ = value; + return this.#\u2118(); + } + ZW_\u200C_NJ(value) { + this.#ZW_\u200C_NJ_ = value; + return this.#ZW_\u200C_NJ(); + } + ZW_\u200D_J(value) { + this.#ZW_\u200D_J_ = value; + return this.#ZW_\u200D_J(); + } + +} + +var c = new C(); + +assert.sameValue(c.$(1), 1); +assert.sameValue(c._(1), 1); +assert.sameValue(c.\u{6F}(1), 1); +assert.sameValue(c.\u2118(1), 1); +assert.sameValue(c.ZW_\u200C_NJ(1), 1); +assert.sameValue(c.ZW_\u200D_J(1), 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/regular-definitions-rs-private-setter-alt.js b/js/src/tests/test262/language/statements/class/elements/regular-definitions-rs-private-setter-alt.js new file mode 100644 index 0000000000..84e201cc46 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/regular-definitions-rs-private-setter-alt.js @@ -0,0 +1,113 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-private-setter-alt.case +// - src/class-elements/productions/cls-decl-regular-definitions.template +/*--- +description: Valid PrivateName as private setter (regular fields defintion) +esid: prod-FieldDefinition +features: [class-methods-private, class-fields-private, class, class-fields-public] +flags: [generated] +info: | + ClassElement : + MethodDefinition + ... + ; + + MethodDefinition : + ... + set ClassElementName ( PropertySetParameterList ) { FunctionBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + #$_; #__; #\u{6F}_; #℘_; #ZW_‌_NJ_; #ZW_‍_J_; + set #$(value) { + this.#$_ = value; + } + set #_(value) { + this.#__ = value; + } + set #\u{6F}(value) { + this.#\u{6F}_ = value; + } + set #℘(value) { + this.#℘_ = value; + } + set #ZW_‌_NJ(value) { + this.#ZW_‌_NJ_ = value; + } + set #ZW_‍_J(value) { + this.#ZW_‍_J_ = value; + } + + $(value) { + this.#$ = value; + return this.#$_; + } + _(value) { + this.#_ = value; + return this.#__; + } + \u{6F}(value) { + this.#\u{6F} = value; + return this.#\u{6F}_; + } + ℘(value) { + this.#℘ = value; + return this.#℘_; + } + ZW_‌_NJ(value) { + this.#ZW_‌_NJ = value; + return this.#ZW_‌_NJ_; + } + ZW_‍_J(value) { + this.#ZW_‍_J = value; + return this.#ZW_‍_J_; + } + +} + +var c = new C(); + +assert.sameValue(c.$(1), 1); +assert.sameValue(c._(1), 1); +assert.sameValue(c.\u{6F}(1), 1); +assert.sameValue(c.℘(1), 1); +assert.sameValue(c.ZW_‌_NJ(1), 1); +assert.sameValue(c.ZW_‍_J(1), 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/regular-definitions-rs-private-setter.js b/js/src/tests/test262/language/statements/class/elements/regular-definitions-rs-private-setter.js new file mode 100644 index 0000000000..9a5ccb9b66 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/regular-definitions-rs-private-setter.js @@ -0,0 +1,113 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-private-setter.case +// - src/class-elements/productions/cls-decl-regular-definitions.template +/*--- +description: Valid PrivateName as private setter (regular fields defintion) +esid: prod-FieldDefinition +features: [class-methods-private, class-fields-private, class, class-fields-public] +flags: [generated] +info: | + ClassElement : + MethodDefinition + ... + ; + + MethodDefinition : + ... + set ClassElementName ( PropertySetParameterList ) { FunctionBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + #$_; #__; #\u{6F}_; #\u2118_; #ZW_\u200C_NJ_; #ZW_\u200D_J_; + set #$(value) { + this.#$_ = value; + } + set #_(value) { + this.#__ = value; + } + set #\u{6F}(value) { + this.#\u{6F}_ = value; + } + set #\u2118(value) { + this.#\u2118_ = value; + } + set #ZW_\u200C_NJ(value) { + this.#ZW_\u200C_NJ_ = value; + } + set #ZW_\u200D_J(value) { + this.#ZW_\u200D_J_ = value; + } + + $(value) { + this.#$ = value; + return this.#$_; + } + _(value) { + this.#_ = value; + return this.#__; + } + \u{6F}(value) { + this.#\u{6F} = value; + return this.#\u{6F}_; + } + \u2118(value) { + this.#\u2118 = value; + return this.#\u2118_; + } + ZW_\u200C_NJ(value) { + this.#ZW_\u200C_NJ = value; + return this.#ZW_\u200C_NJ_; + } + ZW_\u200D_J(value) { + this.#ZW_\u200D_J = value; + return this.#ZW_\u200D_J_; + } + +} + +var c = new C(); + +assert.sameValue(c.$(1), 1); +assert.sameValue(c._(1), 1); +assert.sameValue(c.\u{6F}(1), 1); +assert.sameValue(c.\u2118(1), 1); +assert.sameValue(c.ZW_\u200C_NJ(1), 1); +assert.sameValue(c.ZW_\u200D_J(1), 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/regular-definitions-rs-privatename-identifier-alt.js b/js/src/tests/test262/language/statements/class/elements/regular-definitions-rs-privatename-identifier-alt.js new file mode 100644 index 0000000000..ded06a1333 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/regular-definitions-rs-privatename-identifier-alt.js @@ -0,0 +1,95 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-privatename-identifier-alt.case +// - src/class-elements/productions/cls-decl-regular-definitions.template +/*--- +description: Valid PrivateName (regular fields defintion) +esid: prod-FieldDefinition +features: [class-fields-private, class, class-fields-public] +flags: [generated] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + #$; #_; #\u{6F}; #℘; #ZW_‌_NJ; #ZW_‍_J + $(value) { + this.#$ = value; + return this.#$; + } + _(value) { + this.#_ = value; + return this.#_; + } + \u{6F}(value) { + this.#\u{6F} = value; + return this.#\u{6F}; + } + ℘(value) { + this.#℘ = value; + return this.#℘; + } + ZW_‌_NJ(value) { + this.#ZW_‌_NJ = value; + return this.#ZW_‌_NJ; + } + ZW_‍_J(value) { + this.#ZW_‍_J = value; + return this.#ZW_‍_J; + } +} + +var c = new C(); + +assert.sameValue(c.$(1), 1); +assert.sameValue(c._(1), 1); +assert.sameValue(c.\u{6F}(1), 1); +assert.sameValue(c.℘(1), 1); +assert.sameValue(c.ZW_‌_NJ(1), 1); +assert.sameValue(c.ZW_‍_J(1), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/regular-definitions-rs-privatename-identifier-initializer-alt.js b/js/src/tests/test262/language/statements/class/elements/regular-definitions-rs-privatename-identifier-initializer-alt.js new file mode 100644 index 0000000000..217f88f14d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/regular-definitions-rs-privatename-identifier-initializer-alt.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-privatename-identifier-initializer-alt.case +// - src/class-elements/productions/cls-decl-regular-definitions.template +/*--- +description: Valid PrivateName (regular fields defintion) +esid: prod-FieldDefinition +features: [class-fields-private, class, class-fields-public] +flags: [generated] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + #$ = 1; #_ = 1; #\u{6F} = 1; #℘ = 1; #ZW_‌_NJ = 1; #ZW_‍_J = 1 + $() { + return this.#$; + } + _() { + return this.#_; + } + \u{6F}() { + return this.#\u{6F}; + } + ℘() { + return this.#℘; + } + ZW_‌_NJ() { + return this.#ZW_‌_NJ; + } + ZW_‍_J() { + return this.#ZW_‍_J; + } +} + +var c = new C(); + +assert.sameValue(c.$(), 1); +assert.sameValue(c._(), 1); +assert.sameValue(c.\u{6F}(), 1); +assert.sameValue(c.℘(), 1); +assert.sameValue(c.ZW_‌_NJ(), 1); +assert.sameValue(c.ZW_‍_J(), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/regular-definitions-rs-privatename-identifier-initializer.js b/js/src/tests/test262/language/statements/class/elements/regular-definitions-rs-privatename-identifier-initializer.js new file mode 100644 index 0000000000..14e266a2f6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/regular-definitions-rs-privatename-identifier-initializer.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-privatename-identifier-initializer.case +// - src/class-elements/productions/cls-decl-regular-definitions.template +/*--- +description: Valid PrivateName (regular fields defintion) +esid: prod-FieldDefinition +features: [class-fields-private, class, class-fields-public] +flags: [generated] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + #$ = 1; #_ = 1; #\u{6F} = 1; #\u2118 = 1; #ZW_\u200C_NJ = 1; #ZW_\u200D_J = 1 + $() { + return this.#$; + } + _() { + return this.#_; + } + \u{6F}() { + return this.#\u{6F}; + } + \u2118() { + return this.#\u2118; + } + ZW_\u200C_NJ() { + return this.#ZW_\u200C_NJ; + } + ZW_\u200D_J() { + return this.#ZW_\u200D_J; + } +} + +var c = new C(); + +assert.sameValue(c.$(), 1); +assert.sameValue(c._(), 1); +assert.sameValue(c.\u{6F}(), 1); +assert.sameValue(c.\u2118(), 1); +assert.sameValue(c.ZW_\u200C_NJ(), 1); +assert.sameValue(c.ZW_\u200D_J(), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/regular-definitions-rs-privatename-identifier.js b/js/src/tests/test262/language/statements/class/elements/regular-definitions-rs-privatename-identifier.js new file mode 100644 index 0000000000..4dfebd2c24 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/regular-definitions-rs-privatename-identifier.js @@ -0,0 +1,95 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-privatename-identifier.case +// - src/class-elements/productions/cls-decl-regular-definitions.template +/*--- +description: Valid PrivateName (regular fields defintion) +esid: prod-FieldDefinition +features: [class-fields-private, class, class-fields-public] +flags: [generated] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + #$; #_; #\u{6F}; #\u2118; #ZW_\u200C_NJ; #ZW_\u200D_J + $(value) { + this.#$ = value; + return this.#$; + } + _(value) { + this.#_ = value; + return this.#_; + } + \u{6F}(value) { + this.#\u{6F} = value; + return this.#\u{6F}; + } + \u2118(value) { + this.#\u2118 = value; + return this.#\u2118; + } + ZW_\u200C_NJ(value) { + this.#ZW_\u200C_NJ = value; + return this.#ZW_\u200C_NJ; + } + ZW_\u200D_J(value) { + this.#ZW_\u200D_J = value; + return this.#ZW_\u200D_J; + } +} + +var c = new C(); + +assert.sameValue(c.$(1), 1); +assert.sameValue(c._(1), 1); +assert.sameValue(c.\u{6F}(1), 1); +assert.sameValue(c.\u2118(1), 1); +assert.sameValue(c.ZW_\u200C_NJ(1), 1); +assert.sameValue(c.ZW_\u200D_J(1), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/regular-definitions-rs-static-async-generator-method-privatename-identifier-alt.js b/js/src/tests/test262/language/statements/class/elements/regular-definitions-rs-static-async-generator-method-privatename-identifier-alt.js new file mode 100644 index 0000000000..77d38c6e02 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/regular-definitions-rs-static-async-generator-method-privatename-identifier-alt.js @@ -0,0 +1,120 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-async-generator-method-privatename-identifier-alt.case +// - src/class-elements/productions/cls-decl-regular-definitions.template +/*--- +description: Valid Static AsyncGeneratorMethod PrivateName (regular fields defintion) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + AsyncGeneratorMethod + + AsyncGeneratorMethod : + async [no LineTerminator here] * ClassElementName ( UniqueFormalParameters){ AsyncGeneratorBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static async * #$(value) { + yield * await value; + } + static async * #_(value) { + yield * await value; + } + static async * #o(value) { + yield * await value; + } + static async * #℘(value) { + yield * await value; + } + static async * #ZW_‌_NJ(value) { + yield * await value; + } + static async * #ZW_‍_J(value) { + yield * await value; + } + static get $() { + return this.#$; + } + static get _() { + return this.#_; + } + static get o() { + return this.#o; + } + static get ℘() { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#℘; + } + static get ZW_‌_NJ() { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#ZW_‌_NJ; + } + static get ZW_‍_J() { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#ZW_‍_J; + } + +} + +var c = new C(); + +Promise.all([ + C.$([1]).next(), + C._([1]).next(), + C.o([1]).next(), + C.℘([1]).next(), // DO NOT CHANGE THE NAME OF THIS FIELD + C.ZW_‌_NJ([1]).next(), // DO NOT CHANGE THE NAME OF THIS FIELD + C.ZW_‍_J([1]).next(), // DO NOT CHANGE THE NAME OF THIS FIELD +]).then(results => { + + assert.sameValue(results[0].value, 1); + assert.sameValue(results[1].value, 1); + assert.sameValue(results[2].value, 1); + assert.sameValue(results[3].value, 1); + assert.sameValue(results[4].value, 1); + assert.sameValue(results[5].value, 1); + +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/regular-definitions-rs-static-async-generator-method-privatename-identifier.js b/js/src/tests/test262/language/statements/class/elements/regular-definitions-rs-static-async-generator-method-privatename-identifier.js new file mode 100644 index 0000000000..7950268e1a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/regular-definitions-rs-static-async-generator-method-privatename-identifier.js @@ -0,0 +1,121 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-async-generator-method-privatename-identifier.case +// - src/class-elements/productions/cls-decl-regular-definitions.template +/*--- +description: Valid Static AsyncGeneratorMethod PrivateName (regular fields defintion) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + AsyncGeneratorMethod + + AsyncGeneratorMethod : + async [no LineTerminator here] * ClassElementName ( UniqueFormalParameters){ AsyncGeneratorBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static async * #$(value) { + yield * await value; + } + static async * #_(value) { + yield * await value; + } + static async * #\u{6F}(value) { + yield * await value; + } + static async * #\u2118(value) { + yield * await value; + } + static async * #ZW_\u200C_NJ(value) { + yield * await value; + } + static async * #ZW_\u200D_J(value) { + yield * await value; + } + static get $() { + return this.#$; + } + static get _() { + return this.#_; + } + static get \u{6F}() { + return this.#\u{6F}; + } + static get \u2118() { + return this.#\u2118; + } + static get ZW_\u200C_NJ() { + return this.#ZW_\u200C_NJ; + } + static get ZW_\u200D_J() { + return this.#ZW_\u200D_J; + } + +} + +var c = new C(); + +Promise.all([ + C.$([1]).next(), + C._([1]).next(), + C.\u{6F}([1]).next(), + C.\u2118([1]).next(), + C.ZW_\u200C_NJ([1]).next(), + C.ZW_\u200D_J([1]).next(), +]).then(results => { + + assert.sameValue(results[0].value, 1); + assert.sameValue(results[1].value, 1); + assert.sameValue(results[2].value, 1); + assert.sameValue(results[3].value, 1); + assert.sameValue(results[4].value, 1); + assert.sameValue(results[5].value, 1); + +}).then($DONE, $DONE); + diff --git a/js/src/tests/test262/language/statements/class/elements/regular-definitions-rs-static-async-method-privatename-identifier-alt.js b/js/src/tests/test262/language/statements/class/elements/regular-definitions-rs-static-async-method-privatename-identifier-alt.js new file mode 100644 index 0000000000..2f28b5eafe --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/regular-definitions-rs-static-async-method-privatename-identifier-alt.js @@ -0,0 +1,120 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-async-method-privatename-identifier-alt.case +// - src/class-elements/productions/cls-decl-regular-definitions.template +/*--- +description: Valid Static AsyncMethod PrivateName (regular fields defintion) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + AsyncMethod + + AsyncMethod : + async [no LineTerminator here] ClassElementName ( UniqueFormalParameters ){ AsyncFunctionBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static async #$(value) { + return await value; + } + static async #_(value) { + return await value; + } + static async #o(value) { + return await value; + } + static async #℘(value) { + return await value; + } + static async #ZW_‌_NJ(value) { + return await value; + } + static async #ZW_‍_J(value) { + return await value; + } + static async $(value) { + return await this.#$(value); + } + static async _(value) { + return await this.#_(value); + } + static async o(value) { + return await this.#o(value); + } + static async ℘(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + return await this.#℘(value); + } + static async ZW_‌_NJ(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + return await this.#ZW_‌_NJ(value); + } + static async ZW_‍_J(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + return await this.#ZW_‍_J(value); + } + +} + +var c = new C(); + +Promise.all([ + C.$(1), + C._(1), + C.o(1), + C.℘(1), // DO NOT CHANGE THE NAME OF THIS FIELD + C.ZW_‌_NJ(1), // DO NOT CHANGE THE NAME OF THIS FIELD + C.ZW_‍_J(1), // DO NOT CHANGE THE NAME OF THIS FIELD +]).then(results => { + + assert.sameValue(results[0], 1); + assert.sameValue(results[1], 1); + assert.sameValue(results[2], 1); + assert.sameValue(results[3], 1); + assert.sameValue(results[4], 1); + assert.sameValue(results[5], 1); + +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/regular-definitions-rs-static-async-method-privatename-identifier.js b/js/src/tests/test262/language/statements/class/elements/regular-definitions-rs-static-async-method-privatename-identifier.js new file mode 100644 index 0000000000..509ef00256 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/regular-definitions-rs-static-async-method-privatename-identifier.js @@ -0,0 +1,121 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-async-method-privatename-identifier.case +// - src/class-elements/productions/cls-decl-regular-definitions.template +/*--- +description: Valid Static AsyncMethod PrivateName (regular fields defintion) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + AsyncMethod + + AsyncMethod : + async [no LineTerminator here] ClassElementName ( UniqueFormalParameters ){ AsyncFunctionBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static async #$(value) { + return await value; + } + static async #_(value) { + return await value; + } + static async #\u{6F}(value) { + return await value; + } + static async #\u2118(value) { + return await value; + } + static async #ZW_\u200C_NJ(value) { + return await value; + } + static async #ZW_\u200D_J(value) { + return await value; + } + static async $(value) { + return await this.#$(value); + } + static async _(value) { + return await this.#_(value); + } + static async \u{6F}(value) { + return await this.#\u{6F}(value); + } + static async \u2118(value) { + return await this.#\u2118(value); + } + static async ZW_\u200C_NJ(value) { + return await this.#ZW_\u200C_NJ(value); + } + static async ZW_\u200D_J(value) { + return await this.#ZW_\u200D_J(value); + } + +} + +var c = new C(); + +Promise.all([ + C.$(1), + C._(1), + C.\u{6F}(1), + C.\u2118(1), + C.ZW_\u200C_NJ(1), + C.ZW_\u200D_J(1), +]).then(results => { + + assert.sameValue(results[0], 1); + assert.sameValue(results[1], 1); + assert.sameValue(results[2], 1); + assert.sameValue(results[3], 1); + assert.sameValue(results[4], 1); + assert.sameValue(results[5], 1); + +}).then($DONE, $DONE); + diff --git a/js/src/tests/test262/language/statements/class/elements/regular-definitions-rs-static-generator-method-privatename-identifier-alt.js b/js/src/tests/test262/language/statements/class/elements/regular-definitions-rs-static-generator-method-privatename-identifier-alt.js new file mode 100644 index 0000000000..2aa0d02e57 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/regular-definitions-rs-static-generator-method-privatename-identifier-alt.js @@ -0,0 +1,110 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-generator-method-privatename-identifier-alt.case +// - src/class-elements/productions/cls-decl-regular-definitions.template +/*--- +description: Valid Static GeneratorMethod PrivateName (regular fields defintion) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public] +flags: [generated] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + GeneratorMethod + + GeneratorMethod : + * ClassElementName ( UniqueFormalParameters ){ GeneratorBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static * #$(value) { + yield * value; + } + static * #_(value) { + yield * value; + } + static * #o(value) { + yield * value; + } + static * #℘(value) { + yield * value; + } + static * #ZW_‌_NJ(value) { + yield * value; + } + static * #ZW_‍_J(value) { + yield * value; + } + static get $() { + return this.#$; + } + static get _() { + return this.#_; + } + static get o() { + return this.#o; + } + static get ℘() { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#℘; + } + static get ZW_‌_NJ() { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#ZW_‌_NJ; + } + static get ZW_‍_J() { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#ZW_‍_J; + } + +} + +var c = new C(); + +assert.sameValue(C.$([1]).next().value, 1); +assert.sameValue(C._([1]).next().value, 1); +assert.sameValue(C.o([1]).next().value, 1); +assert.sameValue(C.℘([1]).next().value, 1); +assert.sameValue(C.ZW_‌_NJ([1]).next().value, 1); +assert.sameValue(C.ZW_‍_J([1]).next().value, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/regular-definitions-rs-static-generator-method-privatename-identifier.js b/js/src/tests/test262/language/statements/class/elements/regular-definitions-rs-static-generator-method-privatename-identifier.js new file mode 100644 index 0000000000..001428d143 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/regular-definitions-rs-static-generator-method-privatename-identifier.js @@ -0,0 +1,111 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-generator-method-privatename-identifier.case +// - src/class-elements/productions/cls-decl-regular-definitions.template +/*--- +description: Valid Static GeneratorMethod PrivateName (regular fields defintion) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public] +flags: [generated] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + GeneratorMethod + + GeneratorMethod : + * ClassElementName ( UniqueFormalParameters ){ GeneratorBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static * #$(value) { + yield * value; + } + static * #_(value) { + yield * value; + } + static * #\u{6F}(value) { + yield * value; + } + static * #\u2118(value) { + yield * value; + } + static * #ZW_\u200C_NJ(value) { + yield * value; + } + static * #ZW_\u200D_J(value) { + yield * value; + } + static get $() { + return this.#$; + } + static get _() { + return this.#_; + } + static get \u{6F}() { + return this.#\u{6F}; + } + static get \u2118() { + return this.#\u2118; + } + static get ZW_\u200C_NJ() { + return this.#ZW_\u200C_NJ; + } + static get ZW_\u200D_J() { + return this.#ZW_\u200D_J; + } + +} + +var c = new C(); + +assert.sameValue(C.$([1]).next().value, 1); +assert.sameValue(C._([1]).next().value, 1); +assert.sameValue(C.\u{6F}([1]).next().value, 1); +assert.sameValue(C.\u2118([1]).next().value, 1); +assert.sameValue(C.ZW_\u200C_NJ([1]).next().value, 1); +assert.sameValue(C.ZW_\u200D_J([1]).next().value, 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/regular-definitions-rs-static-method-privatename-identifier-alt.js b/js/src/tests/test262/language/statements/class/elements/regular-definitions-rs-static-method-privatename-identifier-alt.js new file mode 100644 index 0000000000..ea4e64890b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/regular-definitions-rs-static-method-privatename-identifier-alt.js @@ -0,0 +1,108 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-method-privatename-identifier-alt.case +// - src/class-elements/productions/cls-decl-regular-definitions.template +/*--- +description: Valid Static Method PrivateName (regular fields defintion) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public] +flags: [generated] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + ClassElementName ( UniqueFormalParameters ){ FunctionBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static #$(value) { + return value; + } + static #_(value) { + return value; + } + static #o(value) { + return value; + } + static #℘(value) { + return value; + } + static #ZW_‌_NJ(value) { + return value; + } + static #ZW_‍_J(value) { + return value; + } + static $(value) { + return this.#$(value); + } + static _(value) { + return this.#_(value); + } + static o(value) { + return this.#o(value); + } + static ℘(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#℘(value); + } + static ZW_‌_NJ(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#ZW_‌_NJ(value); + } + static ZW_‍_J(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#ZW_‍_J(value); + } + +} + +var c = new C(); + +assert.sameValue(C.$(1), 1); +assert.sameValue(C._(1), 1); +assert.sameValue(C.o(1), 1); +assert.sameValue(C.℘(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD +assert.sameValue(C.ZW_‌_NJ(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD +assert.sameValue(C.ZW_‍_J(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/regular-definitions-rs-static-method-privatename-identifier.js b/js/src/tests/test262/language/statements/class/elements/regular-definitions-rs-static-method-privatename-identifier.js new file mode 100644 index 0000000000..9af7fea9a5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/regular-definitions-rs-static-method-privatename-identifier.js @@ -0,0 +1,108 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-method-privatename-identifier.case +// - src/class-elements/productions/cls-decl-regular-definitions.template +/*--- +description: Valid Static Method PrivateName (regular fields defintion) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public] +flags: [generated] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + ClassElementName ( UniqueFormalParameters ){ FunctionBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static #$(value) { + return value; + } + static #_(value) { + return value; + } + static #\u{6F}(value) { + return value; + } + static #\u2118(value) { + return value; + } + static #ZW_\u200C_NJ(value) { + return value; + } + static #ZW_\u200D_J(value) { + return value; + } + static $(value) { + return this.#$(value); + } + static _(value) { + return this.#_(value); + } + static \u{6F}(value) { + return this.#\u{6F}(value); + } + static \u2118(value) { + return this.#\u2118(value); + } + static ZW_\u200C_NJ(value) { + return this.#ZW_\u200C_NJ(value); + } + static ZW_\u200D_J(value) { + return this.#ZW_\u200D_J(value); + } + +} + +var c = new C(); + +assert.sameValue(C.$(1), 1); +assert.sameValue(C._(1), 1); +assert.sameValue(C.\u{6F}(1), 1); +assert.sameValue(C.\u2118(1), 1); +assert.sameValue(C.ZW_\u200C_NJ(1), 1); +assert.sameValue(C.ZW_\u200D_J(1), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/regular-definitions-rs-static-privatename-identifier-alt-by-classname.js b/js/src/tests/test262/language/statements/class/elements/regular-definitions-rs-static-privatename-identifier-alt-by-classname.js new file mode 100644 index 0000000000..0635aee73e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/regular-definitions-rs-static-privatename-identifier-alt-by-classname.js @@ -0,0 +1,96 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-privatename-identifier-alt-by-classname.case +// - src/class-elements/productions/cls-decl-regular-definitions.template +/*--- +description: Valid Static PrivateName (regular fields defintion) +esid: prod-FieldDefinition +features: [class-static-fields-private, class, class-fields-public] +flags: [generated] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static #$; static #_; static #\u{6F}; static #℘; static #ZW_‌_NJ; static #ZW_‍_J + static $(value) { + C.#$ = value; + return C.#$; + } + static _(value) { + C.#_ = value; + return C.#_; + } + static o(value) { + C.#\u{6F} = value; + return C.#\u{6F}; + } + static ℘(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + C.#℘ = value; + return C.#℘; + } + static ZW_‌_NJ(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + C.#ZW_‌_NJ = value; + return C.#ZW_‌_NJ; + } + static ZW_‍_J(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + C.#ZW_‍_J = value; + return C.#ZW_‍_J; + } +} + +var c = new C(); + +assert.sameValue(C.$(1), 1); +assert.sameValue(C._(1), 1); +assert.sameValue(C.o(1), 1); +assert.sameValue(C.℘(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD +assert.sameValue(C.ZW_‌_NJ(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD +assert.sameValue(C.ZW_‍_J(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/regular-definitions-rs-static-privatename-identifier-alt.js b/js/src/tests/test262/language/statements/class/elements/regular-definitions-rs-static-privatename-identifier-alt.js new file mode 100644 index 0000000000..954d8585db --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/regular-definitions-rs-static-privatename-identifier-alt.js @@ -0,0 +1,96 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-privatename-identifier-alt.case +// - src/class-elements/productions/cls-decl-regular-definitions.template +/*--- +description: Valid Static PrivateName (regular fields defintion) +esid: prod-FieldDefinition +features: [class-static-fields-private, class, class-fields-public] +flags: [generated] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static #$; static #_; static #\u{6F}; static #℘; static #ZW_‌_NJ; static #ZW_‍_J + static $(value) { + this.#$ = value; + return this.#$; + } + static _(value) { + this.#_ = value; + return this.#_; + } + static o(value) { + this.#\u{6F} = value; + return this.#\u{6F}; + } + static ℘(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + this.#℘ = value; + return this.#℘; + } + static ZW_‌_NJ(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + this.#ZW_‌_NJ = value; + return this.#ZW_‌_NJ; + } + static ZW_‍_J(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + this.#ZW_‍_J = value; + return this.#ZW_‍_J; + } +} + +var c = new C(); + +assert.sameValue(C.$(1), 1); +assert.sameValue(C._(1), 1); +assert.sameValue(C.o(1), 1); +assert.sameValue(C.℘(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD +assert.sameValue(C.ZW_‌_NJ(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD +assert.sameValue(C.ZW_‍_J(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/regular-definitions-rs-static-privatename-identifier-by-classname.js b/js/src/tests/test262/language/statements/class/elements/regular-definitions-rs-static-privatename-identifier-by-classname.js new file mode 100644 index 0000000000..1d89459791 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/regular-definitions-rs-static-privatename-identifier-by-classname.js @@ -0,0 +1,96 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-privatename-identifier-by-classname.case +// - src/class-elements/productions/cls-decl-regular-definitions.template +/*--- +description: Valid Static PrivateName (regular fields defintion) +esid: prod-FieldDefinition +features: [class-static-fields-private, class, class-fields-public] +flags: [generated] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static #$; static #_; static #\u{6F}; static #\u2118; static #ZW_\u200C_NJ; static #ZW_\u200D_J + static $(value) { + C.#$ = value; + return C.#$; + } + static _(value) { + C.#_ = value; + return C.#_; + } + static \u{6F}(value) { + C.#\u{6F} = value; + return C.#\u{6F}; + } + static \u2118(value) { + C.#\u2118 = value; + return C.#\u2118; + } + static ZW_\u200C_NJ(value) { + C.#ZW_\u200C_NJ = value; + return C.#ZW_\u200C_NJ; + } + static ZW_\u200D_J(value) { + C.#ZW_\u200D_J = value; + return C.#ZW_\u200D_J; + } +} + +var c = new C(); + +assert.sameValue(C.$(1), 1); +assert.sameValue(C._(1), 1); +assert.sameValue(C.\u{6F}(1), 1); +assert.sameValue(C.\u2118(1), 1); +assert.sameValue(C.ZW_\u200C_NJ(1), 1); +assert.sameValue(C.ZW_\u200D_J(1), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/regular-definitions-rs-static-privatename-identifier-initializer-alt-by-classname.js b/js/src/tests/test262/language/statements/class/elements/regular-definitions-rs-static-privatename-identifier-initializer-alt-by-classname.js new file mode 100644 index 0000000000..eaa4c940db --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/regular-definitions-rs-static-privatename-identifier-initializer-alt-by-classname.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-privatename-identifier-initializer-alt-by-classname.case +// - src/class-elements/productions/cls-decl-regular-definitions.template +/*--- +description: Valid Static PrivateName (regular fields defintion) +esid: prod-FieldDefinition +features: [class-static-fields-private, class, class-fields-public] +flags: [generated] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static #$ = 1; static #_ = 1; static #\u{6F} = 1; static #℘ = 1; static #ZW_‌_NJ = 1; static #ZW_‍_J = 1 + static $() { + return C.#$; + } + static _() { + return C.#_; + } + static \u{6F}() { + return C.#\u{6F}; + } + static ℘() { + return C.#℘; + } + static ZW_‌_NJ() { + return C.#ZW_‌_NJ; + } + static ZW_‍_J() { + return C.#ZW_‍_J; + } +} + +var c = new C(); + +assert.sameValue(C.$(), 1); +assert.sameValue(C._(), 1); +assert.sameValue(C.\u{6F}(), 1); +assert.sameValue(C.℘(), 1); +assert.sameValue(C.ZW_‌_NJ(), 1); +assert.sameValue(C.ZW_‍_J(), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/regular-definitions-rs-static-privatename-identifier-initializer-alt.js b/js/src/tests/test262/language/statements/class/elements/regular-definitions-rs-static-privatename-identifier-initializer-alt.js new file mode 100644 index 0000000000..f735e6dfc2 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/regular-definitions-rs-static-privatename-identifier-initializer-alt.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-privatename-identifier-initializer-alt.case +// - src/class-elements/productions/cls-decl-regular-definitions.template +/*--- +description: Valid Static PrivateName (regular fields defintion) +esid: prod-FieldDefinition +features: [class-static-fields-private, class, class-fields-public] +flags: [generated] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static #$ = 1; static #_ = 1; static #\u{6F} = 1; static #℘ = 1; static #ZW_‌_NJ = 1; static #ZW_‍_J = 1 + static $() { + return this.#$; + } + static _() { + return this.#_; + } + static \u{6F}() { + return this.#\u{6F}; + } + static ℘() { + return this.#℘; + } + static ZW_‌_NJ() { + return this.#ZW_‌_NJ; + } + static ZW_‍_J() { + return this.#ZW_‍_J; + } +} + +var c = new C(); + +assert.sameValue(C.$(), 1); +assert.sameValue(C._(), 1); +assert.sameValue(C.\u{6F}(), 1); +assert.sameValue(C.℘(), 1); +assert.sameValue(C.ZW_‌_NJ(), 1); +assert.sameValue(C.ZW_‍_J(), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/regular-definitions-rs-static-privatename-identifier-initializer.js b/js/src/tests/test262/language/statements/class/elements/regular-definitions-rs-static-privatename-identifier-initializer.js new file mode 100644 index 0000000000..d75bea949f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/regular-definitions-rs-static-privatename-identifier-initializer.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-privatename-identifier-initializer.case +// - src/class-elements/productions/cls-decl-regular-definitions.template +/*--- +description: Valid Static PrivateName (regular fields defintion) +esid: prod-FieldDefinition +features: [class-static-fields-private, class, class-fields-public] +flags: [generated] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static #$ = 1; static #_ = 1; static #\u{6F} = 1; static #\u2118 = 1; static #ZW_\u200C_NJ = 1; static #ZW_\u200D_J = 1 + static $() { + return this.#$; + } + static _() { + return this.#_; + } + static \u{6F}() { + return this.#\u{6F}; + } + static \u2118() { + return this.#\u2118; + } + static ZW_\u200C_NJ() { + return this.#ZW_\u200C_NJ; + } + static ZW_\u200D_J() { + return this.#ZW_\u200D_J; + } +} + +var c = new C(); + +assert.sameValue(C.$(), 1); +assert.sameValue(C._(), 1); +assert.sameValue(C.\u{6F}(), 1); +assert.sameValue(C.\u2118(), 1); +assert.sameValue(C.ZW_\u200C_NJ(), 1); +assert.sameValue(C.ZW_\u200D_J(), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/regular-definitions-rs-static-privatename-identifier.js b/js/src/tests/test262/language/statements/class/elements/regular-definitions-rs-static-privatename-identifier.js new file mode 100644 index 0000000000..92e2e032a9 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/regular-definitions-rs-static-privatename-identifier.js @@ -0,0 +1,96 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-privatename-identifier.case +// - src/class-elements/productions/cls-decl-regular-definitions.template +/*--- +description: Valid Static PrivateName (regular fields defintion) +esid: prod-FieldDefinition +features: [class-static-fields-private, class, class-fields-public] +flags: [generated] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static #$; static #_; static #\u{6F}; static #\u2118; static #ZW_\u200C_NJ; static #ZW_\u200D_J + static $(value) { + this.#$ = value; + return this.#$; + } + static _(value) { + this.#_ = value; + return this.#_; + } + static \u{6F}(value) { + this.#\u{6F} = value; + return this.#\u{6F}; + } + static \u2118(value) { + this.#\u2118 = value; + return this.#\u2118; + } + static ZW_\u200C_NJ(value) { + this.#ZW_\u200C_NJ = value; + return this.#ZW_\u200C_NJ; + } + static ZW_\u200D_J(value) { + this.#ZW_\u200D_J = value; + return this.#ZW_\u200D_J; + } +} + +var c = new C(); + +assert.sameValue(C.$(1), 1); +assert.sameValue(C._(1), 1); +assert.sameValue(C.\u{6F}(1), 1); +assert.sameValue(C.\u2118(1), 1); +assert.sameValue(C.ZW_\u200C_NJ(1), 1); +assert.sameValue(C.ZW_\u200D_J(1), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/regular-definitions-static-private-fields.js b/js/src/tests/test262/language/statements/class/elements/regular-definitions-static-private-fields.js new file mode 100644 index 0000000000..acb79ba75a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/regular-definitions-static-private-fields.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/static-private-fields.case +// - src/class-elements/productions/cls-decl-regular-definitions.template +/*--- +description: static private fields (regular fields defintion) +esid: prod-FieldDefinition +features: [class-static-fields-private, class, class-fields-public] +flags: [generated] +info: | + ClassElement : + ... + static FieldDefinition ; + + FieldDefinition : + ClassElementName Initializer_opt + + ClassElementName : + PrivateName + + PrivateName : + # IdentifierName + +---*/ + + +class C { + static #x; static #y + static x() { + this.#x = 42; + return this.#x; + } + static y() { + this.#y = 43; + return this.#y; + } +} + +var c = new C(); + +// Test the private fields do not appear as properties before set to value +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#x"), "test 1"); +assert(!Object.prototype.hasOwnProperty.call(C, "#x"), "test 2"); +assert(!Object.prototype.hasOwnProperty.call(c, "#x"), "test 3"); + +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#y"), "test 4"); +assert(!Object.prototype.hasOwnProperty.call(C, "#y"), "test 5"); +assert(!Object.prototype.hasOwnProperty.call(c, "#y"), "test 6"); + +// Test if private fields can be sucessfully accessed and set to value +assert.sameValue(C.x(), 42, "test 7"); +assert.sameValue(C.y(), 43, "test 8"); + +// Test the private fields do not appear as properties before after set to value +assert(!Object.prototype.hasOwnProperty.call(C, "#x"), "test 9"); +assert(!Object.prototype.hasOwnProperty.call(C, "#y"), "test 10"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/regular-definitions-static-private-methods-with-fields.js b/js/src/tests/test262/language/statements/class/elements/regular-definitions-static-private-methods-with-fields.js new file mode 100644 index 0000000000..f09d69a8e5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/regular-definitions-static-private-methods-with-fields.js @@ -0,0 +1,74 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/static-private-methods-with-fields.case +// - src/class-elements/productions/cls-decl-regular-definitions.template +/*--- +description: static private methods with fields (regular fields defintion) +esid: prod-FieldDefinition +features: [class-static-methods-private, class-static-fields-private, class, class-fields-public] +flags: [generated] +info: | + ClassElement : + ... + static FieldDefinition ; + + FieldDefinition : + ClassElementName Initializer_opt + + ClassElementName : + PrivateName + + PrivateName : + # IdentifierName + +---*/ + + +class C { + static #xVal; static #yVal + static #x(value) { + this.#xVal = value; + return this.#xVal; + } + static #y(value) { + this.#yVal = value; + return this.#yVal; + } + static x() { + return this.#x(42); + } + static y() { + return this.#y(43); + } +} + +var c = new C(); + +// Test the private methods do not appear as properties before set to value +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#x"), "test 1"); +assert(!Object.prototype.hasOwnProperty.call(C, "#x"), "test 2"); +assert(!Object.prototype.hasOwnProperty.call(c, "#x"), "test 3"); + +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#y"), "test 4"); +assert(!Object.prototype.hasOwnProperty.call(C, "#y"), "test 5"); +assert(!Object.prototype.hasOwnProperty.call(c, "#y"), "test 6"); + +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#xVal"), "test 7"); +assert(!Object.prototype.hasOwnProperty.call(C, "#xVal"), "test 8"); +assert(!Object.prototype.hasOwnProperty.call(c, "#xVal"), "test 9"); + +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#yVal"), "test 10"); +assert(!Object.prototype.hasOwnProperty.call(C, "#yVal"), "test 11"); +assert(!Object.prototype.hasOwnProperty.call(c, "#yVal"), "test 12"); + +// Test if private fields can be sucessfully accessed and set to value +assert.sameValue(C.x(), 42, "test 13"); +assert.sameValue(C.y(), 43, "test 14"); + +// Test the private fields do not appear as properties before after set to value +assert(!Object.prototype.hasOwnProperty.call(C, "#x"), "test 15"); +assert(!Object.prototype.hasOwnProperty.call(C, "#y"), "test 16"); + +assert(!Object.prototype.hasOwnProperty.call(C, "#xVal"), "test 17"); +assert(!Object.prototype.hasOwnProperty.call(C, "#yVal"), "test 18"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/regular-definitions-static-private-methods.js b/js/src/tests/test262/language/statements/class/elements/regular-definitions-static-private-methods.js new file mode 100644 index 0000000000..a3a431ebad --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/regular-definitions-static-private-methods.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/static-private-methods.case +// - src/class-elements/productions/cls-decl-regular-definitions.template +/*--- +description: static private methods (regular fields defintion) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public] +flags: [generated] +info: | + ClassElement : + ... + static FieldDefinition ; + + FieldDefinition : + ClassElementName Initializer_opt + + ClassElementName : + PrivateName + + PrivateName : + # IdentifierName + +---*/ + + +class C { + + static #x(value) { + return value / 2; + } + static #y(value) { + return value * 2; + } + static x() { + return this.#x(84); + } + static y() { + return this.#y(43); + } +} + +var c = new C(); + +// Test the private methods do not appear as properties before set to value +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#x"), "test 1"); +assert(!Object.prototype.hasOwnProperty.call(C, "#x"), "test 2"); +assert(!Object.prototype.hasOwnProperty.call(c, "#x"), "test 3"); + +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#y"), "test 4"); +assert(!Object.prototype.hasOwnProperty.call(C, "#y"), "test 5"); +assert(!Object.prototype.hasOwnProperty.call(c, "#y"), "test 6"); + +// Test if private fields can be sucessfully accessed and set to value +assert.sameValue(C.x(), 42, "test 7"); +assert.sameValue(C.y(), 86, "test 8"); + +// Test the private fields do not appear as properties before after set to value +assert(!Object.prototype.hasOwnProperty.call(C, "#x"), "test 9"); +assert(!Object.prototype.hasOwnProperty.call(C, "#y"), "test 10"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/regular-definitions-string-literal-names.js b/js/src/tests/test262/language/statements/class/elements/regular-definitions-string-literal-names.js new file mode 100644 index 0000000000..225e14ff86 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/regular-definitions-string-literal-names.js @@ -0,0 +1,96 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/string-literal-names.case +// - src/class-elements/productions/cls-decl-regular-definitions.template +/*--- +description: String literal names (regular fields defintion) +esid: prod-FieldDefinition +features: [class-fields-public, class] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PropertyName + +---*/ + + +class C { + 'a'; "b"; 'c' = 39; + "d" = 42 + +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "a"), + "a does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "a"), + "a does not appear as an own property on C constructor" +); + +verifyProperty(c, "a", { + value: undefined, + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "b"), + "b does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "b"), + "b does not appear as an own property on C constructor" +); + +verifyProperty(c, "b", { + value: undefined, + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "c"), + "c does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "c"), + "c does not appear as an own property on C constructor" +); + +verifyProperty(c, "c", { + value: 39, + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "d"), + "d does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "d"), + "d does not appear as an own property on C constructor" +); + +verifyProperty(c, "d", { + value: 42, + enumerable: true, + writable: true, + configurable: true +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-async-gen-computed-names.js b/js/src/tests/test262/language/statements/class/elements/same-line-async-gen-computed-names.js new file mode 100644 index 0000000000..972f1370c5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-async-gen-computed-names.js @@ -0,0 +1,120 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/computed-names.case +// - src/class-elements/productions/cls-decl-after-same-line-async-gen.template +/*--- +description: Computed property names (field definitions after an async generator in the same line) +esid: prod-FieldDefinition +features: [class-fields-public, computed-property-names, class, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PropertyName + +---*/ +var x = "b"; + + + +class C { + async *m() { return 42; } [x] = 42; [10] = "meep"; ["not initialized"]; + +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +c.m().next().then(function(v) { + assert.sameValue(v.value, 42); + assert.sameValue(v.done, true); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "b"), + "b doesn't appear as an own property on C prototype" + ); + assert( + !Object.prototype.hasOwnProperty.call(C, "b"), + "b doesn't appear as an own property on C constructor" + ); + + verifyProperty(c, "b", { + value: 42, + enumerable: true, + writable: true, + configurable: true + }); + + assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "x"), + "x doesn't appear as an own property on C prototype" + ); + assert( + !Object.prototype.hasOwnProperty.call(C, "x"), + "x doesn't appear as an own property on C constructor" + ); + assert( + !Object.prototype.hasOwnProperty.call(c, "x"), + "x doesn't appear as an own property on C instance" + ); + + assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "10"), + "10 doesn't appear as an own property on C prototype" + ); + assert( + !Object.prototype.hasOwnProperty.call(C, "10"), + "10 doesn't appear as an own property on C constructor" + ); + + verifyProperty(c, "10", { + value: "meep", + enumerable: true, + writable: true, + configurable: true + }); + + assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "not initialized"), + "'not initialized' doesn't appear as an own property on C prototype" + ); + assert( + !Object.prototype.hasOwnProperty.call(C, "not initialized"), + "'not initialized' doesn't appear as an own property on C constructor" + ); + + verifyProperty(c, "not initialized", { + value: undefined, + enumerable: true, + writable: true, + configurable: true + }); + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-async-gen-computed-symbol-names.js b/js/src/tests/test262/language/statements/class/elements/same-line-async-gen-computed-symbol-names.js new file mode 100644 index 0000000000..9c37193020 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-async-gen-computed-symbol-names.js @@ -0,0 +1,118 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/computed-symbol-names.case +// - src/class-elements/productions/cls-decl-after-same-line-async-gen.template +/*--- +description: Computed property symbol names (field definitions after an async generator in the same line) +esid: prod-FieldDefinition +features: [class-fields-public, Symbol, computed-property-names, class, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PropertyName + +---*/ +var x = Symbol(); +var y = Symbol(); + + + +class C { + async *m() { return 42; } [x]; [y] = 42; + +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +c.m().next().then(function(v) { + assert.sameValue(v.value, 42); + assert.sameValue(v.done, true); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert( + !Object.prototype.hasOwnProperty.call(C.prototype, x), + "Symbol x doesn't appear as an own property on C prototype" + ); + assert( + !Object.prototype.hasOwnProperty.call(C, x), + "Symbol x doesn't appear as an own property on C constructor" + ); + + verifyProperty(c, x, { + value: undefined, + enumerable: true, + writable: true, + configurable: true + }); + + assert( + !Object.prototype.hasOwnProperty.call(C.prototype, y), + "Symbol y doesn't appear as an own property on C prototype" + ); + assert( + !Object.prototype.hasOwnProperty.call(C, y), + "Symbol y doesn't appear as an own property on C constructor" + ); + + verifyProperty(c, y, { + value: 42, + enumerable: true, + writable: true, + configurable: true + }); + + assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "x"), + "x doesn't appear as an own property on C prototype" + ); + assert( + !Object.prototype.hasOwnProperty.call(C, "x"), + "x doesn't appear as an own property on C constructor" + ); + assert( + !Object.prototype.hasOwnProperty.call(c, "x"), + "x doesn't appear as an own property on C instance" + ); + + assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "y"), + "y doesn't appear as an own property on C prototype" + ); + assert( + !Object.prototype.hasOwnProperty.call(C, "y"), + "y doesn't appear as an own property on C constructor" + ); + assert( + !Object.prototype.hasOwnProperty.call(c, "y"), + "y doesn't appear as an own property on C instance" + ); + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-async-gen-grammar-privatename-identifier-semantics-stringvalue.js b/js/src/tests/test262/language/statements/class/elements/same-line-async-gen-grammar-privatename-identifier-semantics-stringvalue.js new file mode 100644 index 0000000000..bf90ea927e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-async-gen-grammar-privatename-identifier-semantics-stringvalue.js @@ -0,0 +1,122 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-privatename-identifier-semantics-stringvalue.case +// - src/class-elements/productions/cls-decl-after-same-line-async-gen.template +/*--- +description: PrivateName Static Semantics, StringValue (field definitions after an async generator in the same line) +esid: prod-FieldDefinition +features: [class-fields-private, class, class-fields-public, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + + + 1. Return the String value consisting of the sequence of code + units corresponding to PrivateName. In determining the sequence + any occurrences of \ UnicodeEscapeSequence are first replaced + with the code point represented by the UnicodeEscapeSequence + and then the code points of the entire PrivateName are converted + to code units by UTF16Encoding (10.1.1) each code point. + +---*/ + + +class C { + async *m() { return 42; } #\u{6F}; + #\u2118; + #ZW_\u200C_NJ; + #ZW_\u200D_J;; + o(value) { + this.#o = value; + return this.#o; + } + ℘(value) { + this.#℘ = value; + return this.#℘; + } + ZW_‌_NJ(value) { // DO NOT CHANGE THE NAME OF THIS METHOD + this.#ZW_‌_NJ = value; + return this.#ZW_‌_NJ; + } + ZW_‍_J(value) { // DO NOT CHANGE THE NAME OF THIS METHOD + this.#ZW_‍_J = value; + return this.#ZW_‍_J; + } +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +c.m().next().then(function(v) { + assert.sameValue(v.value, 42); + assert.sameValue(v.done, true); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert.sameValue(c.o(1), 1); + assert.sameValue(c.℘(1), 1); + assert.sameValue(c.ZW_‌_NJ(1), 1); + assert.sameValue(c.ZW_‍_J(1), 1); + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-async-gen-literal-names-asi.js b/js/src/tests/test262/language/statements/class/elements/same-line-async-gen-literal-names-asi.js new file mode 100644 index 0000000000..25edbf3dce --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-async-gen-literal-names-asi.js @@ -0,0 +1,90 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/literal-names-asi.case +// - src/class-elements/productions/cls-decl-after-same-line-async-gen.template +/*--- +description: Literal property names with ASI (field definitions after an async generator in the same line) +esid: prod-FieldDefinition +features: [class-fields-public, class, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PropertyName + +---*/ + + +class C { + async *m() { return 42; } a + b = 42;; + +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +c.m().next().then(function(v) { + assert.sameValue(v.value, 42); + assert.sameValue(v.done, true); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "a"), + "a doesn't appear as an own property on C prototype" + ); + assert( + !Object.prototype.hasOwnProperty.call(C, "a"), + "a doesn't appear as an own property on C constructor" + ); + + verifyProperty(c, "a", { + value: undefined, + enumerable: true, + writable: true, + configurable: true + }); + + assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "b"), + "b doesn't appear as an own property on C prototype" + ); + assert( + !Object.prototype.hasOwnProperty.call(C, "b"), + "b doesn't appear as an own property on C constructor" + ); + + verifyProperty(c, "b", { + value: 42, + enumerable: true, + writable: true, + configurable: true + }); + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-async-gen-literal-names.js b/js/src/tests/test262/language/statements/class/elements/same-line-async-gen-literal-names.js new file mode 100644 index 0000000000..8ed11bb12f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-async-gen-literal-names.js @@ -0,0 +1,109 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/literal-names.case +// - src/class-elements/productions/cls-decl-after-same-line-async-gen.template +/*--- +description: Literal property names (field definitions after an async generator in the same line) +esid: prod-FieldDefinition +features: [class-fields-public, class, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PropertyName + +---*/ +const fn = function() {} + + + +class C { + async *m() { return 42; } a; b = 42; + c = fn; + +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +c.m().next().then(function(v) { + assert.sameValue(v.value, 42); + assert.sameValue(v.done, true); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "a"), + "a doesn't appear as an own property on C prototype" + ); + assert( + !Object.prototype.hasOwnProperty.call(C, "a"), + "a doesn't appear as an own property on C constructor" + ); + + verifyProperty(c, "a", { + value: undefined, + enumerable: true, + writable: true, + configurable: true + }); + + assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "b"), + "b doesn't appear as an own property on C prototype" + ); + assert( + !Object.prototype.hasOwnProperty.call(C, "b"), + "b doesn't appear as an own property on C constructor" + ); + + verifyProperty(c, "b", { + value: 42, + enumerable: true, + writable: true, + configurable: true + }); + + assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "c"), + "c doesn't appear as an own property on C prototype" + ); + assert( + !Object.prototype.hasOwnProperty.call(C, "c"), + "c doesn't appear as an own property on C constructor" + ); + + verifyProperty(c, "c", { + value: fn, + enumerable: true, + writable: true, + configurable: true + }); + + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-async-gen-private-field-usage.js b/js/src/tests/test262/language/statements/class/elements/same-line-async-gen-private-field-usage.js new file mode 100644 index 0000000000..636bfeba55 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-async-gen-private-field-usage.js @@ -0,0 +1,62 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/private-field-usage.case +// - src/class-elements/productions/cls-decl-after-same-line-async-gen.template +/*--- +description: PrivateName CallExpression usage (private field) (field definitions after an async generator in the same line) +esid: prod-FieldDefinition +features: [class-fields-private, class, class-fields-public, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + Updated Productions + + CallExpression[Yield, Await]: + CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await] + SuperCall[?Yield, ?Await] + CallExpression[?Yield, ?Await]Arguments[?Yield, ?Await] + CallExpression[?Yield, ?Await][Expression[+In, ?Yield, ?Await]] + CallExpression[?Yield, ?Await].IdentifierName + CallExpression[?Yield, ?Await]TemplateLiteral[?Yield, ?Await] + CallExpression[?Yield, ?Await].PrivateName + +---*/ + + +class C { + async *m() { return 42; } #m = 'test262';; + method() { + return this.#m; + } +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +c.m().next().then(function(v) { + assert.sameValue(v.value, 42); + assert.sameValue(v.done, true); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert.sameValue(c.method(), 'test262'); + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-async-gen-private-method-getter-usage.js b/js/src/tests/test262/language/statements/class/elements/same-line-async-gen-private-method-getter-usage.js new file mode 100644 index 0000000000..664a70addb --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-async-gen-private-method-getter-usage.js @@ -0,0 +1,62 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/private-method-getter-usage.case +// - src/class-elements/productions/cls-decl-after-same-line-async-gen.template +/*--- +description: PrivateName CallExpression usage (Accesor get method) (field definitions after an async generator in the same line) +esid: prod-FieldDefinition +features: [class-methods-private, class, class-fields-public, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + Updated Productions + + CallExpression[Yield, Await]: + CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await] + SuperCall[?Yield, ?Await] + CallExpression[?Yield, ?Await]Arguments[?Yield, ?Await] + CallExpression[?Yield, ?Await][Expression[+In, ?Yield, ?Await]] + CallExpression[?Yield, ?Await].IdentifierName + CallExpression[?Yield, ?Await]TemplateLiteral[?Yield, ?Await] + CallExpression[?Yield, ?Await].PrivateName + +---*/ + + +class C { + async *m() { return 42; } get #m() { return 'test262'; }; + method() { + return this.#m; + } +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +c.m().next().then(function(v) { + assert.sameValue(v.value, 42); + assert.sameValue(v.done, true); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert.sameValue(c.method(), 'test262'); + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-async-gen-private-method-usage.js b/js/src/tests/test262/language/statements/class/elements/same-line-async-gen-private-method-usage.js new file mode 100644 index 0000000000..5195b40603 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-async-gen-private-method-usage.js @@ -0,0 +1,62 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/private-method-usage.case +// - src/class-elements/productions/cls-decl-after-same-line-async-gen.template +/*--- +description: PrivateName CallExpression usage (private method) (field definitions after an async generator in the same line) +esid: prod-FieldDefinition +features: [class-methods-private, class, class-fields-public, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + Updated Productions + + CallExpression[Yield, Await]: + CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await] + SuperCall[?Yield, ?Await] + CallExpression[?Yield, ?Await]Arguments[?Yield, ?Await] + CallExpression[?Yield, ?Await][Expression[+In, ?Yield, ?Await]] + CallExpression[?Yield, ?Await].IdentifierName + CallExpression[?Yield, ?Await]TemplateLiteral[?Yield, ?Await] + CallExpression[?Yield, ?Await].PrivateName + +---*/ + + +class C { + async *m() { return 42; } #m() { return 'test262'; }; + method() { + return this.#m(); + } +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +c.m().next().then(function(v) { + assert.sameValue(v.value, 42); + assert.sameValue(v.done, true); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert.sameValue(c.method(), 'test262'); + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-async-gen-private-names.js b/js/src/tests/test262/language/statements/class/elements/same-line-async-gen-private-names.js new file mode 100644 index 0000000000..5ad4376496 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-async-gen-private-names.js @@ -0,0 +1,84 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/private-names.case +// - src/class-elements/productions/cls-decl-after-same-line-async-gen.template +/*--- +description: private names (field definitions after an async generator in the same line) +esid: prod-FieldDefinition +features: [class-fields-private, class, class-fields-public, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + ... + FieldDefinition ; + + FieldDefinition : + ClassElementName Initializer_opt + + ClassElementName : + PrivateName + + PrivateName : + # IdentifierName + +---*/ + + +class C { + async *m() { return 42; } #x; #y; + x() { + this.#x = 42; + return this.#x; + } + y() { + this.#y = 43; + return this.#y; + } +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +c.m().next().then(function(v) { + assert.sameValue(v.value, 42); + assert.sameValue(v.done, true); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + // Test the private fields do not appear as properties before set to value + assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#x"), "test 1"); + assert(!Object.prototype.hasOwnProperty.call(C, "#x"), "test 2"); + assert(!Object.prototype.hasOwnProperty.call(c, "#x"), "test 3"); + + assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#y"), "test 4"); + assert(!Object.prototype.hasOwnProperty.call(C, "#y"), "test 5"); + assert(!Object.prototype.hasOwnProperty.call(c, "#y"), "test 6"); + + // Test if private fields can be sucessfully accessed and set to value + assert.sameValue(c.x(), 42, "test 7"); + assert.sameValue(c.y(), 43, "test 8"); + + // Test the private fields do not appear as properties before after set to value + assert(!Object.prototype.hasOwnProperty.call(c, "#x"), "test 9"); + assert(!Object.prototype.hasOwnProperty.call(c, "#y"), "test 10"); + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-async-gen-rs-field-identifier-initializer.js b/js/src/tests/test262/language/statements/class/elements/same-line-async-gen-rs-field-identifier-initializer.js new file mode 100644 index 0000000000..e25f83ab69 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-async-gen-rs-field-identifier-initializer.js @@ -0,0 +1,100 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-field-identifier-initializer.case +// - src/class-elements/productions/cls-decl-after-same-line-async-gen.template +/*--- +description: Valid FieldDefinition (field definitions after an async generator in the same line) +esid: prod-FieldDefinition +features: [class-fields-public, class, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + ... + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + + PropertyName : + LiteralPropertyName + ComputedPropertyName + + LiteralPropertyName : + IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + async *m() { return 42; } $ = 1; _ = 1; \u{6F} = 1; \u2118 = 1; ZW_\u200C_NJ = 1; ZW_\u200D_J = 1; + +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +c.m().next().then(function(v) { + assert.sameValue(v.value, 42); + assert.sameValue(v.done, true); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert.sameValue(c.$, 1); + assert.sameValue(c._, 1); + assert.sameValue(c.\u{6F}, 1); + assert.sameValue(c.\u2118, 1); + assert.sameValue(c.ZW_\u200C_NJ, 1); + assert.sameValue(c.ZW_\u200D_J, 1); + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-async-gen-rs-field-identifier.js b/js/src/tests/test262/language/statements/class/elements/same-line-async-gen-rs-field-identifier.js new file mode 100644 index 0000000000..a82d9db938 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-async-gen-rs-field-identifier.js @@ -0,0 +1,107 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-field-identifier.case +// - src/class-elements/productions/cls-decl-after-same-line-async-gen.template +/*--- +description: Valid FieldDefinition (field definitions after an async generator in the same line) +esid: prod-FieldDefinition +features: [class-fields-public, class, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + ... + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + + PropertyName : + LiteralPropertyName + ComputedPropertyName + + LiteralPropertyName : + IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + async *m() { return 42; } $; _; \u{6F}; \u2118; ZW_\u200C_NJ; ZW_\u200D_J; + +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +c.m().next().then(function(v) { + assert.sameValue(v.value, 42); + assert.sameValue(v.done, true); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + c.$ = 1; + c._ = 1; + c.\u{6F} = 1; + c.\u2118 = 1; + c.ZW_\u200C_NJ = 1; + c.ZW_\u200D_J = 1; + + assert.sameValue(c.$, 1); + assert.sameValue(c._, 1); + assert.sameValue(c.\u{6F}, 1); + assert.sameValue(c.\u2118, 1); + assert.sameValue(c.ZW_\u200C_NJ, 1); + assert.sameValue(c.ZW_\u200D_J, 1); + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-async-gen-rs-private-getter-alt.js b/js/src/tests/test262/language/statements/class/elements/same-line-async-gen-rs-private-getter-alt.js new file mode 100644 index 0000000000..e4fe4a9217 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-async-gen-rs-private-getter-alt.js @@ -0,0 +1,141 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-private-getter-alt.case +// - src/class-elements/productions/cls-decl-after-same-line-async-gen.template +/*--- +description: Valid PrivateName as private getter (field definitions after an async generator in the same line) +esid: prod-FieldDefinition +features: [class-methods-private, class-fields-private, class, class-fields-public, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + ... + ; + + MethodDefinition : + ... + get ClassElementName ( ){ FunctionBody } + ... + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + async *m() { return 42; } #$_; #__; #\u{6F}_; #℘_; #ZW_‌_NJ_; #ZW_‍_J_; + get #$() { + return this.#$_; + } + get #_() { + return this.#__; + } + get #\u{6F}() { + return this.#\u{6F}_; + } + get #℘() { + return this.#℘_; + } + get #ZW_‌_NJ() { + return this.#ZW_‌_NJ_; + } + get #ZW_‍_J() { + return this.#ZW_‍_J_; + } +; + $(value) { + this.#$_ = value; + return this.#$; + } + _(value) { + this.#__ = value; + return this.#_; + } + \u{6F}(value) { + this.#\u{6F}_ = value; + return this.#\u{6F}; + } + ℘(value) { + this.#℘_ = value; + return this.#℘; + } + ZW_‌_NJ(value) { + this.#ZW_‌_NJ_ = value; + return this.#ZW_‌_NJ; + } + ZW_‍_J(value) { + this.#ZW_‍_J_ = value; + return this.#ZW_‍_J; + } + +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +c.m().next().then(function(v) { + assert.sameValue(v.value, 42); + assert.sameValue(v.done, true); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert.sameValue(c.$(1), 1); + assert.sameValue(c._(1), 1); + assert.sameValue(c.\u{6F}(1), 1); + assert.sameValue(c.℘(1), 1); + assert.sameValue(c.ZW_‌_NJ(1), 1); + assert.sameValue(c.ZW_‍_J(1), 1); + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-async-gen-rs-private-getter.js b/js/src/tests/test262/language/statements/class/elements/same-line-async-gen-rs-private-getter.js new file mode 100644 index 0000000000..cbd190d896 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-async-gen-rs-private-getter.js @@ -0,0 +1,141 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-private-getter.case +// - src/class-elements/productions/cls-decl-after-same-line-async-gen.template +/*--- +description: Valid PrivateName as private getter (field definitions after an async generator in the same line) +esid: prod-FieldDefinition +features: [class-methods-private, class-fields-private, class, class-fields-public, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + ... + ; + + MethodDefinition : + ... + get ClassElementName ( ){ FunctionBody } + ... + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + async *m() { return 42; } #$_; #__; #\u{6F}_; #\u2118_; #ZW_\u200C_NJ_; #ZW_\u200D_J_; + get #$() { + return this.#$_; + } + get #_() { + return this.#__; + } + get #\u{6F}() { + return this.#\u{6F}_; + } + get #\u2118() { + return this.#\u2118_; + } + get #ZW_\u200C_NJ() { + return this.#ZW_\u200C_NJ_; + } + get #ZW_\u200D_J() { + return this.#ZW_\u200D_J_; + } +; + $(value) { + this.#$_ = value; + return this.#$; + } + _(value) { + this.#__ = value; + return this.#_; + } + \u{6F}(value) { + this.#\u{6F}_ = value; + return this.#\u{6F}; + } + \u2118(value) { + this.#\u2118_ = value; + return this.#\u2118; + } + ZW_\u200C_NJ(value) { + this.#ZW_\u200C_NJ_ = value; + return this.#ZW_\u200C_NJ; + } + ZW_\u200D_J(value) { + this.#ZW_\u200D_J_ = value; + return this.#ZW_\u200D_J; + } + +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +c.m().next().then(function(v) { + assert.sameValue(v.value, 42); + assert.sameValue(v.done, true); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert.sameValue(c.$(1), 1); + assert.sameValue(c._(1), 1); + assert.sameValue(c.\u{6F}(1), 1); + assert.sameValue(c.\u2118(1), 1); + assert.sameValue(c.ZW_\u200C_NJ(1), 1); + assert.sameValue(c.ZW_\u200D_J(1), 1); + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-async-gen-rs-private-method-alt.js b/js/src/tests/test262/language/statements/class/elements/same-line-async-gen-rs-private-method-alt.js new file mode 100644 index 0000000000..c167ec0e40 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-async-gen-rs-private-method-alt.js @@ -0,0 +1,140 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-private-method-alt.case +// - src/class-elements/productions/cls-decl-after-same-line-async-gen.template +/*--- +description: Valid PrivateName as private method (field definitions after an async generator in the same line) +esid: prod-FieldDefinition +features: [class-methods-private, class-fields-private, class, class-fields-public, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + ... + ; + + MethodDefinition : + ClassElementName ( UniqueFormalParameters ) { FunctionBody } + ... + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + async *m() { return 42; } #$_; #__; #\u{6F}_; #℘_; #ZW_‌_NJ_; #ZW_‍_J_; + #$() { + return this.#$_; + } + #_() { + return this.#__; + } + #\u{6F}() { + return this.#\u{6F}_; + } + #℘() { + return this.#℘_; + } + #ZW_‌_NJ() { + return this.#ZW_‌_NJ_; + } + #ZW_‍_J() { + return this.#ZW_‍_J_; + } +; + $(value) { + this.#$_ = value; + return this.#$(); + } + _(value) { + this.#__ = value; + return this.#_(); + } + \u{6F}(value) { + this.#\u{6F}_ = value; + return this.#\u{6F}(); + } + ℘(value) { + this.#℘_ = value; + return this.#℘(); + } + ZW_‌_NJ(value) { + this.#ZW_‌_NJ_ = value; + return this.#ZW_‌_NJ(); + } + ZW_‍_J(value) { + this.#ZW_‍_J_ = value; + return this.#ZW_‍_J(); + } + +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +c.m().next().then(function(v) { + assert.sameValue(v.value, 42); + assert.sameValue(v.done, true); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert.sameValue(c.$(1), 1); + assert.sameValue(c._(1), 1); + assert.sameValue(c.\u{6F}(1), 1); + assert.sameValue(c.℘(1), 1); + assert.sameValue(c.ZW_‌_NJ(1), 1); + assert.sameValue(c.ZW_‍_J(1), 1); + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-async-gen-rs-private-method.js b/js/src/tests/test262/language/statements/class/elements/same-line-async-gen-rs-private-method.js new file mode 100644 index 0000000000..01c26b751d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-async-gen-rs-private-method.js @@ -0,0 +1,140 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-private-method.case +// - src/class-elements/productions/cls-decl-after-same-line-async-gen.template +/*--- +description: Valid PrivateName as private method (field definitions after an async generator in the same line) +esid: prod-FieldDefinition +features: [class-methods-private, class-fields-private, class, class-fields-public, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + ... + ; + + MethodDefinition : + ClassElementName ( UniqueFormalParameters ) { FunctionBody } + ... + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + async *m() { return 42; } #$_; #__; #\u{6F}_; #\u2118_; #ZW_\u200C_NJ_; #ZW_\u200D_J_; + #$() { + return this.#$_; + } + #_() { + return this.#__; + } + #\u{6F}() { + return this.#\u{6F}_; + } + #\u2118() { + return this.#\u2118_; + } + #ZW_\u200C_NJ() { + return this.#ZW_\u200C_NJ_; + } + #ZW_\u200D_J() { + return this.#ZW_\u200D_J_; + } +; + $(value) { + this.#$_ = value; + return this.#$(); + } + _(value) { + this.#__ = value; + return this.#_(); + } + \u{6F}(value) { + this.#\u{6F}_ = value; + return this.#\u{6F}(); + } + \u2118(value) { + this.#\u2118_ = value; + return this.#\u2118(); + } + ZW_\u200C_NJ(value) { + this.#ZW_\u200C_NJ_ = value; + return this.#ZW_\u200C_NJ(); + } + ZW_\u200D_J(value) { + this.#ZW_\u200D_J_ = value; + return this.#ZW_\u200D_J(); + } + +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +c.m().next().then(function(v) { + assert.sameValue(v.value, 42); + assert.sameValue(v.done, true); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert.sameValue(c.$(1), 1); + assert.sameValue(c._(1), 1); + assert.sameValue(c.\u{6F}(1), 1); + assert.sameValue(c.\u2118(1), 1); + assert.sameValue(c.ZW_\u200C_NJ(1), 1); + assert.sameValue(c.ZW_\u200D_J(1), 1); + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-async-gen-rs-private-setter-alt.js b/js/src/tests/test262/language/statements/class/elements/same-line-async-gen-rs-private-setter-alt.js new file mode 100644 index 0000000000..f74c1c7df2 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-async-gen-rs-private-setter-alt.js @@ -0,0 +1,140 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-private-setter-alt.case +// - src/class-elements/productions/cls-decl-after-same-line-async-gen.template +/*--- +description: Valid PrivateName as private setter (field definitions after an async generator in the same line) +esid: prod-FieldDefinition +features: [class-methods-private, class-fields-private, class, class-fields-public, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + ... + ; + + MethodDefinition : + ... + set ClassElementName ( PropertySetParameterList ) { FunctionBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + async *m() { return 42; } #$_; #__; #\u{6F}_; #℘_; #ZW_‌_NJ_; #ZW_‍_J_; + set #$(value) { + this.#$_ = value; + } + set #_(value) { + this.#__ = value; + } + set #\u{6F}(value) { + this.#\u{6F}_ = value; + } + set #℘(value) { + this.#℘_ = value; + } + set #ZW_‌_NJ(value) { + this.#ZW_‌_NJ_ = value; + } + set #ZW_‍_J(value) { + this.#ZW_‍_J_ = value; + } +; + $(value) { + this.#$ = value; + return this.#$_; + } + _(value) { + this.#_ = value; + return this.#__; + } + \u{6F}(value) { + this.#\u{6F} = value; + return this.#\u{6F}_; + } + ℘(value) { + this.#℘ = value; + return this.#℘_; + } + ZW_‌_NJ(value) { + this.#ZW_‌_NJ = value; + return this.#ZW_‌_NJ_; + } + ZW_‍_J(value) { + this.#ZW_‍_J = value; + return this.#ZW_‍_J_; + } + +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +c.m().next().then(function(v) { + assert.sameValue(v.value, 42); + assert.sameValue(v.done, true); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert.sameValue(c.$(1), 1); + assert.sameValue(c._(1), 1); + assert.sameValue(c.\u{6F}(1), 1); + assert.sameValue(c.℘(1), 1); + assert.sameValue(c.ZW_‌_NJ(1), 1); + assert.sameValue(c.ZW_‍_J(1), 1); + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-async-gen-rs-private-setter.js b/js/src/tests/test262/language/statements/class/elements/same-line-async-gen-rs-private-setter.js new file mode 100644 index 0000000000..a8f4b7a0ef --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-async-gen-rs-private-setter.js @@ -0,0 +1,140 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-private-setter.case +// - src/class-elements/productions/cls-decl-after-same-line-async-gen.template +/*--- +description: Valid PrivateName as private setter (field definitions after an async generator in the same line) +esid: prod-FieldDefinition +features: [class-methods-private, class-fields-private, class, class-fields-public, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + ... + ; + + MethodDefinition : + ... + set ClassElementName ( PropertySetParameterList ) { FunctionBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + async *m() { return 42; } #$_; #__; #\u{6F}_; #\u2118_; #ZW_\u200C_NJ_; #ZW_\u200D_J_; + set #$(value) { + this.#$_ = value; + } + set #_(value) { + this.#__ = value; + } + set #\u{6F}(value) { + this.#\u{6F}_ = value; + } + set #\u2118(value) { + this.#\u2118_ = value; + } + set #ZW_\u200C_NJ(value) { + this.#ZW_\u200C_NJ_ = value; + } + set #ZW_\u200D_J(value) { + this.#ZW_\u200D_J_ = value; + } +; + $(value) { + this.#$ = value; + return this.#$_; + } + _(value) { + this.#_ = value; + return this.#__; + } + \u{6F}(value) { + this.#\u{6F} = value; + return this.#\u{6F}_; + } + \u2118(value) { + this.#\u2118 = value; + return this.#\u2118_; + } + ZW_\u200C_NJ(value) { + this.#ZW_\u200C_NJ = value; + return this.#ZW_\u200C_NJ_; + } + ZW_\u200D_J(value) { + this.#ZW_\u200D_J = value; + return this.#ZW_\u200D_J_; + } + +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +c.m().next().then(function(v) { + assert.sameValue(v.value, 42); + assert.sameValue(v.done, true); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert.sameValue(c.$(1), 1); + assert.sameValue(c._(1), 1); + assert.sameValue(c.\u{6F}(1), 1); + assert.sameValue(c.\u2118(1), 1); + assert.sameValue(c.ZW_\u200C_NJ(1), 1); + assert.sameValue(c.ZW_\u200D_J(1), 1); + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-async-gen-rs-privatename-identifier-alt.js b/js/src/tests/test262/language/statements/class/elements/same-line-async-gen-rs-privatename-identifier-alt.js new file mode 100644 index 0000000000..e85d80c565 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-async-gen-rs-privatename-identifier-alt.js @@ -0,0 +1,122 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-privatename-identifier-alt.case +// - src/class-elements/productions/cls-decl-after-same-line-async-gen.template +/*--- +description: Valid PrivateName (field definitions after an async generator in the same line) +esid: prod-FieldDefinition +features: [class-fields-private, class, class-fields-public, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + async *m() { return 42; } #$; #_; #\u{6F}; #℘; #ZW_‌_NJ; #ZW_‍_J; + $(value) { + this.#$ = value; + return this.#$; + } + _(value) { + this.#_ = value; + return this.#_; + } + \u{6F}(value) { + this.#\u{6F} = value; + return this.#\u{6F}; + } + ℘(value) { + this.#℘ = value; + return this.#℘; + } + ZW_‌_NJ(value) { + this.#ZW_‌_NJ = value; + return this.#ZW_‌_NJ; + } + ZW_‍_J(value) { + this.#ZW_‍_J = value; + return this.#ZW_‍_J; + } +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +c.m().next().then(function(v) { + assert.sameValue(v.value, 42); + assert.sameValue(v.done, true); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert.sameValue(c.$(1), 1); + assert.sameValue(c._(1), 1); + assert.sameValue(c.\u{6F}(1), 1); + assert.sameValue(c.℘(1), 1); + assert.sameValue(c.ZW_‌_NJ(1), 1); + assert.sameValue(c.ZW_‍_J(1), 1); + + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-async-gen-rs-privatename-identifier-initializer-alt.js b/js/src/tests/test262/language/statements/class/elements/same-line-async-gen-rs-privatename-identifier-initializer-alt.js new file mode 100644 index 0000000000..297996f81f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-async-gen-rs-privatename-identifier-initializer-alt.js @@ -0,0 +1,116 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-privatename-identifier-initializer-alt.case +// - src/class-elements/productions/cls-decl-after-same-line-async-gen.template +/*--- +description: Valid PrivateName (field definitions after an async generator in the same line) +esid: prod-FieldDefinition +features: [class-fields-private, class, class-fields-public, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + async *m() { return 42; } #$ = 1; #_ = 1; #\u{6F} = 1; #℘ = 1; #ZW_‌_NJ = 1; #ZW_‍_J = 1; + $() { + return this.#$; + } + _() { + return this.#_; + } + \u{6F}() { + return this.#\u{6F}; + } + ℘() { + return this.#℘; + } + ZW_‌_NJ() { + return this.#ZW_‌_NJ; + } + ZW_‍_J() { + return this.#ZW_‍_J; + } +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +c.m().next().then(function(v) { + assert.sameValue(v.value, 42); + assert.sameValue(v.done, true); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert.sameValue(c.$(), 1); + assert.sameValue(c._(), 1); + assert.sameValue(c.\u{6F}(), 1); + assert.sameValue(c.℘(), 1); + assert.sameValue(c.ZW_‌_NJ(), 1); + assert.sameValue(c.ZW_‍_J(), 1); + + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-async-gen-rs-privatename-identifier-initializer.js b/js/src/tests/test262/language/statements/class/elements/same-line-async-gen-rs-privatename-identifier-initializer.js new file mode 100644 index 0000000000..c7bb2db17b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-async-gen-rs-privatename-identifier-initializer.js @@ -0,0 +1,116 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-privatename-identifier-initializer.case +// - src/class-elements/productions/cls-decl-after-same-line-async-gen.template +/*--- +description: Valid PrivateName (field definitions after an async generator in the same line) +esid: prod-FieldDefinition +features: [class-fields-private, class, class-fields-public, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + async *m() { return 42; } #$ = 1; #_ = 1; #\u{6F} = 1; #\u2118 = 1; #ZW_\u200C_NJ = 1; #ZW_\u200D_J = 1; + $() { + return this.#$; + } + _() { + return this.#_; + } + \u{6F}() { + return this.#\u{6F}; + } + \u2118() { + return this.#\u2118; + } + ZW_\u200C_NJ() { + return this.#ZW_\u200C_NJ; + } + ZW_\u200D_J() { + return this.#ZW_\u200D_J; + } +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +c.m().next().then(function(v) { + assert.sameValue(v.value, 42); + assert.sameValue(v.done, true); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert.sameValue(c.$(), 1); + assert.sameValue(c._(), 1); + assert.sameValue(c.\u{6F}(), 1); + assert.sameValue(c.\u2118(), 1); + assert.sameValue(c.ZW_\u200C_NJ(), 1); + assert.sameValue(c.ZW_\u200D_J(), 1); + + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-async-gen-rs-privatename-identifier.js b/js/src/tests/test262/language/statements/class/elements/same-line-async-gen-rs-privatename-identifier.js new file mode 100644 index 0000000000..25e094aa92 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-async-gen-rs-privatename-identifier.js @@ -0,0 +1,122 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-privatename-identifier.case +// - src/class-elements/productions/cls-decl-after-same-line-async-gen.template +/*--- +description: Valid PrivateName (field definitions after an async generator in the same line) +esid: prod-FieldDefinition +features: [class-fields-private, class, class-fields-public, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + async *m() { return 42; } #$; #_; #\u{6F}; #\u2118; #ZW_\u200C_NJ; #ZW_\u200D_J; + $(value) { + this.#$ = value; + return this.#$; + } + _(value) { + this.#_ = value; + return this.#_; + } + \u{6F}(value) { + this.#\u{6F} = value; + return this.#\u{6F}; + } + \u2118(value) { + this.#\u2118 = value; + return this.#\u2118; + } + ZW_\u200C_NJ(value) { + this.#ZW_\u200C_NJ = value; + return this.#ZW_\u200C_NJ; + } + ZW_\u200D_J(value) { + this.#ZW_\u200D_J = value; + return this.#ZW_\u200D_J; + } +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +c.m().next().then(function(v) { + assert.sameValue(v.value, 42); + assert.sameValue(v.done, true); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert.sameValue(c.$(1), 1); + assert.sameValue(c._(1), 1); + assert.sameValue(c.\u{6F}(1), 1); + assert.sameValue(c.\u2118(1), 1); + assert.sameValue(c.ZW_\u200C_NJ(1), 1); + assert.sameValue(c.ZW_\u200D_J(1), 1); + + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-async-gen-rs-static-async-generator-method-privatename-identifier-alt.js b/js/src/tests/test262/language/statements/class/elements/same-line-async-gen-rs-static-async-generator-method-privatename-identifier-alt.js new file mode 100644 index 0000000000..4f39dd59e4 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-async-gen-rs-static-async-generator-method-privatename-identifier-alt.js @@ -0,0 +1,148 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-async-generator-method-privatename-identifier-alt.case +// - src/class-elements/productions/cls-decl-after-same-line-async-gen.template +/*--- +description: Valid Static AsyncGeneratorMethod PrivateName (field definitions after an async generator in the same line) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + AsyncGeneratorMethod + + AsyncGeneratorMethod : + async [no LineTerminator here] * ClassElementName ( UniqueFormalParameters){ AsyncGeneratorBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + async *m() { return 42; } static async * #$(value) { + yield * await value; + } + static async * #_(value) { + yield * await value; + } + static async * #o(value) { + yield * await value; + } + static async * #℘(value) { + yield * await value; + } + static async * #ZW_‌_NJ(value) { + yield * await value; + } + static async * #ZW_‍_J(value) { + yield * await value; + }; + static get $() { + return this.#$; + } + static get _() { + return this.#_; + } + static get o() { + return this.#o; + } + static get ℘() { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#℘; + } + static get ZW_‌_NJ() { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#ZW_‌_NJ; + } + static get ZW_‍_J() { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#ZW_‍_J; + } + +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +c.m().next().then(function(v) { + assert.sameValue(v.value, 42); + assert.sameValue(v.done, true); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + Promise.all([ + C.$([1]).next(), + C._([1]).next(), + C.o([1]).next(), + C.℘([1]).next(), // DO NOT CHANGE THE NAME OF THIS FIELD + C.ZW_‌_NJ([1]).next(), // DO NOT CHANGE THE NAME OF THIS FIELD + C.ZW_‍_J([1]).next(), // DO NOT CHANGE THE NAME OF THIS FIELD + ]).then(results => { + + assert.sameValue(results[0].value, 1); + assert.sameValue(results[1].value, 1); + assert.sameValue(results[2].value, 1); + assert.sameValue(results[3].value, 1); + assert.sameValue(results[4].value, 1); + assert.sameValue(results[5].value, 1); + + }).then($DONE, $DONE); + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-async-gen-rs-static-async-generator-method-privatename-identifier.js b/js/src/tests/test262/language/statements/class/elements/same-line-async-gen-rs-static-async-generator-method-privatename-identifier.js new file mode 100644 index 0000000000..71476df72b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-async-gen-rs-static-async-generator-method-privatename-identifier.js @@ -0,0 +1,149 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-async-generator-method-privatename-identifier.case +// - src/class-elements/productions/cls-decl-after-same-line-async-gen.template +/*--- +description: Valid Static AsyncGeneratorMethod PrivateName (field definitions after an async generator in the same line) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + AsyncGeneratorMethod + + AsyncGeneratorMethod : + async [no LineTerminator here] * ClassElementName ( UniqueFormalParameters){ AsyncGeneratorBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + async *m() { return 42; } static async * #$(value) { + yield * await value; + } + static async * #_(value) { + yield * await value; + } + static async * #\u{6F}(value) { + yield * await value; + } + static async * #\u2118(value) { + yield * await value; + } + static async * #ZW_\u200C_NJ(value) { + yield * await value; + } + static async * #ZW_\u200D_J(value) { + yield * await value; + }; + static get $() { + return this.#$; + } + static get _() { + return this.#_; + } + static get \u{6F}() { + return this.#\u{6F}; + } + static get \u2118() { + return this.#\u2118; + } + static get ZW_\u200C_NJ() { + return this.#ZW_\u200C_NJ; + } + static get ZW_\u200D_J() { + return this.#ZW_\u200D_J; + } + +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +c.m().next().then(function(v) { + assert.sameValue(v.value, 42); + assert.sameValue(v.done, true); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + Promise.all([ + C.$([1]).next(), + C._([1]).next(), + C.\u{6F}([1]).next(), + C.\u2118([1]).next(), + C.ZW_\u200C_NJ([1]).next(), + C.ZW_\u200D_J([1]).next(), + ]).then(results => { + + assert.sameValue(results[0].value, 1); + assert.sameValue(results[1].value, 1); + assert.sameValue(results[2].value, 1); + assert.sameValue(results[3].value, 1); + assert.sameValue(results[4].value, 1); + assert.sameValue(results[5].value, 1); + + }).then($DONE, $DONE); + + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-async-gen-rs-static-async-method-privatename-identifier-alt.js b/js/src/tests/test262/language/statements/class/elements/same-line-async-gen-rs-static-async-method-privatename-identifier-alt.js new file mode 100644 index 0000000000..9a7993365e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-async-gen-rs-static-async-method-privatename-identifier-alt.js @@ -0,0 +1,148 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-async-method-privatename-identifier-alt.case +// - src/class-elements/productions/cls-decl-after-same-line-async-gen.template +/*--- +description: Valid Static AsyncMethod PrivateName (field definitions after an async generator in the same line) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + AsyncMethod + + AsyncMethod : + async [no LineTerminator here] ClassElementName ( UniqueFormalParameters ){ AsyncFunctionBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + async *m() { return 42; } static async #$(value) { + return await value; + } + static async #_(value) { + return await value; + } + static async #o(value) { + return await value; + } + static async #℘(value) { + return await value; + } + static async #ZW_‌_NJ(value) { + return await value; + } + static async #ZW_‍_J(value) { + return await value; + }; + static async $(value) { + return await this.#$(value); + } + static async _(value) { + return await this.#_(value); + } + static async o(value) { + return await this.#o(value); + } + static async ℘(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + return await this.#℘(value); + } + static async ZW_‌_NJ(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + return await this.#ZW_‌_NJ(value); + } + static async ZW_‍_J(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + return await this.#ZW_‍_J(value); + } + +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +c.m().next().then(function(v) { + assert.sameValue(v.value, 42); + assert.sameValue(v.done, true); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + Promise.all([ + C.$(1), + C._(1), + C.o(1), + C.℘(1), // DO NOT CHANGE THE NAME OF THIS FIELD + C.ZW_‌_NJ(1), // DO NOT CHANGE THE NAME OF THIS FIELD + C.ZW_‍_J(1), // DO NOT CHANGE THE NAME OF THIS FIELD + ]).then(results => { + + assert.sameValue(results[0], 1); + assert.sameValue(results[1], 1); + assert.sameValue(results[2], 1); + assert.sameValue(results[3], 1); + assert.sameValue(results[4], 1); + assert.sameValue(results[5], 1); + + }).then($DONE, $DONE); + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-async-gen-rs-static-async-method-privatename-identifier.js b/js/src/tests/test262/language/statements/class/elements/same-line-async-gen-rs-static-async-method-privatename-identifier.js new file mode 100644 index 0000000000..ab1f021ca8 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-async-gen-rs-static-async-method-privatename-identifier.js @@ -0,0 +1,149 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-async-method-privatename-identifier.case +// - src/class-elements/productions/cls-decl-after-same-line-async-gen.template +/*--- +description: Valid Static AsyncMethod PrivateName (field definitions after an async generator in the same line) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + AsyncMethod + + AsyncMethod : + async [no LineTerminator here] ClassElementName ( UniqueFormalParameters ){ AsyncFunctionBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + async *m() { return 42; } static async #$(value) { + return await value; + } + static async #_(value) { + return await value; + } + static async #\u{6F}(value) { + return await value; + } + static async #\u2118(value) { + return await value; + } + static async #ZW_\u200C_NJ(value) { + return await value; + } + static async #ZW_\u200D_J(value) { + return await value; + }; + static async $(value) { + return await this.#$(value); + } + static async _(value) { + return await this.#_(value); + } + static async \u{6F}(value) { + return await this.#\u{6F}(value); + } + static async \u2118(value) { + return await this.#\u2118(value); + } + static async ZW_\u200C_NJ(value) { + return await this.#ZW_\u200C_NJ(value); + } + static async ZW_\u200D_J(value) { + return await this.#ZW_\u200D_J(value); + } + +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +c.m().next().then(function(v) { + assert.sameValue(v.value, 42); + assert.sameValue(v.done, true); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + Promise.all([ + C.$(1), + C._(1), + C.\u{6F}(1), + C.\u2118(1), + C.ZW_\u200C_NJ(1), + C.ZW_\u200D_J(1), + ]).then(results => { + + assert.sameValue(results[0], 1); + assert.sameValue(results[1], 1); + assert.sameValue(results[2], 1); + assert.sameValue(results[3], 1); + assert.sameValue(results[4], 1); + assert.sameValue(results[5], 1); + + }).then($DONE, $DONE); + + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-async-gen-rs-static-generator-method-privatename-identifier-alt.js b/js/src/tests/test262/language/statements/class/elements/same-line-async-gen-rs-static-generator-method-privatename-identifier-alt.js new file mode 100644 index 0000000000..3d3f000cdb --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-async-gen-rs-static-generator-method-privatename-identifier-alt.js @@ -0,0 +1,137 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-generator-method-privatename-identifier-alt.case +// - src/class-elements/productions/cls-decl-after-same-line-async-gen.template +/*--- +description: Valid Static GeneratorMethod PrivateName (field definitions after an async generator in the same line) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + GeneratorMethod + + GeneratorMethod : + * ClassElementName ( UniqueFormalParameters ){ GeneratorBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + async *m() { return 42; } static * #$(value) { + yield * value; + } + static * #_(value) { + yield * value; + } + static * #o(value) { + yield * value; + } + static * #℘(value) { + yield * value; + } + static * #ZW_‌_NJ(value) { + yield * value; + } + static * #ZW_‍_J(value) { + yield * value; + }; + static get $() { + return this.#$; + } + static get _() { + return this.#_; + } + static get o() { + return this.#o; + } + static get ℘() { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#℘; + } + static get ZW_‌_NJ() { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#ZW_‌_NJ; + } + static get ZW_‍_J() { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#ZW_‍_J; + } + +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +c.m().next().then(function(v) { + assert.sameValue(v.value, 42); + assert.sameValue(v.done, true); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert.sameValue(C.$([1]).next().value, 1); + assert.sameValue(C._([1]).next().value, 1); + assert.sameValue(C.o([1]).next().value, 1); + assert.sameValue(C.℘([1]).next().value, 1); + assert.sameValue(C.ZW_‌_NJ([1]).next().value, 1); + assert.sameValue(C.ZW_‍_J([1]).next().value, 1); + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-async-gen-rs-static-generator-method-privatename-identifier.js b/js/src/tests/test262/language/statements/class/elements/same-line-async-gen-rs-static-generator-method-privatename-identifier.js new file mode 100644 index 0000000000..0bf793f536 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-async-gen-rs-static-generator-method-privatename-identifier.js @@ -0,0 +1,138 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-generator-method-privatename-identifier.case +// - src/class-elements/productions/cls-decl-after-same-line-async-gen.template +/*--- +description: Valid Static GeneratorMethod PrivateName (field definitions after an async generator in the same line) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + GeneratorMethod + + GeneratorMethod : + * ClassElementName ( UniqueFormalParameters ){ GeneratorBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + async *m() { return 42; } static * #$(value) { + yield * value; + } + static * #_(value) { + yield * value; + } + static * #\u{6F}(value) { + yield * value; + } + static * #\u2118(value) { + yield * value; + } + static * #ZW_\u200C_NJ(value) { + yield * value; + } + static * #ZW_\u200D_J(value) { + yield * value; + }; + static get $() { + return this.#$; + } + static get _() { + return this.#_; + } + static get \u{6F}() { + return this.#\u{6F}; + } + static get \u2118() { + return this.#\u2118; + } + static get ZW_\u200C_NJ() { + return this.#ZW_\u200C_NJ; + } + static get ZW_\u200D_J() { + return this.#ZW_\u200D_J; + } + +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +c.m().next().then(function(v) { + assert.sameValue(v.value, 42); + assert.sameValue(v.done, true); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert.sameValue(C.$([1]).next().value, 1); + assert.sameValue(C._([1]).next().value, 1); + assert.sameValue(C.\u{6F}([1]).next().value, 1); + assert.sameValue(C.\u2118([1]).next().value, 1); + assert.sameValue(C.ZW_\u200C_NJ([1]).next().value, 1); + assert.sameValue(C.ZW_\u200D_J([1]).next().value, 1); + + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-async-gen-rs-static-method-privatename-identifier-alt.js b/js/src/tests/test262/language/statements/class/elements/same-line-async-gen-rs-static-method-privatename-identifier-alt.js new file mode 100644 index 0000000000..57fa08c44f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-async-gen-rs-static-method-privatename-identifier-alt.js @@ -0,0 +1,135 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-method-privatename-identifier-alt.case +// - src/class-elements/productions/cls-decl-after-same-line-async-gen.template +/*--- +description: Valid Static Method PrivateName (field definitions after an async generator in the same line) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + ClassElementName ( UniqueFormalParameters ){ FunctionBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + async *m() { return 42; } static #$(value) { + return value; + } + static #_(value) { + return value; + } + static #o(value) { + return value; + } + static #℘(value) { + return value; + } + static #ZW_‌_NJ(value) { + return value; + } + static #ZW_‍_J(value) { + return value; + }; + static $(value) { + return this.#$(value); + } + static _(value) { + return this.#_(value); + } + static o(value) { + return this.#o(value); + } + static ℘(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#℘(value); + } + static ZW_‌_NJ(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#ZW_‌_NJ(value); + } + static ZW_‍_J(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#ZW_‍_J(value); + } + +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +c.m().next().then(function(v) { + assert.sameValue(v.value, 42); + assert.sameValue(v.done, true); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert.sameValue(C.$(1), 1); + assert.sameValue(C._(1), 1); + assert.sameValue(C.o(1), 1); + assert.sameValue(C.℘(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD + assert.sameValue(C.ZW_‌_NJ(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD + assert.sameValue(C.ZW_‍_J(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD + + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-async-gen-rs-static-method-privatename-identifier.js b/js/src/tests/test262/language/statements/class/elements/same-line-async-gen-rs-static-method-privatename-identifier.js new file mode 100644 index 0000000000..403e3b857b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-async-gen-rs-static-method-privatename-identifier.js @@ -0,0 +1,135 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-method-privatename-identifier.case +// - src/class-elements/productions/cls-decl-after-same-line-async-gen.template +/*--- +description: Valid Static Method PrivateName (field definitions after an async generator in the same line) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + ClassElementName ( UniqueFormalParameters ){ FunctionBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + async *m() { return 42; } static #$(value) { + return value; + } + static #_(value) { + return value; + } + static #\u{6F}(value) { + return value; + } + static #\u2118(value) { + return value; + } + static #ZW_\u200C_NJ(value) { + return value; + } + static #ZW_\u200D_J(value) { + return value; + }; + static $(value) { + return this.#$(value); + } + static _(value) { + return this.#_(value); + } + static \u{6F}(value) { + return this.#\u{6F}(value); + } + static \u2118(value) { + return this.#\u2118(value); + } + static ZW_\u200C_NJ(value) { + return this.#ZW_\u200C_NJ(value); + } + static ZW_\u200D_J(value) { + return this.#ZW_\u200D_J(value); + } + +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +c.m().next().then(function(v) { + assert.sameValue(v.value, 42); + assert.sameValue(v.done, true); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert.sameValue(C.$(1), 1); + assert.sameValue(C._(1), 1); + assert.sameValue(C.\u{6F}(1), 1); + assert.sameValue(C.\u2118(1), 1); + assert.sameValue(C.ZW_\u200C_NJ(1), 1); + assert.sameValue(C.ZW_\u200D_J(1), 1); + + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-async-gen-rs-static-privatename-identifier-alt-by-classname.js b/js/src/tests/test262/language/statements/class/elements/same-line-async-gen-rs-static-privatename-identifier-alt-by-classname.js new file mode 100644 index 0000000000..16eb36e6fb --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-async-gen-rs-static-privatename-identifier-alt-by-classname.js @@ -0,0 +1,123 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-privatename-identifier-alt-by-classname.case +// - src/class-elements/productions/cls-decl-after-same-line-async-gen.template +/*--- +description: Valid Static PrivateName (field definitions after an async generator in the same line) +esid: prod-FieldDefinition +features: [class-static-fields-private, class, class-fields-public, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + async *m() { return 42; } static #$; static #_; static #\u{6F}; static #℘; static #ZW_‌_NJ; static #ZW_‍_J; + static $(value) { + C.#$ = value; + return C.#$; + } + static _(value) { + C.#_ = value; + return C.#_; + } + static o(value) { + C.#\u{6F} = value; + return C.#\u{6F}; + } + static ℘(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + C.#℘ = value; + return C.#℘; + } + static ZW_‌_NJ(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + C.#ZW_‌_NJ = value; + return C.#ZW_‌_NJ; + } + static ZW_‍_J(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + C.#ZW_‍_J = value; + return C.#ZW_‍_J; + } +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +c.m().next().then(function(v) { + assert.sameValue(v.value, 42); + assert.sameValue(v.done, true); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert.sameValue(C.$(1), 1); + assert.sameValue(C._(1), 1); + assert.sameValue(C.o(1), 1); + assert.sameValue(C.℘(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD + assert.sameValue(C.ZW_‌_NJ(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD + assert.sameValue(C.ZW_‍_J(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD + + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-async-gen-rs-static-privatename-identifier-alt.js b/js/src/tests/test262/language/statements/class/elements/same-line-async-gen-rs-static-privatename-identifier-alt.js new file mode 100644 index 0000000000..1e9a245c1f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-async-gen-rs-static-privatename-identifier-alt.js @@ -0,0 +1,123 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-privatename-identifier-alt.case +// - src/class-elements/productions/cls-decl-after-same-line-async-gen.template +/*--- +description: Valid Static PrivateName (field definitions after an async generator in the same line) +esid: prod-FieldDefinition +features: [class-static-fields-private, class, class-fields-public, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + async *m() { return 42; } static #$; static #_; static #\u{6F}; static #℘; static #ZW_‌_NJ; static #ZW_‍_J; + static $(value) { + this.#$ = value; + return this.#$; + } + static _(value) { + this.#_ = value; + return this.#_; + } + static o(value) { + this.#\u{6F} = value; + return this.#\u{6F}; + } + static ℘(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + this.#℘ = value; + return this.#℘; + } + static ZW_‌_NJ(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + this.#ZW_‌_NJ = value; + return this.#ZW_‌_NJ; + } + static ZW_‍_J(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + this.#ZW_‍_J = value; + return this.#ZW_‍_J; + } +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +c.m().next().then(function(v) { + assert.sameValue(v.value, 42); + assert.sameValue(v.done, true); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert.sameValue(C.$(1), 1); + assert.sameValue(C._(1), 1); + assert.sameValue(C.o(1), 1); + assert.sameValue(C.℘(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD + assert.sameValue(C.ZW_‌_NJ(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD + assert.sameValue(C.ZW_‍_J(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD + + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-async-gen-rs-static-privatename-identifier-by-classname.js b/js/src/tests/test262/language/statements/class/elements/same-line-async-gen-rs-static-privatename-identifier-by-classname.js new file mode 100644 index 0000000000..e9351775f5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-async-gen-rs-static-privatename-identifier-by-classname.js @@ -0,0 +1,123 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-privatename-identifier-by-classname.case +// - src/class-elements/productions/cls-decl-after-same-line-async-gen.template +/*--- +description: Valid Static PrivateName (field definitions after an async generator in the same line) +esid: prod-FieldDefinition +features: [class-static-fields-private, class, class-fields-public, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + async *m() { return 42; } static #$; static #_; static #\u{6F}; static #\u2118; static #ZW_\u200C_NJ; static #ZW_\u200D_J; + static $(value) { + C.#$ = value; + return C.#$; + } + static _(value) { + C.#_ = value; + return C.#_; + } + static \u{6F}(value) { + C.#\u{6F} = value; + return C.#\u{6F}; + } + static \u2118(value) { + C.#\u2118 = value; + return C.#\u2118; + } + static ZW_\u200C_NJ(value) { + C.#ZW_\u200C_NJ = value; + return C.#ZW_\u200C_NJ; + } + static ZW_\u200D_J(value) { + C.#ZW_\u200D_J = value; + return C.#ZW_\u200D_J; + } +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +c.m().next().then(function(v) { + assert.sameValue(v.value, 42); + assert.sameValue(v.done, true); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert.sameValue(C.$(1), 1); + assert.sameValue(C._(1), 1); + assert.sameValue(C.\u{6F}(1), 1); + assert.sameValue(C.\u2118(1), 1); + assert.sameValue(C.ZW_\u200C_NJ(1), 1); + assert.sameValue(C.ZW_\u200D_J(1), 1); + + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-async-gen-rs-static-privatename-identifier-initializer-alt-by-classname.js b/js/src/tests/test262/language/statements/class/elements/same-line-async-gen-rs-static-privatename-identifier-initializer-alt-by-classname.js new file mode 100644 index 0000000000..9b954de62d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-async-gen-rs-static-privatename-identifier-initializer-alt-by-classname.js @@ -0,0 +1,117 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-privatename-identifier-initializer-alt-by-classname.case +// - src/class-elements/productions/cls-decl-after-same-line-async-gen.template +/*--- +description: Valid Static PrivateName (field definitions after an async generator in the same line) +esid: prod-FieldDefinition +features: [class-static-fields-private, class, class-fields-public, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + async *m() { return 42; } static #$ = 1; static #_ = 1; static #\u{6F} = 1; static #℘ = 1; static #ZW_‌_NJ = 1; static #ZW_‍_J = 1; + static $() { + return C.#$; + } + static _() { + return C.#_; + } + static \u{6F}() { + return C.#\u{6F}; + } + static ℘() { + return C.#℘; + } + static ZW_‌_NJ() { + return C.#ZW_‌_NJ; + } + static ZW_‍_J() { + return C.#ZW_‍_J; + } +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +c.m().next().then(function(v) { + assert.sameValue(v.value, 42); + assert.sameValue(v.done, true); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert.sameValue(C.$(), 1); + assert.sameValue(C._(), 1); + assert.sameValue(C.\u{6F}(), 1); + assert.sameValue(C.℘(), 1); + assert.sameValue(C.ZW_‌_NJ(), 1); + assert.sameValue(C.ZW_‍_J(), 1); + + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-async-gen-rs-static-privatename-identifier-initializer-alt.js b/js/src/tests/test262/language/statements/class/elements/same-line-async-gen-rs-static-privatename-identifier-initializer-alt.js new file mode 100644 index 0000000000..ef223e30dd --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-async-gen-rs-static-privatename-identifier-initializer-alt.js @@ -0,0 +1,117 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-privatename-identifier-initializer-alt.case +// - src/class-elements/productions/cls-decl-after-same-line-async-gen.template +/*--- +description: Valid Static PrivateName (field definitions after an async generator in the same line) +esid: prod-FieldDefinition +features: [class-static-fields-private, class, class-fields-public, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + async *m() { return 42; } static #$ = 1; static #_ = 1; static #\u{6F} = 1; static #℘ = 1; static #ZW_‌_NJ = 1; static #ZW_‍_J = 1; + static $() { + return this.#$; + } + static _() { + return this.#_; + } + static \u{6F}() { + return this.#\u{6F}; + } + static ℘() { + return this.#℘; + } + static ZW_‌_NJ() { + return this.#ZW_‌_NJ; + } + static ZW_‍_J() { + return this.#ZW_‍_J; + } +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +c.m().next().then(function(v) { + assert.sameValue(v.value, 42); + assert.sameValue(v.done, true); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert.sameValue(C.$(), 1); + assert.sameValue(C._(), 1); + assert.sameValue(C.\u{6F}(), 1); + assert.sameValue(C.℘(), 1); + assert.sameValue(C.ZW_‌_NJ(), 1); + assert.sameValue(C.ZW_‍_J(), 1); + + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-async-gen-rs-static-privatename-identifier-initializer.js b/js/src/tests/test262/language/statements/class/elements/same-line-async-gen-rs-static-privatename-identifier-initializer.js new file mode 100644 index 0000000000..89b39924ff --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-async-gen-rs-static-privatename-identifier-initializer.js @@ -0,0 +1,117 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-privatename-identifier-initializer.case +// - src/class-elements/productions/cls-decl-after-same-line-async-gen.template +/*--- +description: Valid Static PrivateName (field definitions after an async generator in the same line) +esid: prod-FieldDefinition +features: [class-static-fields-private, class, class-fields-public, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + async *m() { return 42; } static #$ = 1; static #_ = 1; static #\u{6F} = 1; static #\u2118 = 1; static #ZW_\u200C_NJ = 1; static #ZW_\u200D_J = 1; + static $() { + return this.#$; + } + static _() { + return this.#_; + } + static \u{6F}() { + return this.#\u{6F}; + } + static \u2118() { + return this.#\u2118; + } + static ZW_\u200C_NJ() { + return this.#ZW_\u200C_NJ; + } + static ZW_\u200D_J() { + return this.#ZW_\u200D_J; + } +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +c.m().next().then(function(v) { + assert.sameValue(v.value, 42); + assert.sameValue(v.done, true); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert.sameValue(C.$(), 1); + assert.sameValue(C._(), 1); + assert.sameValue(C.\u{6F}(), 1); + assert.sameValue(C.\u2118(), 1); + assert.sameValue(C.ZW_\u200C_NJ(), 1); + assert.sameValue(C.ZW_\u200D_J(), 1); + + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-async-gen-rs-static-privatename-identifier.js b/js/src/tests/test262/language/statements/class/elements/same-line-async-gen-rs-static-privatename-identifier.js new file mode 100644 index 0000000000..cc7eb655b6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-async-gen-rs-static-privatename-identifier.js @@ -0,0 +1,123 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-privatename-identifier.case +// - src/class-elements/productions/cls-decl-after-same-line-async-gen.template +/*--- +description: Valid Static PrivateName (field definitions after an async generator in the same line) +esid: prod-FieldDefinition +features: [class-static-fields-private, class, class-fields-public, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + async *m() { return 42; } static #$; static #_; static #\u{6F}; static #\u2118; static #ZW_\u200C_NJ; static #ZW_\u200D_J; + static $(value) { + this.#$ = value; + return this.#$; + } + static _(value) { + this.#_ = value; + return this.#_; + } + static \u{6F}(value) { + this.#\u{6F} = value; + return this.#\u{6F}; + } + static \u2118(value) { + this.#\u2118 = value; + return this.#\u2118; + } + static ZW_\u200C_NJ(value) { + this.#ZW_\u200C_NJ = value; + return this.#ZW_\u200C_NJ; + } + static ZW_\u200D_J(value) { + this.#ZW_\u200D_J = value; + return this.#ZW_\u200D_J; + } +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +c.m().next().then(function(v) { + assert.sameValue(v.value, 42); + assert.sameValue(v.done, true); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert.sameValue(C.$(1), 1); + assert.sameValue(C._(1), 1); + assert.sameValue(C.\u{6F}(1), 1); + assert.sameValue(C.\u2118(1), 1); + assert.sameValue(C.ZW_\u200C_NJ(1), 1); + assert.sameValue(C.ZW_\u200D_J(1), 1); + + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-async-gen-static-private-fields.js b/js/src/tests/test262/language/statements/class/elements/same-line-async-gen-static-private-fields.js new file mode 100644 index 0000000000..534bf0f6aa --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-async-gen-static-private-fields.js @@ -0,0 +1,84 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/static-private-fields.case +// - src/class-elements/productions/cls-decl-after-same-line-async-gen.template +/*--- +description: static private fields (field definitions after an async generator in the same line) +esid: prod-FieldDefinition +features: [class-static-fields-private, class, class-fields-public, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + ... + static FieldDefinition ; + + FieldDefinition : + ClassElementName Initializer_opt + + ClassElementName : + PrivateName + + PrivateName : + # IdentifierName + +---*/ + + +class C { + async *m() { return 42; } static #x; static #y; + static x() { + this.#x = 42; + return this.#x; + } + static y() { + this.#y = 43; + return this.#y; + } +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +c.m().next().then(function(v) { + assert.sameValue(v.value, 42); + assert.sameValue(v.done, true); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + // Test the private fields do not appear as properties before set to value + assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#x"), "test 1"); + assert(!Object.prototype.hasOwnProperty.call(C, "#x"), "test 2"); + assert(!Object.prototype.hasOwnProperty.call(c, "#x"), "test 3"); + + assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#y"), "test 4"); + assert(!Object.prototype.hasOwnProperty.call(C, "#y"), "test 5"); + assert(!Object.prototype.hasOwnProperty.call(c, "#y"), "test 6"); + + // Test if private fields can be sucessfully accessed and set to value + assert.sameValue(C.x(), 42, "test 7"); + assert.sameValue(C.y(), 43, "test 8"); + + // Test the private fields do not appear as properties before after set to value + assert(!Object.prototype.hasOwnProperty.call(C, "#x"), "test 9"); + assert(!Object.prototype.hasOwnProperty.call(C, "#y"), "test 10"); + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-async-gen-static-private-methods-with-fields.js b/js/src/tests/test262/language/statements/class/elements/same-line-async-gen-static-private-methods-with-fields.js new file mode 100644 index 0000000000..508876ee08 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-async-gen-static-private-methods-with-fields.js @@ -0,0 +1,101 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/static-private-methods-with-fields.case +// - src/class-elements/productions/cls-decl-after-same-line-async-gen.template +/*--- +description: static private methods with fields (field definitions after an async generator in the same line) +esid: prod-FieldDefinition +features: [class-static-methods-private, class-static-fields-private, class, class-fields-public, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + ... + static FieldDefinition ; + + FieldDefinition : + ClassElementName Initializer_opt + + ClassElementName : + PrivateName + + PrivateName : + # IdentifierName + +---*/ + + +class C { + async *m() { return 42; } static #xVal; static #yVal; + static #x(value) { + this.#xVal = value; + return this.#xVal; + } + static #y(value) { + this.#yVal = value; + return this.#yVal; + } + static x() { + return this.#x(42); + } + static y() { + return this.#y(43); + } +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +c.m().next().then(function(v) { + assert.sameValue(v.value, 42); + assert.sameValue(v.done, true); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + // Test the private methods do not appear as properties before set to value + assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#x"), "test 1"); + assert(!Object.prototype.hasOwnProperty.call(C, "#x"), "test 2"); + assert(!Object.prototype.hasOwnProperty.call(c, "#x"), "test 3"); + + assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#y"), "test 4"); + assert(!Object.prototype.hasOwnProperty.call(C, "#y"), "test 5"); + assert(!Object.prototype.hasOwnProperty.call(c, "#y"), "test 6"); + + assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#xVal"), "test 7"); + assert(!Object.prototype.hasOwnProperty.call(C, "#xVal"), "test 8"); + assert(!Object.prototype.hasOwnProperty.call(c, "#xVal"), "test 9"); + + assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#yVal"), "test 10"); + assert(!Object.prototype.hasOwnProperty.call(C, "#yVal"), "test 11"); + assert(!Object.prototype.hasOwnProperty.call(c, "#yVal"), "test 12"); + + // Test if private fields can be sucessfully accessed and set to value + assert.sameValue(C.x(), 42, "test 13"); + assert.sameValue(C.y(), 43, "test 14"); + + // Test the private fields do not appear as properties before after set to value + assert(!Object.prototype.hasOwnProperty.call(C, "#x"), "test 15"); + assert(!Object.prototype.hasOwnProperty.call(C, "#y"), "test 16"); + + assert(!Object.prototype.hasOwnProperty.call(C, "#xVal"), "test 17"); + assert(!Object.prototype.hasOwnProperty.call(C, "#yVal"), "test 18"); + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-async-gen-static-private-methods.js b/js/src/tests/test262/language/statements/class/elements/same-line-async-gen-static-private-methods.js new file mode 100644 index 0000000000..9b6f577fca --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-async-gen-static-private-methods.js @@ -0,0 +1,88 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/static-private-methods.case +// - src/class-elements/productions/cls-decl-after-same-line-async-gen.template +/*--- +description: static private methods (field definitions after an async generator in the same line) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + ... + static FieldDefinition ; + + FieldDefinition : + ClassElementName Initializer_opt + + ClassElementName : + PrivateName + + PrivateName : + # IdentifierName + +---*/ + + +class C { + async *m() { return 42; } ; + static #x(value) { + return value / 2; + } + static #y(value) { + return value * 2; + } + static x() { + return this.#x(84); + } + static y() { + return this.#y(43); + } +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +c.m().next().then(function(v) { + assert.sameValue(v.value, 42); + assert.sameValue(v.done, true); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + // Test the private methods do not appear as properties before set to value + assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#x"), "test 1"); + assert(!Object.prototype.hasOwnProperty.call(C, "#x"), "test 2"); + assert(!Object.prototype.hasOwnProperty.call(c, "#x"), "test 3"); + + assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#y"), "test 4"); + assert(!Object.prototype.hasOwnProperty.call(C, "#y"), "test 5"); + assert(!Object.prototype.hasOwnProperty.call(c, "#y"), "test 6"); + + // Test if private fields can be sucessfully accessed and set to value + assert.sameValue(C.x(), 42, "test 7"); + assert.sameValue(C.y(), 86, "test 8"); + + // Test the private fields do not appear as properties before after set to value + assert(!Object.prototype.hasOwnProperty.call(C, "#x"), "test 9"); + assert(!Object.prototype.hasOwnProperty.call(C, "#y"), "test 10"); + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-async-gen-string-literal-names.js b/js/src/tests/test262/language/statements/class/elements/same-line-async-gen-string-literal-names.js new file mode 100644 index 0000000000..911faa1d9a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-async-gen-string-literal-names.js @@ -0,0 +1,122 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/string-literal-names.case +// - src/class-elements/productions/cls-decl-after-same-line-async-gen.template +/*--- +description: String literal names (field definitions after an async generator in the same line) +esid: prod-FieldDefinition +features: [class-fields-public, class, async-iteration] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PropertyName + +---*/ + + +class C { + async *m() { return 42; } 'a'; "b"; 'c' = 39; + "d" = 42; + +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +c.m().next().then(function(v) { + assert.sameValue(v.value, 42); + assert.sameValue(v.done, true); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "a"), + "a does not appear as an own property on C prototype" + ); + assert( + !Object.prototype.hasOwnProperty.call(C, "a"), + "a does not appear as an own property on C constructor" + ); + + verifyProperty(c, "a", { + value: undefined, + enumerable: true, + writable: true, + configurable: true + }); + + assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "b"), + "b does not appear as an own property on C prototype" + ); + assert( + !Object.prototype.hasOwnProperty.call(C, "b"), + "b does not appear as an own property on C constructor" + ); + + verifyProperty(c, "b", { + value: undefined, + enumerable: true, + writable: true, + configurable: true + }); + + assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "c"), + "c does not appear as an own property on C prototype" + ); + assert( + !Object.prototype.hasOwnProperty.call(C, "c"), + "c does not appear as an own property on C constructor" + ); + + verifyProperty(c, "c", { + value: 39, + enumerable: true, + writable: true, + configurable: true + }); + + assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "d"), + "d does not appear as an own property on C prototype" + ); + assert( + !Object.prototype.hasOwnProperty.call(C, "d"), + "d does not appear as an own property on C constructor" + ); + + verifyProperty(c, "d", { + value: 42, + enumerable: true, + writable: true, + configurable: true + }); + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-async-method-computed-names.js b/js/src/tests/test262/language/statements/class/elements/same-line-async-method-computed-names.js new file mode 100644 index 0000000000..9bb608a2f8 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-async-method-computed-names.js @@ -0,0 +1,119 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/computed-names.case +// - src/class-elements/productions/cls-decl-after-same-line-async-method.template +/*--- +description: Computed property names (field definitions after an async method in the same line) +esid: prod-FieldDefinition +features: [class-fields-public, computed-property-names, class, async-functions] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PropertyName + +---*/ +var x = "b"; + + + +class C { + async m() { return 42; } [x] = 42; [10] = "meep"; ["not initialized"]; + +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +c.m().then(function(v) { + assert.sameValue(v, 42); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "b"), + "b doesn't appear as an own property on C prototype" + ); + assert( + !Object.prototype.hasOwnProperty.call(C, "b"), + "b doesn't appear as an own property on C constructor" + ); + + verifyProperty(c, "b", { + value: 42, + enumerable: true, + writable: true, + configurable: true + }); + + assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "x"), + "x doesn't appear as an own property on C prototype" + ); + assert( + !Object.prototype.hasOwnProperty.call(C, "x"), + "x doesn't appear as an own property on C constructor" + ); + assert( + !Object.prototype.hasOwnProperty.call(c, "x"), + "x doesn't appear as an own property on C instance" + ); + + assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "10"), + "10 doesn't appear as an own property on C prototype" + ); + assert( + !Object.prototype.hasOwnProperty.call(C, "10"), + "10 doesn't appear as an own property on C constructor" + ); + + verifyProperty(c, "10", { + value: "meep", + enumerable: true, + writable: true, + configurable: true + }); + + assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "not initialized"), + "'not initialized' doesn't appear as an own property on C prototype" + ); + assert( + !Object.prototype.hasOwnProperty.call(C, "not initialized"), + "'not initialized' doesn't appear as an own property on C constructor" + ); + + verifyProperty(c, "not initialized", { + value: undefined, + enumerable: true, + writable: true, + configurable: true + }); + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-async-method-computed-symbol-names.js b/js/src/tests/test262/language/statements/class/elements/same-line-async-method-computed-symbol-names.js new file mode 100644 index 0000000000..395584354c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-async-method-computed-symbol-names.js @@ -0,0 +1,117 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/computed-symbol-names.case +// - src/class-elements/productions/cls-decl-after-same-line-async-method.template +/*--- +description: Computed property symbol names (field definitions after an async method in the same line) +esid: prod-FieldDefinition +features: [class-fields-public, Symbol, computed-property-names, class, async-functions] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PropertyName + +---*/ +var x = Symbol(); +var y = Symbol(); + + + +class C { + async m() { return 42; } [x]; [y] = 42; + +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +c.m().then(function(v) { + assert.sameValue(v, 42); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert( + !Object.prototype.hasOwnProperty.call(C.prototype, x), + "Symbol x doesn't appear as an own property on C prototype" + ); + assert( + !Object.prototype.hasOwnProperty.call(C, x), + "Symbol x doesn't appear as an own property on C constructor" + ); + + verifyProperty(c, x, { + value: undefined, + enumerable: true, + writable: true, + configurable: true + }); + + assert( + !Object.prototype.hasOwnProperty.call(C.prototype, y), + "Symbol y doesn't appear as an own property on C prototype" + ); + assert( + !Object.prototype.hasOwnProperty.call(C, y), + "Symbol y doesn't appear as an own property on C constructor" + ); + + verifyProperty(c, y, { + value: 42, + enumerable: true, + writable: true, + configurable: true + }); + + assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "x"), + "x doesn't appear as an own property on C prototype" + ); + assert( + !Object.prototype.hasOwnProperty.call(C, "x"), + "x doesn't appear as an own property on C constructor" + ); + assert( + !Object.prototype.hasOwnProperty.call(c, "x"), + "x doesn't appear as an own property on C instance" + ); + + assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "y"), + "y doesn't appear as an own property on C prototype" + ); + assert( + !Object.prototype.hasOwnProperty.call(C, "y"), + "y doesn't appear as an own property on C constructor" + ); + assert( + !Object.prototype.hasOwnProperty.call(c, "y"), + "y doesn't appear as an own property on C instance" + ); + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-async-method-grammar-privatename-identifier-semantics-stringvalue.js b/js/src/tests/test262/language/statements/class/elements/same-line-async-method-grammar-privatename-identifier-semantics-stringvalue.js new file mode 100644 index 0000000000..b474834e14 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-async-method-grammar-privatename-identifier-semantics-stringvalue.js @@ -0,0 +1,121 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-privatename-identifier-semantics-stringvalue.case +// - src/class-elements/productions/cls-decl-after-same-line-async-method.template +/*--- +description: PrivateName Static Semantics, StringValue (field definitions after an async method in the same line) +esid: prod-FieldDefinition +features: [class-fields-private, class, class-fields-public, async-functions] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + + + 1. Return the String value consisting of the sequence of code + units corresponding to PrivateName. In determining the sequence + any occurrences of \ UnicodeEscapeSequence are first replaced + with the code point represented by the UnicodeEscapeSequence + and then the code points of the entire PrivateName are converted + to code units by UTF16Encoding (10.1.1) each code point. + +---*/ + + +class C { + async m() { return 42; } #\u{6F}; + #\u2118; + #ZW_\u200C_NJ; + #ZW_\u200D_J;; + o(value) { + this.#o = value; + return this.#o; + } + ℘(value) { + this.#℘ = value; + return this.#℘; + } + ZW_‌_NJ(value) { // DO NOT CHANGE THE NAME OF THIS METHOD + this.#ZW_‌_NJ = value; + return this.#ZW_‌_NJ; + } + ZW_‍_J(value) { // DO NOT CHANGE THE NAME OF THIS METHOD + this.#ZW_‍_J = value; + return this.#ZW_‍_J; + } +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +c.m().then(function(v) { + assert.sameValue(v, 42); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert.sameValue(c.o(1), 1); + assert.sameValue(c.℘(1), 1); + assert.sameValue(c.ZW_‌_NJ(1), 1); + assert.sameValue(c.ZW_‍_J(1), 1); + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-async-method-literal-names-asi.js b/js/src/tests/test262/language/statements/class/elements/same-line-async-method-literal-names-asi.js new file mode 100644 index 0000000000..ace9109e4b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-async-method-literal-names-asi.js @@ -0,0 +1,89 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/literal-names-asi.case +// - src/class-elements/productions/cls-decl-after-same-line-async-method.template +/*--- +description: Literal property names with ASI (field definitions after an async method in the same line) +esid: prod-FieldDefinition +features: [class-fields-public, class, async-functions] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PropertyName + +---*/ + + +class C { + async m() { return 42; } a + b = 42;; + +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +c.m().then(function(v) { + assert.sameValue(v, 42); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "a"), + "a doesn't appear as an own property on C prototype" + ); + assert( + !Object.prototype.hasOwnProperty.call(C, "a"), + "a doesn't appear as an own property on C constructor" + ); + + verifyProperty(c, "a", { + value: undefined, + enumerable: true, + writable: true, + configurable: true + }); + + assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "b"), + "b doesn't appear as an own property on C prototype" + ); + assert( + !Object.prototype.hasOwnProperty.call(C, "b"), + "b doesn't appear as an own property on C constructor" + ); + + verifyProperty(c, "b", { + value: 42, + enumerable: true, + writable: true, + configurable: true + }); + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-async-method-literal-names.js b/js/src/tests/test262/language/statements/class/elements/same-line-async-method-literal-names.js new file mode 100644 index 0000000000..3bafafbc0d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-async-method-literal-names.js @@ -0,0 +1,108 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/literal-names.case +// - src/class-elements/productions/cls-decl-after-same-line-async-method.template +/*--- +description: Literal property names (field definitions after an async method in the same line) +esid: prod-FieldDefinition +features: [class-fields-public, class, async-functions] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PropertyName + +---*/ +const fn = function() {} + + + +class C { + async m() { return 42; } a; b = 42; + c = fn; + +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +c.m().then(function(v) { + assert.sameValue(v, 42); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "a"), + "a doesn't appear as an own property on C prototype" + ); + assert( + !Object.prototype.hasOwnProperty.call(C, "a"), + "a doesn't appear as an own property on C constructor" + ); + + verifyProperty(c, "a", { + value: undefined, + enumerable: true, + writable: true, + configurable: true + }); + + assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "b"), + "b doesn't appear as an own property on C prototype" + ); + assert( + !Object.prototype.hasOwnProperty.call(C, "b"), + "b doesn't appear as an own property on C constructor" + ); + + verifyProperty(c, "b", { + value: 42, + enumerable: true, + writable: true, + configurable: true + }); + + assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "c"), + "c doesn't appear as an own property on C prototype" + ); + assert( + !Object.prototype.hasOwnProperty.call(C, "c"), + "c doesn't appear as an own property on C constructor" + ); + + verifyProperty(c, "c", { + value: fn, + enumerable: true, + writable: true, + configurable: true + }); + + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-async-method-private-field-usage.js b/js/src/tests/test262/language/statements/class/elements/same-line-async-method-private-field-usage.js new file mode 100644 index 0000000000..66469c293d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-async-method-private-field-usage.js @@ -0,0 +1,61 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/private-field-usage.case +// - src/class-elements/productions/cls-decl-after-same-line-async-method.template +/*--- +description: PrivateName CallExpression usage (private field) (field definitions after an async method in the same line) +esid: prod-FieldDefinition +features: [class-fields-private, class, class-fields-public, async-functions] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + Updated Productions + + CallExpression[Yield, Await]: + CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await] + SuperCall[?Yield, ?Await] + CallExpression[?Yield, ?Await]Arguments[?Yield, ?Await] + CallExpression[?Yield, ?Await][Expression[+In, ?Yield, ?Await]] + CallExpression[?Yield, ?Await].IdentifierName + CallExpression[?Yield, ?Await]TemplateLiteral[?Yield, ?Await] + CallExpression[?Yield, ?Await].PrivateName + +---*/ + + +class C { + async m() { return 42; } #m = 'test262';; + method() { + return this.#m; + } +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +c.m().then(function(v) { + assert.sameValue(v, 42); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert.sameValue(c.method(), 'test262'); + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-async-method-private-method-getter-usage.js b/js/src/tests/test262/language/statements/class/elements/same-line-async-method-private-method-getter-usage.js new file mode 100644 index 0000000000..f71ee44739 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-async-method-private-method-getter-usage.js @@ -0,0 +1,61 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/private-method-getter-usage.case +// - src/class-elements/productions/cls-decl-after-same-line-async-method.template +/*--- +description: PrivateName CallExpression usage (Accesor get method) (field definitions after an async method in the same line) +esid: prod-FieldDefinition +features: [class-methods-private, class, class-fields-public, async-functions] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + Updated Productions + + CallExpression[Yield, Await]: + CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await] + SuperCall[?Yield, ?Await] + CallExpression[?Yield, ?Await]Arguments[?Yield, ?Await] + CallExpression[?Yield, ?Await][Expression[+In, ?Yield, ?Await]] + CallExpression[?Yield, ?Await].IdentifierName + CallExpression[?Yield, ?Await]TemplateLiteral[?Yield, ?Await] + CallExpression[?Yield, ?Await].PrivateName + +---*/ + + +class C { + async m() { return 42; } get #m() { return 'test262'; }; + method() { + return this.#m; + } +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +c.m().then(function(v) { + assert.sameValue(v, 42); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert.sameValue(c.method(), 'test262'); + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-async-method-private-method-usage.js b/js/src/tests/test262/language/statements/class/elements/same-line-async-method-private-method-usage.js new file mode 100644 index 0000000000..f5b90f8685 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-async-method-private-method-usage.js @@ -0,0 +1,61 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/private-method-usage.case +// - src/class-elements/productions/cls-decl-after-same-line-async-method.template +/*--- +description: PrivateName CallExpression usage (private method) (field definitions after an async method in the same line) +esid: prod-FieldDefinition +features: [class-methods-private, class, class-fields-public, async-functions] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + Updated Productions + + CallExpression[Yield, Await]: + CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await] + SuperCall[?Yield, ?Await] + CallExpression[?Yield, ?Await]Arguments[?Yield, ?Await] + CallExpression[?Yield, ?Await][Expression[+In, ?Yield, ?Await]] + CallExpression[?Yield, ?Await].IdentifierName + CallExpression[?Yield, ?Await]TemplateLiteral[?Yield, ?Await] + CallExpression[?Yield, ?Await].PrivateName + +---*/ + + +class C { + async m() { return 42; } #m() { return 'test262'; }; + method() { + return this.#m(); + } +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +c.m().then(function(v) { + assert.sameValue(v, 42); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert.sameValue(c.method(), 'test262'); + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-async-method-private-names.js b/js/src/tests/test262/language/statements/class/elements/same-line-async-method-private-names.js new file mode 100644 index 0000000000..7dde827b1e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-async-method-private-names.js @@ -0,0 +1,83 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/private-names.case +// - src/class-elements/productions/cls-decl-after-same-line-async-method.template +/*--- +description: private names (field definitions after an async method in the same line) +esid: prod-FieldDefinition +features: [class-fields-private, class, class-fields-public, async-functions] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + ... + FieldDefinition ; + + FieldDefinition : + ClassElementName Initializer_opt + + ClassElementName : + PrivateName + + PrivateName : + # IdentifierName + +---*/ + + +class C { + async m() { return 42; } #x; #y; + x() { + this.#x = 42; + return this.#x; + } + y() { + this.#y = 43; + return this.#y; + } +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +c.m().then(function(v) { + assert.sameValue(v, 42); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + // Test the private fields do not appear as properties before set to value + assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#x"), "test 1"); + assert(!Object.prototype.hasOwnProperty.call(C, "#x"), "test 2"); + assert(!Object.prototype.hasOwnProperty.call(c, "#x"), "test 3"); + + assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#y"), "test 4"); + assert(!Object.prototype.hasOwnProperty.call(C, "#y"), "test 5"); + assert(!Object.prototype.hasOwnProperty.call(c, "#y"), "test 6"); + + // Test if private fields can be sucessfully accessed and set to value + assert.sameValue(c.x(), 42, "test 7"); + assert.sameValue(c.y(), 43, "test 8"); + + // Test the private fields do not appear as properties before after set to value + assert(!Object.prototype.hasOwnProperty.call(c, "#x"), "test 9"); + assert(!Object.prototype.hasOwnProperty.call(c, "#y"), "test 10"); + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-async-method-rs-field-identifier-initializer.js b/js/src/tests/test262/language/statements/class/elements/same-line-async-method-rs-field-identifier-initializer.js new file mode 100644 index 0000000000..ea1128fafb --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-async-method-rs-field-identifier-initializer.js @@ -0,0 +1,99 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-field-identifier-initializer.case +// - src/class-elements/productions/cls-decl-after-same-line-async-method.template +/*--- +description: Valid FieldDefinition (field definitions after an async method in the same line) +esid: prod-FieldDefinition +features: [class-fields-public, class, async-functions] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + ... + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + + PropertyName : + LiteralPropertyName + ComputedPropertyName + + LiteralPropertyName : + IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + async m() { return 42; } $ = 1; _ = 1; \u{6F} = 1; \u2118 = 1; ZW_\u200C_NJ = 1; ZW_\u200D_J = 1; + +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +c.m().then(function(v) { + assert.sameValue(v, 42); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert.sameValue(c.$, 1); + assert.sameValue(c._, 1); + assert.sameValue(c.\u{6F}, 1); + assert.sameValue(c.\u2118, 1); + assert.sameValue(c.ZW_\u200C_NJ, 1); + assert.sameValue(c.ZW_\u200D_J, 1); + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-async-method-rs-field-identifier.js b/js/src/tests/test262/language/statements/class/elements/same-line-async-method-rs-field-identifier.js new file mode 100644 index 0000000000..5846d564c5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-async-method-rs-field-identifier.js @@ -0,0 +1,106 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-field-identifier.case +// - src/class-elements/productions/cls-decl-after-same-line-async-method.template +/*--- +description: Valid FieldDefinition (field definitions after an async method in the same line) +esid: prod-FieldDefinition +features: [class-fields-public, class, async-functions] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + ... + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + + PropertyName : + LiteralPropertyName + ComputedPropertyName + + LiteralPropertyName : + IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + async m() { return 42; } $; _; \u{6F}; \u2118; ZW_\u200C_NJ; ZW_\u200D_J; + +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +c.m().then(function(v) { + assert.sameValue(v, 42); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + c.$ = 1; + c._ = 1; + c.\u{6F} = 1; + c.\u2118 = 1; + c.ZW_\u200C_NJ = 1; + c.ZW_\u200D_J = 1; + + assert.sameValue(c.$, 1); + assert.sameValue(c._, 1); + assert.sameValue(c.\u{6F}, 1); + assert.sameValue(c.\u2118, 1); + assert.sameValue(c.ZW_\u200C_NJ, 1); + assert.sameValue(c.ZW_\u200D_J, 1); + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-async-method-rs-private-getter-alt.js b/js/src/tests/test262/language/statements/class/elements/same-line-async-method-rs-private-getter-alt.js new file mode 100644 index 0000000000..4054d76491 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-async-method-rs-private-getter-alt.js @@ -0,0 +1,140 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-private-getter-alt.case +// - src/class-elements/productions/cls-decl-after-same-line-async-method.template +/*--- +description: Valid PrivateName as private getter (field definitions after an async method in the same line) +esid: prod-FieldDefinition +features: [class-methods-private, class-fields-private, class, class-fields-public, async-functions] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + ... + ; + + MethodDefinition : + ... + get ClassElementName ( ){ FunctionBody } + ... + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + async m() { return 42; } #$_; #__; #\u{6F}_; #℘_; #ZW_‌_NJ_; #ZW_‍_J_; + get #$() { + return this.#$_; + } + get #_() { + return this.#__; + } + get #\u{6F}() { + return this.#\u{6F}_; + } + get #℘() { + return this.#℘_; + } + get #ZW_‌_NJ() { + return this.#ZW_‌_NJ_; + } + get #ZW_‍_J() { + return this.#ZW_‍_J_; + } +; + $(value) { + this.#$_ = value; + return this.#$; + } + _(value) { + this.#__ = value; + return this.#_; + } + \u{6F}(value) { + this.#\u{6F}_ = value; + return this.#\u{6F}; + } + ℘(value) { + this.#℘_ = value; + return this.#℘; + } + ZW_‌_NJ(value) { + this.#ZW_‌_NJ_ = value; + return this.#ZW_‌_NJ; + } + ZW_‍_J(value) { + this.#ZW_‍_J_ = value; + return this.#ZW_‍_J; + } + +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +c.m().then(function(v) { + assert.sameValue(v, 42); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert.sameValue(c.$(1), 1); + assert.sameValue(c._(1), 1); + assert.sameValue(c.\u{6F}(1), 1); + assert.sameValue(c.℘(1), 1); + assert.sameValue(c.ZW_‌_NJ(1), 1); + assert.sameValue(c.ZW_‍_J(1), 1); + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-async-method-rs-private-getter.js b/js/src/tests/test262/language/statements/class/elements/same-line-async-method-rs-private-getter.js new file mode 100644 index 0000000000..993a5984e9 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-async-method-rs-private-getter.js @@ -0,0 +1,140 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-private-getter.case +// - src/class-elements/productions/cls-decl-after-same-line-async-method.template +/*--- +description: Valid PrivateName as private getter (field definitions after an async method in the same line) +esid: prod-FieldDefinition +features: [class-methods-private, class-fields-private, class, class-fields-public, async-functions] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + ... + ; + + MethodDefinition : + ... + get ClassElementName ( ){ FunctionBody } + ... + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + async m() { return 42; } #$_; #__; #\u{6F}_; #\u2118_; #ZW_\u200C_NJ_; #ZW_\u200D_J_; + get #$() { + return this.#$_; + } + get #_() { + return this.#__; + } + get #\u{6F}() { + return this.#\u{6F}_; + } + get #\u2118() { + return this.#\u2118_; + } + get #ZW_\u200C_NJ() { + return this.#ZW_\u200C_NJ_; + } + get #ZW_\u200D_J() { + return this.#ZW_\u200D_J_; + } +; + $(value) { + this.#$_ = value; + return this.#$; + } + _(value) { + this.#__ = value; + return this.#_; + } + \u{6F}(value) { + this.#\u{6F}_ = value; + return this.#\u{6F}; + } + \u2118(value) { + this.#\u2118_ = value; + return this.#\u2118; + } + ZW_\u200C_NJ(value) { + this.#ZW_\u200C_NJ_ = value; + return this.#ZW_\u200C_NJ; + } + ZW_\u200D_J(value) { + this.#ZW_\u200D_J_ = value; + return this.#ZW_\u200D_J; + } + +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +c.m().then(function(v) { + assert.sameValue(v, 42); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert.sameValue(c.$(1), 1); + assert.sameValue(c._(1), 1); + assert.sameValue(c.\u{6F}(1), 1); + assert.sameValue(c.\u2118(1), 1); + assert.sameValue(c.ZW_\u200C_NJ(1), 1); + assert.sameValue(c.ZW_\u200D_J(1), 1); + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-async-method-rs-private-method-alt.js b/js/src/tests/test262/language/statements/class/elements/same-line-async-method-rs-private-method-alt.js new file mode 100644 index 0000000000..dc90a7d4a1 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-async-method-rs-private-method-alt.js @@ -0,0 +1,139 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-private-method-alt.case +// - src/class-elements/productions/cls-decl-after-same-line-async-method.template +/*--- +description: Valid PrivateName as private method (field definitions after an async method in the same line) +esid: prod-FieldDefinition +features: [class-methods-private, class-fields-private, class, class-fields-public, async-functions] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + ... + ; + + MethodDefinition : + ClassElementName ( UniqueFormalParameters ) { FunctionBody } + ... + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + async m() { return 42; } #$_; #__; #\u{6F}_; #℘_; #ZW_‌_NJ_; #ZW_‍_J_; + #$() { + return this.#$_; + } + #_() { + return this.#__; + } + #\u{6F}() { + return this.#\u{6F}_; + } + #℘() { + return this.#℘_; + } + #ZW_‌_NJ() { + return this.#ZW_‌_NJ_; + } + #ZW_‍_J() { + return this.#ZW_‍_J_; + } +; + $(value) { + this.#$_ = value; + return this.#$(); + } + _(value) { + this.#__ = value; + return this.#_(); + } + \u{6F}(value) { + this.#\u{6F}_ = value; + return this.#\u{6F}(); + } + ℘(value) { + this.#℘_ = value; + return this.#℘(); + } + ZW_‌_NJ(value) { + this.#ZW_‌_NJ_ = value; + return this.#ZW_‌_NJ(); + } + ZW_‍_J(value) { + this.#ZW_‍_J_ = value; + return this.#ZW_‍_J(); + } + +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +c.m().then(function(v) { + assert.sameValue(v, 42); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert.sameValue(c.$(1), 1); + assert.sameValue(c._(1), 1); + assert.sameValue(c.\u{6F}(1), 1); + assert.sameValue(c.℘(1), 1); + assert.sameValue(c.ZW_‌_NJ(1), 1); + assert.sameValue(c.ZW_‍_J(1), 1); + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-async-method-rs-private-method.js b/js/src/tests/test262/language/statements/class/elements/same-line-async-method-rs-private-method.js new file mode 100644 index 0000000000..c385f47f7c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-async-method-rs-private-method.js @@ -0,0 +1,139 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-private-method.case +// - src/class-elements/productions/cls-decl-after-same-line-async-method.template +/*--- +description: Valid PrivateName as private method (field definitions after an async method in the same line) +esid: prod-FieldDefinition +features: [class-methods-private, class-fields-private, class, class-fields-public, async-functions] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + ... + ; + + MethodDefinition : + ClassElementName ( UniqueFormalParameters ) { FunctionBody } + ... + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + async m() { return 42; } #$_; #__; #\u{6F}_; #\u2118_; #ZW_\u200C_NJ_; #ZW_\u200D_J_; + #$() { + return this.#$_; + } + #_() { + return this.#__; + } + #\u{6F}() { + return this.#\u{6F}_; + } + #\u2118() { + return this.#\u2118_; + } + #ZW_\u200C_NJ() { + return this.#ZW_\u200C_NJ_; + } + #ZW_\u200D_J() { + return this.#ZW_\u200D_J_; + } +; + $(value) { + this.#$_ = value; + return this.#$(); + } + _(value) { + this.#__ = value; + return this.#_(); + } + \u{6F}(value) { + this.#\u{6F}_ = value; + return this.#\u{6F}(); + } + \u2118(value) { + this.#\u2118_ = value; + return this.#\u2118(); + } + ZW_\u200C_NJ(value) { + this.#ZW_\u200C_NJ_ = value; + return this.#ZW_\u200C_NJ(); + } + ZW_\u200D_J(value) { + this.#ZW_\u200D_J_ = value; + return this.#ZW_\u200D_J(); + } + +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +c.m().then(function(v) { + assert.sameValue(v, 42); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert.sameValue(c.$(1), 1); + assert.sameValue(c._(1), 1); + assert.sameValue(c.\u{6F}(1), 1); + assert.sameValue(c.\u2118(1), 1); + assert.sameValue(c.ZW_\u200C_NJ(1), 1); + assert.sameValue(c.ZW_\u200D_J(1), 1); + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-async-method-rs-private-setter-alt.js b/js/src/tests/test262/language/statements/class/elements/same-line-async-method-rs-private-setter-alt.js new file mode 100644 index 0000000000..a832fc5cd3 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-async-method-rs-private-setter-alt.js @@ -0,0 +1,139 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-private-setter-alt.case +// - src/class-elements/productions/cls-decl-after-same-line-async-method.template +/*--- +description: Valid PrivateName as private setter (field definitions after an async method in the same line) +esid: prod-FieldDefinition +features: [class-methods-private, class-fields-private, class, class-fields-public, async-functions] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + ... + ; + + MethodDefinition : + ... + set ClassElementName ( PropertySetParameterList ) { FunctionBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + async m() { return 42; } #$_; #__; #\u{6F}_; #℘_; #ZW_‌_NJ_; #ZW_‍_J_; + set #$(value) { + this.#$_ = value; + } + set #_(value) { + this.#__ = value; + } + set #\u{6F}(value) { + this.#\u{6F}_ = value; + } + set #℘(value) { + this.#℘_ = value; + } + set #ZW_‌_NJ(value) { + this.#ZW_‌_NJ_ = value; + } + set #ZW_‍_J(value) { + this.#ZW_‍_J_ = value; + } +; + $(value) { + this.#$ = value; + return this.#$_; + } + _(value) { + this.#_ = value; + return this.#__; + } + \u{6F}(value) { + this.#\u{6F} = value; + return this.#\u{6F}_; + } + ℘(value) { + this.#℘ = value; + return this.#℘_; + } + ZW_‌_NJ(value) { + this.#ZW_‌_NJ = value; + return this.#ZW_‌_NJ_; + } + ZW_‍_J(value) { + this.#ZW_‍_J = value; + return this.#ZW_‍_J_; + } + +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +c.m().then(function(v) { + assert.sameValue(v, 42); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert.sameValue(c.$(1), 1); + assert.sameValue(c._(1), 1); + assert.sameValue(c.\u{6F}(1), 1); + assert.sameValue(c.℘(1), 1); + assert.sameValue(c.ZW_‌_NJ(1), 1); + assert.sameValue(c.ZW_‍_J(1), 1); + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-async-method-rs-private-setter.js b/js/src/tests/test262/language/statements/class/elements/same-line-async-method-rs-private-setter.js new file mode 100644 index 0000000000..d6915b0c31 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-async-method-rs-private-setter.js @@ -0,0 +1,139 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-private-setter.case +// - src/class-elements/productions/cls-decl-after-same-line-async-method.template +/*--- +description: Valid PrivateName as private setter (field definitions after an async method in the same line) +esid: prod-FieldDefinition +features: [class-methods-private, class-fields-private, class, class-fields-public, async-functions] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + ... + ; + + MethodDefinition : + ... + set ClassElementName ( PropertySetParameterList ) { FunctionBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + async m() { return 42; } #$_; #__; #\u{6F}_; #\u2118_; #ZW_\u200C_NJ_; #ZW_\u200D_J_; + set #$(value) { + this.#$_ = value; + } + set #_(value) { + this.#__ = value; + } + set #\u{6F}(value) { + this.#\u{6F}_ = value; + } + set #\u2118(value) { + this.#\u2118_ = value; + } + set #ZW_\u200C_NJ(value) { + this.#ZW_\u200C_NJ_ = value; + } + set #ZW_\u200D_J(value) { + this.#ZW_\u200D_J_ = value; + } +; + $(value) { + this.#$ = value; + return this.#$_; + } + _(value) { + this.#_ = value; + return this.#__; + } + \u{6F}(value) { + this.#\u{6F} = value; + return this.#\u{6F}_; + } + \u2118(value) { + this.#\u2118 = value; + return this.#\u2118_; + } + ZW_\u200C_NJ(value) { + this.#ZW_\u200C_NJ = value; + return this.#ZW_\u200C_NJ_; + } + ZW_\u200D_J(value) { + this.#ZW_\u200D_J = value; + return this.#ZW_\u200D_J_; + } + +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +c.m().then(function(v) { + assert.sameValue(v, 42); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert.sameValue(c.$(1), 1); + assert.sameValue(c._(1), 1); + assert.sameValue(c.\u{6F}(1), 1); + assert.sameValue(c.\u2118(1), 1); + assert.sameValue(c.ZW_\u200C_NJ(1), 1); + assert.sameValue(c.ZW_\u200D_J(1), 1); + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-async-method-rs-privatename-identifier-alt.js b/js/src/tests/test262/language/statements/class/elements/same-line-async-method-rs-privatename-identifier-alt.js new file mode 100644 index 0000000000..598efcb28a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-async-method-rs-privatename-identifier-alt.js @@ -0,0 +1,121 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-privatename-identifier-alt.case +// - src/class-elements/productions/cls-decl-after-same-line-async-method.template +/*--- +description: Valid PrivateName (field definitions after an async method in the same line) +esid: prod-FieldDefinition +features: [class-fields-private, class, class-fields-public, async-functions] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + async m() { return 42; } #$; #_; #\u{6F}; #℘; #ZW_‌_NJ; #ZW_‍_J; + $(value) { + this.#$ = value; + return this.#$; + } + _(value) { + this.#_ = value; + return this.#_; + } + \u{6F}(value) { + this.#\u{6F} = value; + return this.#\u{6F}; + } + ℘(value) { + this.#℘ = value; + return this.#℘; + } + ZW_‌_NJ(value) { + this.#ZW_‌_NJ = value; + return this.#ZW_‌_NJ; + } + ZW_‍_J(value) { + this.#ZW_‍_J = value; + return this.#ZW_‍_J; + } +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +c.m().then(function(v) { + assert.sameValue(v, 42); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert.sameValue(c.$(1), 1); + assert.sameValue(c._(1), 1); + assert.sameValue(c.\u{6F}(1), 1); + assert.sameValue(c.℘(1), 1); + assert.sameValue(c.ZW_‌_NJ(1), 1); + assert.sameValue(c.ZW_‍_J(1), 1); + + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-async-method-rs-privatename-identifier-initializer-alt.js b/js/src/tests/test262/language/statements/class/elements/same-line-async-method-rs-privatename-identifier-initializer-alt.js new file mode 100644 index 0000000000..31760905fa --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-async-method-rs-privatename-identifier-initializer-alt.js @@ -0,0 +1,115 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-privatename-identifier-initializer-alt.case +// - src/class-elements/productions/cls-decl-after-same-line-async-method.template +/*--- +description: Valid PrivateName (field definitions after an async method in the same line) +esid: prod-FieldDefinition +features: [class-fields-private, class, class-fields-public, async-functions] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + async m() { return 42; } #$ = 1; #_ = 1; #\u{6F} = 1; #℘ = 1; #ZW_‌_NJ = 1; #ZW_‍_J = 1; + $() { + return this.#$; + } + _() { + return this.#_; + } + \u{6F}() { + return this.#\u{6F}; + } + ℘() { + return this.#℘; + } + ZW_‌_NJ() { + return this.#ZW_‌_NJ; + } + ZW_‍_J() { + return this.#ZW_‍_J; + } +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +c.m().then(function(v) { + assert.sameValue(v, 42); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert.sameValue(c.$(), 1); + assert.sameValue(c._(), 1); + assert.sameValue(c.\u{6F}(), 1); + assert.sameValue(c.℘(), 1); + assert.sameValue(c.ZW_‌_NJ(), 1); + assert.sameValue(c.ZW_‍_J(), 1); + + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-async-method-rs-privatename-identifier-initializer.js b/js/src/tests/test262/language/statements/class/elements/same-line-async-method-rs-privatename-identifier-initializer.js new file mode 100644 index 0000000000..3de36353e8 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-async-method-rs-privatename-identifier-initializer.js @@ -0,0 +1,115 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-privatename-identifier-initializer.case +// - src/class-elements/productions/cls-decl-after-same-line-async-method.template +/*--- +description: Valid PrivateName (field definitions after an async method in the same line) +esid: prod-FieldDefinition +features: [class-fields-private, class, class-fields-public, async-functions] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + async m() { return 42; } #$ = 1; #_ = 1; #\u{6F} = 1; #\u2118 = 1; #ZW_\u200C_NJ = 1; #ZW_\u200D_J = 1; + $() { + return this.#$; + } + _() { + return this.#_; + } + \u{6F}() { + return this.#\u{6F}; + } + \u2118() { + return this.#\u2118; + } + ZW_\u200C_NJ() { + return this.#ZW_\u200C_NJ; + } + ZW_\u200D_J() { + return this.#ZW_\u200D_J; + } +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +c.m().then(function(v) { + assert.sameValue(v, 42); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert.sameValue(c.$(), 1); + assert.sameValue(c._(), 1); + assert.sameValue(c.\u{6F}(), 1); + assert.sameValue(c.\u2118(), 1); + assert.sameValue(c.ZW_\u200C_NJ(), 1); + assert.sameValue(c.ZW_\u200D_J(), 1); + + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-async-method-rs-privatename-identifier.js b/js/src/tests/test262/language/statements/class/elements/same-line-async-method-rs-privatename-identifier.js new file mode 100644 index 0000000000..f76b713628 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-async-method-rs-privatename-identifier.js @@ -0,0 +1,121 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-privatename-identifier.case +// - src/class-elements/productions/cls-decl-after-same-line-async-method.template +/*--- +description: Valid PrivateName (field definitions after an async method in the same line) +esid: prod-FieldDefinition +features: [class-fields-private, class, class-fields-public, async-functions] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + async m() { return 42; } #$; #_; #\u{6F}; #\u2118; #ZW_\u200C_NJ; #ZW_\u200D_J; + $(value) { + this.#$ = value; + return this.#$; + } + _(value) { + this.#_ = value; + return this.#_; + } + \u{6F}(value) { + this.#\u{6F} = value; + return this.#\u{6F}; + } + \u2118(value) { + this.#\u2118 = value; + return this.#\u2118; + } + ZW_\u200C_NJ(value) { + this.#ZW_\u200C_NJ = value; + return this.#ZW_\u200C_NJ; + } + ZW_\u200D_J(value) { + this.#ZW_\u200D_J = value; + return this.#ZW_\u200D_J; + } +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +c.m().then(function(v) { + assert.sameValue(v, 42); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert.sameValue(c.$(1), 1); + assert.sameValue(c._(1), 1); + assert.sameValue(c.\u{6F}(1), 1); + assert.sameValue(c.\u2118(1), 1); + assert.sameValue(c.ZW_\u200C_NJ(1), 1); + assert.sameValue(c.ZW_\u200D_J(1), 1); + + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-async-method-rs-static-async-generator-method-privatename-identifier-alt.js b/js/src/tests/test262/language/statements/class/elements/same-line-async-method-rs-static-async-generator-method-privatename-identifier-alt.js new file mode 100644 index 0000000000..27f480eabb --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-async-method-rs-static-async-generator-method-privatename-identifier-alt.js @@ -0,0 +1,147 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-async-generator-method-privatename-identifier-alt.case +// - src/class-elements/productions/cls-decl-after-same-line-async-method.template +/*--- +description: Valid Static AsyncGeneratorMethod PrivateName (field definitions after an async method in the same line) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public, async-functions] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + AsyncGeneratorMethod + + AsyncGeneratorMethod : + async [no LineTerminator here] * ClassElementName ( UniqueFormalParameters){ AsyncGeneratorBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + async m() { return 42; } static async * #$(value) { + yield * await value; + } + static async * #_(value) { + yield * await value; + } + static async * #o(value) { + yield * await value; + } + static async * #℘(value) { + yield * await value; + } + static async * #ZW_‌_NJ(value) { + yield * await value; + } + static async * #ZW_‍_J(value) { + yield * await value; + }; + static get $() { + return this.#$; + } + static get _() { + return this.#_; + } + static get o() { + return this.#o; + } + static get ℘() { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#℘; + } + static get ZW_‌_NJ() { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#ZW_‌_NJ; + } + static get ZW_‍_J() { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#ZW_‍_J; + } + +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +c.m().then(function(v) { + assert.sameValue(v, 42); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + Promise.all([ + C.$([1]).next(), + C._([1]).next(), + C.o([1]).next(), + C.℘([1]).next(), // DO NOT CHANGE THE NAME OF THIS FIELD + C.ZW_‌_NJ([1]).next(), // DO NOT CHANGE THE NAME OF THIS FIELD + C.ZW_‍_J([1]).next(), // DO NOT CHANGE THE NAME OF THIS FIELD + ]).then(results => { + + assert.sameValue(results[0].value, 1); + assert.sameValue(results[1].value, 1); + assert.sameValue(results[2].value, 1); + assert.sameValue(results[3].value, 1); + assert.sameValue(results[4].value, 1); + assert.sameValue(results[5].value, 1); + + }).then($DONE, $DONE); + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-async-method-rs-static-async-generator-method-privatename-identifier.js b/js/src/tests/test262/language/statements/class/elements/same-line-async-method-rs-static-async-generator-method-privatename-identifier.js new file mode 100644 index 0000000000..1c319cbca0 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-async-method-rs-static-async-generator-method-privatename-identifier.js @@ -0,0 +1,148 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-async-generator-method-privatename-identifier.case +// - src/class-elements/productions/cls-decl-after-same-line-async-method.template +/*--- +description: Valid Static AsyncGeneratorMethod PrivateName (field definitions after an async method in the same line) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public, async-functions] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + AsyncGeneratorMethod + + AsyncGeneratorMethod : + async [no LineTerminator here] * ClassElementName ( UniqueFormalParameters){ AsyncGeneratorBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + async m() { return 42; } static async * #$(value) { + yield * await value; + } + static async * #_(value) { + yield * await value; + } + static async * #\u{6F}(value) { + yield * await value; + } + static async * #\u2118(value) { + yield * await value; + } + static async * #ZW_\u200C_NJ(value) { + yield * await value; + } + static async * #ZW_\u200D_J(value) { + yield * await value; + }; + static get $() { + return this.#$; + } + static get _() { + return this.#_; + } + static get \u{6F}() { + return this.#\u{6F}; + } + static get \u2118() { + return this.#\u2118; + } + static get ZW_\u200C_NJ() { + return this.#ZW_\u200C_NJ; + } + static get ZW_\u200D_J() { + return this.#ZW_\u200D_J; + } + +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +c.m().then(function(v) { + assert.sameValue(v, 42); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + Promise.all([ + C.$([1]).next(), + C._([1]).next(), + C.\u{6F}([1]).next(), + C.\u2118([1]).next(), + C.ZW_\u200C_NJ([1]).next(), + C.ZW_\u200D_J([1]).next(), + ]).then(results => { + + assert.sameValue(results[0].value, 1); + assert.sameValue(results[1].value, 1); + assert.sameValue(results[2].value, 1); + assert.sameValue(results[3].value, 1); + assert.sameValue(results[4].value, 1); + assert.sameValue(results[5].value, 1); + + }).then($DONE, $DONE); + + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-async-method-rs-static-async-method-privatename-identifier-alt.js b/js/src/tests/test262/language/statements/class/elements/same-line-async-method-rs-static-async-method-privatename-identifier-alt.js new file mode 100644 index 0000000000..b7b7784982 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-async-method-rs-static-async-method-privatename-identifier-alt.js @@ -0,0 +1,147 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-async-method-privatename-identifier-alt.case +// - src/class-elements/productions/cls-decl-after-same-line-async-method.template +/*--- +description: Valid Static AsyncMethod PrivateName (field definitions after an async method in the same line) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public, async-functions] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + AsyncMethod + + AsyncMethod : + async [no LineTerminator here] ClassElementName ( UniqueFormalParameters ){ AsyncFunctionBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + async m() { return 42; } static async #$(value) { + return await value; + } + static async #_(value) { + return await value; + } + static async #o(value) { + return await value; + } + static async #℘(value) { + return await value; + } + static async #ZW_‌_NJ(value) { + return await value; + } + static async #ZW_‍_J(value) { + return await value; + }; + static async $(value) { + return await this.#$(value); + } + static async _(value) { + return await this.#_(value); + } + static async o(value) { + return await this.#o(value); + } + static async ℘(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + return await this.#℘(value); + } + static async ZW_‌_NJ(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + return await this.#ZW_‌_NJ(value); + } + static async ZW_‍_J(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + return await this.#ZW_‍_J(value); + } + +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +c.m().then(function(v) { + assert.sameValue(v, 42); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + Promise.all([ + C.$(1), + C._(1), + C.o(1), + C.℘(1), // DO NOT CHANGE THE NAME OF THIS FIELD + C.ZW_‌_NJ(1), // DO NOT CHANGE THE NAME OF THIS FIELD + C.ZW_‍_J(1), // DO NOT CHANGE THE NAME OF THIS FIELD + ]).then(results => { + + assert.sameValue(results[0], 1); + assert.sameValue(results[1], 1); + assert.sameValue(results[2], 1); + assert.sameValue(results[3], 1); + assert.sameValue(results[4], 1); + assert.sameValue(results[5], 1); + + }).then($DONE, $DONE); + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-async-method-rs-static-async-method-privatename-identifier.js b/js/src/tests/test262/language/statements/class/elements/same-line-async-method-rs-static-async-method-privatename-identifier.js new file mode 100644 index 0000000000..e960409e25 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-async-method-rs-static-async-method-privatename-identifier.js @@ -0,0 +1,148 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-async-method-privatename-identifier.case +// - src/class-elements/productions/cls-decl-after-same-line-async-method.template +/*--- +description: Valid Static AsyncMethod PrivateName (field definitions after an async method in the same line) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public, async-functions] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + AsyncMethod + + AsyncMethod : + async [no LineTerminator here] ClassElementName ( UniqueFormalParameters ){ AsyncFunctionBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + async m() { return 42; } static async #$(value) { + return await value; + } + static async #_(value) { + return await value; + } + static async #\u{6F}(value) { + return await value; + } + static async #\u2118(value) { + return await value; + } + static async #ZW_\u200C_NJ(value) { + return await value; + } + static async #ZW_\u200D_J(value) { + return await value; + }; + static async $(value) { + return await this.#$(value); + } + static async _(value) { + return await this.#_(value); + } + static async \u{6F}(value) { + return await this.#\u{6F}(value); + } + static async \u2118(value) { + return await this.#\u2118(value); + } + static async ZW_\u200C_NJ(value) { + return await this.#ZW_\u200C_NJ(value); + } + static async ZW_\u200D_J(value) { + return await this.#ZW_\u200D_J(value); + } + +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +c.m().then(function(v) { + assert.sameValue(v, 42); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + Promise.all([ + C.$(1), + C._(1), + C.\u{6F}(1), + C.\u2118(1), + C.ZW_\u200C_NJ(1), + C.ZW_\u200D_J(1), + ]).then(results => { + + assert.sameValue(results[0], 1); + assert.sameValue(results[1], 1); + assert.sameValue(results[2], 1); + assert.sameValue(results[3], 1); + assert.sameValue(results[4], 1); + assert.sameValue(results[5], 1); + + }).then($DONE, $DONE); + + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-async-method-rs-static-generator-method-privatename-identifier-alt.js b/js/src/tests/test262/language/statements/class/elements/same-line-async-method-rs-static-generator-method-privatename-identifier-alt.js new file mode 100644 index 0000000000..cf980b1e01 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-async-method-rs-static-generator-method-privatename-identifier-alt.js @@ -0,0 +1,136 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-generator-method-privatename-identifier-alt.case +// - src/class-elements/productions/cls-decl-after-same-line-async-method.template +/*--- +description: Valid Static GeneratorMethod PrivateName (field definitions after an async method in the same line) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public, async-functions] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + GeneratorMethod + + GeneratorMethod : + * ClassElementName ( UniqueFormalParameters ){ GeneratorBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + async m() { return 42; } static * #$(value) { + yield * value; + } + static * #_(value) { + yield * value; + } + static * #o(value) { + yield * value; + } + static * #℘(value) { + yield * value; + } + static * #ZW_‌_NJ(value) { + yield * value; + } + static * #ZW_‍_J(value) { + yield * value; + }; + static get $() { + return this.#$; + } + static get _() { + return this.#_; + } + static get o() { + return this.#o; + } + static get ℘() { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#℘; + } + static get ZW_‌_NJ() { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#ZW_‌_NJ; + } + static get ZW_‍_J() { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#ZW_‍_J; + } + +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +c.m().then(function(v) { + assert.sameValue(v, 42); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert.sameValue(C.$([1]).next().value, 1); + assert.sameValue(C._([1]).next().value, 1); + assert.sameValue(C.o([1]).next().value, 1); + assert.sameValue(C.℘([1]).next().value, 1); + assert.sameValue(C.ZW_‌_NJ([1]).next().value, 1); + assert.sameValue(C.ZW_‍_J([1]).next().value, 1); + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-async-method-rs-static-generator-method-privatename-identifier.js b/js/src/tests/test262/language/statements/class/elements/same-line-async-method-rs-static-generator-method-privatename-identifier.js new file mode 100644 index 0000000000..1ec439eb20 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-async-method-rs-static-generator-method-privatename-identifier.js @@ -0,0 +1,137 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-generator-method-privatename-identifier.case +// - src/class-elements/productions/cls-decl-after-same-line-async-method.template +/*--- +description: Valid Static GeneratorMethod PrivateName (field definitions after an async method in the same line) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public, async-functions] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + GeneratorMethod + + GeneratorMethod : + * ClassElementName ( UniqueFormalParameters ){ GeneratorBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + async m() { return 42; } static * #$(value) { + yield * value; + } + static * #_(value) { + yield * value; + } + static * #\u{6F}(value) { + yield * value; + } + static * #\u2118(value) { + yield * value; + } + static * #ZW_\u200C_NJ(value) { + yield * value; + } + static * #ZW_\u200D_J(value) { + yield * value; + }; + static get $() { + return this.#$; + } + static get _() { + return this.#_; + } + static get \u{6F}() { + return this.#\u{6F}; + } + static get \u2118() { + return this.#\u2118; + } + static get ZW_\u200C_NJ() { + return this.#ZW_\u200C_NJ; + } + static get ZW_\u200D_J() { + return this.#ZW_\u200D_J; + } + +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +c.m().then(function(v) { + assert.sameValue(v, 42); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert.sameValue(C.$([1]).next().value, 1); + assert.sameValue(C._([1]).next().value, 1); + assert.sameValue(C.\u{6F}([1]).next().value, 1); + assert.sameValue(C.\u2118([1]).next().value, 1); + assert.sameValue(C.ZW_\u200C_NJ([1]).next().value, 1); + assert.sameValue(C.ZW_\u200D_J([1]).next().value, 1); + + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-async-method-rs-static-method-privatename-identifier-alt.js b/js/src/tests/test262/language/statements/class/elements/same-line-async-method-rs-static-method-privatename-identifier-alt.js new file mode 100644 index 0000000000..a170bf16ce --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-async-method-rs-static-method-privatename-identifier-alt.js @@ -0,0 +1,134 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-method-privatename-identifier-alt.case +// - src/class-elements/productions/cls-decl-after-same-line-async-method.template +/*--- +description: Valid Static Method PrivateName (field definitions after an async method in the same line) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public, async-functions] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + ClassElementName ( UniqueFormalParameters ){ FunctionBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + async m() { return 42; } static #$(value) { + return value; + } + static #_(value) { + return value; + } + static #o(value) { + return value; + } + static #℘(value) { + return value; + } + static #ZW_‌_NJ(value) { + return value; + } + static #ZW_‍_J(value) { + return value; + }; + static $(value) { + return this.#$(value); + } + static _(value) { + return this.#_(value); + } + static o(value) { + return this.#o(value); + } + static ℘(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#℘(value); + } + static ZW_‌_NJ(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#ZW_‌_NJ(value); + } + static ZW_‍_J(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#ZW_‍_J(value); + } + +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +c.m().then(function(v) { + assert.sameValue(v, 42); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert.sameValue(C.$(1), 1); + assert.sameValue(C._(1), 1); + assert.sameValue(C.o(1), 1); + assert.sameValue(C.℘(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD + assert.sameValue(C.ZW_‌_NJ(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD + assert.sameValue(C.ZW_‍_J(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD + + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-async-method-rs-static-method-privatename-identifier.js b/js/src/tests/test262/language/statements/class/elements/same-line-async-method-rs-static-method-privatename-identifier.js new file mode 100644 index 0000000000..fa4edb8610 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-async-method-rs-static-method-privatename-identifier.js @@ -0,0 +1,134 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-method-privatename-identifier.case +// - src/class-elements/productions/cls-decl-after-same-line-async-method.template +/*--- +description: Valid Static Method PrivateName (field definitions after an async method in the same line) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public, async-functions] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + ClassElementName ( UniqueFormalParameters ){ FunctionBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + async m() { return 42; } static #$(value) { + return value; + } + static #_(value) { + return value; + } + static #\u{6F}(value) { + return value; + } + static #\u2118(value) { + return value; + } + static #ZW_\u200C_NJ(value) { + return value; + } + static #ZW_\u200D_J(value) { + return value; + }; + static $(value) { + return this.#$(value); + } + static _(value) { + return this.#_(value); + } + static \u{6F}(value) { + return this.#\u{6F}(value); + } + static \u2118(value) { + return this.#\u2118(value); + } + static ZW_\u200C_NJ(value) { + return this.#ZW_\u200C_NJ(value); + } + static ZW_\u200D_J(value) { + return this.#ZW_\u200D_J(value); + } + +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +c.m().then(function(v) { + assert.sameValue(v, 42); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert.sameValue(C.$(1), 1); + assert.sameValue(C._(1), 1); + assert.sameValue(C.\u{6F}(1), 1); + assert.sameValue(C.\u2118(1), 1); + assert.sameValue(C.ZW_\u200C_NJ(1), 1); + assert.sameValue(C.ZW_\u200D_J(1), 1); + + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-async-method-rs-static-privatename-identifier-alt-by-classname.js b/js/src/tests/test262/language/statements/class/elements/same-line-async-method-rs-static-privatename-identifier-alt-by-classname.js new file mode 100644 index 0000000000..dc5ef17df1 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-async-method-rs-static-privatename-identifier-alt-by-classname.js @@ -0,0 +1,122 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-privatename-identifier-alt-by-classname.case +// - src/class-elements/productions/cls-decl-after-same-line-async-method.template +/*--- +description: Valid Static PrivateName (field definitions after an async method in the same line) +esid: prod-FieldDefinition +features: [class-static-fields-private, class, class-fields-public, async-functions] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + async m() { return 42; } static #$; static #_; static #\u{6F}; static #℘; static #ZW_‌_NJ; static #ZW_‍_J; + static $(value) { + C.#$ = value; + return C.#$; + } + static _(value) { + C.#_ = value; + return C.#_; + } + static o(value) { + C.#\u{6F} = value; + return C.#\u{6F}; + } + static ℘(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + C.#℘ = value; + return C.#℘; + } + static ZW_‌_NJ(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + C.#ZW_‌_NJ = value; + return C.#ZW_‌_NJ; + } + static ZW_‍_J(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + C.#ZW_‍_J = value; + return C.#ZW_‍_J; + } +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +c.m().then(function(v) { + assert.sameValue(v, 42); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert.sameValue(C.$(1), 1); + assert.sameValue(C._(1), 1); + assert.sameValue(C.o(1), 1); + assert.sameValue(C.℘(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD + assert.sameValue(C.ZW_‌_NJ(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD + assert.sameValue(C.ZW_‍_J(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD + + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-async-method-rs-static-privatename-identifier-alt.js b/js/src/tests/test262/language/statements/class/elements/same-line-async-method-rs-static-privatename-identifier-alt.js new file mode 100644 index 0000000000..a1b13ded29 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-async-method-rs-static-privatename-identifier-alt.js @@ -0,0 +1,122 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-privatename-identifier-alt.case +// - src/class-elements/productions/cls-decl-after-same-line-async-method.template +/*--- +description: Valid Static PrivateName (field definitions after an async method in the same line) +esid: prod-FieldDefinition +features: [class-static-fields-private, class, class-fields-public, async-functions] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + async m() { return 42; } static #$; static #_; static #\u{6F}; static #℘; static #ZW_‌_NJ; static #ZW_‍_J; + static $(value) { + this.#$ = value; + return this.#$; + } + static _(value) { + this.#_ = value; + return this.#_; + } + static o(value) { + this.#\u{6F} = value; + return this.#\u{6F}; + } + static ℘(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + this.#℘ = value; + return this.#℘; + } + static ZW_‌_NJ(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + this.#ZW_‌_NJ = value; + return this.#ZW_‌_NJ; + } + static ZW_‍_J(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + this.#ZW_‍_J = value; + return this.#ZW_‍_J; + } +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +c.m().then(function(v) { + assert.sameValue(v, 42); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert.sameValue(C.$(1), 1); + assert.sameValue(C._(1), 1); + assert.sameValue(C.o(1), 1); + assert.sameValue(C.℘(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD + assert.sameValue(C.ZW_‌_NJ(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD + assert.sameValue(C.ZW_‍_J(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD + + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-async-method-rs-static-privatename-identifier-by-classname.js b/js/src/tests/test262/language/statements/class/elements/same-line-async-method-rs-static-privatename-identifier-by-classname.js new file mode 100644 index 0000000000..82513e2be7 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-async-method-rs-static-privatename-identifier-by-classname.js @@ -0,0 +1,122 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-privatename-identifier-by-classname.case +// - src/class-elements/productions/cls-decl-after-same-line-async-method.template +/*--- +description: Valid Static PrivateName (field definitions after an async method in the same line) +esid: prod-FieldDefinition +features: [class-static-fields-private, class, class-fields-public, async-functions] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + async m() { return 42; } static #$; static #_; static #\u{6F}; static #\u2118; static #ZW_\u200C_NJ; static #ZW_\u200D_J; + static $(value) { + C.#$ = value; + return C.#$; + } + static _(value) { + C.#_ = value; + return C.#_; + } + static \u{6F}(value) { + C.#\u{6F} = value; + return C.#\u{6F}; + } + static \u2118(value) { + C.#\u2118 = value; + return C.#\u2118; + } + static ZW_\u200C_NJ(value) { + C.#ZW_\u200C_NJ = value; + return C.#ZW_\u200C_NJ; + } + static ZW_\u200D_J(value) { + C.#ZW_\u200D_J = value; + return C.#ZW_\u200D_J; + } +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +c.m().then(function(v) { + assert.sameValue(v, 42); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert.sameValue(C.$(1), 1); + assert.sameValue(C._(1), 1); + assert.sameValue(C.\u{6F}(1), 1); + assert.sameValue(C.\u2118(1), 1); + assert.sameValue(C.ZW_\u200C_NJ(1), 1); + assert.sameValue(C.ZW_\u200D_J(1), 1); + + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-async-method-rs-static-privatename-identifier-initializer-alt-by-classname.js b/js/src/tests/test262/language/statements/class/elements/same-line-async-method-rs-static-privatename-identifier-initializer-alt-by-classname.js new file mode 100644 index 0000000000..046f6161b5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-async-method-rs-static-privatename-identifier-initializer-alt-by-classname.js @@ -0,0 +1,116 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-privatename-identifier-initializer-alt-by-classname.case +// - src/class-elements/productions/cls-decl-after-same-line-async-method.template +/*--- +description: Valid Static PrivateName (field definitions after an async method in the same line) +esid: prod-FieldDefinition +features: [class-static-fields-private, class, class-fields-public, async-functions] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + async m() { return 42; } static #$ = 1; static #_ = 1; static #\u{6F} = 1; static #℘ = 1; static #ZW_‌_NJ = 1; static #ZW_‍_J = 1; + static $() { + return C.#$; + } + static _() { + return C.#_; + } + static \u{6F}() { + return C.#\u{6F}; + } + static ℘() { + return C.#℘; + } + static ZW_‌_NJ() { + return C.#ZW_‌_NJ; + } + static ZW_‍_J() { + return C.#ZW_‍_J; + } +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +c.m().then(function(v) { + assert.sameValue(v, 42); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert.sameValue(C.$(), 1); + assert.sameValue(C._(), 1); + assert.sameValue(C.\u{6F}(), 1); + assert.sameValue(C.℘(), 1); + assert.sameValue(C.ZW_‌_NJ(), 1); + assert.sameValue(C.ZW_‍_J(), 1); + + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-async-method-rs-static-privatename-identifier-initializer-alt.js b/js/src/tests/test262/language/statements/class/elements/same-line-async-method-rs-static-privatename-identifier-initializer-alt.js new file mode 100644 index 0000000000..741d42cf4f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-async-method-rs-static-privatename-identifier-initializer-alt.js @@ -0,0 +1,116 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-privatename-identifier-initializer-alt.case +// - src/class-elements/productions/cls-decl-after-same-line-async-method.template +/*--- +description: Valid Static PrivateName (field definitions after an async method in the same line) +esid: prod-FieldDefinition +features: [class-static-fields-private, class, class-fields-public, async-functions] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + async m() { return 42; } static #$ = 1; static #_ = 1; static #\u{6F} = 1; static #℘ = 1; static #ZW_‌_NJ = 1; static #ZW_‍_J = 1; + static $() { + return this.#$; + } + static _() { + return this.#_; + } + static \u{6F}() { + return this.#\u{6F}; + } + static ℘() { + return this.#℘; + } + static ZW_‌_NJ() { + return this.#ZW_‌_NJ; + } + static ZW_‍_J() { + return this.#ZW_‍_J; + } +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +c.m().then(function(v) { + assert.sameValue(v, 42); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert.sameValue(C.$(), 1); + assert.sameValue(C._(), 1); + assert.sameValue(C.\u{6F}(), 1); + assert.sameValue(C.℘(), 1); + assert.sameValue(C.ZW_‌_NJ(), 1); + assert.sameValue(C.ZW_‍_J(), 1); + + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-async-method-rs-static-privatename-identifier-initializer.js b/js/src/tests/test262/language/statements/class/elements/same-line-async-method-rs-static-privatename-identifier-initializer.js new file mode 100644 index 0000000000..661d3c7f3e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-async-method-rs-static-privatename-identifier-initializer.js @@ -0,0 +1,116 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-privatename-identifier-initializer.case +// - src/class-elements/productions/cls-decl-after-same-line-async-method.template +/*--- +description: Valid Static PrivateName (field definitions after an async method in the same line) +esid: prod-FieldDefinition +features: [class-static-fields-private, class, class-fields-public, async-functions] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + async m() { return 42; } static #$ = 1; static #_ = 1; static #\u{6F} = 1; static #\u2118 = 1; static #ZW_\u200C_NJ = 1; static #ZW_\u200D_J = 1; + static $() { + return this.#$; + } + static _() { + return this.#_; + } + static \u{6F}() { + return this.#\u{6F}; + } + static \u2118() { + return this.#\u2118; + } + static ZW_\u200C_NJ() { + return this.#ZW_\u200C_NJ; + } + static ZW_\u200D_J() { + return this.#ZW_\u200D_J; + } +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +c.m().then(function(v) { + assert.sameValue(v, 42); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert.sameValue(C.$(), 1); + assert.sameValue(C._(), 1); + assert.sameValue(C.\u{6F}(), 1); + assert.sameValue(C.\u2118(), 1); + assert.sameValue(C.ZW_\u200C_NJ(), 1); + assert.sameValue(C.ZW_\u200D_J(), 1); + + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-async-method-rs-static-privatename-identifier.js b/js/src/tests/test262/language/statements/class/elements/same-line-async-method-rs-static-privatename-identifier.js new file mode 100644 index 0000000000..8e4d1e4cb4 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-async-method-rs-static-privatename-identifier.js @@ -0,0 +1,122 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-privatename-identifier.case +// - src/class-elements/productions/cls-decl-after-same-line-async-method.template +/*--- +description: Valid Static PrivateName (field definitions after an async method in the same line) +esid: prod-FieldDefinition +features: [class-static-fields-private, class, class-fields-public, async-functions] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + async m() { return 42; } static #$; static #_; static #\u{6F}; static #\u2118; static #ZW_\u200C_NJ; static #ZW_\u200D_J; + static $(value) { + this.#$ = value; + return this.#$; + } + static _(value) { + this.#_ = value; + return this.#_; + } + static \u{6F}(value) { + this.#\u{6F} = value; + return this.#\u{6F}; + } + static \u2118(value) { + this.#\u2118 = value; + return this.#\u2118; + } + static ZW_\u200C_NJ(value) { + this.#ZW_\u200C_NJ = value; + return this.#ZW_\u200C_NJ; + } + static ZW_\u200D_J(value) { + this.#ZW_\u200D_J = value; + return this.#ZW_\u200D_J; + } +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +c.m().then(function(v) { + assert.sameValue(v, 42); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert.sameValue(C.$(1), 1); + assert.sameValue(C._(1), 1); + assert.sameValue(C.\u{6F}(1), 1); + assert.sameValue(C.\u2118(1), 1); + assert.sameValue(C.ZW_\u200C_NJ(1), 1); + assert.sameValue(C.ZW_\u200D_J(1), 1); + + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-async-method-static-private-fields.js b/js/src/tests/test262/language/statements/class/elements/same-line-async-method-static-private-fields.js new file mode 100644 index 0000000000..6ae1baeb9d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-async-method-static-private-fields.js @@ -0,0 +1,83 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/static-private-fields.case +// - src/class-elements/productions/cls-decl-after-same-line-async-method.template +/*--- +description: static private fields (field definitions after an async method in the same line) +esid: prod-FieldDefinition +features: [class-static-fields-private, class, class-fields-public, async-functions] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + ... + static FieldDefinition ; + + FieldDefinition : + ClassElementName Initializer_opt + + ClassElementName : + PrivateName + + PrivateName : + # IdentifierName + +---*/ + + +class C { + async m() { return 42; } static #x; static #y; + static x() { + this.#x = 42; + return this.#x; + } + static y() { + this.#y = 43; + return this.#y; + } +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +c.m().then(function(v) { + assert.sameValue(v, 42); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + // Test the private fields do not appear as properties before set to value + assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#x"), "test 1"); + assert(!Object.prototype.hasOwnProperty.call(C, "#x"), "test 2"); + assert(!Object.prototype.hasOwnProperty.call(c, "#x"), "test 3"); + + assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#y"), "test 4"); + assert(!Object.prototype.hasOwnProperty.call(C, "#y"), "test 5"); + assert(!Object.prototype.hasOwnProperty.call(c, "#y"), "test 6"); + + // Test if private fields can be sucessfully accessed and set to value + assert.sameValue(C.x(), 42, "test 7"); + assert.sameValue(C.y(), 43, "test 8"); + + // Test the private fields do not appear as properties before after set to value + assert(!Object.prototype.hasOwnProperty.call(C, "#x"), "test 9"); + assert(!Object.prototype.hasOwnProperty.call(C, "#y"), "test 10"); + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-async-method-static-private-methods-with-fields.js b/js/src/tests/test262/language/statements/class/elements/same-line-async-method-static-private-methods-with-fields.js new file mode 100644 index 0000000000..91bd3fbf19 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-async-method-static-private-methods-with-fields.js @@ -0,0 +1,100 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/static-private-methods-with-fields.case +// - src/class-elements/productions/cls-decl-after-same-line-async-method.template +/*--- +description: static private methods with fields (field definitions after an async method in the same line) +esid: prod-FieldDefinition +features: [class-static-methods-private, class-static-fields-private, class, class-fields-public, async-functions] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + ... + static FieldDefinition ; + + FieldDefinition : + ClassElementName Initializer_opt + + ClassElementName : + PrivateName + + PrivateName : + # IdentifierName + +---*/ + + +class C { + async m() { return 42; } static #xVal; static #yVal; + static #x(value) { + this.#xVal = value; + return this.#xVal; + } + static #y(value) { + this.#yVal = value; + return this.#yVal; + } + static x() { + return this.#x(42); + } + static y() { + return this.#y(43); + } +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +c.m().then(function(v) { + assert.sameValue(v, 42); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + // Test the private methods do not appear as properties before set to value + assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#x"), "test 1"); + assert(!Object.prototype.hasOwnProperty.call(C, "#x"), "test 2"); + assert(!Object.prototype.hasOwnProperty.call(c, "#x"), "test 3"); + + assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#y"), "test 4"); + assert(!Object.prototype.hasOwnProperty.call(C, "#y"), "test 5"); + assert(!Object.prototype.hasOwnProperty.call(c, "#y"), "test 6"); + + assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#xVal"), "test 7"); + assert(!Object.prototype.hasOwnProperty.call(C, "#xVal"), "test 8"); + assert(!Object.prototype.hasOwnProperty.call(c, "#xVal"), "test 9"); + + assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#yVal"), "test 10"); + assert(!Object.prototype.hasOwnProperty.call(C, "#yVal"), "test 11"); + assert(!Object.prototype.hasOwnProperty.call(c, "#yVal"), "test 12"); + + // Test if private fields can be sucessfully accessed and set to value + assert.sameValue(C.x(), 42, "test 13"); + assert.sameValue(C.y(), 43, "test 14"); + + // Test the private fields do not appear as properties before after set to value + assert(!Object.prototype.hasOwnProperty.call(C, "#x"), "test 15"); + assert(!Object.prototype.hasOwnProperty.call(C, "#y"), "test 16"); + + assert(!Object.prototype.hasOwnProperty.call(C, "#xVal"), "test 17"); + assert(!Object.prototype.hasOwnProperty.call(C, "#yVal"), "test 18"); + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-async-method-static-private-methods.js b/js/src/tests/test262/language/statements/class/elements/same-line-async-method-static-private-methods.js new file mode 100644 index 0000000000..942d52a517 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-async-method-static-private-methods.js @@ -0,0 +1,87 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/static-private-methods.case +// - src/class-elements/productions/cls-decl-after-same-line-async-method.template +/*--- +description: static private methods (field definitions after an async method in the same line) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public, async-functions] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + ... + static FieldDefinition ; + + FieldDefinition : + ClassElementName Initializer_opt + + ClassElementName : + PrivateName + + PrivateName : + # IdentifierName + +---*/ + + +class C { + async m() { return 42; } ; + static #x(value) { + return value / 2; + } + static #y(value) { + return value * 2; + } + static x() { + return this.#x(84); + } + static y() { + return this.#y(43); + } +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +c.m().then(function(v) { + assert.sameValue(v, 42); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + // Test the private methods do not appear as properties before set to value + assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#x"), "test 1"); + assert(!Object.prototype.hasOwnProperty.call(C, "#x"), "test 2"); + assert(!Object.prototype.hasOwnProperty.call(c, "#x"), "test 3"); + + assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#y"), "test 4"); + assert(!Object.prototype.hasOwnProperty.call(C, "#y"), "test 5"); + assert(!Object.prototype.hasOwnProperty.call(c, "#y"), "test 6"); + + // Test if private fields can be sucessfully accessed and set to value + assert.sameValue(C.x(), 42, "test 7"); + assert.sameValue(C.y(), 86, "test 8"); + + // Test the private fields do not appear as properties before after set to value + assert(!Object.prototype.hasOwnProperty.call(C, "#x"), "test 9"); + assert(!Object.prototype.hasOwnProperty.call(C, "#y"), "test 10"); + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-async-method-string-literal-names.js b/js/src/tests/test262/language/statements/class/elements/same-line-async-method-string-literal-names.js new file mode 100644 index 0000000000..102f81d4b1 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-async-method-string-literal-names.js @@ -0,0 +1,121 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/string-literal-names.case +// - src/class-elements/productions/cls-decl-after-same-line-async-method.template +/*--- +description: String literal names (field definitions after an async method in the same line) +esid: prod-FieldDefinition +features: [class-fields-public, class, async-functions] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PropertyName + +---*/ + + +class C { + async m() { return 42; } 'a'; "b"; 'c' = 39; + "d" = 42; + +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +c.m().then(function(v) { + assert.sameValue(v, 42); + + function assertions() { + // Cover $DONE handler for async cases. + function $DONE(error) { + if (error) { + throw new Test262Error('Test262:AsyncTestFailure') + } + } + assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "a"), + "a does not appear as an own property on C prototype" + ); + assert( + !Object.prototype.hasOwnProperty.call(C, "a"), + "a does not appear as an own property on C constructor" + ); + + verifyProperty(c, "a", { + value: undefined, + enumerable: true, + writable: true, + configurable: true + }); + + assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "b"), + "b does not appear as an own property on C prototype" + ); + assert( + !Object.prototype.hasOwnProperty.call(C, "b"), + "b does not appear as an own property on C constructor" + ); + + verifyProperty(c, "b", { + value: undefined, + enumerable: true, + writable: true, + configurable: true + }); + + assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "c"), + "c does not appear as an own property on C prototype" + ); + assert( + !Object.prototype.hasOwnProperty.call(C, "c"), + "c does not appear as an own property on C constructor" + ); + + verifyProperty(c, "c", { + value: 39, + enumerable: true, + writable: true, + configurable: true + }); + + assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "d"), + "d does not appear as an own property on C prototype" + ); + assert( + !Object.prototype.hasOwnProperty.call(C, "d"), + "d does not appear as an own property on C constructor" + ); + + verifyProperty(c, "d", { + value: 42, + enumerable: true, + writable: true, + configurable: true + }); + } + + return Promise.resolve(assertions()); +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-gen-computed-names.js b/js/src/tests/test262/language/statements/class/elements/same-line-gen-computed-names.js new file mode 100644 index 0000000000..c6756902a5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-gen-computed-names.js @@ -0,0 +1,107 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/computed-names.case +// - src/class-elements/productions/cls-decl-same-line-generator.template +/*--- +description: Computed property names (field definitions followed by a generator method in the same line) +esid: prod-FieldDefinition +features: [class-fields-public, computed-property-names, class, generators] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PropertyName + +---*/ +var x = "b"; + + + +class C { + [x] = 42; [10] = "meep"; ["not initialized"]; *m() { return 42; } + +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "b"), + "b doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "b"), + "b doesn't appear as an own property on C constructor" +); + +verifyProperty(c, "b", { + value: 42, + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "x"), + "x doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "x"), + "x doesn't appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "x"), + "x doesn't appear as an own property on C instance" +); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "10"), + "10 doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "10"), + "10 doesn't appear as an own property on C constructor" +); + +verifyProperty(c, "10", { + value: "meep", + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "not initialized"), + "'not initialized' doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "not initialized"), + "'not initialized' doesn't appear as an own property on C constructor" +); + +verifyProperty(c, "not initialized", { + value: undefined, + enumerable: true, + writable: true, + configurable: true +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-gen-computed-symbol-names.js b/js/src/tests/test262/language/statements/class/elements/same-line-gen-computed-symbol-names.js new file mode 100644 index 0000000000..fd3271ada5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-gen-computed-symbol-names.js @@ -0,0 +1,105 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/computed-symbol-names.case +// - src/class-elements/productions/cls-decl-same-line-generator.template +/*--- +description: Computed property symbol names (field definitions followed by a generator method in the same line) +esid: prod-FieldDefinition +features: [class-fields-public, Symbol, computed-property-names, class, generators] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PropertyName + +---*/ +var x = Symbol(); +var y = Symbol(); + + + +class C { + [x]; [y] = 42; *m() { return 42; } + +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, x), + "Symbol x doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, x), + "Symbol x doesn't appear as an own property on C constructor" +); + +verifyProperty(c, x, { + value: undefined, + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, y), + "Symbol y doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, y), + "Symbol y doesn't appear as an own property on C constructor" +); + +verifyProperty(c, y, { + value: 42, + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "x"), + "x doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "x"), + "x doesn't appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "x"), + "x doesn't appear as an own property on C instance" +); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "y"), + "y doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "y"), + "y doesn't appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "y"), + "y doesn't appear as an own property on C instance" +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-gen-grammar-privatename-identifier-semantics-stringvalue.js b/js/src/tests/test262/language/statements/class/elements/same-line-gen-grammar-privatename-identifier-semantics-stringvalue.js new file mode 100644 index 0000000000..765b14e562 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-gen-grammar-privatename-identifier-semantics-stringvalue.js @@ -0,0 +1,109 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-privatename-identifier-semantics-stringvalue.case +// - src/class-elements/productions/cls-decl-same-line-generator.template +/*--- +description: PrivateName Static Semantics, StringValue (field definitions followed by a generator method in the same line) +esid: prod-FieldDefinition +features: [class-fields-private, class, class-fields-public, generators] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + + + 1. Return the String value consisting of the sequence of code + units corresponding to PrivateName. In determining the sequence + any occurrences of \ UnicodeEscapeSequence are first replaced + with the code point represented by the UnicodeEscapeSequence + and then the code points of the entire PrivateName are converted + to code units by UTF16Encoding (10.1.1) each code point. + +---*/ + + +class C { + #\u{6F}; + #\u2118; + #ZW_\u200C_NJ; + #ZW_\u200D_J;; *m() { return 42; } + o(value) { + this.#o = value; + return this.#o; + } + ℘(value) { + this.#℘ = value; + return this.#℘; + } + ZW_‌_NJ(value) { // DO NOT CHANGE THE NAME OF THIS METHOD + this.#ZW_‌_NJ = value; + return this.#ZW_‌_NJ; + } + ZW_‍_J(value) { // DO NOT CHANGE THE NAME OF THIS METHOD + this.#ZW_‍_J = value; + return this.#ZW_‍_J; + } +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.o(1), 1); +assert.sameValue(c.℘(1), 1); +assert.sameValue(c.ZW_‌_NJ(1), 1); +assert.sameValue(c.ZW_‍_J(1), 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-gen-literal-names-asi.js b/js/src/tests/test262/language/statements/class/elements/same-line-gen-literal-names-asi.js new file mode 100644 index 0000000000..1b44e6acd0 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-gen-literal-names-asi.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/literal-names-asi.case +// - src/class-elements/productions/cls-decl-same-line-generator.template +/*--- +description: Literal property names with ASI (field definitions followed by a generator method in the same line) +esid: prod-FieldDefinition +features: [class-fields-public, class, generators] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PropertyName + +---*/ + + +class C { + a + b = 42;; *m() { return 42; } + +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "a"), + "a doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "a"), + "a doesn't appear as an own property on C constructor" +); + +verifyProperty(c, "a", { + value: undefined, + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "b"), + "b doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "b"), + "b doesn't appear as an own property on C constructor" +); + +verifyProperty(c, "b", { + value: 42, + enumerable: true, + writable: true, + configurable: true +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-gen-literal-names.js b/js/src/tests/test262/language/statements/class/elements/same-line-gen-literal-names.js new file mode 100644 index 0000000000..690e9b4775 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-gen-literal-names.js @@ -0,0 +1,96 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/literal-names.case +// - src/class-elements/productions/cls-decl-same-line-generator.template +/*--- +description: Literal property names (field definitions followed by a generator method in the same line) +esid: prod-FieldDefinition +features: [class-fields-public, class, generators] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PropertyName + +---*/ +const fn = function() {} + + + +class C { + a; b = 42; + c = fn; *m() { return 42; } + +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "a"), + "a doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "a"), + "a doesn't appear as an own property on C constructor" +); + +verifyProperty(c, "a", { + value: undefined, + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "b"), + "b doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "b"), + "b doesn't appear as an own property on C constructor" +); + +verifyProperty(c, "b", { + value: 42, + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "c"), + "c doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "c"), + "c doesn't appear as an own property on C constructor" +); + +verifyProperty(c, "c", { + value: fn, + enumerable: true, + writable: true, + configurable: true +}); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-gen-private-field-usage.js b/js/src/tests/test262/language/statements/class/elements/same-line-gen-private-field-usage.js new file mode 100644 index 0000000000..e9c9b07277 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-gen-private-field-usage.js @@ -0,0 +1,49 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/private-field-usage.case +// - src/class-elements/productions/cls-decl-same-line-generator.template +/*--- +description: PrivateName CallExpression usage (private field) (field definitions followed by a generator method in the same line) +esid: prod-FieldDefinition +features: [class-fields-private, class, class-fields-public, generators] +flags: [generated] +includes: [propertyHelper.js] +info: | + Updated Productions + + CallExpression[Yield, Await]: + CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await] + SuperCall[?Yield, ?Await] + CallExpression[?Yield, ?Await]Arguments[?Yield, ?Await] + CallExpression[?Yield, ?Await][Expression[+In, ?Yield, ?Await]] + CallExpression[?Yield, ?Await].IdentifierName + CallExpression[?Yield, ?Await]TemplateLiteral[?Yield, ?Await] + CallExpression[?Yield, ?Await].PrivateName + +---*/ + + +class C { + #m = 'test262';; *m() { return 42; } + method() { + return this.#m; + } +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.method(), 'test262'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-gen-private-method-getter-usage.js b/js/src/tests/test262/language/statements/class/elements/same-line-gen-private-method-getter-usage.js new file mode 100644 index 0000000000..b4d9b582f2 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-gen-private-method-getter-usage.js @@ -0,0 +1,49 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/private-method-getter-usage.case +// - src/class-elements/productions/cls-decl-same-line-generator.template +/*--- +description: PrivateName CallExpression usage (Accesor get method) (field definitions followed by a generator method in the same line) +esid: prod-FieldDefinition +features: [class-methods-private, class, class-fields-public, generators] +flags: [generated] +includes: [propertyHelper.js] +info: | + Updated Productions + + CallExpression[Yield, Await]: + CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await] + SuperCall[?Yield, ?Await] + CallExpression[?Yield, ?Await]Arguments[?Yield, ?Await] + CallExpression[?Yield, ?Await][Expression[+In, ?Yield, ?Await]] + CallExpression[?Yield, ?Await].IdentifierName + CallExpression[?Yield, ?Await]TemplateLiteral[?Yield, ?Await] + CallExpression[?Yield, ?Await].PrivateName + +---*/ + + +class C { + get #m() { return 'test262'; }; *m() { return 42; } + method() { + return this.#m; + } +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.method(), 'test262'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-gen-private-method-usage.js b/js/src/tests/test262/language/statements/class/elements/same-line-gen-private-method-usage.js new file mode 100644 index 0000000000..29ff1bffb1 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-gen-private-method-usage.js @@ -0,0 +1,49 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/private-method-usage.case +// - src/class-elements/productions/cls-decl-same-line-generator.template +/*--- +description: PrivateName CallExpression usage (private method) (field definitions followed by a generator method in the same line) +esid: prod-FieldDefinition +features: [class-methods-private, class, class-fields-public, generators] +flags: [generated] +includes: [propertyHelper.js] +info: | + Updated Productions + + CallExpression[Yield, Await]: + CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await] + SuperCall[?Yield, ?Await] + CallExpression[?Yield, ?Await]Arguments[?Yield, ?Await] + CallExpression[?Yield, ?Await][Expression[+In, ?Yield, ?Await]] + CallExpression[?Yield, ?Await].IdentifierName + CallExpression[?Yield, ?Await]TemplateLiteral[?Yield, ?Await] + CallExpression[?Yield, ?Await].PrivateName + +---*/ + + +class C { + #m() { return 'test262'; }; *m() { return 42; } + method() { + return this.#m(); + } +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.method(), 'test262'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-gen-private-names.js b/js/src/tests/test262/language/statements/class/elements/same-line-gen-private-names.js new file mode 100644 index 0000000000..012a9b8507 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-gen-private-names.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/private-names.case +// - src/class-elements/productions/cls-decl-same-line-generator.template +/*--- +description: private names (field definitions followed by a generator method in the same line) +esid: prod-FieldDefinition +features: [class-fields-private, class, class-fields-public, generators] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + ... + FieldDefinition ; + + FieldDefinition : + ClassElementName Initializer_opt + + ClassElementName : + PrivateName + + PrivateName : + # IdentifierName + +---*/ + + +class C { + #x; #y; *m() { return 42; } + x() { + this.#x = 42; + return this.#x; + } + y() { + this.#y = 43; + return this.#y; + } +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +// Test the private fields do not appear as properties before set to value +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#x"), "test 1"); +assert(!Object.prototype.hasOwnProperty.call(C, "#x"), "test 2"); +assert(!Object.prototype.hasOwnProperty.call(c, "#x"), "test 3"); + +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#y"), "test 4"); +assert(!Object.prototype.hasOwnProperty.call(C, "#y"), "test 5"); +assert(!Object.prototype.hasOwnProperty.call(c, "#y"), "test 6"); + +// Test if private fields can be sucessfully accessed and set to value +assert.sameValue(c.x(), 42, "test 7"); +assert.sameValue(c.y(), 43, "test 8"); + +// Test the private fields do not appear as properties before after set to value +assert(!Object.prototype.hasOwnProperty.call(c, "#x"), "test 9"); +assert(!Object.prototype.hasOwnProperty.call(c, "#y"), "test 10"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-gen-rs-field-identifier-initializer.js b/js/src/tests/test262/language/statements/class/elements/same-line-gen-rs-field-identifier-initializer.js new file mode 100644 index 0000000000..73314ca1ed --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-gen-rs-field-identifier-initializer.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-field-identifier-initializer.case +// - src/class-elements/productions/cls-decl-same-line-generator.template +/*--- +description: Valid FieldDefinition (field definitions followed by a generator method in the same line) +esid: prod-FieldDefinition +features: [class-fields-public, class, generators] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + ... + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + + PropertyName : + LiteralPropertyName + ComputedPropertyName + + LiteralPropertyName : + IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + $ = 1; _ = 1; \u{6F} = 1; \u2118 = 1; ZW_\u200C_NJ = 1; ZW_\u200D_J = 1; *m() { return 42; } + +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.$, 1); +assert.sameValue(c._, 1); +assert.sameValue(c.\u{6F}, 1); +assert.sameValue(c.\u2118, 1); +assert.sameValue(c.ZW_\u200C_NJ, 1); +assert.sameValue(c.ZW_\u200D_J, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-gen-rs-field-identifier.js b/js/src/tests/test262/language/statements/class/elements/same-line-gen-rs-field-identifier.js new file mode 100644 index 0000000000..e718d9e508 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-gen-rs-field-identifier.js @@ -0,0 +1,94 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-field-identifier.case +// - src/class-elements/productions/cls-decl-same-line-generator.template +/*--- +description: Valid FieldDefinition (field definitions followed by a generator method in the same line) +esid: prod-FieldDefinition +features: [class-fields-public, class, generators] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + ... + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + + PropertyName : + LiteralPropertyName + ComputedPropertyName + + LiteralPropertyName : + IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + $; _; \u{6F}; \u2118; ZW_\u200C_NJ; ZW_\u200D_J; *m() { return 42; } + +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +c.$ = 1; +c._ = 1; +c.\u{6F} = 1; +c.\u2118 = 1; +c.ZW_\u200C_NJ = 1; +c.ZW_\u200D_J = 1; + +assert.sameValue(c.$, 1); +assert.sameValue(c._, 1); +assert.sameValue(c.\u{6F}, 1); +assert.sameValue(c.\u2118, 1); +assert.sameValue(c.ZW_\u200C_NJ, 1); +assert.sameValue(c.ZW_\u200D_J, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-gen-rs-private-getter-alt.js b/js/src/tests/test262/language/statements/class/elements/same-line-gen-rs-private-getter-alt.js new file mode 100644 index 0000000000..55096fe306 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-gen-rs-private-getter-alt.js @@ -0,0 +1,128 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-private-getter-alt.case +// - src/class-elements/productions/cls-decl-same-line-generator.template +/*--- +description: Valid PrivateName as private getter (field definitions followed by a generator method in the same line) +esid: prod-FieldDefinition +features: [class-methods-private, class-fields-private, class, class-fields-public, generators] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + ... + ; + + MethodDefinition : + ... + get ClassElementName ( ){ FunctionBody } + ... + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + #$_; #__; #\u{6F}_; #℘_; #ZW_‌_NJ_; #ZW_‍_J_; + get #$() { + return this.#$_; + } + get #_() { + return this.#__; + } + get #\u{6F}() { + return this.#\u{6F}_; + } + get #℘() { + return this.#℘_; + } + get #ZW_‌_NJ() { + return this.#ZW_‌_NJ_; + } + get #ZW_‍_J() { + return this.#ZW_‍_J_; + } +; *m() { return 42; } + $(value) { + this.#$_ = value; + return this.#$; + } + _(value) { + this.#__ = value; + return this.#_; + } + \u{6F}(value) { + this.#\u{6F}_ = value; + return this.#\u{6F}; + } + ℘(value) { + this.#℘_ = value; + return this.#℘; + } + ZW_‌_NJ(value) { + this.#ZW_‌_NJ_ = value; + return this.#ZW_‌_NJ; + } + ZW_‍_J(value) { + this.#ZW_‍_J_ = value; + return this.#ZW_‍_J; + } + +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.$(1), 1); +assert.sameValue(c._(1), 1); +assert.sameValue(c.\u{6F}(1), 1); +assert.sameValue(c.℘(1), 1); +assert.sameValue(c.ZW_‌_NJ(1), 1); +assert.sameValue(c.ZW_‍_J(1), 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-gen-rs-private-getter.js b/js/src/tests/test262/language/statements/class/elements/same-line-gen-rs-private-getter.js new file mode 100644 index 0000000000..80244ca087 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-gen-rs-private-getter.js @@ -0,0 +1,128 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-private-getter.case +// - src/class-elements/productions/cls-decl-same-line-generator.template +/*--- +description: Valid PrivateName as private getter (field definitions followed by a generator method in the same line) +esid: prod-FieldDefinition +features: [class-methods-private, class-fields-private, class, class-fields-public, generators] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + ... + ; + + MethodDefinition : + ... + get ClassElementName ( ){ FunctionBody } + ... + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + #$_; #__; #\u{6F}_; #\u2118_; #ZW_\u200C_NJ_; #ZW_\u200D_J_; + get #$() { + return this.#$_; + } + get #_() { + return this.#__; + } + get #\u{6F}() { + return this.#\u{6F}_; + } + get #\u2118() { + return this.#\u2118_; + } + get #ZW_\u200C_NJ() { + return this.#ZW_\u200C_NJ_; + } + get #ZW_\u200D_J() { + return this.#ZW_\u200D_J_; + } +; *m() { return 42; } + $(value) { + this.#$_ = value; + return this.#$; + } + _(value) { + this.#__ = value; + return this.#_; + } + \u{6F}(value) { + this.#\u{6F}_ = value; + return this.#\u{6F}; + } + \u2118(value) { + this.#\u2118_ = value; + return this.#\u2118; + } + ZW_\u200C_NJ(value) { + this.#ZW_\u200C_NJ_ = value; + return this.#ZW_\u200C_NJ; + } + ZW_\u200D_J(value) { + this.#ZW_\u200D_J_ = value; + return this.#ZW_\u200D_J; + } + +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.$(1), 1); +assert.sameValue(c._(1), 1); +assert.sameValue(c.\u{6F}(1), 1); +assert.sameValue(c.\u2118(1), 1); +assert.sameValue(c.ZW_\u200C_NJ(1), 1); +assert.sameValue(c.ZW_\u200D_J(1), 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-gen-rs-private-method-alt.js b/js/src/tests/test262/language/statements/class/elements/same-line-gen-rs-private-method-alt.js new file mode 100644 index 0000000000..8f4d65d8d5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-gen-rs-private-method-alt.js @@ -0,0 +1,127 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-private-method-alt.case +// - src/class-elements/productions/cls-decl-same-line-generator.template +/*--- +description: Valid PrivateName as private method (field definitions followed by a generator method in the same line) +esid: prod-FieldDefinition +features: [class-methods-private, class-fields-private, class, class-fields-public, generators] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + ... + ; + + MethodDefinition : + ClassElementName ( UniqueFormalParameters ) { FunctionBody } + ... + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + #$_; #__; #\u{6F}_; #℘_; #ZW_‌_NJ_; #ZW_‍_J_; + #$() { + return this.#$_; + } + #_() { + return this.#__; + } + #\u{6F}() { + return this.#\u{6F}_; + } + #℘() { + return this.#℘_; + } + #ZW_‌_NJ() { + return this.#ZW_‌_NJ_; + } + #ZW_‍_J() { + return this.#ZW_‍_J_; + } +; *m() { return 42; } + $(value) { + this.#$_ = value; + return this.#$(); + } + _(value) { + this.#__ = value; + return this.#_(); + } + \u{6F}(value) { + this.#\u{6F}_ = value; + return this.#\u{6F}(); + } + ℘(value) { + this.#℘_ = value; + return this.#℘(); + } + ZW_‌_NJ(value) { + this.#ZW_‌_NJ_ = value; + return this.#ZW_‌_NJ(); + } + ZW_‍_J(value) { + this.#ZW_‍_J_ = value; + return this.#ZW_‍_J(); + } + +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.$(1), 1); +assert.sameValue(c._(1), 1); +assert.sameValue(c.\u{6F}(1), 1); +assert.sameValue(c.℘(1), 1); +assert.sameValue(c.ZW_‌_NJ(1), 1); +assert.sameValue(c.ZW_‍_J(1), 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-gen-rs-private-method.js b/js/src/tests/test262/language/statements/class/elements/same-line-gen-rs-private-method.js new file mode 100644 index 0000000000..d81c4e3383 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-gen-rs-private-method.js @@ -0,0 +1,127 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-private-method.case +// - src/class-elements/productions/cls-decl-same-line-generator.template +/*--- +description: Valid PrivateName as private method (field definitions followed by a generator method in the same line) +esid: prod-FieldDefinition +features: [class-methods-private, class-fields-private, class, class-fields-public, generators] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + ... + ; + + MethodDefinition : + ClassElementName ( UniqueFormalParameters ) { FunctionBody } + ... + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + #$_; #__; #\u{6F}_; #\u2118_; #ZW_\u200C_NJ_; #ZW_\u200D_J_; + #$() { + return this.#$_; + } + #_() { + return this.#__; + } + #\u{6F}() { + return this.#\u{6F}_; + } + #\u2118() { + return this.#\u2118_; + } + #ZW_\u200C_NJ() { + return this.#ZW_\u200C_NJ_; + } + #ZW_\u200D_J() { + return this.#ZW_\u200D_J_; + } +; *m() { return 42; } + $(value) { + this.#$_ = value; + return this.#$(); + } + _(value) { + this.#__ = value; + return this.#_(); + } + \u{6F}(value) { + this.#\u{6F}_ = value; + return this.#\u{6F}(); + } + \u2118(value) { + this.#\u2118_ = value; + return this.#\u2118(); + } + ZW_\u200C_NJ(value) { + this.#ZW_\u200C_NJ_ = value; + return this.#ZW_\u200C_NJ(); + } + ZW_\u200D_J(value) { + this.#ZW_\u200D_J_ = value; + return this.#ZW_\u200D_J(); + } + +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.$(1), 1); +assert.sameValue(c._(1), 1); +assert.sameValue(c.\u{6F}(1), 1); +assert.sameValue(c.\u2118(1), 1); +assert.sameValue(c.ZW_\u200C_NJ(1), 1); +assert.sameValue(c.ZW_\u200D_J(1), 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-gen-rs-private-setter-alt.js b/js/src/tests/test262/language/statements/class/elements/same-line-gen-rs-private-setter-alt.js new file mode 100644 index 0000000000..a2b835d6ac --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-gen-rs-private-setter-alt.js @@ -0,0 +1,127 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-private-setter-alt.case +// - src/class-elements/productions/cls-decl-same-line-generator.template +/*--- +description: Valid PrivateName as private setter (field definitions followed by a generator method in the same line) +esid: prod-FieldDefinition +features: [class-methods-private, class-fields-private, class, class-fields-public, generators] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + ... + ; + + MethodDefinition : + ... + set ClassElementName ( PropertySetParameterList ) { FunctionBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + #$_; #__; #\u{6F}_; #℘_; #ZW_‌_NJ_; #ZW_‍_J_; + set #$(value) { + this.#$_ = value; + } + set #_(value) { + this.#__ = value; + } + set #\u{6F}(value) { + this.#\u{6F}_ = value; + } + set #℘(value) { + this.#℘_ = value; + } + set #ZW_‌_NJ(value) { + this.#ZW_‌_NJ_ = value; + } + set #ZW_‍_J(value) { + this.#ZW_‍_J_ = value; + } +; *m() { return 42; } + $(value) { + this.#$ = value; + return this.#$_; + } + _(value) { + this.#_ = value; + return this.#__; + } + \u{6F}(value) { + this.#\u{6F} = value; + return this.#\u{6F}_; + } + ℘(value) { + this.#℘ = value; + return this.#℘_; + } + ZW_‌_NJ(value) { + this.#ZW_‌_NJ = value; + return this.#ZW_‌_NJ_; + } + ZW_‍_J(value) { + this.#ZW_‍_J = value; + return this.#ZW_‍_J_; + } + +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.$(1), 1); +assert.sameValue(c._(1), 1); +assert.sameValue(c.\u{6F}(1), 1); +assert.sameValue(c.℘(1), 1); +assert.sameValue(c.ZW_‌_NJ(1), 1); +assert.sameValue(c.ZW_‍_J(1), 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-gen-rs-private-setter.js b/js/src/tests/test262/language/statements/class/elements/same-line-gen-rs-private-setter.js new file mode 100644 index 0000000000..f0a4e46f00 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-gen-rs-private-setter.js @@ -0,0 +1,127 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-private-setter.case +// - src/class-elements/productions/cls-decl-same-line-generator.template +/*--- +description: Valid PrivateName as private setter (field definitions followed by a generator method in the same line) +esid: prod-FieldDefinition +features: [class-methods-private, class-fields-private, class, class-fields-public, generators] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + ... + ; + + MethodDefinition : + ... + set ClassElementName ( PropertySetParameterList ) { FunctionBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + #$_; #__; #\u{6F}_; #\u2118_; #ZW_\u200C_NJ_; #ZW_\u200D_J_; + set #$(value) { + this.#$_ = value; + } + set #_(value) { + this.#__ = value; + } + set #\u{6F}(value) { + this.#\u{6F}_ = value; + } + set #\u2118(value) { + this.#\u2118_ = value; + } + set #ZW_\u200C_NJ(value) { + this.#ZW_\u200C_NJ_ = value; + } + set #ZW_\u200D_J(value) { + this.#ZW_\u200D_J_ = value; + } +; *m() { return 42; } + $(value) { + this.#$ = value; + return this.#$_; + } + _(value) { + this.#_ = value; + return this.#__; + } + \u{6F}(value) { + this.#\u{6F} = value; + return this.#\u{6F}_; + } + \u2118(value) { + this.#\u2118 = value; + return this.#\u2118_; + } + ZW_\u200C_NJ(value) { + this.#ZW_\u200C_NJ = value; + return this.#ZW_\u200C_NJ_; + } + ZW_\u200D_J(value) { + this.#ZW_\u200D_J = value; + return this.#ZW_\u200D_J_; + } + +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.$(1), 1); +assert.sameValue(c._(1), 1); +assert.sameValue(c.\u{6F}(1), 1); +assert.sameValue(c.\u2118(1), 1); +assert.sameValue(c.ZW_\u200C_NJ(1), 1); +assert.sameValue(c.ZW_\u200D_J(1), 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-gen-rs-privatename-identifier-alt.js b/js/src/tests/test262/language/statements/class/elements/same-line-gen-rs-privatename-identifier-alt.js new file mode 100644 index 0000000000..ca087b0399 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-gen-rs-privatename-identifier-alt.js @@ -0,0 +1,109 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-privatename-identifier-alt.case +// - src/class-elements/productions/cls-decl-same-line-generator.template +/*--- +description: Valid PrivateName (field definitions followed by a generator method in the same line) +esid: prod-FieldDefinition +features: [class-fields-private, class, class-fields-public, generators] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + #$; #_; #\u{6F}; #℘; #ZW_‌_NJ; #ZW_‍_J; *m() { return 42; } + $(value) { + this.#$ = value; + return this.#$; + } + _(value) { + this.#_ = value; + return this.#_; + } + \u{6F}(value) { + this.#\u{6F} = value; + return this.#\u{6F}; + } + ℘(value) { + this.#℘ = value; + return this.#℘; + } + ZW_‌_NJ(value) { + this.#ZW_‌_NJ = value; + return this.#ZW_‌_NJ; + } + ZW_‍_J(value) { + this.#ZW_‍_J = value; + return this.#ZW_‍_J; + } +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.$(1), 1); +assert.sameValue(c._(1), 1); +assert.sameValue(c.\u{6F}(1), 1); +assert.sameValue(c.℘(1), 1); +assert.sameValue(c.ZW_‌_NJ(1), 1); +assert.sameValue(c.ZW_‍_J(1), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-gen-rs-privatename-identifier-initializer-alt.js b/js/src/tests/test262/language/statements/class/elements/same-line-gen-rs-privatename-identifier-initializer-alt.js new file mode 100644 index 0000000000..f21f1a2e71 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-gen-rs-privatename-identifier-initializer-alt.js @@ -0,0 +1,103 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-privatename-identifier-initializer-alt.case +// - src/class-elements/productions/cls-decl-same-line-generator.template +/*--- +description: Valid PrivateName (field definitions followed by a generator method in the same line) +esid: prod-FieldDefinition +features: [class-fields-private, class, class-fields-public, generators] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + #$ = 1; #_ = 1; #\u{6F} = 1; #℘ = 1; #ZW_‌_NJ = 1; #ZW_‍_J = 1; *m() { return 42; } + $() { + return this.#$; + } + _() { + return this.#_; + } + \u{6F}() { + return this.#\u{6F}; + } + ℘() { + return this.#℘; + } + ZW_‌_NJ() { + return this.#ZW_‌_NJ; + } + ZW_‍_J() { + return this.#ZW_‍_J; + } +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.$(), 1); +assert.sameValue(c._(), 1); +assert.sameValue(c.\u{6F}(), 1); +assert.sameValue(c.℘(), 1); +assert.sameValue(c.ZW_‌_NJ(), 1); +assert.sameValue(c.ZW_‍_J(), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-gen-rs-privatename-identifier-initializer.js b/js/src/tests/test262/language/statements/class/elements/same-line-gen-rs-privatename-identifier-initializer.js new file mode 100644 index 0000000000..2ccadb6eae --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-gen-rs-privatename-identifier-initializer.js @@ -0,0 +1,103 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-privatename-identifier-initializer.case +// - src/class-elements/productions/cls-decl-same-line-generator.template +/*--- +description: Valid PrivateName (field definitions followed by a generator method in the same line) +esid: prod-FieldDefinition +features: [class-fields-private, class, class-fields-public, generators] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + #$ = 1; #_ = 1; #\u{6F} = 1; #\u2118 = 1; #ZW_\u200C_NJ = 1; #ZW_\u200D_J = 1; *m() { return 42; } + $() { + return this.#$; + } + _() { + return this.#_; + } + \u{6F}() { + return this.#\u{6F}; + } + \u2118() { + return this.#\u2118; + } + ZW_\u200C_NJ() { + return this.#ZW_\u200C_NJ; + } + ZW_\u200D_J() { + return this.#ZW_\u200D_J; + } +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.$(), 1); +assert.sameValue(c._(), 1); +assert.sameValue(c.\u{6F}(), 1); +assert.sameValue(c.\u2118(), 1); +assert.sameValue(c.ZW_\u200C_NJ(), 1); +assert.sameValue(c.ZW_\u200D_J(), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-gen-rs-privatename-identifier.js b/js/src/tests/test262/language/statements/class/elements/same-line-gen-rs-privatename-identifier.js new file mode 100644 index 0000000000..485a9bd34d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-gen-rs-privatename-identifier.js @@ -0,0 +1,109 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-privatename-identifier.case +// - src/class-elements/productions/cls-decl-same-line-generator.template +/*--- +description: Valid PrivateName (field definitions followed by a generator method in the same line) +esid: prod-FieldDefinition +features: [class-fields-private, class, class-fields-public, generators] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + #$; #_; #\u{6F}; #\u2118; #ZW_\u200C_NJ; #ZW_\u200D_J; *m() { return 42; } + $(value) { + this.#$ = value; + return this.#$; + } + _(value) { + this.#_ = value; + return this.#_; + } + \u{6F}(value) { + this.#\u{6F} = value; + return this.#\u{6F}; + } + \u2118(value) { + this.#\u2118 = value; + return this.#\u2118; + } + ZW_\u200C_NJ(value) { + this.#ZW_\u200C_NJ = value; + return this.#ZW_\u200C_NJ; + } + ZW_\u200D_J(value) { + this.#ZW_\u200D_J = value; + return this.#ZW_\u200D_J; + } +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.$(1), 1); +assert.sameValue(c._(1), 1); +assert.sameValue(c.\u{6F}(1), 1); +assert.sameValue(c.\u2118(1), 1); +assert.sameValue(c.ZW_\u200C_NJ(1), 1); +assert.sameValue(c.ZW_\u200D_J(1), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-gen-rs-static-async-generator-method-privatename-identifier-alt.js b/js/src/tests/test262/language/statements/class/elements/same-line-gen-rs-static-async-generator-method-privatename-identifier-alt.js new file mode 100644 index 0000000000..a6a8c640d1 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-gen-rs-static-async-generator-method-privatename-identifier-alt.js @@ -0,0 +1,134 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-async-generator-method-privatename-identifier-alt.case +// - src/class-elements/productions/cls-decl-same-line-generator.template +/*--- +description: Valid Static AsyncGeneratorMethod PrivateName (field definitions followed by a generator method in the same line) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public, generators] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + AsyncGeneratorMethod + + AsyncGeneratorMethod : + async [no LineTerminator here] * ClassElementName ( UniqueFormalParameters){ AsyncGeneratorBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static async * #$(value) { + yield * await value; + } + static async * #_(value) { + yield * await value; + } + static async * #o(value) { + yield * await value; + } + static async * #℘(value) { + yield * await value; + } + static async * #ZW_‌_NJ(value) { + yield * await value; + } + static async * #ZW_‍_J(value) { + yield * await value; + }; *m() { return 42; } + static get $() { + return this.#$; + } + static get _() { + return this.#_; + } + static get o() { + return this.#o; + } + static get ℘() { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#℘; + } + static get ZW_‌_NJ() { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#ZW_‌_NJ; + } + static get ZW_‍_J() { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#ZW_‍_J; + } + +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +Promise.all([ + C.$([1]).next(), + C._([1]).next(), + C.o([1]).next(), + C.℘([1]).next(), // DO NOT CHANGE THE NAME OF THIS FIELD + C.ZW_‌_NJ([1]).next(), // DO NOT CHANGE THE NAME OF THIS FIELD + C.ZW_‍_J([1]).next(), // DO NOT CHANGE THE NAME OF THIS FIELD +]).then(results => { + + assert.sameValue(results[0].value, 1); + assert.sameValue(results[1].value, 1); + assert.sameValue(results[2].value, 1); + assert.sameValue(results[3].value, 1); + assert.sameValue(results[4].value, 1); + assert.sameValue(results[5].value, 1); + +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-gen-rs-static-async-generator-method-privatename-identifier.js b/js/src/tests/test262/language/statements/class/elements/same-line-gen-rs-static-async-generator-method-privatename-identifier.js new file mode 100644 index 0000000000..fe03ce23f1 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-gen-rs-static-async-generator-method-privatename-identifier.js @@ -0,0 +1,135 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-async-generator-method-privatename-identifier.case +// - src/class-elements/productions/cls-decl-same-line-generator.template +/*--- +description: Valid Static AsyncGeneratorMethod PrivateName (field definitions followed by a generator method in the same line) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public, generators] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + AsyncGeneratorMethod + + AsyncGeneratorMethod : + async [no LineTerminator here] * ClassElementName ( UniqueFormalParameters){ AsyncGeneratorBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static async * #$(value) { + yield * await value; + } + static async * #_(value) { + yield * await value; + } + static async * #\u{6F}(value) { + yield * await value; + } + static async * #\u2118(value) { + yield * await value; + } + static async * #ZW_\u200C_NJ(value) { + yield * await value; + } + static async * #ZW_\u200D_J(value) { + yield * await value; + }; *m() { return 42; } + static get $() { + return this.#$; + } + static get _() { + return this.#_; + } + static get \u{6F}() { + return this.#\u{6F}; + } + static get \u2118() { + return this.#\u2118; + } + static get ZW_\u200C_NJ() { + return this.#ZW_\u200C_NJ; + } + static get ZW_\u200D_J() { + return this.#ZW_\u200D_J; + } + +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +Promise.all([ + C.$([1]).next(), + C._([1]).next(), + C.\u{6F}([1]).next(), + C.\u2118([1]).next(), + C.ZW_\u200C_NJ([1]).next(), + C.ZW_\u200D_J([1]).next(), +]).then(results => { + + assert.sameValue(results[0].value, 1); + assert.sameValue(results[1].value, 1); + assert.sameValue(results[2].value, 1); + assert.sameValue(results[3].value, 1); + assert.sameValue(results[4].value, 1); + assert.sameValue(results[5].value, 1); + +}).then($DONE, $DONE); + diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-gen-rs-static-async-method-privatename-identifier-alt.js b/js/src/tests/test262/language/statements/class/elements/same-line-gen-rs-static-async-method-privatename-identifier-alt.js new file mode 100644 index 0000000000..22b486db39 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-gen-rs-static-async-method-privatename-identifier-alt.js @@ -0,0 +1,134 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-async-method-privatename-identifier-alt.case +// - src/class-elements/productions/cls-decl-same-line-generator.template +/*--- +description: Valid Static AsyncMethod PrivateName (field definitions followed by a generator method in the same line) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public, generators] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + AsyncMethod + + AsyncMethod : + async [no LineTerminator here] ClassElementName ( UniqueFormalParameters ){ AsyncFunctionBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static async #$(value) { + return await value; + } + static async #_(value) { + return await value; + } + static async #o(value) { + return await value; + } + static async #℘(value) { + return await value; + } + static async #ZW_‌_NJ(value) { + return await value; + } + static async #ZW_‍_J(value) { + return await value; + }; *m() { return 42; } + static async $(value) { + return await this.#$(value); + } + static async _(value) { + return await this.#_(value); + } + static async o(value) { + return await this.#o(value); + } + static async ℘(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + return await this.#℘(value); + } + static async ZW_‌_NJ(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + return await this.#ZW_‌_NJ(value); + } + static async ZW_‍_J(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + return await this.#ZW_‍_J(value); + } + +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +Promise.all([ + C.$(1), + C._(1), + C.o(1), + C.℘(1), // DO NOT CHANGE THE NAME OF THIS FIELD + C.ZW_‌_NJ(1), // DO NOT CHANGE THE NAME OF THIS FIELD + C.ZW_‍_J(1), // DO NOT CHANGE THE NAME OF THIS FIELD +]).then(results => { + + assert.sameValue(results[0], 1); + assert.sameValue(results[1], 1); + assert.sameValue(results[2], 1); + assert.sameValue(results[3], 1); + assert.sameValue(results[4], 1); + assert.sameValue(results[5], 1); + +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-gen-rs-static-async-method-privatename-identifier.js b/js/src/tests/test262/language/statements/class/elements/same-line-gen-rs-static-async-method-privatename-identifier.js new file mode 100644 index 0000000000..3ef061db5d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-gen-rs-static-async-method-privatename-identifier.js @@ -0,0 +1,135 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-async-method-privatename-identifier.case +// - src/class-elements/productions/cls-decl-same-line-generator.template +/*--- +description: Valid Static AsyncMethod PrivateName (field definitions followed by a generator method in the same line) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public, generators] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + AsyncMethod + + AsyncMethod : + async [no LineTerminator here] ClassElementName ( UniqueFormalParameters ){ AsyncFunctionBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static async #$(value) { + return await value; + } + static async #_(value) { + return await value; + } + static async #\u{6F}(value) { + return await value; + } + static async #\u2118(value) { + return await value; + } + static async #ZW_\u200C_NJ(value) { + return await value; + } + static async #ZW_\u200D_J(value) { + return await value; + }; *m() { return 42; } + static async $(value) { + return await this.#$(value); + } + static async _(value) { + return await this.#_(value); + } + static async \u{6F}(value) { + return await this.#\u{6F}(value); + } + static async \u2118(value) { + return await this.#\u2118(value); + } + static async ZW_\u200C_NJ(value) { + return await this.#ZW_\u200C_NJ(value); + } + static async ZW_\u200D_J(value) { + return await this.#ZW_\u200D_J(value); + } + +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +Promise.all([ + C.$(1), + C._(1), + C.\u{6F}(1), + C.\u2118(1), + C.ZW_\u200C_NJ(1), + C.ZW_\u200D_J(1), +]).then(results => { + + assert.sameValue(results[0], 1); + assert.sameValue(results[1], 1); + assert.sameValue(results[2], 1); + assert.sameValue(results[3], 1); + assert.sameValue(results[4], 1); + assert.sameValue(results[5], 1); + +}).then($DONE, $DONE); + diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-gen-rs-static-generator-method-privatename-identifier-alt.js b/js/src/tests/test262/language/statements/class/elements/same-line-gen-rs-static-generator-method-privatename-identifier-alt.js new file mode 100644 index 0000000000..37181ecc10 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-gen-rs-static-generator-method-privatename-identifier-alt.js @@ -0,0 +1,124 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-generator-method-privatename-identifier-alt.case +// - src/class-elements/productions/cls-decl-same-line-generator.template +/*--- +description: Valid Static GeneratorMethod PrivateName (field definitions followed by a generator method in the same line) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public, generators] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + GeneratorMethod + + GeneratorMethod : + * ClassElementName ( UniqueFormalParameters ){ GeneratorBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static * #$(value) { + yield * value; + } + static * #_(value) { + yield * value; + } + static * #o(value) { + yield * value; + } + static * #℘(value) { + yield * value; + } + static * #ZW_‌_NJ(value) { + yield * value; + } + static * #ZW_‍_J(value) { + yield * value; + }; *m() { return 42; } + static get $() { + return this.#$; + } + static get _() { + return this.#_; + } + static get o() { + return this.#o; + } + static get ℘() { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#℘; + } + static get ZW_‌_NJ() { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#ZW_‌_NJ; + } + static get ZW_‍_J() { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#ZW_‍_J; + } + +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(C.$([1]).next().value, 1); +assert.sameValue(C._([1]).next().value, 1); +assert.sameValue(C.o([1]).next().value, 1); +assert.sameValue(C.℘([1]).next().value, 1); +assert.sameValue(C.ZW_‌_NJ([1]).next().value, 1); +assert.sameValue(C.ZW_‍_J([1]).next().value, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-gen-rs-static-generator-method-privatename-identifier.js b/js/src/tests/test262/language/statements/class/elements/same-line-gen-rs-static-generator-method-privatename-identifier.js new file mode 100644 index 0000000000..3630e7b33c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-gen-rs-static-generator-method-privatename-identifier.js @@ -0,0 +1,125 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-generator-method-privatename-identifier.case +// - src/class-elements/productions/cls-decl-same-line-generator.template +/*--- +description: Valid Static GeneratorMethod PrivateName (field definitions followed by a generator method in the same line) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public, generators] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + GeneratorMethod + + GeneratorMethod : + * ClassElementName ( UniqueFormalParameters ){ GeneratorBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static * #$(value) { + yield * value; + } + static * #_(value) { + yield * value; + } + static * #\u{6F}(value) { + yield * value; + } + static * #\u2118(value) { + yield * value; + } + static * #ZW_\u200C_NJ(value) { + yield * value; + } + static * #ZW_\u200D_J(value) { + yield * value; + }; *m() { return 42; } + static get $() { + return this.#$; + } + static get _() { + return this.#_; + } + static get \u{6F}() { + return this.#\u{6F}; + } + static get \u2118() { + return this.#\u2118; + } + static get ZW_\u200C_NJ() { + return this.#ZW_\u200C_NJ; + } + static get ZW_\u200D_J() { + return this.#ZW_\u200D_J; + } + +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(C.$([1]).next().value, 1); +assert.sameValue(C._([1]).next().value, 1); +assert.sameValue(C.\u{6F}([1]).next().value, 1); +assert.sameValue(C.\u2118([1]).next().value, 1); +assert.sameValue(C.ZW_\u200C_NJ([1]).next().value, 1); +assert.sameValue(C.ZW_\u200D_J([1]).next().value, 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-gen-rs-static-method-privatename-identifier-alt.js b/js/src/tests/test262/language/statements/class/elements/same-line-gen-rs-static-method-privatename-identifier-alt.js new file mode 100644 index 0000000000..b6f7007c88 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-gen-rs-static-method-privatename-identifier-alt.js @@ -0,0 +1,122 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-method-privatename-identifier-alt.case +// - src/class-elements/productions/cls-decl-same-line-generator.template +/*--- +description: Valid Static Method PrivateName (field definitions followed by a generator method in the same line) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public, generators] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + ClassElementName ( UniqueFormalParameters ){ FunctionBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static #$(value) { + return value; + } + static #_(value) { + return value; + } + static #o(value) { + return value; + } + static #℘(value) { + return value; + } + static #ZW_‌_NJ(value) { + return value; + } + static #ZW_‍_J(value) { + return value; + }; *m() { return 42; } + static $(value) { + return this.#$(value); + } + static _(value) { + return this.#_(value); + } + static o(value) { + return this.#o(value); + } + static ℘(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#℘(value); + } + static ZW_‌_NJ(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#ZW_‌_NJ(value); + } + static ZW_‍_J(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#ZW_‍_J(value); + } + +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(C.$(1), 1); +assert.sameValue(C._(1), 1); +assert.sameValue(C.o(1), 1); +assert.sameValue(C.℘(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD +assert.sameValue(C.ZW_‌_NJ(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD +assert.sameValue(C.ZW_‍_J(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-gen-rs-static-method-privatename-identifier.js b/js/src/tests/test262/language/statements/class/elements/same-line-gen-rs-static-method-privatename-identifier.js new file mode 100644 index 0000000000..ce032fa68c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-gen-rs-static-method-privatename-identifier.js @@ -0,0 +1,122 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-method-privatename-identifier.case +// - src/class-elements/productions/cls-decl-same-line-generator.template +/*--- +description: Valid Static Method PrivateName (field definitions followed by a generator method in the same line) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public, generators] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + ClassElementName ( UniqueFormalParameters ){ FunctionBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static #$(value) { + return value; + } + static #_(value) { + return value; + } + static #\u{6F}(value) { + return value; + } + static #\u2118(value) { + return value; + } + static #ZW_\u200C_NJ(value) { + return value; + } + static #ZW_\u200D_J(value) { + return value; + }; *m() { return 42; } + static $(value) { + return this.#$(value); + } + static _(value) { + return this.#_(value); + } + static \u{6F}(value) { + return this.#\u{6F}(value); + } + static \u2118(value) { + return this.#\u2118(value); + } + static ZW_\u200C_NJ(value) { + return this.#ZW_\u200C_NJ(value); + } + static ZW_\u200D_J(value) { + return this.#ZW_\u200D_J(value); + } + +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(C.$(1), 1); +assert.sameValue(C._(1), 1); +assert.sameValue(C.\u{6F}(1), 1); +assert.sameValue(C.\u2118(1), 1); +assert.sameValue(C.ZW_\u200C_NJ(1), 1); +assert.sameValue(C.ZW_\u200D_J(1), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-gen-rs-static-privatename-identifier-alt-by-classname.js b/js/src/tests/test262/language/statements/class/elements/same-line-gen-rs-static-privatename-identifier-alt-by-classname.js new file mode 100644 index 0000000000..836a203e5c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-gen-rs-static-privatename-identifier-alt-by-classname.js @@ -0,0 +1,110 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-privatename-identifier-alt-by-classname.case +// - src/class-elements/productions/cls-decl-same-line-generator.template +/*--- +description: Valid Static PrivateName (field definitions followed by a generator method in the same line) +esid: prod-FieldDefinition +features: [class-static-fields-private, class, class-fields-public, generators] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static #$; static #_; static #\u{6F}; static #℘; static #ZW_‌_NJ; static #ZW_‍_J; *m() { return 42; } + static $(value) { + C.#$ = value; + return C.#$; + } + static _(value) { + C.#_ = value; + return C.#_; + } + static o(value) { + C.#\u{6F} = value; + return C.#\u{6F}; + } + static ℘(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + C.#℘ = value; + return C.#℘; + } + static ZW_‌_NJ(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + C.#ZW_‌_NJ = value; + return C.#ZW_‌_NJ; + } + static ZW_‍_J(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + C.#ZW_‍_J = value; + return C.#ZW_‍_J; + } +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(C.$(1), 1); +assert.sameValue(C._(1), 1); +assert.sameValue(C.o(1), 1); +assert.sameValue(C.℘(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD +assert.sameValue(C.ZW_‌_NJ(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD +assert.sameValue(C.ZW_‍_J(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-gen-rs-static-privatename-identifier-alt.js b/js/src/tests/test262/language/statements/class/elements/same-line-gen-rs-static-privatename-identifier-alt.js new file mode 100644 index 0000000000..dd7f2c74ba --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-gen-rs-static-privatename-identifier-alt.js @@ -0,0 +1,110 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-privatename-identifier-alt.case +// - src/class-elements/productions/cls-decl-same-line-generator.template +/*--- +description: Valid Static PrivateName (field definitions followed by a generator method in the same line) +esid: prod-FieldDefinition +features: [class-static-fields-private, class, class-fields-public, generators] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static #$; static #_; static #\u{6F}; static #℘; static #ZW_‌_NJ; static #ZW_‍_J; *m() { return 42; } + static $(value) { + this.#$ = value; + return this.#$; + } + static _(value) { + this.#_ = value; + return this.#_; + } + static o(value) { + this.#\u{6F} = value; + return this.#\u{6F}; + } + static ℘(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + this.#℘ = value; + return this.#℘; + } + static ZW_‌_NJ(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + this.#ZW_‌_NJ = value; + return this.#ZW_‌_NJ; + } + static ZW_‍_J(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + this.#ZW_‍_J = value; + return this.#ZW_‍_J; + } +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(C.$(1), 1); +assert.sameValue(C._(1), 1); +assert.sameValue(C.o(1), 1); +assert.sameValue(C.℘(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD +assert.sameValue(C.ZW_‌_NJ(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD +assert.sameValue(C.ZW_‍_J(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-gen-rs-static-privatename-identifier-by-classname.js b/js/src/tests/test262/language/statements/class/elements/same-line-gen-rs-static-privatename-identifier-by-classname.js new file mode 100644 index 0000000000..f99a1b1503 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-gen-rs-static-privatename-identifier-by-classname.js @@ -0,0 +1,110 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-privatename-identifier-by-classname.case +// - src/class-elements/productions/cls-decl-same-line-generator.template +/*--- +description: Valid Static PrivateName (field definitions followed by a generator method in the same line) +esid: prod-FieldDefinition +features: [class-static-fields-private, class, class-fields-public, generators] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static #$; static #_; static #\u{6F}; static #\u2118; static #ZW_\u200C_NJ; static #ZW_\u200D_J; *m() { return 42; } + static $(value) { + C.#$ = value; + return C.#$; + } + static _(value) { + C.#_ = value; + return C.#_; + } + static \u{6F}(value) { + C.#\u{6F} = value; + return C.#\u{6F}; + } + static \u2118(value) { + C.#\u2118 = value; + return C.#\u2118; + } + static ZW_\u200C_NJ(value) { + C.#ZW_\u200C_NJ = value; + return C.#ZW_\u200C_NJ; + } + static ZW_\u200D_J(value) { + C.#ZW_\u200D_J = value; + return C.#ZW_\u200D_J; + } +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(C.$(1), 1); +assert.sameValue(C._(1), 1); +assert.sameValue(C.\u{6F}(1), 1); +assert.sameValue(C.\u2118(1), 1); +assert.sameValue(C.ZW_\u200C_NJ(1), 1); +assert.sameValue(C.ZW_\u200D_J(1), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-gen-rs-static-privatename-identifier-initializer-alt-by-classname.js b/js/src/tests/test262/language/statements/class/elements/same-line-gen-rs-static-privatename-identifier-initializer-alt-by-classname.js new file mode 100644 index 0000000000..43ade49028 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-gen-rs-static-privatename-identifier-initializer-alt-by-classname.js @@ -0,0 +1,104 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-privatename-identifier-initializer-alt-by-classname.case +// - src/class-elements/productions/cls-decl-same-line-generator.template +/*--- +description: Valid Static PrivateName (field definitions followed by a generator method in the same line) +esid: prod-FieldDefinition +features: [class-static-fields-private, class, class-fields-public, generators] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static #$ = 1; static #_ = 1; static #\u{6F} = 1; static #℘ = 1; static #ZW_‌_NJ = 1; static #ZW_‍_J = 1; *m() { return 42; } + static $() { + return C.#$; + } + static _() { + return C.#_; + } + static \u{6F}() { + return C.#\u{6F}; + } + static ℘() { + return C.#℘; + } + static ZW_‌_NJ() { + return C.#ZW_‌_NJ; + } + static ZW_‍_J() { + return C.#ZW_‍_J; + } +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(C.$(), 1); +assert.sameValue(C._(), 1); +assert.sameValue(C.\u{6F}(), 1); +assert.sameValue(C.℘(), 1); +assert.sameValue(C.ZW_‌_NJ(), 1); +assert.sameValue(C.ZW_‍_J(), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-gen-rs-static-privatename-identifier-initializer-alt.js b/js/src/tests/test262/language/statements/class/elements/same-line-gen-rs-static-privatename-identifier-initializer-alt.js new file mode 100644 index 0000000000..473ea08121 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-gen-rs-static-privatename-identifier-initializer-alt.js @@ -0,0 +1,104 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-privatename-identifier-initializer-alt.case +// - src/class-elements/productions/cls-decl-same-line-generator.template +/*--- +description: Valid Static PrivateName (field definitions followed by a generator method in the same line) +esid: prod-FieldDefinition +features: [class-static-fields-private, class, class-fields-public, generators] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static #$ = 1; static #_ = 1; static #\u{6F} = 1; static #℘ = 1; static #ZW_‌_NJ = 1; static #ZW_‍_J = 1; *m() { return 42; } + static $() { + return this.#$; + } + static _() { + return this.#_; + } + static \u{6F}() { + return this.#\u{6F}; + } + static ℘() { + return this.#℘; + } + static ZW_‌_NJ() { + return this.#ZW_‌_NJ; + } + static ZW_‍_J() { + return this.#ZW_‍_J; + } +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(C.$(), 1); +assert.sameValue(C._(), 1); +assert.sameValue(C.\u{6F}(), 1); +assert.sameValue(C.℘(), 1); +assert.sameValue(C.ZW_‌_NJ(), 1); +assert.sameValue(C.ZW_‍_J(), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-gen-rs-static-privatename-identifier-initializer.js b/js/src/tests/test262/language/statements/class/elements/same-line-gen-rs-static-privatename-identifier-initializer.js new file mode 100644 index 0000000000..734395af36 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-gen-rs-static-privatename-identifier-initializer.js @@ -0,0 +1,104 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-privatename-identifier-initializer.case +// - src/class-elements/productions/cls-decl-same-line-generator.template +/*--- +description: Valid Static PrivateName (field definitions followed by a generator method in the same line) +esid: prod-FieldDefinition +features: [class-static-fields-private, class, class-fields-public, generators] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static #$ = 1; static #_ = 1; static #\u{6F} = 1; static #\u2118 = 1; static #ZW_\u200C_NJ = 1; static #ZW_\u200D_J = 1; *m() { return 42; } + static $() { + return this.#$; + } + static _() { + return this.#_; + } + static \u{6F}() { + return this.#\u{6F}; + } + static \u2118() { + return this.#\u2118; + } + static ZW_\u200C_NJ() { + return this.#ZW_\u200C_NJ; + } + static ZW_\u200D_J() { + return this.#ZW_\u200D_J; + } +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(C.$(), 1); +assert.sameValue(C._(), 1); +assert.sameValue(C.\u{6F}(), 1); +assert.sameValue(C.\u2118(), 1); +assert.sameValue(C.ZW_\u200C_NJ(), 1); +assert.sameValue(C.ZW_\u200D_J(), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-gen-rs-static-privatename-identifier.js b/js/src/tests/test262/language/statements/class/elements/same-line-gen-rs-static-privatename-identifier.js new file mode 100644 index 0000000000..3903cb11b4 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-gen-rs-static-privatename-identifier.js @@ -0,0 +1,110 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-privatename-identifier.case +// - src/class-elements/productions/cls-decl-same-line-generator.template +/*--- +description: Valid Static PrivateName (field definitions followed by a generator method in the same line) +esid: prod-FieldDefinition +features: [class-static-fields-private, class, class-fields-public, generators] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static #$; static #_; static #\u{6F}; static #\u2118; static #ZW_\u200C_NJ; static #ZW_\u200D_J; *m() { return 42; } + static $(value) { + this.#$ = value; + return this.#$; + } + static _(value) { + this.#_ = value; + return this.#_; + } + static \u{6F}(value) { + this.#\u{6F} = value; + return this.#\u{6F}; + } + static \u2118(value) { + this.#\u2118 = value; + return this.#\u2118; + } + static ZW_\u200C_NJ(value) { + this.#ZW_\u200C_NJ = value; + return this.#ZW_\u200C_NJ; + } + static ZW_\u200D_J(value) { + this.#ZW_\u200D_J = value; + return this.#ZW_\u200D_J; + } +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(C.$(1), 1); +assert.sameValue(C._(1), 1); +assert.sameValue(C.\u{6F}(1), 1); +assert.sameValue(C.\u2118(1), 1); +assert.sameValue(C.ZW_\u200C_NJ(1), 1); +assert.sameValue(C.ZW_\u200D_J(1), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-gen-static-private-fields.js b/js/src/tests/test262/language/statements/class/elements/same-line-gen-static-private-fields.js new file mode 100644 index 0000000000..8c27b417ab --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-gen-static-private-fields.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/static-private-fields.case +// - src/class-elements/productions/cls-decl-same-line-generator.template +/*--- +description: static private fields (field definitions followed by a generator method in the same line) +esid: prod-FieldDefinition +features: [class-static-fields-private, class, class-fields-public, generators] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + ... + static FieldDefinition ; + + FieldDefinition : + ClassElementName Initializer_opt + + ClassElementName : + PrivateName + + PrivateName : + # IdentifierName + +---*/ + + +class C { + static #x; static #y; *m() { return 42; } + static x() { + this.#x = 42; + return this.#x; + } + static y() { + this.#y = 43; + return this.#y; + } +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +// Test the private fields do not appear as properties before set to value +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#x"), "test 1"); +assert(!Object.prototype.hasOwnProperty.call(C, "#x"), "test 2"); +assert(!Object.prototype.hasOwnProperty.call(c, "#x"), "test 3"); + +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#y"), "test 4"); +assert(!Object.prototype.hasOwnProperty.call(C, "#y"), "test 5"); +assert(!Object.prototype.hasOwnProperty.call(c, "#y"), "test 6"); + +// Test if private fields can be sucessfully accessed and set to value +assert.sameValue(C.x(), 42, "test 7"); +assert.sameValue(C.y(), 43, "test 8"); + +// Test the private fields do not appear as properties before after set to value +assert(!Object.prototype.hasOwnProperty.call(C, "#x"), "test 9"); +assert(!Object.prototype.hasOwnProperty.call(C, "#y"), "test 10"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-gen-static-private-methods-with-fields.js b/js/src/tests/test262/language/statements/class/elements/same-line-gen-static-private-methods-with-fields.js new file mode 100644 index 0000000000..fa0c3345e5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-gen-static-private-methods-with-fields.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/static-private-methods-with-fields.case +// - src/class-elements/productions/cls-decl-same-line-generator.template +/*--- +description: static private methods with fields (field definitions followed by a generator method in the same line) +esid: prod-FieldDefinition +features: [class-static-methods-private, class-static-fields-private, class, class-fields-public, generators] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + ... + static FieldDefinition ; + + FieldDefinition : + ClassElementName Initializer_opt + + ClassElementName : + PrivateName + + PrivateName : + # IdentifierName + +---*/ + + +class C { + static #xVal; static #yVal; *m() { return 42; } + static #x(value) { + this.#xVal = value; + return this.#xVal; + } + static #y(value) { + this.#yVal = value; + return this.#yVal; + } + static x() { + return this.#x(42); + } + static y() { + return this.#y(43); + } +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +// Test the private methods do not appear as properties before set to value +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#x"), "test 1"); +assert(!Object.prototype.hasOwnProperty.call(C, "#x"), "test 2"); +assert(!Object.prototype.hasOwnProperty.call(c, "#x"), "test 3"); + +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#y"), "test 4"); +assert(!Object.prototype.hasOwnProperty.call(C, "#y"), "test 5"); +assert(!Object.prototype.hasOwnProperty.call(c, "#y"), "test 6"); + +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#xVal"), "test 7"); +assert(!Object.prototype.hasOwnProperty.call(C, "#xVal"), "test 8"); +assert(!Object.prototype.hasOwnProperty.call(c, "#xVal"), "test 9"); + +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#yVal"), "test 10"); +assert(!Object.prototype.hasOwnProperty.call(C, "#yVal"), "test 11"); +assert(!Object.prototype.hasOwnProperty.call(c, "#yVal"), "test 12"); + +// Test if private fields can be sucessfully accessed and set to value +assert.sameValue(C.x(), 42, "test 13"); +assert.sameValue(C.y(), 43, "test 14"); + +// Test the private fields do not appear as properties before after set to value +assert(!Object.prototype.hasOwnProperty.call(C, "#x"), "test 15"); +assert(!Object.prototype.hasOwnProperty.call(C, "#y"), "test 16"); + +assert(!Object.prototype.hasOwnProperty.call(C, "#xVal"), "test 17"); +assert(!Object.prototype.hasOwnProperty.call(C, "#yVal"), "test 18"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-gen-static-private-methods.js b/js/src/tests/test262/language/statements/class/elements/same-line-gen-static-private-methods.js new file mode 100644 index 0000000000..9a54e8a48f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-gen-static-private-methods.js @@ -0,0 +1,75 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/static-private-methods.case +// - src/class-elements/productions/cls-decl-same-line-generator.template +/*--- +description: static private methods (field definitions followed by a generator method in the same line) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public, generators] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + ... + static FieldDefinition ; + + FieldDefinition : + ClassElementName Initializer_opt + + ClassElementName : + PrivateName + + PrivateName : + # IdentifierName + +---*/ + + +class C { + ; *m() { return 42; } + static #x(value) { + return value / 2; + } + static #y(value) { + return value * 2; + } + static x() { + return this.#x(84); + } + static y() { + return this.#y(43); + } +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +// Test the private methods do not appear as properties before set to value +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#x"), "test 1"); +assert(!Object.prototype.hasOwnProperty.call(C, "#x"), "test 2"); +assert(!Object.prototype.hasOwnProperty.call(c, "#x"), "test 3"); + +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#y"), "test 4"); +assert(!Object.prototype.hasOwnProperty.call(C, "#y"), "test 5"); +assert(!Object.prototype.hasOwnProperty.call(c, "#y"), "test 6"); + +// Test if private fields can be sucessfully accessed and set to value +assert.sameValue(C.x(), 42, "test 7"); +assert.sameValue(C.y(), 86, "test 8"); + +// Test the private fields do not appear as properties before after set to value +assert(!Object.prototype.hasOwnProperty.call(C, "#x"), "test 9"); +assert(!Object.prototype.hasOwnProperty.call(C, "#y"), "test 10"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-gen-string-literal-names.js b/js/src/tests/test262/language/statements/class/elements/same-line-gen-string-literal-names.js new file mode 100644 index 0000000000..6735a3a627 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-gen-string-literal-names.js @@ -0,0 +1,109 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/string-literal-names.case +// - src/class-elements/productions/cls-decl-same-line-generator.template +/*--- +description: String literal names (field definitions followed by a generator method in the same line) +esid: prod-FieldDefinition +features: [class-fields-public, class, generators] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PropertyName + +---*/ + + +class C { + 'a'; "b"; 'c' = 39; + "d" = 42; *m() { return 42; } + +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "a"), + "a does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "a"), + "a does not appear as an own property on C constructor" +); + +verifyProperty(c, "a", { + value: undefined, + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "b"), + "b does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "b"), + "b does not appear as an own property on C constructor" +); + +verifyProperty(c, "b", { + value: undefined, + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "c"), + "c does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "c"), + "c does not appear as an own property on C constructor" +); + +verifyProperty(c, "c", { + value: 39, + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "d"), + "d does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "d"), + "d does not appear as an own property on C constructor" +); + +verifyProperty(c, "d", { + value: 42, + enumerable: true, + writable: true, + configurable: true +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-method-computed-names.js b/js/src/tests/test262/language/statements/class/elements/same-line-method-computed-names.js new file mode 100644 index 0000000000..d2e624c169 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-method-computed-names.js @@ -0,0 +1,107 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/computed-names.case +// - src/class-elements/productions/cls-decl-same-line-method.template +/*--- +description: Computed property names (field definitions followed by a method in the same line) +esid: prod-FieldDefinition +features: [class-fields-public, computed-property-names, class] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PropertyName + +---*/ +var x = "b"; + + + +class C { + [x] = 42; [10] = "meep"; ["not initialized"]; m() { return 42; } + +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "b"), + "b doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "b"), + "b doesn't appear as an own property on C constructor" +); + +verifyProperty(c, "b", { + value: 42, + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "x"), + "x doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "x"), + "x doesn't appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "x"), + "x doesn't appear as an own property on C instance" +); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "10"), + "10 doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "10"), + "10 doesn't appear as an own property on C constructor" +); + +verifyProperty(c, "10", { + value: "meep", + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "not initialized"), + "'not initialized' doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "not initialized"), + "'not initialized' doesn't appear as an own property on C constructor" +); + +verifyProperty(c, "not initialized", { + value: undefined, + enumerable: true, + writable: true, + configurable: true +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-method-computed-symbol-names.js b/js/src/tests/test262/language/statements/class/elements/same-line-method-computed-symbol-names.js new file mode 100644 index 0000000000..60f11abfc5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-method-computed-symbol-names.js @@ -0,0 +1,105 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/computed-symbol-names.case +// - src/class-elements/productions/cls-decl-same-line-method.template +/*--- +description: Computed property symbol names (field definitions followed by a method in the same line) +esid: prod-FieldDefinition +features: [class-fields-public, Symbol, computed-property-names, class] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PropertyName + +---*/ +var x = Symbol(); +var y = Symbol(); + + + +class C { + [x]; [y] = 42; m() { return 42; } + +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, x), + "Symbol x doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, x), + "Symbol x doesn't appear as an own property on C constructor" +); + +verifyProperty(c, x, { + value: undefined, + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, y), + "Symbol y doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, y), + "Symbol y doesn't appear as an own property on C constructor" +); + +verifyProperty(c, y, { + value: 42, + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "x"), + "x doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "x"), + "x doesn't appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "x"), + "x doesn't appear as an own property on C instance" +); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "y"), + "y doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "y"), + "y doesn't appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "y"), + "y doesn't appear as an own property on C instance" +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-method-grammar-privatename-identifier-semantics-stringvalue.js b/js/src/tests/test262/language/statements/class/elements/same-line-method-grammar-privatename-identifier-semantics-stringvalue.js new file mode 100644 index 0000000000..4a6e3dc26a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-method-grammar-privatename-identifier-semantics-stringvalue.js @@ -0,0 +1,109 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-privatename-identifier-semantics-stringvalue.case +// - src/class-elements/productions/cls-decl-same-line-method.template +/*--- +description: PrivateName Static Semantics, StringValue (field definitions followed by a method in the same line) +esid: prod-FieldDefinition +features: [class-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + + + 1. Return the String value consisting of the sequence of code + units corresponding to PrivateName. In determining the sequence + any occurrences of \ UnicodeEscapeSequence are first replaced + with the code point represented by the UnicodeEscapeSequence + and then the code points of the entire PrivateName are converted + to code units by UTF16Encoding (10.1.1) each code point. + +---*/ + + +class C { + #\u{6F}; + #\u2118; + #ZW_\u200C_NJ; + #ZW_\u200D_J;; m() { return 42; } + o(value) { + this.#o = value; + return this.#o; + } + ℘(value) { + this.#℘ = value; + return this.#℘; + } + ZW_‌_NJ(value) { // DO NOT CHANGE THE NAME OF THIS METHOD + this.#ZW_‌_NJ = value; + return this.#ZW_‌_NJ; + } + ZW_‍_J(value) { // DO NOT CHANGE THE NAME OF THIS METHOD + this.#ZW_‍_J = value; + return this.#ZW_‍_J; + } +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.o(1), 1); +assert.sameValue(c.℘(1), 1); +assert.sameValue(c.ZW_‌_NJ(1), 1); +assert.sameValue(c.ZW_‍_J(1), 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-method-literal-names-asi.js b/js/src/tests/test262/language/statements/class/elements/same-line-method-literal-names-asi.js new file mode 100644 index 0000000000..86b5cabe86 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-method-literal-names-asi.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/literal-names-asi.case +// - src/class-elements/productions/cls-decl-same-line-method.template +/*--- +description: Literal property names with ASI (field definitions followed by a method in the same line) +esid: prod-FieldDefinition +features: [class-fields-public, class] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PropertyName + +---*/ + + +class C { + a + b = 42;; m() { return 42; } + +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "a"), + "a doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "a"), + "a doesn't appear as an own property on C constructor" +); + +verifyProperty(c, "a", { + value: undefined, + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "b"), + "b doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "b"), + "b doesn't appear as an own property on C constructor" +); + +verifyProperty(c, "b", { + value: 42, + enumerable: true, + writable: true, + configurable: true +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-method-literal-names.js b/js/src/tests/test262/language/statements/class/elements/same-line-method-literal-names.js new file mode 100644 index 0000000000..ffad35e421 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-method-literal-names.js @@ -0,0 +1,96 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/literal-names.case +// - src/class-elements/productions/cls-decl-same-line-method.template +/*--- +description: Literal property names (field definitions followed by a method in the same line) +esid: prod-FieldDefinition +features: [class-fields-public, class] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PropertyName + +---*/ +const fn = function() {} + + + +class C { + a; b = 42; + c = fn; m() { return 42; } + +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "a"), + "a doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "a"), + "a doesn't appear as an own property on C constructor" +); + +verifyProperty(c, "a", { + value: undefined, + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "b"), + "b doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "b"), + "b doesn't appear as an own property on C constructor" +); + +verifyProperty(c, "b", { + value: 42, + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "c"), + "c doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "c"), + "c doesn't appear as an own property on C constructor" +); + +verifyProperty(c, "c", { + value: fn, + enumerable: true, + writable: true, + configurable: true +}); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-method-private-field-usage.js b/js/src/tests/test262/language/statements/class/elements/same-line-method-private-field-usage.js new file mode 100644 index 0000000000..e41e34de6c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-method-private-field-usage.js @@ -0,0 +1,49 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/private-field-usage.case +// - src/class-elements/productions/cls-decl-same-line-method.template +/*--- +description: PrivateName CallExpression usage (private field) (field definitions followed by a method in the same line) +esid: prod-FieldDefinition +features: [class-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + Updated Productions + + CallExpression[Yield, Await]: + CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await] + SuperCall[?Yield, ?Await] + CallExpression[?Yield, ?Await]Arguments[?Yield, ?Await] + CallExpression[?Yield, ?Await][Expression[+In, ?Yield, ?Await]] + CallExpression[?Yield, ?Await].IdentifierName + CallExpression[?Yield, ?Await]TemplateLiteral[?Yield, ?Await] + CallExpression[?Yield, ?Await].PrivateName + +---*/ + + +class C { + #m = 'test262';; m() { return 42; } + method() { + return this.#m; + } +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.method(), 'test262'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-method-private-method-getter-usage.js b/js/src/tests/test262/language/statements/class/elements/same-line-method-private-method-getter-usage.js new file mode 100644 index 0000000000..fcc4466573 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-method-private-method-getter-usage.js @@ -0,0 +1,49 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/private-method-getter-usage.case +// - src/class-elements/productions/cls-decl-same-line-method.template +/*--- +description: PrivateName CallExpression usage (Accesor get method) (field definitions followed by a method in the same line) +esid: prod-FieldDefinition +features: [class-methods-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + Updated Productions + + CallExpression[Yield, Await]: + CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await] + SuperCall[?Yield, ?Await] + CallExpression[?Yield, ?Await]Arguments[?Yield, ?Await] + CallExpression[?Yield, ?Await][Expression[+In, ?Yield, ?Await]] + CallExpression[?Yield, ?Await].IdentifierName + CallExpression[?Yield, ?Await]TemplateLiteral[?Yield, ?Await] + CallExpression[?Yield, ?Await].PrivateName + +---*/ + + +class C { + get #m() { return 'test262'; }; m() { return 42; } + method() { + return this.#m; + } +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.method(), 'test262'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-method-private-method-usage.js b/js/src/tests/test262/language/statements/class/elements/same-line-method-private-method-usage.js new file mode 100644 index 0000000000..03ec6f24e2 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-method-private-method-usage.js @@ -0,0 +1,49 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/private-method-usage.case +// - src/class-elements/productions/cls-decl-same-line-method.template +/*--- +description: PrivateName CallExpression usage (private method) (field definitions followed by a method in the same line) +esid: prod-FieldDefinition +features: [class-methods-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + Updated Productions + + CallExpression[Yield, Await]: + CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await] + SuperCall[?Yield, ?Await] + CallExpression[?Yield, ?Await]Arguments[?Yield, ?Await] + CallExpression[?Yield, ?Await][Expression[+In, ?Yield, ?Await]] + CallExpression[?Yield, ?Await].IdentifierName + CallExpression[?Yield, ?Await]TemplateLiteral[?Yield, ?Await] + CallExpression[?Yield, ?Await].PrivateName + +---*/ + + +class C { + #m() { return 'test262'; }; m() { return 42; } + method() { + return this.#m(); + } +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.method(), 'test262'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-method-private-names.js b/js/src/tests/test262/language/statements/class/elements/same-line-method-private-names.js new file mode 100644 index 0000000000..0977dfbdd1 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-method-private-names.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/private-names.case +// - src/class-elements/productions/cls-decl-same-line-method.template +/*--- +description: private names (field definitions followed by a method in the same line) +esid: prod-FieldDefinition +features: [class-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + ... + FieldDefinition ; + + FieldDefinition : + ClassElementName Initializer_opt + + ClassElementName : + PrivateName + + PrivateName : + # IdentifierName + +---*/ + + +class C { + #x; #y; m() { return 42; } + x() { + this.#x = 42; + return this.#x; + } + y() { + this.#y = 43; + return this.#y; + } +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +// Test the private fields do not appear as properties before set to value +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#x"), "test 1"); +assert(!Object.prototype.hasOwnProperty.call(C, "#x"), "test 2"); +assert(!Object.prototype.hasOwnProperty.call(c, "#x"), "test 3"); + +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#y"), "test 4"); +assert(!Object.prototype.hasOwnProperty.call(C, "#y"), "test 5"); +assert(!Object.prototype.hasOwnProperty.call(c, "#y"), "test 6"); + +// Test if private fields can be sucessfully accessed and set to value +assert.sameValue(c.x(), 42, "test 7"); +assert.sameValue(c.y(), 43, "test 8"); + +// Test the private fields do not appear as properties before after set to value +assert(!Object.prototype.hasOwnProperty.call(c, "#x"), "test 9"); +assert(!Object.prototype.hasOwnProperty.call(c, "#y"), "test 10"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-method-rs-field-identifier-initializer.js b/js/src/tests/test262/language/statements/class/elements/same-line-method-rs-field-identifier-initializer.js new file mode 100644 index 0000000000..4a14ab6d0e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-method-rs-field-identifier-initializer.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-field-identifier-initializer.case +// - src/class-elements/productions/cls-decl-same-line-method.template +/*--- +description: Valid FieldDefinition (field definitions followed by a method in the same line) +esid: prod-FieldDefinition +features: [class-fields-public, class] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + ... + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + + PropertyName : + LiteralPropertyName + ComputedPropertyName + + LiteralPropertyName : + IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + $ = 1; _ = 1; \u{6F} = 1; \u2118 = 1; ZW_\u200C_NJ = 1; ZW_\u200D_J = 1; m() { return 42; } + +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.$, 1); +assert.sameValue(c._, 1); +assert.sameValue(c.\u{6F}, 1); +assert.sameValue(c.\u2118, 1); +assert.sameValue(c.ZW_\u200C_NJ, 1); +assert.sameValue(c.ZW_\u200D_J, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-method-rs-field-identifier.js b/js/src/tests/test262/language/statements/class/elements/same-line-method-rs-field-identifier.js new file mode 100644 index 0000000000..2261cbc387 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-method-rs-field-identifier.js @@ -0,0 +1,94 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-field-identifier.case +// - src/class-elements/productions/cls-decl-same-line-method.template +/*--- +description: Valid FieldDefinition (field definitions followed by a method in the same line) +esid: prod-FieldDefinition +features: [class-fields-public, class] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + ... + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + + PropertyName : + LiteralPropertyName + ComputedPropertyName + + LiteralPropertyName : + IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + $; _; \u{6F}; \u2118; ZW_\u200C_NJ; ZW_\u200D_J; m() { return 42; } + +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +c.$ = 1; +c._ = 1; +c.\u{6F} = 1; +c.\u2118 = 1; +c.ZW_\u200C_NJ = 1; +c.ZW_\u200D_J = 1; + +assert.sameValue(c.$, 1); +assert.sameValue(c._, 1); +assert.sameValue(c.\u{6F}, 1); +assert.sameValue(c.\u2118, 1); +assert.sameValue(c.ZW_\u200C_NJ, 1); +assert.sameValue(c.ZW_\u200D_J, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-method-rs-private-getter-alt.js b/js/src/tests/test262/language/statements/class/elements/same-line-method-rs-private-getter-alt.js new file mode 100644 index 0000000000..5d5831486a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-method-rs-private-getter-alt.js @@ -0,0 +1,128 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-private-getter-alt.case +// - src/class-elements/productions/cls-decl-same-line-method.template +/*--- +description: Valid PrivateName as private getter (field definitions followed by a method in the same line) +esid: prod-FieldDefinition +features: [class-methods-private, class-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + ... + ; + + MethodDefinition : + ... + get ClassElementName ( ){ FunctionBody } + ... + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + #$_; #__; #\u{6F}_; #℘_; #ZW_‌_NJ_; #ZW_‍_J_; + get #$() { + return this.#$_; + } + get #_() { + return this.#__; + } + get #\u{6F}() { + return this.#\u{6F}_; + } + get #℘() { + return this.#℘_; + } + get #ZW_‌_NJ() { + return this.#ZW_‌_NJ_; + } + get #ZW_‍_J() { + return this.#ZW_‍_J_; + } +; m() { return 42; } + $(value) { + this.#$_ = value; + return this.#$; + } + _(value) { + this.#__ = value; + return this.#_; + } + \u{6F}(value) { + this.#\u{6F}_ = value; + return this.#\u{6F}; + } + ℘(value) { + this.#℘_ = value; + return this.#℘; + } + ZW_‌_NJ(value) { + this.#ZW_‌_NJ_ = value; + return this.#ZW_‌_NJ; + } + ZW_‍_J(value) { + this.#ZW_‍_J_ = value; + return this.#ZW_‍_J; + } + +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.$(1), 1); +assert.sameValue(c._(1), 1); +assert.sameValue(c.\u{6F}(1), 1); +assert.sameValue(c.℘(1), 1); +assert.sameValue(c.ZW_‌_NJ(1), 1); +assert.sameValue(c.ZW_‍_J(1), 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-method-rs-private-getter.js b/js/src/tests/test262/language/statements/class/elements/same-line-method-rs-private-getter.js new file mode 100644 index 0000000000..8698f33905 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-method-rs-private-getter.js @@ -0,0 +1,128 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-private-getter.case +// - src/class-elements/productions/cls-decl-same-line-method.template +/*--- +description: Valid PrivateName as private getter (field definitions followed by a method in the same line) +esid: prod-FieldDefinition +features: [class-methods-private, class-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + ... + ; + + MethodDefinition : + ... + get ClassElementName ( ){ FunctionBody } + ... + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + #$_; #__; #\u{6F}_; #\u2118_; #ZW_\u200C_NJ_; #ZW_\u200D_J_; + get #$() { + return this.#$_; + } + get #_() { + return this.#__; + } + get #\u{6F}() { + return this.#\u{6F}_; + } + get #\u2118() { + return this.#\u2118_; + } + get #ZW_\u200C_NJ() { + return this.#ZW_\u200C_NJ_; + } + get #ZW_\u200D_J() { + return this.#ZW_\u200D_J_; + } +; m() { return 42; } + $(value) { + this.#$_ = value; + return this.#$; + } + _(value) { + this.#__ = value; + return this.#_; + } + \u{6F}(value) { + this.#\u{6F}_ = value; + return this.#\u{6F}; + } + \u2118(value) { + this.#\u2118_ = value; + return this.#\u2118; + } + ZW_\u200C_NJ(value) { + this.#ZW_\u200C_NJ_ = value; + return this.#ZW_\u200C_NJ; + } + ZW_\u200D_J(value) { + this.#ZW_\u200D_J_ = value; + return this.#ZW_\u200D_J; + } + +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.$(1), 1); +assert.sameValue(c._(1), 1); +assert.sameValue(c.\u{6F}(1), 1); +assert.sameValue(c.\u2118(1), 1); +assert.sameValue(c.ZW_\u200C_NJ(1), 1); +assert.sameValue(c.ZW_\u200D_J(1), 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-method-rs-private-method-alt.js b/js/src/tests/test262/language/statements/class/elements/same-line-method-rs-private-method-alt.js new file mode 100644 index 0000000000..18d7aa16d2 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-method-rs-private-method-alt.js @@ -0,0 +1,127 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-private-method-alt.case +// - src/class-elements/productions/cls-decl-same-line-method.template +/*--- +description: Valid PrivateName as private method (field definitions followed by a method in the same line) +esid: prod-FieldDefinition +features: [class-methods-private, class-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + ... + ; + + MethodDefinition : + ClassElementName ( UniqueFormalParameters ) { FunctionBody } + ... + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + #$_; #__; #\u{6F}_; #℘_; #ZW_‌_NJ_; #ZW_‍_J_; + #$() { + return this.#$_; + } + #_() { + return this.#__; + } + #\u{6F}() { + return this.#\u{6F}_; + } + #℘() { + return this.#℘_; + } + #ZW_‌_NJ() { + return this.#ZW_‌_NJ_; + } + #ZW_‍_J() { + return this.#ZW_‍_J_; + } +; m() { return 42; } + $(value) { + this.#$_ = value; + return this.#$(); + } + _(value) { + this.#__ = value; + return this.#_(); + } + \u{6F}(value) { + this.#\u{6F}_ = value; + return this.#\u{6F}(); + } + ℘(value) { + this.#℘_ = value; + return this.#℘(); + } + ZW_‌_NJ(value) { + this.#ZW_‌_NJ_ = value; + return this.#ZW_‌_NJ(); + } + ZW_‍_J(value) { + this.#ZW_‍_J_ = value; + return this.#ZW_‍_J(); + } + +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.$(1), 1); +assert.sameValue(c._(1), 1); +assert.sameValue(c.\u{6F}(1), 1); +assert.sameValue(c.℘(1), 1); +assert.sameValue(c.ZW_‌_NJ(1), 1); +assert.sameValue(c.ZW_‍_J(1), 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-method-rs-private-method.js b/js/src/tests/test262/language/statements/class/elements/same-line-method-rs-private-method.js new file mode 100644 index 0000000000..85cff2317b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-method-rs-private-method.js @@ -0,0 +1,127 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-private-method.case +// - src/class-elements/productions/cls-decl-same-line-method.template +/*--- +description: Valid PrivateName as private method (field definitions followed by a method in the same line) +esid: prod-FieldDefinition +features: [class-methods-private, class-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + ... + ; + + MethodDefinition : + ClassElementName ( UniqueFormalParameters ) { FunctionBody } + ... + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + #$_; #__; #\u{6F}_; #\u2118_; #ZW_\u200C_NJ_; #ZW_\u200D_J_; + #$() { + return this.#$_; + } + #_() { + return this.#__; + } + #\u{6F}() { + return this.#\u{6F}_; + } + #\u2118() { + return this.#\u2118_; + } + #ZW_\u200C_NJ() { + return this.#ZW_\u200C_NJ_; + } + #ZW_\u200D_J() { + return this.#ZW_\u200D_J_; + } +; m() { return 42; } + $(value) { + this.#$_ = value; + return this.#$(); + } + _(value) { + this.#__ = value; + return this.#_(); + } + \u{6F}(value) { + this.#\u{6F}_ = value; + return this.#\u{6F}(); + } + \u2118(value) { + this.#\u2118_ = value; + return this.#\u2118(); + } + ZW_\u200C_NJ(value) { + this.#ZW_\u200C_NJ_ = value; + return this.#ZW_\u200C_NJ(); + } + ZW_\u200D_J(value) { + this.#ZW_\u200D_J_ = value; + return this.#ZW_\u200D_J(); + } + +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.$(1), 1); +assert.sameValue(c._(1), 1); +assert.sameValue(c.\u{6F}(1), 1); +assert.sameValue(c.\u2118(1), 1); +assert.sameValue(c.ZW_\u200C_NJ(1), 1); +assert.sameValue(c.ZW_\u200D_J(1), 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-method-rs-private-setter-alt.js b/js/src/tests/test262/language/statements/class/elements/same-line-method-rs-private-setter-alt.js new file mode 100644 index 0000000000..c6d74ba3f4 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-method-rs-private-setter-alt.js @@ -0,0 +1,127 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-private-setter-alt.case +// - src/class-elements/productions/cls-decl-same-line-method.template +/*--- +description: Valid PrivateName as private setter (field definitions followed by a method in the same line) +esid: prod-FieldDefinition +features: [class-methods-private, class-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + ... + ; + + MethodDefinition : + ... + set ClassElementName ( PropertySetParameterList ) { FunctionBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + #$_; #__; #\u{6F}_; #℘_; #ZW_‌_NJ_; #ZW_‍_J_; + set #$(value) { + this.#$_ = value; + } + set #_(value) { + this.#__ = value; + } + set #\u{6F}(value) { + this.#\u{6F}_ = value; + } + set #℘(value) { + this.#℘_ = value; + } + set #ZW_‌_NJ(value) { + this.#ZW_‌_NJ_ = value; + } + set #ZW_‍_J(value) { + this.#ZW_‍_J_ = value; + } +; m() { return 42; } + $(value) { + this.#$ = value; + return this.#$_; + } + _(value) { + this.#_ = value; + return this.#__; + } + \u{6F}(value) { + this.#\u{6F} = value; + return this.#\u{6F}_; + } + ℘(value) { + this.#℘ = value; + return this.#℘_; + } + ZW_‌_NJ(value) { + this.#ZW_‌_NJ = value; + return this.#ZW_‌_NJ_; + } + ZW_‍_J(value) { + this.#ZW_‍_J = value; + return this.#ZW_‍_J_; + } + +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.$(1), 1); +assert.sameValue(c._(1), 1); +assert.sameValue(c.\u{6F}(1), 1); +assert.sameValue(c.℘(1), 1); +assert.sameValue(c.ZW_‌_NJ(1), 1); +assert.sameValue(c.ZW_‍_J(1), 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-method-rs-private-setter.js b/js/src/tests/test262/language/statements/class/elements/same-line-method-rs-private-setter.js new file mode 100644 index 0000000000..b626dbbe6c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-method-rs-private-setter.js @@ -0,0 +1,127 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-private-setter.case +// - src/class-elements/productions/cls-decl-same-line-method.template +/*--- +description: Valid PrivateName as private setter (field definitions followed by a method in the same line) +esid: prod-FieldDefinition +features: [class-methods-private, class-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + ... + ; + + MethodDefinition : + ... + set ClassElementName ( PropertySetParameterList ) { FunctionBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + #$_; #__; #\u{6F}_; #\u2118_; #ZW_\u200C_NJ_; #ZW_\u200D_J_; + set #$(value) { + this.#$_ = value; + } + set #_(value) { + this.#__ = value; + } + set #\u{6F}(value) { + this.#\u{6F}_ = value; + } + set #\u2118(value) { + this.#\u2118_ = value; + } + set #ZW_\u200C_NJ(value) { + this.#ZW_\u200C_NJ_ = value; + } + set #ZW_\u200D_J(value) { + this.#ZW_\u200D_J_ = value; + } +; m() { return 42; } + $(value) { + this.#$ = value; + return this.#$_; + } + _(value) { + this.#_ = value; + return this.#__; + } + \u{6F}(value) { + this.#\u{6F} = value; + return this.#\u{6F}_; + } + \u2118(value) { + this.#\u2118 = value; + return this.#\u2118_; + } + ZW_\u200C_NJ(value) { + this.#ZW_\u200C_NJ = value; + return this.#ZW_\u200C_NJ_; + } + ZW_\u200D_J(value) { + this.#ZW_\u200D_J = value; + return this.#ZW_\u200D_J_; + } + +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.$(1), 1); +assert.sameValue(c._(1), 1); +assert.sameValue(c.\u{6F}(1), 1); +assert.sameValue(c.\u2118(1), 1); +assert.sameValue(c.ZW_\u200C_NJ(1), 1); +assert.sameValue(c.ZW_\u200D_J(1), 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-method-rs-privatename-identifier-alt.js b/js/src/tests/test262/language/statements/class/elements/same-line-method-rs-privatename-identifier-alt.js new file mode 100644 index 0000000000..305a538f48 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-method-rs-privatename-identifier-alt.js @@ -0,0 +1,109 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-privatename-identifier-alt.case +// - src/class-elements/productions/cls-decl-same-line-method.template +/*--- +description: Valid PrivateName (field definitions followed by a method in the same line) +esid: prod-FieldDefinition +features: [class-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + #$; #_; #\u{6F}; #℘; #ZW_‌_NJ; #ZW_‍_J; m() { return 42; } + $(value) { + this.#$ = value; + return this.#$; + } + _(value) { + this.#_ = value; + return this.#_; + } + \u{6F}(value) { + this.#\u{6F} = value; + return this.#\u{6F}; + } + ℘(value) { + this.#℘ = value; + return this.#℘; + } + ZW_‌_NJ(value) { + this.#ZW_‌_NJ = value; + return this.#ZW_‌_NJ; + } + ZW_‍_J(value) { + this.#ZW_‍_J = value; + return this.#ZW_‍_J; + } +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.$(1), 1); +assert.sameValue(c._(1), 1); +assert.sameValue(c.\u{6F}(1), 1); +assert.sameValue(c.℘(1), 1); +assert.sameValue(c.ZW_‌_NJ(1), 1); +assert.sameValue(c.ZW_‍_J(1), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-method-rs-privatename-identifier-initializer-alt.js b/js/src/tests/test262/language/statements/class/elements/same-line-method-rs-privatename-identifier-initializer-alt.js new file mode 100644 index 0000000000..a560f28089 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-method-rs-privatename-identifier-initializer-alt.js @@ -0,0 +1,103 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-privatename-identifier-initializer-alt.case +// - src/class-elements/productions/cls-decl-same-line-method.template +/*--- +description: Valid PrivateName (field definitions followed by a method in the same line) +esid: prod-FieldDefinition +features: [class-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + #$ = 1; #_ = 1; #\u{6F} = 1; #℘ = 1; #ZW_‌_NJ = 1; #ZW_‍_J = 1; m() { return 42; } + $() { + return this.#$; + } + _() { + return this.#_; + } + \u{6F}() { + return this.#\u{6F}; + } + ℘() { + return this.#℘; + } + ZW_‌_NJ() { + return this.#ZW_‌_NJ; + } + ZW_‍_J() { + return this.#ZW_‍_J; + } +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.$(), 1); +assert.sameValue(c._(), 1); +assert.sameValue(c.\u{6F}(), 1); +assert.sameValue(c.℘(), 1); +assert.sameValue(c.ZW_‌_NJ(), 1); +assert.sameValue(c.ZW_‍_J(), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-method-rs-privatename-identifier-initializer.js b/js/src/tests/test262/language/statements/class/elements/same-line-method-rs-privatename-identifier-initializer.js new file mode 100644 index 0000000000..370cd34157 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-method-rs-privatename-identifier-initializer.js @@ -0,0 +1,103 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-privatename-identifier-initializer.case +// - src/class-elements/productions/cls-decl-same-line-method.template +/*--- +description: Valid PrivateName (field definitions followed by a method in the same line) +esid: prod-FieldDefinition +features: [class-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + #$ = 1; #_ = 1; #\u{6F} = 1; #\u2118 = 1; #ZW_\u200C_NJ = 1; #ZW_\u200D_J = 1; m() { return 42; } + $() { + return this.#$; + } + _() { + return this.#_; + } + \u{6F}() { + return this.#\u{6F}; + } + \u2118() { + return this.#\u2118; + } + ZW_\u200C_NJ() { + return this.#ZW_\u200C_NJ; + } + ZW_\u200D_J() { + return this.#ZW_\u200D_J; + } +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.$(), 1); +assert.sameValue(c._(), 1); +assert.sameValue(c.\u{6F}(), 1); +assert.sameValue(c.\u2118(), 1); +assert.sameValue(c.ZW_\u200C_NJ(), 1); +assert.sameValue(c.ZW_\u200D_J(), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-method-rs-privatename-identifier.js b/js/src/tests/test262/language/statements/class/elements/same-line-method-rs-privatename-identifier.js new file mode 100644 index 0000000000..026bb6e756 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-method-rs-privatename-identifier.js @@ -0,0 +1,109 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-privatename-identifier.case +// - src/class-elements/productions/cls-decl-same-line-method.template +/*--- +description: Valid PrivateName (field definitions followed by a method in the same line) +esid: prod-FieldDefinition +features: [class-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + #$; #_; #\u{6F}; #\u2118; #ZW_\u200C_NJ; #ZW_\u200D_J; m() { return 42; } + $(value) { + this.#$ = value; + return this.#$; + } + _(value) { + this.#_ = value; + return this.#_; + } + \u{6F}(value) { + this.#\u{6F} = value; + return this.#\u{6F}; + } + \u2118(value) { + this.#\u2118 = value; + return this.#\u2118; + } + ZW_\u200C_NJ(value) { + this.#ZW_\u200C_NJ = value; + return this.#ZW_\u200C_NJ; + } + ZW_\u200D_J(value) { + this.#ZW_\u200D_J = value; + return this.#ZW_\u200D_J; + } +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.$(1), 1); +assert.sameValue(c._(1), 1); +assert.sameValue(c.\u{6F}(1), 1); +assert.sameValue(c.\u2118(1), 1); +assert.sameValue(c.ZW_\u200C_NJ(1), 1); +assert.sameValue(c.ZW_\u200D_J(1), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-method-rs-static-async-generator-method-privatename-identifier-alt.js b/js/src/tests/test262/language/statements/class/elements/same-line-method-rs-static-async-generator-method-privatename-identifier-alt.js new file mode 100644 index 0000000000..d001e108f3 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-method-rs-static-async-generator-method-privatename-identifier-alt.js @@ -0,0 +1,134 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-async-generator-method-privatename-identifier-alt.case +// - src/class-elements/productions/cls-decl-same-line-method.template +/*--- +description: Valid Static AsyncGeneratorMethod PrivateName (field definitions followed by a method in the same line) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + AsyncGeneratorMethod + + AsyncGeneratorMethod : + async [no LineTerminator here] * ClassElementName ( UniqueFormalParameters){ AsyncGeneratorBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static async * #$(value) { + yield * await value; + } + static async * #_(value) { + yield * await value; + } + static async * #o(value) { + yield * await value; + } + static async * #℘(value) { + yield * await value; + } + static async * #ZW_‌_NJ(value) { + yield * await value; + } + static async * #ZW_‍_J(value) { + yield * await value; + }; m() { return 42; } + static get $() { + return this.#$; + } + static get _() { + return this.#_; + } + static get o() { + return this.#o; + } + static get ℘() { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#℘; + } + static get ZW_‌_NJ() { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#ZW_‌_NJ; + } + static get ZW_‍_J() { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#ZW_‍_J; + } + +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +Promise.all([ + C.$([1]).next(), + C._([1]).next(), + C.o([1]).next(), + C.℘([1]).next(), // DO NOT CHANGE THE NAME OF THIS FIELD + C.ZW_‌_NJ([1]).next(), // DO NOT CHANGE THE NAME OF THIS FIELD + C.ZW_‍_J([1]).next(), // DO NOT CHANGE THE NAME OF THIS FIELD +]).then(results => { + + assert.sameValue(results[0].value, 1); + assert.sameValue(results[1].value, 1); + assert.sameValue(results[2].value, 1); + assert.sameValue(results[3].value, 1); + assert.sameValue(results[4].value, 1); + assert.sameValue(results[5].value, 1); + +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-method-rs-static-async-generator-method-privatename-identifier.js b/js/src/tests/test262/language/statements/class/elements/same-line-method-rs-static-async-generator-method-privatename-identifier.js new file mode 100644 index 0000000000..5da3af0260 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-method-rs-static-async-generator-method-privatename-identifier.js @@ -0,0 +1,135 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-async-generator-method-privatename-identifier.case +// - src/class-elements/productions/cls-decl-same-line-method.template +/*--- +description: Valid Static AsyncGeneratorMethod PrivateName (field definitions followed by a method in the same line) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + AsyncGeneratorMethod + + AsyncGeneratorMethod : + async [no LineTerminator here] * ClassElementName ( UniqueFormalParameters){ AsyncGeneratorBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static async * #$(value) { + yield * await value; + } + static async * #_(value) { + yield * await value; + } + static async * #\u{6F}(value) { + yield * await value; + } + static async * #\u2118(value) { + yield * await value; + } + static async * #ZW_\u200C_NJ(value) { + yield * await value; + } + static async * #ZW_\u200D_J(value) { + yield * await value; + }; m() { return 42; } + static get $() { + return this.#$; + } + static get _() { + return this.#_; + } + static get \u{6F}() { + return this.#\u{6F}; + } + static get \u2118() { + return this.#\u2118; + } + static get ZW_\u200C_NJ() { + return this.#ZW_\u200C_NJ; + } + static get ZW_\u200D_J() { + return this.#ZW_\u200D_J; + } + +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +Promise.all([ + C.$([1]).next(), + C._([1]).next(), + C.\u{6F}([1]).next(), + C.\u2118([1]).next(), + C.ZW_\u200C_NJ([1]).next(), + C.ZW_\u200D_J([1]).next(), +]).then(results => { + + assert.sameValue(results[0].value, 1); + assert.sameValue(results[1].value, 1); + assert.sameValue(results[2].value, 1); + assert.sameValue(results[3].value, 1); + assert.sameValue(results[4].value, 1); + assert.sameValue(results[5].value, 1); + +}).then($DONE, $DONE); + diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-method-rs-static-async-method-privatename-identifier-alt.js b/js/src/tests/test262/language/statements/class/elements/same-line-method-rs-static-async-method-privatename-identifier-alt.js new file mode 100644 index 0000000000..3d0f4dffea --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-method-rs-static-async-method-privatename-identifier-alt.js @@ -0,0 +1,134 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-async-method-privatename-identifier-alt.case +// - src/class-elements/productions/cls-decl-same-line-method.template +/*--- +description: Valid Static AsyncMethod PrivateName (field definitions followed by a method in the same line) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + AsyncMethod + + AsyncMethod : + async [no LineTerminator here] ClassElementName ( UniqueFormalParameters ){ AsyncFunctionBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static async #$(value) { + return await value; + } + static async #_(value) { + return await value; + } + static async #o(value) { + return await value; + } + static async #℘(value) { + return await value; + } + static async #ZW_‌_NJ(value) { + return await value; + } + static async #ZW_‍_J(value) { + return await value; + }; m() { return 42; } + static async $(value) { + return await this.#$(value); + } + static async _(value) { + return await this.#_(value); + } + static async o(value) { + return await this.#o(value); + } + static async ℘(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + return await this.#℘(value); + } + static async ZW_‌_NJ(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + return await this.#ZW_‌_NJ(value); + } + static async ZW_‍_J(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + return await this.#ZW_‍_J(value); + } + +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +Promise.all([ + C.$(1), + C._(1), + C.o(1), + C.℘(1), // DO NOT CHANGE THE NAME OF THIS FIELD + C.ZW_‌_NJ(1), // DO NOT CHANGE THE NAME OF THIS FIELD + C.ZW_‍_J(1), // DO NOT CHANGE THE NAME OF THIS FIELD +]).then(results => { + + assert.sameValue(results[0], 1); + assert.sameValue(results[1], 1); + assert.sameValue(results[2], 1); + assert.sameValue(results[3], 1); + assert.sameValue(results[4], 1); + assert.sameValue(results[5], 1); + +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-method-rs-static-async-method-privatename-identifier.js b/js/src/tests/test262/language/statements/class/elements/same-line-method-rs-static-async-method-privatename-identifier.js new file mode 100644 index 0000000000..ab5ea4157e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-method-rs-static-async-method-privatename-identifier.js @@ -0,0 +1,135 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-async-method-privatename-identifier.case +// - src/class-elements/productions/cls-decl-same-line-method.template +/*--- +description: Valid Static AsyncMethod PrivateName (field definitions followed by a method in the same line) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public] +flags: [generated, async] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + AsyncMethod + + AsyncMethod : + async [no LineTerminator here] ClassElementName ( UniqueFormalParameters ){ AsyncFunctionBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static async #$(value) { + return await value; + } + static async #_(value) { + return await value; + } + static async #\u{6F}(value) { + return await value; + } + static async #\u2118(value) { + return await value; + } + static async #ZW_\u200C_NJ(value) { + return await value; + } + static async #ZW_\u200D_J(value) { + return await value; + }; m() { return 42; } + static async $(value) { + return await this.#$(value); + } + static async _(value) { + return await this.#_(value); + } + static async \u{6F}(value) { + return await this.#\u{6F}(value); + } + static async \u2118(value) { + return await this.#\u2118(value); + } + static async ZW_\u200C_NJ(value) { + return await this.#ZW_\u200C_NJ(value); + } + static async ZW_\u200D_J(value) { + return await this.#ZW_\u200D_J(value); + } + +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +Promise.all([ + C.$(1), + C._(1), + C.\u{6F}(1), + C.\u2118(1), + C.ZW_\u200C_NJ(1), + C.ZW_\u200D_J(1), +]).then(results => { + + assert.sameValue(results[0], 1); + assert.sameValue(results[1], 1); + assert.sameValue(results[2], 1); + assert.sameValue(results[3], 1); + assert.sameValue(results[4], 1); + assert.sameValue(results[5], 1); + +}).then($DONE, $DONE); + diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-method-rs-static-generator-method-privatename-identifier-alt.js b/js/src/tests/test262/language/statements/class/elements/same-line-method-rs-static-generator-method-privatename-identifier-alt.js new file mode 100644 index 0000000000..b2fb9a471b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-method-rs-static-generator-method-privatename-identifier-alt.js @@ -0,0 +1,124 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-generator-method-privatename-identifier-alt.case +// - src/class-elements/productions/cls-decl-same-line-method.template +/*--- +description: Valid Static GeneratorMethod PrivateName (field definitions followed by a method in the same line) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + GeneratorMethod + + GeneratorMethod : + * ClassElementName ( UniqueFormalParameters ){ GeneratorBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static * #$(value) { + yield * value; + } + static * #_(value) { + yield * value; + } + static * #o(value) { + yield * value; + } + static * #℘(value) { + yield * value; + } + static * #ZW_‌_NJ(value) { + yield * value; + } + static * #ZW_‍_J(value) { + yield * value; + }; m() { return 42; } + static get $() { + return this.#$; + } + static get _() { + return this.#_; + } + static get o() { + return this.#o; + } + static get ℘() { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#℘; + } + static get ZW_‌_NJ() { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#ZW_‌_NJ; + } + static get ZW_‍_J() { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#ZW_‍_J; + } + +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(C.$([1]).next().value, 1); +assert.sameValue(C._([1]).next().value, 1); +assert.sameValue(C.o([1]).next().value, 1); +assert.sameValue(C.℘([1]).next().value, 1); +assert.sameValue(C.ZW_‌_NJ([1]).next().value, 1); +assert.sameValue(C.ZW_‍_J([1]).next().value, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-method-rs-static-generator-method-privatename-identifier.js b/js/src/tests/test262/language/statements/class/elements/same-line-method-rs-static-generator-method-privatename-identifier.js new file mode 100644 index 0000000000..610ae1f044 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-method-rs-static-generator-method-privatename-identifier.js @@ -0,0 +1,125 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-generator-method-privatename-identifier.case +// - src/class-elements/productions/cls-decl-same-line-method.template +/*--- +description: Valid Static GeneratorMethod PrivateName (field definitions followed by a method in the same line) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + GeneratorMethod + + GeneratorMethod : + * ClassElementName ( UniqueFormalParameters ){ GeneratorBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static * #$(value) { + yield * value; + } + static * #_(value) { + yield * value; + } + static * #\u{6F}(value) { + yield * value; + } + static * #\u2118(value) { + yield * value; + } + static * #ZW_\u200C_NJ(value) { + yield * value; + } + static * #ZW_\u200D_J(value) { + yield * value; + }; m() { return 42; } + static get $() { + return this.#$; + } + static get _() { + return this.#_; + } + static get \u{6F}() { + return this.#\u{6F}; + } + static get \u2118() { + return this.#\u2118; + } + static get ZW_\u200C_NJ() { + return this.#ZW_\u200C_NJ; + } + static get ZW_\u200D_J() { + return this.#ZW_\u200D_J; + } + +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(C.$([1]).next().value, 1); +assert.sameValue(C._([1]).next().value, 1); +assert.sameValue(C.\u{6F}([1]).next().value, 1); +assert.sameValue(C.\u2118([1]).next().value, 1); +assert.sameValue(C.ZW_\u200C_NJ([1]).next().value, 1); +assert.sameValue(C.ZW_\u200D_J([1]).next().value, 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-method-rs-static-method-privatename-identifier-alt.js b/js/src/tests/test262/language/statements/class/elements/same-line-method-rs-static-method-privatename-identifier-alt.js new file mode 100644 index 0000000000..c37597597d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-method-rs-static-method-privatename-identifier-alt.js @@ -0,0 +1,122 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-method-privatename-identifier-alt.case +// - src/class-elements/productions/cls-decl-same-line-method.template +/*--- +description: Valid Static Method PrivateName (field definitions followed by a method in the same line) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + ClassElementName ( UniqueFormalParameters ){ FunctionBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static #$(value) { + return value; + } + static #_(value) { + return value; + } + static #o(value) { + return value; + } + static #℘(value) { + return value; + } + static #ZW_‌_NJ(value) { + return value; + } + static #ZW_‍_J(value) { + return value; + }; m() { return 42; } + static $(value) { + return this.#$(value); + } + static _(value) { + return this.#_(value); + } + static o(value) { + return this.#o(value); + } + static ℘(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#℘(value); + } + static ZW_‌_NJ(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#ZW_‌_NJ(value); + } + static ZW_‍_J(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#ZW_‍_J(value); + } + +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(C.$(1), 1); +assert.sameValue(C._(1), 1); +assert.sameValue(C.o(1), 1); +assert.sameValue(C.℘(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD +assert.sameValue(C.ZW_‌_NJ(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD +assert.sameValue(C.ZW_‍_J(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-method-rs-static-method-privatename-identifier.js b/js/src/tests/test262/language/statements/class/elements/same-line-method-rs-static-method-privatename-identifier.js new file mode 100644 index 0000000000..f169846a04 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-method-rs-static-method-privatename-identifier.js @@ -0,0 +1,122 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-method-privatename-identifier.case +// - src/class-elements/productions/cls-decl-same-line-method.template +/*--- +description: Valid Static Method PrivateName (field definitions followed by a method in the same line) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + ClassElementName ( UniqueFormalParameters ){ FunctionBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static #$(value) { + return value; + } + static #_(value) { + return value; + } + static #\u{6F}(value) { + return value; + } + static #\u2118(value) { + return value; + } + static #ZW_\u200C_NJ(value) { + return value; + } + static #ZW_\u200D_J(value) { + return value; + }; m() { return 42; } + static $(value) { + return this.#$(value); + } + static _(value) { + return this.#_(value); + } + static \u{6F}(value) { + return this.#\u{6F}(value); + } + static \u2118(value) { + return this.#\u2118(value); + } + static ZW_\u200C_NJ(value) { + return this.#ZW_\u200C_NJ(value); + } + static ZW_\u200D_J(value) { + return this.#ZW_\u200D_J(value); + } + +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(C.$(1), 1); +assert.sameValue(C._(1), 1); +assert.sameValue(C.\u{6F}(1), 1); +assert.sameValue(C.\u2118(1), 1); +assert.sameValue(C.ZW_\u200C_NJ(1), 1); +assert.sameValue(C.ZW_\u200D_J(1), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-method-rs-static-privatename-identifier-alt-by-classname.js b/js/src/tests/test262/language/statements/class/elements/same-line-method-rs-static-privatename-identifier-alt-by-classname.js new file mode 100644 index 0000000000..b0ddf9a34e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-method-rs-static-privatename-identifier-alt-by-classname.js @@ -0,0 +1,110 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-privatename-identifier-alt-by-classname.case +// - src/class-elements/productions/cls-decl-same-line-method.template +/*--- +description: Valid Static PrivateName (field definitions followed by a method in the same line) +esid: prod-FieldDefinition +features: [class-static-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static #$; static #_; static #\u{6F}; static #℘; static #ZW_‌_NJ; static #ZW_‍_J; m() { return 42; } + static $(value) { + C.#$ = value; + return C.#$; + } + static _(value) { + C.#_ = value; + return C.#_; + } + static o(value) { + C.#\u{6F} = value; + return C.#\u{6F}; + } + static ℘(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + C.#℘ = value; + return C.#℘; + } + static ZW_‌_NJ(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + C.#ZW_‌_NJ = value; + return C.#ZW_‌_NJ; + } + static ZW_‍_J(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + C.#ZW_‍_J = value; + return C.#ZW_‍_J; + } +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(C.$(1), 1); +assert.sameValue(C._(1), 1); +assert.sameValue(C.o(1), 1); +assert.sameValue(C.℘(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD +assert.sameValue(C.ZW_‌_NJ(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD +assert.sameValue(C.ZW_‍_J(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-method-rs-static-privatename-identifier-alt.js b/js/src/tests/test262/language/statements/class/elements/same-line-method-rs-static-privatename-identifier-alt.js new file mode 100644 index 0000000000..2cc1ad9a75 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-method-rs-static-privatename-identifier-alt.js @@ -0,0 +1,110 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-privatename-identifier-alt.case +// - src/class-elements/productions/cls-decl-same-line-method.template +/*--- +description: Valid Static PrivateName (field definitions followed by a method in the same line) +esid: prod-FieldDefinition +features: [class-static-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static #$; static #_; static #\u{6F}; static #℘; static #ZW_‌_NJ; static #ZW_‍_J; m() { return 42; } + static $(value) { + this.#$ = value; + return this.#$; + } + static _(value) { + this.#_ = value; + return this.#_; + } + static o(value) { + this.#\u{6F} = value; + return this.#\u{6F}; + } + static ℘(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + this.#℘ = value; + return this.#℘; + } + static ZW_‌_NJ(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + this.#ZW_‌_NJ = value; + return this.#ZW_‌_NJ; + } + static ZW_‍_J(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + this.#ZW_‍_J = value; + return this.#ZW_‍_J; + } +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(C.$(1), 1); +assert.sameValue(C._(1), 1); +assert.sameValue(C.o(1), 1); +assert.sameValue(C.℘(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD +assert.sameValue(C.ZW_‌_NJ(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD +assert.sameValue(C.ZW_‍_J(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-method-rs-static-privatename-identifier-by-classname.js b/js/src/tests/test262/language/statements/class/elements/same-line-method-rs-static-privatename-identifier-by-classname.js new file mode 100644 index 0000000000..5c113a6763 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-method-rs-static-privatename-identifier-by-classname.js @@ -0,0 +1,110 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-privatename-identifier-by-classname.case +// - src/class-elements/productions/cls-decl-same-line-method.template +/*--- +description: Valid Static PrivateName (field definitions followed by a method in the same line) +esid: prod-FieldDefinition +features: [class-static-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static #$; static #_; static #\u{6F}; static #\u2118; static #ZW_\u200C_NJ; static #ZW_\u200D_J; m() { return 42; } + static $(value) { + C.#$ = value; + return C.#$; + } + static _(value) { + C.#_ = value; + return C.#_; + } + static \u{6F}(value) { + C.#\u{6F} = value; + return C.#\u{6F}; + } + static \u2118(value) { + C.#\u2118 = value; + return C.#\u2118; + } + static ZW_\u200C_NJ(value) { + C.#ZW_\u200C_NJ = value; + return C.#ZW_\u200C_NJ; + } + static ZW_\u200D_J(value) { + C.#ZW_\u200D_J = value; + return C.#ZW_\u200D_J; + } +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(C.$(1), 1); +assert.sameValue(C._(1), 1); +assert.sameValue(C.\u{6F}(1), 1); +assert.sameValue(C.\u2118(1), 1); +assert.sameValue(C.ZW_\u200C_NJ(1), 1); +assert.sameValue(C.ZW_\u200D_J(1), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-method-rs-static-privatename-identifier-initializer-alt-by-classname.js b/js/src/tests/test262/language/statements/class/elements/same-line-method-rs-static-privatename-identifier-initializer-alt-by-classname.js new file mode 100644 index 0000000000..b99b7b6fb7 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-method-rs-static-privatename-identifier-initializer-alt-by-classname.js @@ -0,0 +1,104 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-privatename-identifier-initializer-alt-by-classname.case +// - src/class-elements/productions/cls-decl-same-line-method.template +/*--- +description: Valid Static PrivateName (field definitions followed by a method in the same line) +esid: prod-FieldDefinition +features: [class-static-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static #$ = 1; static #_ = 1; static #\u{6F} = 1; static #℘ = 1; static #ZW_‌_NJ = 1; static #ZW_‍_J = 1; m() { return 42; } + static $() { + return C.#$; + } + static _() { + return C.#_; + } + static \u{6F}() { + return C.#\u{6F}; + } + static ℘() { + return C.#℘; + } + static ZW_‌_NJ() { + return C.#ZW_‌_NJ; + } + static ZW_‍_J() { + return C.#ZW_‍_J; + } +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(C.$(), 1); +assert.sameValue(C._(), 1); +assert.sameValue(C.\u{6F}(), 1); +assert.sameValue(C.℘(), 1); +assert.sameValue(C.ZW_‌_NJ(), 1); +assert.sameValue(C.ZW_‍_J(), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-method-rs-static-privatename-identifier-initializer-alt.js b/js/src/tests/test262/language/statements/class/elements/same-line-method-rs-static-privatename-identifier-initializer-alt.js new file mode 100644 index 0000000000..726b917af6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-method-rs-static-privatename-identifier-initializer-alt.js @@ -0,0 +1,104 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-privatename-identifier-initializer-alt.case +// - src/class-elements/productions/cls-decl-same-line-method.template +/*--- +description: Valid Static PrivateName (field definitions followed by a method in the same line) +esid: prod-FieldDefinition +features: [class-static-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static #$ = 1; static #_ = 1; static #\u{6F} = 1; static #℘ = 1; static #ZW_‌_NJ = 1; static #ZW_‍_J = 1; m() { return 42; } + static $() { + return this.#$; + } + static _() { + return this.#_; + } + static \u{6F}() { + return this.#\u{6F}; + } + static ℘() { + return this.#℘; + } + static ZW_‌_NJ() { + return this.#ZW_‌_NJ; + } + static ZW_‍_J() { + return this.#ZW_‍_J; + } +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(C.$(), 1); +assert.sameValue(C._(), 1); +assert.sameValue(C.\u{6F}(), 1); +assert.sameValue(C.℘(), 1); +assert.sameValue(C.ZW_‌_NJ(), 1); +assert.sameValue(C.ZW_‍_J(), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-method-rs-static-privatename-identifier-initializer.js b/js/src/tests/test262/language/statements/class/elements/same-line-method-rs-static-privatename-identifier-initializer.js new file mode 100644 index 0000000000..dc6cc0adc8 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-method-rs-static-privatename-identifier-initializer.js @@ -0,0 +1,104 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-privatename-identifier-initializer.case +// - src/class-elements/productions/cls-decl-same-line-method.template +/*--- +description: Valid Static PrivateName (field definitions followed by a method in the same line) +esid: prod-FieldDefinition +features: [class-static-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static #$ = 1; static #_ = 1; static #\u{6F} = 1; static #\u2118 = 1; static #ZW_\u200C_NJ = 1; static #ZW_\u200D_J = 1; m() { return 42; } + static $() { + return this.#$; + } + static _() { + return this.#_; + } + static \u{6F}() { + return this.#\u{6F}; + } + static \u2118() { + return this.#\u2118; + } + static ZW_\u200C_NJ() { + return this.#ZW_\u200C_NJ; + } + static ZW_\u200D_J() { + return this.#ZW_\u200D_J; + } +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(C.$(), 1); +assert.sameValue(C._(), 1); +assert.sameValue(C.\u{6F}(), 1); +assert.sameValue(C.\u2118(), 1); +assert.sameValue(C.ZW_\u200C_NJ(), 1); +assert.sameValue(C.ZW_\u200D_J(), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-method-rs-static-privatename-identifier.js b/js/src/tests/test262/language/statements/class/elements/same-line-method-rs-static-privatename-identifier.js new file mode 100644 index 0000000000..eeedf66852 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-method-rs-static-privatename-identifier.js @@ -0,0 +1,110 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-privatename-identifier.case +// - src/class-elements/productions/cls-decl-same-line-method.template +/*--- +description: Valid Static PrivateName (field definitions followed by a method in the same line) +esid: prod-FieldDefinition +features: [class-static-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + static #$; static #_; static #\u{6F}; static #\u2118; static #ZW_\u200C_NJ; static #ZW_\u200D_J; m() { return 42; } + static $(value) { + this.#$ = value; + return this.#$; + } + static _(value) { + this.#_ = value; + return this.#_; + } + static \u{6F}(value) { + this.#\u{6F} = value; + return this.#\u{6F}; + } + static \u2118(value) { + this.#\u2118 = value; + return this.#\u2118; + } + static ZW_\u200C_NJ(value) { + this.#ZW_\u200C_NJ = value; + return this.#ZW_\u200C_NJ; + } + static ZW_\u200D_J(value) { + this.#ZW_\u200D_J = value; + return this.#ZW_\u200D_J; + } +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(C.$(1), 1); +assert.sameValue(C._(1), 1); +assert.sameValue(C.\u{6F}(1), 1); +assert.sameValue(C.\u2118(1), 1); +assert.sameValue(C.ZW_\u200C_NJ(1), 1); +assert.sameValue(C.ZW_\u200D_J(1), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-method-static-private-fields.js b/js/src/tests/test262/language/statements/class/elements/same-line-method-static-private-fields.js new file mode 100644 index 0000000000..b829baa278 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-method-static-private-fields.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/static-private-fields.case +// - src/class-elements/productions/cls-decl-same-line-method.template +/*--- +description: static private fields (field definitions followed by a method in the same line) +esid: prod-FieldDefinition +features: [class-static-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + ... + static FieldDefinition ; + + FieldDefinition : + ClassElementName Initializer_opt + + ClassElementName : + PrivateName + + PrivateName : + # IdentifierName + +---*/ + + +class C { + static #x; static #y; m() { return 42; } + static x() { + this.#x = 42; + return this.#x; + } + static y() { + this.#y = 43; + return this.#y; + } +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +// Test the private fields do not appear as properties before set to value +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#x"), "test 1"); +assert(!Object.prototype.hasOwnProperty.call(C, "#x"), "test 2"); +assert(!Object.prototype.hasOwnProperty.call(c, "#x"), "test 3"); + +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#y"), "test 4"); +assert(!Object.prototype.hasOwnProperty.call(C, "#y"), "test 5"); +assert(!Object.prototype.hasOwnProperty.call(c, "#y"), "test 6"); + +// Test if private fields can be sucessfully accessed and set to value +assert.sameValue(C.x(), 42, "test 7"); +assert.sameValue(C.y(), 43, "test 8"); + +// Test the private fields do not appear as properties before after set to value +assert(!Object.prototype.hasOwnProperty.call(C, "#x"), "test 9"); +assert(!Object.prototype.hasOwnProperty.call(C, "#y"), "test 10"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-method-static-private-methods-with-fields.js b/js/src/tests/test262/language/statements/class/elements/same-line-method-static-private-methods-with-fields.js new file mode 100644 index 0000000000..122e89c869 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-method-static-private-methods-with-fields.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/static-private-methods-with-fields.case +// - src/class-elements/productions/cls-decl-same-line-method.template +/*--- +description: static private methods with fields (field definitions followed by a method in the same line) +esid: prod-FieldDefinition +features: [class-static-methods-private, class-static-fields-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + ... + static FieldDefinition ; + + FieldDefinition : + ClassElementName Initializer_opt + + ClassElementName : + PrivateName + + PrivateName : + # IdentifierName + +---*/ + + +class C { + static #xVal; static #yVal; m() { return 42; } + static #x(value) { + this.#xVal = value; + return this.#xVal; + } + static #y(value) { + this.#yVal = value; + return this.#yVal; + } + static x() { + return this.#x(42); + } + static y() { + return this.#y(43); + } +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +// Test the private methods do not appear as properties before set to value +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#x"), "test 1"); +assert(!Object.prototype.hasOwnProperty.call(C, "#x"), "test 2"); +assert(!Object.prototype.hasOwnProperty.call(c, "#x"), "test 3"); + +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#y"), "test 4"); +assert(!Object.prototype.hasOwnProperty.call(C, "#y"), "test 5"); +assert(!Object.prototype.hasOwnProperty.call(c, "#y"), "test 6"); + +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#xVal"), "test 7"); +assert(!Object.prototype.hasOwnProperty.call(C, "#xVal"), "test 8"); +assert(!Object.prototype.hasOwnProperty.call(c, "#xVal"), "test 9"); + +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#yVal"), "test 10"); +assert(!Object.prototype.hasOwnProperty.call(C, "#yVal"), "test 11"); +assert(!Object.prototype.hasOwnProperty.call(c, "#yVal"), "test 12"); + +// Test if private fields can be sucessfully accessed and set to value +assert.sameValue(C.x(), 42, "test 13"); +assert.sameValue(C.y(), 43, "test 14"); + +// Test the private fields do not appear as properties before after set to value +assert(!Object.prototype.hasOwnProperty.call(C, "#x"), "test 15"); +assert(!Object.prototype.hasOwnProperty.call(C, "#y"), "test 16"); + +assert(!Object.prototype.hasOwnProperty.call(C, "#xVal"), "test 17"); +assert(!Object.prototype.hasOwnProperty.call(C, "#yVal"), "test 18"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-method-static-private-methods.js b/js/src/tests/test262/language/statements/class/elements/same-line-method-static-private-methods.js new file mode 100644 index 0000000000..23d279092e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-method-static-private-methods.js @@ -0,0 +1,75 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/static-private-methods.case +// - src/class-elements/productions/cls-decl-same-line-method.template +/*--- +description: static private methods (field definitions followed by a method in the same line) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement : + ... + static FieldDefinition ; + + FieldDefinition : + ClassElementName Initializer_opt + + ClassElementName : + PrivateName + + PrivateName : + # IdentifierName + +---*/ + + +class C { + ; m() { return 42; } + static #x(value) { + return value / 2; + } + static #y(value) { + return value * 2; + } + static x() { + return this.#x(84); + } + static y() { + return this.#y(43); + } +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +// Test the private methods do not appear as properties before set to value +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#x"), "test 1"); +assert(!Object.prototype.hasOwnProperty.call(C, "#x"), "test 2"); +assert(!Object.prototype.hasOwnProperty.call(c, "#x"), "test 3"); + +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#y"), "test 4"); +assert(!Object.prototype.hasOwnProperty.call(C, "#y"), "test 5"); +assert(!Object.prototype.hasOwnProperty.call(c, "#y"), "test 6"); + +// Test if private fields can be sucessfully accessed and set to value +assert.sameValue(C.x(), 42, "test 7"); +assert.sameValue(C.y(), 86, "test 8"); + +// Test the private fields do not appear as properties before after set to value +assert(!Object.prototype.hasOwnProperty.call(C, "#x"), "test 9"); +assert(!Object.prototype.hasOwnProperty.call(C, "#y"), "test 10"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/same-line-method-string-literal-names.js b/js/src/tests/test262/language/statements/class/elements/same-line-method-string-literal-names.js new file mode 100644 index 0000000000..bc189fe759 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/same-line-method-string-literal-names.js @@ -0,0 +1,109 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/string-literal-names.case +// - src/class-elements/productions/cls-decl-same-line-method.template +/*--- +description: String literal names (field definitions followed by a method in the same line) +esid: prod-FieldDefinition +features: [class-fields-public, class] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PropertyName + +---*/ + + +class C { + 'a'; "b"; 'c' = 39; + "d" = 42; m() { return 42; } + +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert( + !Object.prototype.hasOwnProperty.call(c, "m"), + "m doesn't appear as an own property on the C instance" +); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "a"), + "a does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "a"), + "a does not appear as an own property on C constructor" +); + +verifyProperty(c, "a", { + value: undefined, + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "b"), + "b does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "b"), + "b does not appear as an own property on C constructor" +); + +verifyProperty(c, "b", { + value: undefined, + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "c"), + "c does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "c"), + "c does not appear as an own property on C constructor" +); + +verifyProperty(c, "c", { + value: 39, + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "d"), + "d does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "d"), + "d does not appear as an own property on C constructor" +); + +verifyProperty(c, "d", { + value: 42, + enumerable: true, + writable: true, + configurable: true +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/set-access-of-missing-private-setter.js b/js/src/tests/test262/language/statements/class/elements/set-access-of-missing-private-setter.js new file mode 100644 index 0000000000..0548a1b526 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/set-access-of-missing-private-setter.js @@ -0,0 +1,42 @@ +// Copyright (C) 2019 Caio Lima (Igalia SL). All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Trying to set a private member without setter throws TypeError +esid: sec-privatefieldset +info: | + PrivateFieldSet ( P, O, value ) + 1. Assert: P is a Private Name. + 2. If O is not an object, throw a TypeError exception. + 3. If P.[[Kind]] is "field", + a. Let entry be PrivateFieldFind(P, O). + b. If entry is empty, throw a TypeError exception. + c. Set entry.[[PrivateFieldValue]] to value. + d. Return. + 4. If P.[[Kind]] is "method", throw a TypeError exception. + 5. Else, + a. Assert: P.[[Kind]] is "accessor". + b. If O.[[PrivateFieldBrands]] does not contain P.[[Brand]], throw a TypeError exception. + c. If P does not have a [[Set]] field, throw a TypeError exception. + d. Let setter be P.[[Set]]. + e. Perform ? Call(setter, O, value). + f. Return. +features: [class-methods-private, class] +---*/ + +class C { + get #f() { + throw new Test262Error(); + } + + setAccess() { + this.#f = 'Test262'; + } +} + +let c = new C(); +assert.throws(TypeError, function() { + c.setAccess(); +}, 'set operation on private accessor without setter should throw TypeError'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/set-access-of-missing-private-static-setter.js b/js/src/tests/test262/language/statements/class/elements/set-access-of-missing-private-static-setter.js new file mode 100644 index 0000000000..cba6b87287 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/set-access-of-missing-private-static-setter.js @@ -0,0 +1,41 @@ +// Copyright (C) 2021 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Trying to set a private member without setter throws TypeError +esid: sec-privatefieldset +info: | + PrivateFieldSet ( P, O, value ) + 1. Assert: P is a Private Name. + 2. If O is not an object, throw a TypeError exception. + 3. If P.[[Kind]] is "field", + a. Let entry be PrivateFieldFind(P, O). + b. If entry is empty, throw a TypeError exception. + c. Set entry.[[PrivateFieldValue]] to value. + d. Return. + 4. If P.[[Kind]] is "method", throw a TypeError exception. + 5. Else, + a. Assert: P.[[Kind]] is "accessor". + b. If O.[[PrivateFieldBrands]] does not contain P.[[Brand]], throw a TypeError exception. + c. If P does not have a [[Set]] field, throw a TypeError exception. + d. Let setter be P.[[Set]]. + e. Perform ? Call(setter, O, value). + f. Return. +features: [class-static-methods-private, class] +---*/ + +class C { + static get #f() { + throw new Test262Error(); + } + + static setAccess() { + this.#f = 'Test262'; + } +} + +assert.throws(TypeError, function() { + C.setAccess(); +}, 'set operation on private accessor without setter should throw TypeError'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/set-access-of-missing-shadowed-private-setter.js b/js/src/tests/test262/language/statements/class/elements/set-access-of-missing-shadowed-private-setter.js new file mode 100644 index 0000000000..9f2657cec9 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/set-access-of-missing-shadowed-private-setter.js @@ -0,0 +1,92 @@ +// Copyright (C) 2019 Caio Lima (Igalia SL). All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Trying to set in PrivateName without setter throws TypeError +esid: sec-privatefieldset +info: | + PrivateFieldSet ( P, O, value ) + 1. Assert: P is a Private Name. + 2. If O is not an object, throw a TypeError exception. + 3. If P.[[Kind]] is "field", + a. Let entry be PrivateFieldFind(P, O). + b. If entry is empty, throw a TypeError exception. + c. Set entry.[[PrivateFieldValue]] to value. + d. Return. + 4. If P.[[Kind]] is "method", throw a TypeError exception. + 5. Else, + a. Assert: P.[[Kind]] is "accessor". + b. If O.[[PrivateFieldBrands]] does not contain P.[[Brand]], throw a TypeError exception. + c. If P does not have a [[Set]] field, throw a TypeError exception. + d. Let setter be P.[[Set]]. + e. Perform ? Call(setter, O, value). + f. Return. +features: [class-methods-private, class-fields-public, class] +---*/ + +class A { + set #f(v) { + throw new Test262Error(); + } +} + +class B extends A { + get #f() { + throw new Test262Error(); + } + + setAccess() { + this.#f = 'Test262'; + } +} + +let b = new B(); +assert.throws(TypeError, function() { + b.setAccess(); +}, 'subclass private accessor should shadow super class private accessor'); + +class C { + set #f(v) { + throw new Test262Error(); + } + + Inner = class { + get #f() { + throw new Test262Error(); + } + + setAccess() { + this.#f = 'Test262'; + } + } +} + +let c = new C(); +let innerC = new c.Inner(); +assert.throws(TypeError, function() { + innerC.setAccess(); +}, 'inner class private accessor should shadow outer class private accessor'); + +class D { + get #f() { + throw new Test262Error(); + } + + Inner = class { + set #f(v) { + throw new Test262Error(); + } + } + + setAccess() { + this.#f = 'Test262'; + } +} + +let d = new D(); +assert.throws(TypeError, function() { + d.setAccess(); +}, 'inner class private accessor should not be visible to outer class private accessor'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/set-access-of-private-method.js b/js/src/tests/test262/language/statements/class/elements/set-access-of-private-method.js new file mode 100644 index 0000000000..13b493274e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/set-access-of-private-method.js @@ -0,0 +1,43 @@ +// Copyright (C) 2019 Caio Lima (Igalia SL). All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Trying to set a private method throws TypeError +esid: sec-privatefieldset +info: | + PrivateFieldSet ( P, O, value ) + 1. Assert: P is a Private Name. + 2. If O is not an object, throw a TypeError exception. + 3. If P.[[Kind]] is "field", + a. Let entry be PrivateFieldFind(P, O). + b. If entry is empty, throw a TypeError exception. + c. Set entry.[[PrivateFieldValue]] to value. + d. Return. + 4. If P.[[Kind]] is "method", throw a TypeError exception. + 5. Else, + a. Assert: P.[[Kind]] is "accessor". + b. If O.[[PrivateFieldBrands]] does not contain P.[[Brand]], throw a TypeError exception. + c. If P does not have a [[Set]] field, throw a TypeError exception. + d. Let setter be P.[[Set]]. + e. Perform ? Call(setter, O, value). + f. Return. +features: [class-methods-private, class] +---*/ + +class C { + #f() { + throw new Test262Error(); + } + + setAccess() { + this.#f = 'Test262'; + } +} + +let c = new C(); +assert.throws(TypeError, function() { + c.setAccess(); +}, 'set operation on private method should throw TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/set-access-of-shadowed-private-method.js b/js/src/tests/test262/language/statements/class/elements/set-access-of-shadowed-private-method.js new file mode 100644 index 0000000000..4a15f281a5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/set-access-of-shadowed-private-method.js @@ -0,0 +1,92 @@ +// Copyright (C) 2019 Caio Lima (Igalia SL). All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Trying to set private method throws TypeError +esid: sec-privatefieldset +info: | + PrivateFieldSet ( P, O, value ) + 1. Assert: P is a Private Name. + 2. If O is not an object, throw a TypeError exception. + 3. If P.[[Kind]] is "field", + a. Let entry be PrivateFieldFind(P, O). + b. If entry is empty, throw a TypeError exception. + c. Set entry.[[PrivateFieldValue]] to value. + d. Return. + 4. If P.[[Kind]] is "method", throw a TypeError exception. + 5. Else, + a. Assert: P.[[Kind]] is "accessor". + b. If O.[[PrivateFieldBrands]] does not contain P.[[Brand]], throw a TypeError exception. + c. If P does not have a [[Set]] field, throw a TypeError exception. + d. Let setter be P.[[Set]]. + e. Perform ? Call(setter, O, value). + f. Return. +features: [class-methods-private, class-fields-public, class] +---*/ + +class A { + set #f(v) { + throw new Test262Error(); + } +} + +class B extends A { + #f() { + throw new Test262Error(); + } + + setAccess() { + this.#f = 'Test262'; + } +} + +let b = new B(); +assert.throws(TypeError, function() { + b.setAccess(); +}, 'subclass private method should shadow super class private accessor'); + +class C { + set #f(v) { + throw new Test262Error(); + } + + Inner = class { + #f() { + throw new Test262Error(); + } + + setAccess() { + this.#f = 'Test262'; + } + } +} + +let c = new C(); +let innerC = new c.Inner(); +assert.throws(TypeError, function() { + innerC.setAccess(); +}, 'inner class private method should shadow outer class private accessor'); + +class D { + #f() { + throw new Test262Error(); + } + + Inner = class { + set #f(v) { + throw new Test262Error(); + } + } + + setAccess() { + this.#f = 'Test262'; + } +} + +let d = new D(); +assert.throws(TypeError, function() { + d.setAccess(); +}, 'inner class private accessor should not be visible to outer class'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/shell.js b/js/src/tests/test262/language/statements/class/elements/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/elements/static-as-valid-instance-field-assigned.js b/js/src/tests/test262/language/statements/class/elements/static-as-valid-instance-field-assigned.js new file mode 100644 index 0000000000..7e6f093768 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/static-as-valid-instance-field-assigned.js @@ -0,0 +1,38 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/static-as-valid-instance-field-assigned.case +// - src/class-elements/default/cls-decl.template +/*--- +description: static is a valid name of an instance field (field definitions in a class declaration) +esid: prod-FieldDefinition +features: [class-fields-public, class] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PropertyName + +---*/ + + +class C { + static = "foo"; +} + +let c = new C(); + +verifyProperty(c, "static", { + value: "foo", + enumerable: true, + writable: true, + configurable: true +}); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/static-as-valid-instance-field.js b/js/src/tests/test262/language/statements/class/elements/static-as-valid-instance-field.js new file mode 100644 index 0000000000..26bb5b7629 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/static-as-valid-instance-field.js @@ -0,0 +1,38 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/static-as-valid-instance-field.case +// - src/class-elements/default/cls-decl.template +/*--- +description: static is a valid name of an instance field (field definitions in a class declaration) +esid: prod-FieldDefinition +features: [class-fields-public, class] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PropertyName + +---*/ + + +class C { + static; +} + +let c = new C(); + +verifyProperty(c, "static", { + value: undefined, + enumerable: true, + writable: true, + configurable: true +}); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/static-as-valid-static-field-assigned.js b/js/src/tests/test262/language/statements/class/elements/static-as-valid-static-field-assigned.js new file mode 100644 index 0000000000..1383f338c0 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/static-as-valid-static-field-assigned.js @@ -0,0 +1,30 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/static-as-valid-static-field-assigned.case +// - src/class-elements/default/cls-decl.template +/*--- +description: static is a valid name of a static field (field definitions in a class declaration) +esid: prod-FieldDefinition +features: [class-static-fields-public, class] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement: + ... + static FieldDefinition ; + +---*/ + + +class C { + static static = "test262"; +} + +verifyProperty(C, "static", { + value: "test262", + enumerable: true, + writable: true, + configurable: true +}); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/static-as-valid-static-field.js b/js/src/tests/test262/language/statements/class/elements/static-as-valid-static-field.js new file mode 100644 index 0000000000..88f818f28c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/static-as-valid-static-field.js @@ -0,0 +1,30 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/static-as-valid-static-field.case +// - src/class-elements/default/cls-decl.template +/*--- +description: static is a valid name of a static field (field definitions in a class declaration) +esid: prod-FieldDefinition +features: [class-static-fields-public, class] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement: + ... + static FieldDefinition ; + +---*/ + + +class C { + static static; +} + +verifyProperty(C, "static", { + value: undefined, + enumerable: true, + writable: true, + configurable: true +}); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/static-comp-name-init-err-contains-arguments.js b/js/src/tests/test262/language/statements/class/elements/static-comp-name-init-err-contains-arguments.js new file mode 100644 index 0000000000..eff2ee5b0a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/static-comp-name-init-err-contains-arguments.js @@ -0,0 +1,36 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/init-err-contains-arguments.case +// - src/class-elements/initializer-error/cls-decl-fields-static-comp-name.template +/*--- +description: Syntax error if `arguments` used in class field (static computed ClassElementName) +esid: sec-class-definitions-static-semantics-early-errors +features: [class, class-fields-public, class-static-fields-public, computed-property-names] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Static Semantics: Early Errors + + FieldDefinition: + PropertyNameInitializeropt + + - It is a Syntax Error if ContainsArguments of Initializer is true. + + Static Semantics: ContainsArguments + IdentifierReference : Identifier + + 1. If the StringValue of Identifier is "arguments", return true. + ... + For all other grammatical productions, recurse on all nonterminals. If any piece returns true, then return true. Otherwise return false. + +---*/ + + +$DONOTEVALUATE(); + +var x = "string"; +class C { + static [x] = arguments; +} diff --git a/js/src/tests/test262/language/statements/class/elements/static-comp-name-init-err-contains-super.js b/js/src/tests/test262/language/statements/class/elements/static-comp-name-init-err-contains-super.js new file mode 100644 index 0000000000..8ea327730f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/static-comp-name-init-err-contains-super.js @@ -0,0 +1,29 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/init-err-contains-super.case +// - src/class-elements/initializer-error/cls-decl-fields-static-comp-name.template +/*--- +description: Syntax error if `super()` used in class field (static computed ClassElementName) +esid: sec-class-definitions-static-semantics-early-errors +features: [class, class-fields-public, class-static-fields-public, computed-property-names] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Static Semantics: Early Errors + + FieldDefinition: + PropertyNameInitializeropt + + - It is a Syntax Error if Initializer is present and Initializer Contains SuperCall is true. + +---*/ + + +$DONOTEVALUATE(); + +var x = "string"; +class C { + static [x] = super(); +} diff --git a/js/src/tests/test262/language/statements/class/elements/static-field-anonymous-function-length.js b/js/src/tests/test262/language/statements/class/elements/static-field-anonymous-function-length.js new file mode 100644 index 0000000000..17c4b304b2 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/static-field-anonymous-function-length.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/static-field-anonymous-function-length.case +// - src/class-elements/default/cls-decl.template +/*--- +description: Anonymous function in field initilizer have length properly set (field definitions in a class declaration) +esid: prod-FieldDefinition +features: [class-static-fields-private, class-static-fields-public, class] +flags: [generated] +info: | + Updated Productions + + ClassElement : + ... + static FieldDefinition ; + + FieldDefinition : + ClassElementName Initializer_opt + + ClassDefinitionEvaluation: + ... + + 27. Let staticFields be a new empty List. + 28. For each ClassElement e in order from elements, + a. If IsStatic of e is false, then + ... + b. Else, + i. Let field be the result of performing PropertyDefinitionEvaluation for m ClassElementEvaluation for e with arguments F and false. + c. If field is an abrupt completion, then + ... + d. If field is not empty, + i. If IsStatic of e is false, append field to instanceFields. + ii. Otherwise, append field to staticFields. + + 34. For each item fieldRecord in order from staticFields, + a. Perform ? DefineField(F, field). + ... + + DefineField(receiver, fieldRecord) + 1. Assert: Type(receiver) is Object. + 2. Assert: fieldRecord is a Record as created by ClassFieldDefinitionEvaluation. + 3. Let name be fieldRecord.[[Name]]. + 4. Let initializer be fieldRecord.[[Initializer]]. + 5. If initializer is not empty, then + a. Let initValue be ? Call(initializer, receiver). + ... + +---*/ + + +class C { + static #field = (a, b) => undefined; + static field = function() {}; + + static accessPrivateField() { + return this.#field; + } + +} + +assert.sameValue(C.accessPrivateField().length, 2); +assert.sameValue(C.field.length, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/static-field-anonymous-function-name.js b/js/src/tests/test262/language/statements/class/elements/static-field-anonymous-function-name.js new file mode 100644 index 0000000000..9fe93ca156 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/static-field-anonymous-function-name.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/static-field-anonymous-function-name.case +// - src/class-elements/default/cls-decl.template +/*--- +description: Anonymous function receives the name of static fields (field definitions in a class declaration) +esid: prod-FieldDefinition +features: [class-static-fields-private, class-static-fields-public, class] +flags: [generated] +info: | + Updated Productions + + ClassElement : + ... + static FieldDefinition ; + + FieldDefinition : + ClassElementName Initializer_opt + + ClassDefinitionEvaluation: + ... + + 27. Let staticFields be a new empty List. + 28. For each ClassElement e in order from elements, + a. If IsStatic of e is false, then + ... + b. Else, + i. Let field be the result of performing PropertyDefinitionEvaluation for m ClassElementEvaluation for e with arguments F and false. + c. If field is an abrupt completion, then + ... + d. If field is not empty, + i. If IsStatic of e is false, append field to instanceFields. + ii. Otherwise, append field to staticFields. + + 34. For each item fieldRecord in order from staticFields, + a. Perform ? DefineField(F, field). + ... + + DefineField(receiver, fieldRecord) + 1. Assert: Type(receiver) is Object. + 2. Assert: fieldRecord is a Record as created by ClassFieldDefinitionEvaluation. + 3. Let name be fieldRecord.[[Name]]. + 4. Let initializer be fieldRecord.[[Initializer]]. + 5. If initializer is not empty, then + a. Let initValue be ? Call(initializer, receiver). + 6. Else, let initValue be undefined. + 7. If fieldRecord.[[IsAnonymousFunctionDefinition]] is true, then + a. Let hasNameProperty be ? HasOwnProperty(initValue, "name"). + b. If hasNameProperty is false, perform SetFunctionName(initValue, fieldName). + 8. If fieldName is a Private Name, + a. Perform ? PrivateFieldAdd(fieldName, receiver, initValue). + 9. Else, + a. Assert: IsPropertyKey(fieldName) is true. + b. Perform ? CreateDataPropertyOrThrow(receiver, fieldName, initValue). + 10. Return. + +---*/ + + +class C { + static #field = () => 'Test262'; + static field = function() { return 42; }; + + static accessPrivateField() { + return this.#field; + } + +} + +assert.sameValue(C.accessPrivateField().name, "#field"); +assert.sameValue(C.field.name, "field"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/static-field-declaration.js b/js/src/tests/test262/language/statements/class/elements/static-field-declaration.js new file mode 100644 index 0000000000..3bdd8ae3e3 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/static-field-declaration.js @@ -0,0 +1,132 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/static-field-declaration.case +// - src/class-elements/default/cls-decl.template +/*--- +description: Static fields are defined using DefineField (field definitions in a class declaration) +esid: prod-FieldDefinition +features: [class-static-fields-public, class] +flags: [generated] +includes: [propertyHelper.js] +info: | + Updated Productions + + ClassElement : + ... + static FieldDefinition ; + + FieldDefinition : + ClassElementName Initializer_opt + + ClassElementName : + PropertyName + + PropertyName : + LiteralPropertyName + ComputedPropertyName + + LiteralPropertyName : + IdentifierName + StringLiteral + NumericLiteral + + ClassDefinitionEvaluation: + ... + + 27. Let staticFields be a new empty List. + 28. For each ClassElement e in order from elements, + a. If IsStatic of e is false, then + ... + b. Else, + i. Let field be the result of performing PropertyDefinitionEvaluation for mClassElementEvaluation for e with arguments F and false. + c. If field is an abrupt completion, then + ... + d. If field is not empty, + i. If IsStatic of e is false, append field to instanceFields. + ii. Otherwise, append field to staticFields. + + 34. For each item fieldRecord in order from staticFields, + a. Perform ? DefineField(F, field). + ... + + DefineField(receiver, fieldRecord) + 1. Assert: Type(receiver) is Object. + 2. Assert: fieldRecord is a Record as created by ClassFieldDefinitionEvaluation. + 3. Let name be fieldRecord.[[Name]]. + 4. Let initializer be fieldRecord.[[Initializer]]. + 5. If initializer is not empty, then + a. Let initValue be ? Call(initializer, receiver). + 6. Else, let initValue be undefined. + 7. If fieldRecord.[[IsAnonymousFunctionDefinition]] is true, then + a. Let hasNameProperty be ? HasOwnProperty(initValue, "name"). + b. If hasNameProperty is false, perform SetFunctionName(initValue, fieldName). + 8. If fieldName is a Private Name, + a. Perform ? PrivateFieldAdd(fieldName, receiver, initValue). + 9. Else, + a. Assert: IsPropertyKey(fieldName) is true. + b. Perform ? CreateDataPropertyOrThrow(receiver, fieldName, initValue). + 10. Return. + +---*/ +var computed = 'h'; + + +class C { + static f = 'test262'; + static 'g'; + static 0 = 'bar'; + static [computed]; +} + +let c = new C(); + +assert.sameValue(c.f, undefined); +assert.sameValue(c.g, undefined); +assert.sameValue(c.h, undefined); +assert.sameValue(c[0], undefined); + +assert( + !Object.prototype.hasOwnProperty.call(c, 'f'), + "f does not appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(c, 'g'), + "g does not appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(c, 'h'), + "h does not appear as an own property on the C instance" +); +assert( + !Object.prototype.hasOwnProperty.call(c, 0), + "0 does not appear as an own property on the C instance" +); + +verifyProperty(C, 'f', { + value: 'test262', + enumerable: true, + writable: true, + configurable: true +}); + +verifyProperty(C, 'g', { + value: undefined, + enumerable: true, + writable: true, + configurable: true +}); + +verifyProperty(C, 0, { + value: 'bar', + enumerable: true, + writable: true, + configurable: true +}); + +verifyProperty(C, 'h', { + value: undefined, + enumerable: true, + writable: true, + configurable: true +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/static-field-init-this-inside-arrow-function.js b/js/src/tests/test262/language/statements/class/elements/static-field-init-this-inside-arrow-function.js new file mode 100644 index 0000000000..e10becfcc2 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/static-field-init-this-inside-arrow-function.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/static-field-init-this-inside-arrow-function.case +// - src/class-elements/default/cls-decl.template +/*--- +description: this in static field initializers refers to class constructor (field definitions in a class declaration) +esid: prod-FieldDefinition +features: [class-static-fields-public, class] +flags: [generated] +info: | + Updated Productions + + ClassElement : + ... + static FieldDefinition ; + + FieldDefinition : + ClassElementName Initializer_opt + + ClassDefinitionEvaluation: + ... + + 27. Let staticFields be a new empty List. + 28. For each ClassElement e in order from elements, + a. If IsStatic of e is false, then + ... + b. Else, + i. Let field be the result of performing PropertyDefinitionEvaluation for m ClassElementEvaluation for e with arguments F and false. + c. If field is an abrupt completion, then + ... + d. If field is not empty, + i. If IsStatic of e is false, append field to instanceFields. + ii. Otherwise, append field to staticFields. + + 34. For each item fieldRecord in order from staticFields, + a. Perform ? DefineField(F, field). + ... + + DefineField(receiver, fieldRecord) + 1. Assert: Type(receiver) is Object. + 2. Assert: fieldRecord is a Record as created by ClassFieldDefinitionEvaluation. + 3. Let name be fieldRecord.[[Name]]. + 4. Let initializer be fieldRecord.[[Initializer]]. + 5. If initializer is not empty, then + a. Let initValue be ? Call(initializer, receiver). + 6. Else, let initValue be undefined. + 7. If fieldRecord.[[IsAnonymousFunctionDefinition]] is true, then + a. Let hasNameProperty be ? HasOwnProperty(initValue, "name"). + b. If hasNameProperty is false, perform SetFunctionName(initValue, fieldName). + 8. If fieldName is a Private Name, + a. Perform ? PrivateFieldAdd(fieldName, receiver, initValue). + 9. Else, + a. Assert: IsPropertyKey(fieldName) is true. + b. Perform ? CreateDataPropertyOrThrow(receiver, fieldName, initValue). + 10. Return. + +---*/ + + +class C { + static f = () => this; +} + +assert.sameValue(C.f(), C); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/static-field-init-with-this.js b/js/src/tests/test262/language/statements/class/elements/static-field-init-with-this.js new file mode 100644 index 0000000000..17541878f8 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/static-field-init-with-this.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/static-field-init-with-this.case +// - src/class-elements/default/cls-decl.template +/*--- +description: Static fields initializer has `this` biding (field definitions in a class declaration) +esid: prod-FieldDefinition +features: [class-static-fields-public, class] +flags: [generated] +info: | + Updated Productions + + ClassElement : + ... + static FieldDefinition ; + + FieldDefinition : + ClassElementName Initializer_opt + + ClassDefinitionEvaluation: + ... + + 27. Let staticFields be a new empty List. + 28. For each ClassElement e in order from elements, + a. If IsStatic of e is false, then + ... + b. Else, + i. Let field be the result of performing PropertyDefinitionEvaluation for m ClassElementEvaluation for e with arguments F and false. + c. If field is an abrupt completion, then + ... + d. If field is not empty, + i. If IsStatic of e is false, append field to instanceFields. + ii. Otherwise, append field to staticFields. + + 34. For each item fieldRecord in order from staticFields, + a. Perform ? DefineField(F, field). + ... + + DefineField(receiver, fieldRecord) + 1. Assert: Type(receiver) is Object. + 2. Assert: fieldRecord is a Record as created by ClassFieldDefinitionEvaluation. + 3. Let name be fieldRecord.[[Name]]. + 4. Let initializer be fieldRecord.[[Initializer]]. + 5. If initializer is not empty, then + a. Let initValue be ? Call(initializer, receiver). + 6. Else, let initValue be undefined. + 7. If fieldRecord.[[IsAnonymousFunctionDefinition]] is true, then + a. Let hasNameProperty be ? HasOwnProperty(initValue, "name"). + b. If hasNameProperty is false, perform SetFunctionName(initValue, fieldName). + 8. If fieldName is a Private Name, + a. Perform ? PrivateFieldAdd(fieldName, receiver, initValue). + 9. Else, + a. Assert: IsPropertyKey(fieldName) is true. + b. Perform ? CreateDataPropertyOrThrow(receiver, fieldName, initValue). + 10. Return. + +---*/ + + +class C { + static f = 'test'; + static g = this.f + '262'; + static h = eval('this.g') + 'test'; +} + +assert.sameValue(C.f, 'test'); +assert.sameValue(C.g, 'test262'); +assert.sameValue(C.h, 'test262test'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/static-field-initializer-error.js b/js/src/tests/test262/language/statements/class/elements/static-field-initializer-error.js new file mode 100644 index 0000000000..e15ee8a192 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/static-field-initializer-error.js @@ -0,0 +1,60 @@ +// Copyright (C) 2019 Caio Lima (Igalia SL). All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Class evaluation is incomplete when initializer resutls in an abrupt completition +esid: sec-define-field +info: | + ClassDefinitionEvaluation: + ... + + 27. Let staticFields be a new empty List. + 28. For each ClassElement e in order from elements, + a. If IsStatic of e is false, then + ... + b. Else, + i. Let field be the result of performing PropertyDefinitionEvaluation for m ClassElementEvaluation for e with arguments F and false. + c. If field is an abrupt completion, then + ... + d. If field is not empty, + i. If IsStatic of e is false, append field to instanceFields. + ii. Otherwise, append field to staticFields. + + 34. For each item fieldRecord in order from staticFields, + a. Perform ? DefineField(F, field). + ... + + DefineField(receiver, fieldRecord) + 1. Assert: Type(receiver) is Object. + 2. Assert: fieldRecord is a Record as created by ClassFieldDefinitionEvaluation. + 3. Let name be fieldRecord.[[Name]]. + 4. Let initializer be fieldRecord.[[Initializer]]. + 5. If initializer is not empty, then + a. Let initValue be ? Call(initializer, receiver). + 6. Else, let initValue be undefined. + 7. If fieldRecord.[[IsAnonymousFunctionDefinition]] is true, then + a. Let hasNameProperty be ? HasOwnProperty(initValue, "name"). + b. If hasNameProperty is false, perform SetFunctionName(initValue, fieldName). + 8. If fieldName is a Private Name, + a. Perform ? PrivateFieldAdd(fieldName, receiver, initValue). + 9. Else, + a. Assert: IsPropertyKey(fieldName) is true. + b. Perform ? CreateDataPropertyOrThrow(receiver, fieldName, initValue). + 10. Return. +features: [class-static-fields-public, class] +---*/ + +function initThrows() { + throw new Test262Error(); +} + +assert.throws(Test262Error, function() { + class C { + static f = initThrows(); + static g; + }; + + assert(false, 'this should never execute'); +}, 'static field initializer should throw exception'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/static-field-redeclaration.js b/js/src/tests/test262/language/statements/class/elements/static-field-redeclaration.js new file mode 100644 index 0000000000..8dc0da889a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/static-field-redeclaration.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/static-field-redeclaration.case +// - src/class-elements/default/cls-decl.template +/*--- +description: Static fields can be redeclared (field definitions in a class declaration) +esid: prod-FieldDefinition +features: [class-static-fields-public, class] +flags: [generated] +info: | + Updated Productions + + ClassElement : + ... + static FieldDefinition ; + + FieldDefinition : + ClassElementName Initializer_opt + + ClassDefinitionEvaluation: + ... + + 27. Let staticFields be a new empty List. + 28. For each ClassElement e in order from elements, + a. If IsStatic of e is false, then + ... + b. Else, + i. Let field be the result of performing PropertyDefinitionEvaluation for m ClassElementEvaluation for e with arguments F and false. + c. If field is an abrupt completion, then + ... + d. If field is not empty, + i. If IsStatic of e is false, append field to instanceFields. + ii. Otherwise, append field to staticFields. + + 34. For each item fieldRecord in order from staticFields, + a. Perform ? DefineField(F, field). + ... + + DefineField(receiver, fieldRecord) + 1. Assert: Type(receiver) is Object. + 2. Assert: fieldRecord is a Record as created by ClassFieldDefinitionEvaluation. + 3. Let name be fieldRecord.[[Name]]. + 4. Let initializer be fieldRecord.[[Initializer]]. + 5. If initializer is not empty, then + a. Let initValue be ? Call(initializer, receiver). + 6. Else, let initValue be undefined. + 7. If fieldRecord.[[IsAnonymousFunctionDefinition]] is true, then + a. Let hasNameProperty be ? HasOwnProperty(initValue, "name"). + b. If hasNameProperty is false, perform SetFunctionName(initValue, fieldName). + 8. If fieldName is a Private Name, + a. Perform ? PrivateFieldAdd(fieldName, receiver, initValue). + 9. Else, + a. Assert: IsPropertyKey(fieldName) is true. + b. Perform ? CreateDataPropertyOrThrow(receiver, fieldName, initValue). + 10. Return. + +---*/ + + +class C { + static f = 'test'; + static f = this.f + '262'; + static g() { + return 45; + }; + static g = this.g(); +} + +assert.sameValue(C.f, 'test262'); +assert.sameValue(C.g, 45); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/static-fielddefinition-initializer-abrupt-completion.js b/js/src/tests/test262/language/statements/class/elements/static-fielddefinition-initializer-abrupt-completion.js new file mode 100644 index 0000000000..c5985614d7 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/static-fielddefinition-initializer-abrupt-completion.js @@ -0,0 +1,35 @@ +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Class construction should error if evaluation of static field initializer errors +esid: runtime-semantics-class-definition-evaluation +info: | + Runtime Semantics: ClassDefinitionEvaluation + ... + 27. For each ClassElement e in order from elements + a. If IsStatic of e is false, then + i. Let fields be the result of performing ClassElementEvaluation + for e with arguments proto and false. + b. Else, + i. Let fields be the result of performing ClassElementEvaluation + for e with arguments F and false. + c. If fields is an abrupt completion, then + i. Set the running execution context's LexicalEnvironment to lex. + ii. Set the running execution context's PrivateNameEnvironment to outerPrivateEnvironment. + iii. Return Completion(status). + +features: [class-static-fields-public] +---*/ + +function f() { + throw new Test262Error(); +} + +assert.throws(Test262Error, function() { + class C { + static x = f(); + } +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/static-literal-init-err-contains-arguments.js b/js/src/tests/test262/language/statements/class/elements/static-literal-init-err-contains-arguments.js new file mode 100644 index 0000000000..5cd2212101 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/static-literal-init-err-contains-arguments.js @@ -0,0 +1,35 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/init-err-contains-arguments.case +// - src/class-elements/initializer-error/cls-decl-fields-static-literal-name.template +/*--- +description: Syntax error if `arguments` used in class field (static literal ClassElementName) +esid: sec-class-definitions-static-semantics-early-errors +features: [class, class-fields-public, class-static-fields-public] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Static Semantics: Early Errors + + FieldDefinition: + PropertyNameInitializeropt + + - It is a Syntax Error if ContainsArguments of Initializer is true. + + Static Semantics: ContainsArguments + IdentifierReference : Identifier + + 1. If the StringValue of Identifier is "arguments", return true. + ... + For all other grammatical productions, recurse on all nonterminals. If any piece returns true, then return true. Otherwise return false. + +---*/ + + +$DONOTEVALUATE(); + +class C { + static x = arguments; +} diff --git a/js/src/tests/test262/language/statements/class/elements/static-literal-init-err-contains-super.js b/js/src/tests/test262/language/statements/class/elements/static-literal-init-err-contains-super.js new file mode 100644 index 0000000000..562c076edc --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/static-literal-init-err-contains-super.js @@ -0,0 +1,28 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/init-err-contains-super.case +// - src/class-elements/initializer-error/cls-decl-fields-static-literal-name.template +/*--- +description: Syntax error if `super()` used in class field (static literal ClassElementName) +esid: sec-class-definitions-static-semantics-early-errors +features: [class, class-fields-public, class-static-fields-public] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Static Semantics: Early Errors + + FieldDefinition: + PropertyNameInitializeropt + + - It is a Syntax Error if Initializer is present and Initializer Contains SuperCall is true. + +---*/ + + +$DONOTEVALUATE(); + +class C { + static x = super(); +} diff --git a/js/src/tests/test262/language/statements/class/elements/static-private-fields-proxy-default-handler-throws.js b/js/src/tests/test262/language/statements/class/elements/static-private-fields-proxy-default-handler-throws.js new file mode 100644 index 0000000000..8752878264 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/static-private-fields-proxy-default-handler-throws.js @@ -0,0 +1,30 @@ +// Copyright (C) 2018 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-privatefieldget +description: Static private fields not accessible via default Proxy handler +info: | + 1. Assert: P is a Private Name value. + 2. If O is not an object, throw a TypeError exception. + 3. Let entry be PrivateFieldFind(P, O). + 4. If entry is empty, throw a TypeError exception. + +features: [class, class-static-fields-private] +---*/ + +class C { + static #x = 1; + static x() { + return this.#x; + } +} + +var P = new Proxy(C, {}); + +assert.sameValue(C.x(), 1); +assert.throws(TypeError, function() { + P.x(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/static-private-getter-access-on-inner-arrow-function.js b/js/src/tests/test262/language/statements/class/elements/static-private-getter-access-on-inner-arrow-function.js new file mode 100644 index 0000000000..d316074af0 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/static-private-getter-access-on-inner-arrow-function.js @@ -0,0 +1,46 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/static-private-getter-access-on-inner-arrow-function.case +// - src/class-elements/default/cls-decl.template +/*--- +description: static private getter access inside of an arrow function (field definitions in a class declaration) +esid: prod-FieldDefinition +features: [class-static-methods-private, class] +flags: [generated] +info: | + PrivateFieldGet (P, O) + 1. Assert: P is a Private Name. + 2. If O is not an object, throw a TypeError exception. + 3. If P.[[Kind]] is "field", + ... + 4. Perform ? PrivateBrandCheck(O, P). + 5. If P.[[Kind]] is "method", + a. Return P.[[Value]]. + ... + + PrivateBrandCheck(O, P) + 1. If O.[[PrivateBrands]] does not contain an entry e such that SameValue(e, P.[[Brand]]) is true, + a. Throw a TypeError exception. + +---*/ + + +class C { + static get #f() { + return 'Test262'; + } + + static access() { + const arrowFunction = () => { + return this.#f; + }; + + return arrowFunction(); + } +} + +assert.sameValue(C.access(), 'Test262'); +assert.throws(TypeError, function() { + C.access.call({}); +}, 'Accessed static private getter from an object which did not contain it'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/static-private-getter-access-on-inner-class.js b/js/src/tests/test262/language/statements/class/elements/static-private-getter-access-on-inner-class.js new file mode 100644 index 0000000000..5242a5170e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/static-private-getter-access-on-inner-class.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/static-private-getter-access-on-inner-class.case +// - src/class-elements/default/cls-decl.template +/*--- +description: static private getter access inside of an inner class (field definitions in a class declaration) +esid: prod-FieldDefinition +features: [class-static-methods-private, class-static-fields-public, class] +flags: [generated] +info: | + PrivateFieldGet (P, O) + 1. Assert: P is a Private Name. + 2. If O is not an object, throw a TypeError exception. + 3. If P.[[Kind]] is "field", + ... + 4. Perform ? PrivateBrandCheck(O, P). + 5. If P.[[Kind]] is "method", + a. Return P.[[Value]]. + ... + + PrivateBrandCheck(O, P) + 1. If O.[[PrivateBrands]] does not contain an entry e such that SameValue(e, P.[[Brand]]) is true, + a. Throw a TypeError exception. + +---*/ + + +class C { + static get #f() { + return 'Test262'; + } + + static Inner = class { + static access(o) { + return o.#f; + } + } +} + +assert.sameValue(C.Inner.access(C), 'Test262'); +assert.throws(TypeError, function() { + C.Inner.access(C.Inner); +}, 'Accessed static private getter from an object which did not contain it'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/static-private-getter-access-on-inner-function.js b/js/src/tests/test262/language/statements/class/elements/static-private-getter-access-on-inner-function.js new file mode 100644 index 0000000000..f1556f68b0 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/static-private-getter-access-on-inner-function.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/static-private-getter-access-on-inner-function.case +// - src/class-elements/default/cls-decl.template +/*--- +description: static private getter access inside of a nested function (field definitions in a class declaration) +esid: prod-FieldDefinition +features: [class-static-methods-private, class] +flags: [generated] +info: | + PrivateFieldGet (P, O) + 1. Assert: P is a Private Name. + 2. If O is not an object, throw a TypeError exception. + 3. If P.[[Kind]] is "field", + ... + 4. Perform ? PrivateBrandCheck(O, P). + 5. If P.[[Kind]] is "method", + a. Return P.[[Value]]. + ... + + PrivateBrandCheck(O, P) + 1. If O.[[PrivateBrands]] does not contain an entry e such that SameValue(e, P.[[Brand]]) is true, + a. Throw a TypeError exception. + +---*/ + + +class C { + static get #f() { + return 'Test262'; + } + + static access() { + const self = this; + + function innerFunction() { + return self.#f; + } + + return innerFunction(); + } +} + +assert.sameValue(C.access(), 'Test262'); +assert.throws(TypeError, function() { + C.access.call({}); +}, 'Accessed static private getter from an arbitrary object'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/static-private-getter.js b/js/src/tests/test262/language/statements/class/elements/static-private-getter.js new file mode 100644 index 0000000000..cf40d3fd0e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/static-private-getter.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/static-private-getter.case +// - src/class-elements/default/cls-decl.template +/*--- +description: static private getter declaration and usage (field definitions in a class declaration) +esid: prod-FieldDefinition +features: [class-static-methods-private, class] +flags: [generated] +info: | + MethodDefinition : + get ClassElementName () { FunctionBody } + set ClassElementName ( PropertySetParameterList ) { FunctionBody } + + ClassTail : ClassHeritage { ClassBody } + ... + 33. If PrivateBoundIdentifiers of ClassBody contains a Private Name P such that P's [[Kind]] field is either "method" or "accessor" and P's [[Brand]] is F, + a. PrivateBrandAdd(F, F). + 34. For each item fieldRecord in order from staticFields, + a. Perform ? DefineField(F, field). + + PrivateFieldGet (P, O) + 1. Assert: P is a Private Name. + 2. If O is not an object, throw a TypeError exception. + 3. If P.[[Kind]] is "field", + ... + 4. Perform ? PrivateBrandCheck(O, P). + 5. If P.[[Kind]] is "method", + ... + 6. Else, + a. Assert: P.[[Kind]] is "accessor". + b. If P does not have a [[Get]] field, throw a TypeError exception. + c. Let getter be P.[[Get]]. + d. Return ? Call(getter, O). + + PrivateBrandCheck(O, P) + 1. If O.[[PrivateBrands]] does not contain an entry e such that SameValue(e, P.[[Brand]]) is true, + a. Throw a TypeError exception. + +---*/ + + +class C { + static get #f() { + return 'Test262'; + } + + static access() { + return this.#f; + } +} + +assert.sameValue(C.access(), 'Test262'); +assert.throws(TypeError, function() { + C.access.call({}); +}, 'Accessed static private getter from an arbitrary object'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/static-private-init-err-contains-arguments.js b/js/src/tests/test262/language/statements/class/elements/static-private-init-err-contains-arguments.js new file mode 100644 index 0000000000..30ee50c855 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/static-private-init-err-contains-arguments.js @@ -0,0 +1,35 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/init-err-contains-arguments.case +// - src/class-elements/initializer-error/cls-decl-fields-static-private-name.template +/*--- +description: Syntax error if `arguments` used in class field (static PrivateName) +esid: sec-class-definitions-static-semantics-early-errors +features: [class, class-fields-public, class-static-fields-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Static Semantics: Early Errors + + FieldDefinition: + PropertyNameInitializeropt + + - It is a Syntax Error if ContainsArguments of Initializer is true. + + Static Semantics: ContainsArguments + IdentifierReference : Identifier + + 1. If the StringValue of Identifier is "arguments", return true. + ... + For all other grammatical productions, recurse on all nonterminals. If any piece returns true, then return true. Otherwise return false. + +---*/ + + +$DONOTEVALUATE(); + +class C { + static #x = arguments; +} diff --git a/js/src/tests/test262/language/statements/class/elements/static-private-init-err-contains-super.js b/js/src/tests/test262/language/statements/class/elements/static-private-init-err-contains-super.js new file mode 100644 index 0000000000..114c6d7109 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/static-private-init-err-contains-super.js @@ -0,0 +1,28 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/init-err-contains-super.case +// - src/class-elements/initializer-error/cls-decl-fields-static-private-name.template +/*--- +description: Syntax error if `super()` used in class field (static PrivateName) +esid: sec-class-definitions-static-semantics-early-errors +features: [class, class-fields-public, class-static-fields-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Static Semantics: Early Errors + + FieldDefinition: + PropertyNameInitializeropt + + - It is a Syntax Error if Initializer is present and Initializer Contains SuperCall is true. + +---*/ + + +$DONOTEVALUATE(); + +class C { + static #x = super(); +} diff --git a/js/src/tests/test262/language/statements/class/elements/static-private-method-access-on-inner-arrow-function.js b/js/src/tests/test262/language/statements/class/elements/static-private-method-access-on-inner-arrow-function.js new file mode 100644 index 0000000000..2145cefe5a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/static-private-method-access-on-inner-arrow-function.js @@ -0,0 +1,44 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/static-private-method-access-on-inner-arrow-function.case +// - src/class-elements/default/cls-decl.template +/*--- +description: Static private method access inside of an arrow function (field definitions in a class declaration) +esid: prod-FieldDefinition +features: [class-static-methods-private, class] +flags: [generated] +info: | + PrivateFieldGet (P, O) + 1. Assert: P is a Private Name. + 2. If O is not an object, throw a TypeError exception. + 3. If P.[[Kind]] is "field", + ... + 4. Perform ? PrivateBrandCheck(O, P). + 5. If P.[[Kind]] is "method", + a. Return P.[[Value]]. + ... + + PrivateBrandCheck(O, P) + 1. If O.[[PrivateBrands]] does not contain an entry e such that SameValue(e, P.[[Brand]]) is true, + a. Throw a TypeError exception. + +---*/ + + +class C { + static #f() { return 42; } + static g() { + const arrowFunction = () => { + return this.#f(); + }; + + return arrowFunction(); + } + +} + +assert.sameValue(C.g(), 42); +assert.throws(TypeError, function() { + C.g.call({}); +}, 'Accessed static private method from an object which did not contain it'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/static-private-method-access-on-inner-function.js b/js/src/tests/test262/language/statements/class/elements/static-private-method-access-on-inner-function.js new file mode 100644 index 0000000000..7e4d1b3a4a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/static-private-method-access-on-inner-function.js @@ -0,0 +1,46 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/static-private-method-access-on-inner-function.case +// - src/class-elements/default/cls-decl.template +/*--- +description: Static private method access inside of a nested function (field definitions in a class declaration) +esid: prod-FieldDefinition +features: [class-static-methods-private, class] +flags: [generated] +info: | + PrivateFieldGet (P, O) + 1. Assert: P is a Private Name. + 2. If O is not an object, throw a TypeError exception. + 3. If P.[[Kind]] is "field", + ... + 4. Perform ? PrivateBrandCheck(O, P). + 5. If P.[[Kind]] is "method", + a. Return P.[[Value]]. + ... + + PrivateBrandCheck(O, P) + 1. If O.[[PrivateBrands]] does not contain an entry e such that SameValue(e, P.[[Brand]]) is true, + a. Throw a TypeError exception. + +---*/ + + +class C { + static #f() { return 42; } + static g() { + const self = this; + + function innerFunction() { + return self.#f(); + } + + return innerFunction(); + } + +} + +assert.sameValue(C.g(), 42); +assert.throws(TypeError, function() { + C.g.call({}); +}, 'Accessed static private method from an object which did not contain it'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/static-private-method-and-instance-method-brand-check.js b/js/src/tests/test262/language/statements/class/elements/static-private-method-and-instance-method-brand-check.js new file mode 100644 index 0000000000..21a112a88c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/static-private-method-and-instance-method-brand-check.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/static-private-method-and-instance-method-brand-check.case +// - src/class-elements/default/cls-decl.template +/*--- +description: Brand for static private names and instance private names are different (field definitions in a class declaration) +esid: prod-FieldDefinition +features: [class-static-methods-private, class-methods-private, class] +flags: [generated] +info: | + ClassTail : ClassHeritage { ClassBody } + ... + 32. If PrivateBoundIdentifiers of ClassBody contains a Private Name P such that P's [[Kind]] field is either "method" or "accessor" and P's [[Brand]] field is proto, + a. Set F.[[PrivateBrand]] to proto. + 33. If PrivateBoundIdentifiers of ClassBody contains a Private Name P such that P's [[Kind]] field is either "method" or "accessor" and P's [[Brand]] is F, + a. PrivateBrandAdd(F, F). + ... + + PrivateFieldGet (P, O) + 1. Assert: P is a Private Name. + 2. If O is not an object, throw a TypeError exception. + 3. If P.[[Kind]] is "field", + ... + 4. Perform ? PrivateBrandCheck(O, P). + 5. If P.[[Kind]] is "method", + a. Return P.[[Value]]. + ... + + PrivateBrandCheck(O, P) + 1. If O.[[PrivateBrands]] does not contain an entry e such that SameValue(e, P.[[Brand]]) is true, + a. Throw a TypeError exception. + +---*/ + + +class C { + static #f() { + return 'static'; + } + + static access() { + return this.#f(); + } + + #instanceMethod() { + return 'instance'; + } + + instanceAccess() { + return this.#instanceMethod(); + } +} + +let c = new C(); +assert.sameValue(C.access(), 'static'); +assert.sameValue(c.instanceAccess(), 'instance'); + +assert.throws(TypeError, function() { + C.access.call(c); +}, 'Accessed static private method from instance of C'); + +assert.throws(TypeError, function() { + c.instanceAccess.call(C); +}, 'Accessed instance private method from C'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/static-private-method-referenced-from-instance-method.js b/js/src/tests/test262/language/statements/class/elements/static-private-method-referenced-from-instance-method.js new file mode 100644 index 0000000000..380b6409a7 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/static-private-method-referenced-from-instance-method.js @@ -0,0 +1,40 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/static-private-method-referenced-from-instance-method.case +// - src/class-elements/default/cls-decl.template +/*--- +description: Static private method referenced from an instance method (field definitions in a class declaration) +esid: prod-FieldDefinition +features: [class-static-methods-private, class] +flags: [generated] +info: | + PrivateFieldGet (P, O) + 1. Assert: P is a Private Name. + 2. If O is not an object, throw a TypeError exception. + 3. If P.[[Kind]] is "field", + ... + 4. Perform ? PrivateBrandCheck(O, P). + 5. If P.[[Kind]] is "method", + a. Return P.[[Value]]. + ... + + PrivateBrandCheck(O, P) + 1. If O.[[PrivateBrands]] does not contain an entry e such that SameValue(e, P.[[Brand]]) is true, + a. Throw a TypeError exception. + +---*/ + + +class C { + static #f() { return 42; } + g() { + return this.#f(); + } + +} + +assert.sameValue(new C().g.call(C), 42); +assert.throws(TypeError, function() { + new C().g(); +}, 'Accessed static private method from an object which did not contain it'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/static-private-method-subclass-receiver.js b/js/src/tests/test262/language/statements/class/elements/static-private-method-subclass-receiver.js new file mode 100644 index 0000000000..cf7c904247 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/static-private-method-subclass-receiver.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/static-private-method-subclass-receiver.case +// - src/class-elements/default/cls-decl.template +/*--- +description: Static private methods on the super-class cannot be called with sub-class as the receiver (field definitions in a class declaration) +esid: prod-FieldDefinition +features: [class-static-methods-private, class] +flags: [generated] +info: | + PrivateFieldGet (P, O) + 1. Assert: P is a Private Name. + 2. If O is not an object, throw a TypeError exception. + 3. If P.[[Kind]] is "field", + ... + 4. Perform ? PrivateBrandCheck(O, P). + 5. If P.[[Kind]] is "method", + a. Return P.[[Value]]. + ... + + PrivateBrandCheck(O, P) + 1. If O.[[PrivateBrands]] does not contain an entry e such that SameValue(e, P.[[Brand]]) is true, + a. Throw a TypeError exception. + +---*/ + + +class C { + static f() { return this.#g(); } + static #g() { return 42; } + +} + +class D extends C {} +assert.sameValue(C.f(), 42); +assert.throws(TypeError, function() { + D.f(); +}, 'D does not contain static private method #g'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/static-private-setter-access-on-inner-arrow-function.js b/js/src/tests/test262/language/statements/class/elements/static-private-setter-access-on-inner-arrow-function.js new file mode 100644 index 0000000000..224f85738b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/static-private-setter-access-on-inner-arrow-function.js @@ -0,0 +1,47 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/static-private-setter-access-on-inner-arrow-function.case +// - src/class-elements/default/cls-decl.template +/*--- +description: static private setter access inside of an arrow function (field definitions in a class declaration) +esid: prod-FieldDefinition +features: [class-static-methods-private, class] +flags: [generated] +info: | + PrivateFieldGet (P, O) + 1. Assert: P is a Private Name. + 2. If O is not an object, throw a TypeError exception. + 3. If P.[[Kind]] is "field", + ... + 4. Perform ? PrivateBrandCheck(O, P). + 5. If P.[[Kind]] is "method", + a. Return P.[[Value]]. + ... + + PrivateBrandCheck(O, P) + 1. If O.[[PrivateBrands]] does not contain an entry e such that SameValue(e, P.[[Brand]]) is true, + a. Throw a TypeError exception. + +---*/ + + +class C { + static set #f(v) { + this._v = v; + } + + static access() { + const arrowFunction = () => { + this.#f = 'Test262'; + }; + + arrowFunction(); + } +} + +C.access(); +assert.sameValue(C._v, 'Test262'); +assert.throws(TypeError, function() { + C.access.call({}); +}, 'Accessed static private setter from an object which did not contain it'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/static-private-setter-access-on-inner-class.js b/js/src/tests/test262/language/statements/class/elements/static-private-setter-access-on-inner-class.js new file mode 100644 index 0000000000..77fcb12d4e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/static-private-setter-access-on-inner-class.js @@ -0,0 +1,46 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/static-private-setter-access-on-inner-class.case +// - src/class-elements/default/cls-decl.template +/*--- +description: static private setter access inside of an inner class (field definitions in a class declaration) +esid: prod-FieldDefinition +features: [class-static-methods-private, class-static-fields-public, class] +flags: [generated] +info: | + PrivateFieldGet (P, O) + 1. Assert: P is a Private Name. + 2. If O is not an object, throw a TypeError exception. + 3. If P.[[Kind]] is "field", + ... + 4. Perform ? PrivateBrandCheck(O, P). + 5. If P.[[Kind]] is "method", + a. Return P.[[Value]]. + ... + + PrivateBrandCheck(O, P) + 1. If O.[[PrivateBrands]] does not contain an entry e such that SameValue(e, P.[[Brand]]) is true, + a. Throw a TypeError exception. + +---*/ + + +class C { + static set #f(v) { + return this._v = v; + } + + static Inner = class { + static access(o) { + o.#f = 'Test262'; + } + } + +} + +C.Inner.access(C) +assert.sameValue(C._v, 'Test262'); +assert.throws(TypeError, function() { + C.Inner.access(C.Inner); +}, 'Accessed static private setter from an object which did not contain it'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/static-private-setter-access-on-inner-function.js b/js/src/tests/test262/language/statements/class/elements/static-private-setter-access-on-inner-function.js new file mode 100644 index 0000000000..3781181dd7 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/static-private-setter-access-on-inner-function.js @@ -0,0 +1,49 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/static-private-setter-access-on-inner-function.case +// - src/class-elements/default/cls-decl.template +/*--- +description: static private setter access inside of a nested function (field definitions in a class declaration) +esid: prod-FieldDefinition +features: [class-static-methods-private, class] +flags: [generated] +info: | + PrivateFieldGet (P, O) + 1. Assert: P is a Private Name. + 2. If O is not an object, throw a TypeError exception. + 3. If P.[[Kind]] is "field", + ... + 4. Perform ? PrivateBrandCheck(O, P). + 5. If P.[[Kind]] is "method", + a. Return P.[[Value]]. + ... + + PrivateBrandCheck(O, P) + 1. If O.[[PrivateBrands]] does not contain an entry e such that SameValue(e, P.[[Brand]]) is true, + a. Throw a TypeError exception. + +---*/ + + +class C { + static set #f(v) { + this._v = v; + } + + static access() { + const self = this; + + function innerFunction() { + self.#f = 'Test262'; + } + + innerFunction(); + } +} + +C.access(); +assert.sameValue(C._v, 'Test262'); +assert.throws(TypeError, function() { + C.access.call({}); +}, 'Accessed static private setter from an arbitrary object'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/static-private-setter.js b/js/src/tests/test262/language/statements/class/elements/static-private-setter.js new file mode 100644 index 0000000000..c39699206f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/static-private-setter.js @@ -0,0 +1,58 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/static-private-setter.case +// - src/class-elements/default/cls-decl.template +/*--- +description: static private setter declaration and usage (field definitions in a class declaration) +esid: prod-FieldDefinition +features: [class-static-methods-private, class] +flags: [generated] +info: | + MethodDefinition : + get ClassElementName () { FunctionBody } + set ClassElementName ( PropertySetParameterList ) { FunctionBody } + + ClassTail : ClassHeritage { ClassBody } + ... + 33. If PrivateBoundIdentifiers of ClassBody contains a Private Name P such that P's [[Kind]] field is either "method" or "accessor" and P's [[Brand]] is F, + a. PrivateBrandAdd(F, F). + 34. For each item fieldRecord in order from staticFields, + a. Perform ? DefineField(F, field). + + PrivateFieldGet (P, O) + 1. Assert: P is a Private Name. + 2. If O is not an object, throw a TypeError exception. + 3. If P.[[Kind]] is "field", + ... + 4. Perform ? PrivateBrandCheck(O, P). + 5. If P.[[Kind]] is "method", + ... + 6. Else, + a. Assert: P.[[Kind]] is "accessor". + b. If P does not have a [[Get]] field, throw a TypeError exception. + c. Let getter be P.[[Get]]. + d. Return ? Call(getter, O). + + PrivateBrandCheck(O, P) + 1. If O.[[PrivateBrands]] does not contain an entry e such that SameValue(e, P.[[Brand]]) is true, + a. Throw a TypeError exception. + +---*/ + + +class C { + static set #f(v) { + this._v = v; + } + + static access() { + this.#f = 'Test262'; + } +} + +C.access(); +assert.sameValue(C._v, 'Test262'); +assert.throws(TypeError, function() { + C.access.call({}); +}, 'Accessed static private setter from an arbitrary object'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/static-string-literal-name-init-err-contains-arguments.js b/js/src/tests/test262/language/statements/class/elements/static-string-literal-name-init-err-contains-arguments.js new file mode 100644 index 0000000000..9be6b18025 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/static-string-literal-name-init-err-contains-arguments.js @@ -0,0 +1,35 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/init-err-contains-arguments.case +// - src/class-elements/initializer-error/cls-decl-fields-static-string-literal-name.template +/*--- +description: Syntax error if `arguments` used in class field (static string literal ClassElementName) +esid: sec-class-definitions-static-semantics-early-errors +features: [class, class-fields-public, class-static-fields-public] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Static Semantics: Early Errors + + FieldDefinition: + PropertyNameInitializeropt + + - It is a Syntax Error if ContainsArguments of Initializer is true. + + Static Semantics: ContainsArguments + IdentifierReference : Identifier + + 1. If the StringValue of Identifier is "arguments", return true. + ... + For all other grammatical productions, recurse on all nonterminals. If any piece returns true, then return true. Otherwise return false. + +---*/ + + +$DONOTEVALUATE(); + +class C { + static 'x' = arguments; +} diff --git a/js/src/tests/test262/language/statements/class/elements/static-string-literal-name-init-err-contains-super.js b/js/src/tests/test262/language/statements/class/elements/static-string-literal-name-init-err-contains-super.js new file mode 100644 index 0000000000..6cbe221dcc --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/static-string-literal-name-init-err-contains-super.js @@ -0,0 +1,28 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/init-err-contains-super.case +// - src/class-elements/initializer-error/cls-decl-fields-static-string-literal-name.template +/*--- +description: Syntax error if `super()` used in class field (static string literal ClassElementName) +esid: sec-class-definitions-static-semantics-early-errors +features: [class, class-fields-public, class-static-fields-public] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Static Semantics: Early Errors + + FieldDefinition: + PropertyNameInitializeropt + + - It is a Syntax Error if Initializer is present and Initializer Contains SuperCall is true. + +---*/ + + +$DONOTEVALUATE(); + +class C { + static 'x' = super(); +} diff --git a/js/src/tests/test262/language/statements/class/elements/string-literal-name-init-err-contains-arguments.js b/js/src/tests/test262/language/statements/class/elements/string-literal-name-init-err-contains-arguments.js new file mode 100644 index 0000000000..efdb64b913 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/string-literal-name-init-err-contains-arguments.js @@ -0,0 +1,35 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/init-err-contains-arguments.case +// - src/class-elements/initializer-error/cls-decl-fields-string-literal-name.template +/*--- +description: Syntax error if `arguments` used in class field (string literal ClassElementName) +esid: sec-class-definitions-static-semantics-early-errors +features: [class, class-fields-public] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Static Semantics: Early Errors + + FieldDefinition: + PropertyNameInitializeropt + + - It is a Syntax Error if ContainsArguments of Initializer is true. + + Static Semantics: ContainsArguments + IdentifierReference : Identifier + + 1. If the StringValue of Identifier is "arguments", return true. + ... + For all other grammatical productions, recurse on all nonterminals. If any piece returns true, then return true. Otherwise return false. + +---*/ + + +$DONOTEVALUATE(); + +class C { + 'x' = arguments; +} diff --git a/js/src/tests/test262/language/statements/class/elements/string-literal-name-init-err-contains-super.js b/js/src/tests/test262/language/statements/class/elements/string-literal-name-init-err-contains-super.js new file mode 100644 index 0000000000..d5bc2d2ddb --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/string-literal-name-init-err-contains-super.js @@ -0,0 +1,28 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/init-err-contains-super.case +// - src/class-elements/initializer-error/cls-decl-fields-string-literal-name.template +/*--- +description: Syntax error if `super()` used in class field (string literal ClassElementName) +esid: sec-class-definitions-static-semantics-early-errors +features: [class, class-fields-public] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Static Semantics: Early Errors + + FieldDefinition: + PropertyNameInitializeropt + + - It is a Syntax Error if Initializer is present and Initializer Contains SuperCall is true. + +---*/ + + +$DONOTEVALUATE(); + +class C { + 'x' = super(); +} diff --git a/js/src/tests/test262/language/statements/class/elements/super-access-from-arrow-func-on-field.js b/js/src/tests/test262/language/statements/class/elements/super-access-from-arrow-func-on-field.js new file mode 100644 index 0000000000..39b381e1ea --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/super-access-from-arrow-func-on-field.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/super-access-from-arrow-func-on-field.case +// - src/class-elements/default/cls-decl.template +/*--- +description: super inside arrow functions on field initializer resolves to class' super (field definitions in a class declaration) +esid: prod-FieldDefinition +features: [class-fields-public, class-static-fields-public, class] +flags: [generated] +info: | + ClassElementName : + PropertyName + PrivateName + + SuperProperty: + super[Expression] + super.IdentifierName + +---*/ + + +class C { + func = () => { + super.prop = 'test262'; + } + + static staticFunc = () => { + super.staticProp = 'static test262'; + } +} + +let c = new C(); +c.func(); +assert.sameValue(c.prop, 'test262'); + +C.staticFunc(); +assert.sameValue(C.staticProp, 'static test262'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/super-access-inside-a-private-getter.js b/js/src/tests/test262/language/statements/class/elements/super-access-inside-a-private-getter.js new file mode 100644 index 0000000000..72cb666ec7 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/super-access-inside-a-private-getter.js @@ -0,0 +1,52 @@ +// Copyright (C) 2019 Caio Lima (Igalia SL). All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Private getter contains proper HomeObject +esid: sec-method-definitions-runtime-semantics-classelementevaluation +info: | + MethodDefinition : get ClassElementName () { FunctionBody } + 1. Let key be the result of evaluating ClassElementName. + 2. ReturnIfAbrupt(key). + 3. If the function code for this MethodDefinition is strict mode code, let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let formalParameterList be an instance of the production FormalParameters:[empty] . + 6. Let closure be FunctionCreate(Method, formalParameterList, FunctionBody, scope, strict). + 7. Perform MakeMethod(closure, homeObject). + 8. Perform SetFunctionName(closure, key, "get"). + 9. If key is a Private Name, + a. If key has a [[Kind]] field, + i. Assert: key.[[Kind]] is "accessor". + ii. Assert: key.[[Brand]] is homeObject. + iii. Assert: key does not have a [[Get]] field. + iv. Set key.[[Get]] to closure. + b. Otherwise, + i. Set key.[[Kind]] to "accessor". + ii. Set key.[[Brand]] to homeObject. + iii. Set key.[[Get]] to closure. + 10. Else, + a. Let desc be the PropertyDescriptor{[[Get]]: closure, [[Enumerable]]: enumerable, [[Configurable]]: true}. + b. Perform ? DefinePropertyOrThrow(homeObject, key, desc). +features: [class-methods-private, class] +---*/ + +class A { + method() { + return "Test262"; + } +} + +class C extends A { + get #m() { + return super.method(); + } + + access() { + return this.#m; + } +} + +let c = new C(); +assert.sameValue(c.access(), "Test262"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/super-access-inside-a-private-method.js b/js/src/tests/test262/language/statements/class/elements/super-access-inside-a-private-method.js new file mode 100644 index 0000000000..df4478828f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/super-access-inside-a-private-method.js @@ -0,0 +1,52 @@ +// Copyright (C) 2019 Caio Lima (Igalia SL). All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Private method contains proper HomeObject +esid: sec-method-definitions-runtime-semantics-classelementevaluation +info: | + MethodDefinition : ClassElementName ( UniqueFormalParameters ) { FunctionBody } + 1. Let methodDef be DefineMethod of MethodDefinition with argument homeObject. + 2. ReturnIfAbrupt(methodDef). + 3. Perform ? DefineOrdinaryMethod(methodDef.[[Key]], homeObject, methodDef.[[Closure]], _enumerable). + + MethodDefinition : PropertyName ( UniqueFormalParameters ) { FunctionBody } + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. Let scope be the running execution context's LexicalEnvironment. + 4. If functionPrototype is present as a parameter, then + a. Let kind be Normal. + b. Let prototype be functionPrototype. + 5. Else, + a. Let kind be Method. + b. Let prototype be the intrinsic object %FunctionPrototype%. + 6. Let closure be FunctionCreate(kind, UniqueFormalParameters, FunctionBody, scope, prototype). + 7. Perform MakeMethod(closure, object). + 8. Set closure.[[SourceText]] to the source text matched by MethodDefinition. + 9. Return the Record { [[Key]]: propKey, [[Closure]]: closure }. +features: [class-methods-private, class] +---*/ + +class A { + method() { + return "Test262"; + } +} + +class C extends A { + #m() { + return super.method(); + } + + access(o) { + return this.#m.call(o); + } +} + +let c = new C(); +assert.sameValue(c.access(c), "Test262"); + +let o = {}; +assert.sameValue(c.access(o), "Test262"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/super-access-inside-a-private-setter.js b/js/src/tests/test262/language/statements/class/elements/super-access-inside-a-private-setter.js new file mode 100644 index 0000000000..3a95d15c89 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/super-access-inside-a-private-setter.js @@ -0,0 +1,52 @@ +// Copyright (C) 2019 Caio Lima (Igalia SL). All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Private setter contains proper HomeObject +esid: sec-method-definitions-runtime-semantics-classelementevaluation +info: | + MethodDefinition : set ClassElementName ( PropertySetParameterList ) { FunctionBody } + 1. Let key be the result of evaluating ClassElementName. + 2. ReturnIfAbrupt(key). + 3. If the function code for this MethodDefinition is strict mode code, let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be FunctionCreate(Method, PropertySetParameterList, FunctionBody, scope, strict). + 6. Perform MakeMethod(closure, homeObject). + 7. Perform SetFunctionName(closure, key, "set"). + 8. If key is a Private Name, + a. If key has a [[Kind]] field, + i. Assert: key.[[Kind]] is "accessor". + ii. Assert: key.[[Brand]] is homeObject. + iii. Assert: key does not have a [[Set]] field. + iv. Set key.[[Set]] to closure. + b. Otherwise, + i. Set key.[[Kind]] to "accessor". + ii. Set key.[[Brand]] to homeObject. + iii. Set key.[[Set]] to closure. + 9. Else, + a. Let desc be the PropertyDescriptor{[[Set]]: closure, [[Enumerable]]: enumerable, [[Configurable]]: true}. + b. Perform ? DefinePropertyOrThrow(homeObject, key, desc). +features: [class-methods-private, class] +---*/ + +class A { + method(v) { + return v; + } +} + +class C extends A { + set #m(v) { + this._v = super.method(v); + } + + access() { + return this.#m = "Test262"; + } +} + +let c = new C(); +c.access(); +assert.sameValue(c._v, "Test262"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/super-fielddefinition-initializer-abrupt-completion.js b/js/src/tests/test262/language/statements/class/elements/super-fielddefinition-initializer-abrupt-completion.js new file mode 100644 index 0000000000..f19282782f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/super-fielddefinition-initializer-abrupt-completion.js @@ -0,0 +1,58 @@ +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Class construction should error if evaluation of field initializer in super errors +esid: sec-super-keyword-runtime-semantics-evaluation +info: | + Runtime Semantics: Evaluation + SuperCall : superArguments + 1. Let newTarget be GetNewTarget(). + 2. If newTarget is undefined, throw a ReferenceError exception. + 3. Let func be ? GetSuperConstructor(). + 4. Let argList be ArgumentListEvaluation of Arguments. + 5. ReturnIfAbrupt(argList). + 6. Let result be ? Construct(func, argList, newTarget). + 7. Let thisER be GetThisEnvironment( ). + 8. Let F be thisER.[[FunctionObject]]. + 9. Assert: F is an ECMAScript function object. + 10. Perform ? InitializeInstanceFields(result, F). + + InitializeInstanceFields ( O, constructor ) + 1. Assert: Type ( O ) is Object. + 2. Assert: Assert constructor is an ECMAScript function object. + 3. Let fieldRecords be the value of constructor's [[Fields]] internal slot. + 4. For each item fieldRecord in order from fieldRecords, + a. If fieldRecord.[[static]] is false, then + i. Perform ? DefineField(O, fieldRecord). + + DefineField(receiver, fieldRecord) + 1. Assert: Type(receiver) is Object. + 2. Assert: fieldRecord is a Record as created by ClassFieldDefinitionEvaluation. + 3. Let fieldName be fieldRecord.[[Name]]. + 4. Let initializer be fieldRecord.[[Initializer]]. + 5. If initializer is not empty, then + a.Let initValue be ? Call(initializer, receiver). + +features: [class, class-fields-public] +---*/ + +function f() { + throw new Test262Error(); +} + +class A { + x = f(); +} + +class C extends A { + constructor() { + super(); + } +} + +assert.throws(Test262Error, function() { + new C(); +}) + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/browser.js b/js/src/tests/test262/language/statements/class/elements/syntax/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/browser.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/class-heritage-array-literal-arrow-heritage.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/class-heritage-array-literal-arrow-heritage.js new file mode 100644 index 0000000000..725572fa81 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/class-heritage-array-literal-arrow-heritage.js @@ -0,0 +1,26 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/class-heritage-array-literal-arrow-heritage.case +// - src/class-elements/syntax/invalid/cls-decl-elements-invalid-syntax.template +/*--- +description: It's a SyntaxError if an array literal evaluated on ClassHeritage uses a private name. (class declaration) +esid: prod-ClassElement +features: [class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassTail : ClassHeritage { ClassBody } + + ClassHeritage : + extends LeftHandSideExpression + +---*/ + + +$DONOTEVALUATE(); + +class C extends () => {} { + +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/class-heritage-array-literal-async-arrow-heritage.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/class-heritage-array-literal-async-arrow-heritage.js new file mode 100644 index 0000000000..64b65965ed --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/class-heritage-array-literal-async-arrow-heritage.js @@ -0,0 +1,26 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/class-heritage-array-literal-async-arrow-heritage.case +// - src/class-elements/syntax/invalid/cls-decl-elements-invalid-syntax.template +/*--- +description: It's a SyntaxError if an array literal evaluated on ClassHeritage uses a private name. (class declaration) +esid: prod-ClassElement +features: [class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassTail : ClassHeritage { ClassBody } + + ClassHeritage : + extends LeftHandSideExpression + +---*/ + + +$DONOTEVALUATE(); + +class C extends async () => {} { + +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/browser.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-covered-err-delete-call-expression-private-method-accessor-get.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-covered-err-delete-call-expression-private-method-accessor-get.js new file mode 100644 index 0000000000..048f87ae90 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-covered-err-delete-call-expression-private-method-accessor-get.js @@ -0,0 +1,42 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/err-delete-call-expression-private-method-accessor-get.case +// - src/class-elements/delete-error/cls-decl-field-delete-covered.template +/*--- +description: It's a SyntaxError if delete operator is applied to CallExpression.PrivateName accessor get method (in field, covered) +esid: sec-class-definitions-static-semantics-early-errors +features: [class-methods-private, class-fields-public, class, class-fields-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Static Semantics: Early Errors + + UnaryExpression : delete UnaryExpression + + It is a Syntax Error if the UnaryExpression is contained in strict mode + code and the derived UnaryExpression is + PrimaryExpression : IdentifierReference , + MemberExpression : MemberExpression.PrivateName , or + CallExpression : CallExpression.PrivateName . + + It is a Syntax Error if the derived UnaryExpression is + PrimaryExpression : CoverParenthesizedExpressionAndArrowParameterList and + CoverParenthesizedExpressionAndArrowParameterList ultimately derives a + phrase that, if used in place of UnaryExpression, would produce a + Syntax Error according to these rules. This rule is recursively applied. + +---*/ + + +$DONOTEVALUATE(); + +class C { + #x; + g = this.f; + x = delete (g().#m); + f() { + return this; + } +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-covered-err-delete-call-expression-private-method-accessor-set.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-covered-err-delete-call-expression-private-method-accessor-set.js new file mode 100644 index 0000000000..f1e82d4242 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-covered-err-delete-call-expression-private-method-accessor-set.js @@ -0,0 +1,42 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/err-delete-call-expression-private-method-accessor-set.case +// - src/class-elements/delete-error/cls-decl-field-delete-covered.template +/*--- +description: It's a SyntaxError if delete operator is applied to CallExpression.PrivateName accessor set method (in field, covered) +esid: sec-class-definitions-static-semantics-early-errors +features: [class, class-fields-private, class-methods-private, class-fields-public] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Static Semantics: Early Errors + + UnaryExpression : delete UnaryExpression + + It is a Syntax Error if the UnaryExpression is contained in strict mode + code and the derived UnaryExpression is + PrimaryExpression : IdentifierReference , + MemberExpression : MemberExpression.PrivateName , or + CallExpression : CallExpression.PrivateName . + + It is a Syntax Error if the derived UnaryExpression is + PrimaryExpression : CoverParenthesizedExpressionAndArrowParameterList and + CoverParenthesizedExpressionAndArrowParameterList ultimately derives a + phrase that, if used in place of UnaryExpression, would produce a + Syntax Error according to these rules. This rule is recursively applied. + +---*/ + + +$DONOTEVALUATE(); + +class C { + #x; + g = this.f; + x = delete (g().#m); + f() { + return this; + } +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-covered-err-delete-call-expression-private-method-async-gen.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-covered-err-delete-call-expression-private-method-async-gen.js new file mode 100644 index 0000000000..c01c57926d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-covered-err-delete-call-expression-private-method-async-gen.js @@ -0,0 +1,42 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/err-delete-call-expression-private-method-async-gen.case +// - src/class-elements/delete-error/cls-decl-field-delete-covered.template +/*--- +description: It's a SyntaxError if delete operator is applied to CallExpression.PrivateName async generator (in field, covered) +esid: sec-class-definitions-static-semantics-early-errors +features: [class-methods-private, async-iteration, class, class-fields-private, class-fields-public] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Static Semantics: Early Errors + + UnaryExpression : delete UnaryExpression + + It is a Syntax Error if the UnaryExpression is contained in strict mode + code and the derived UnaryExpression is + PrimaryExpression : IdentifierReference , + MemberExpression : MemberExpression.PrivateName , or + CallExpression : CallExpression.PrivateName . + + It is a Syntax Error if the derived UnaryExpression is + PrimaryExpression : CoverParenthesizedExpressionAndArrowParameterList and + CoverParenthesizedExpressionAndArrowParameterList ultimately derives a + phrase that, if used in place of UnaryExpression, would produce a + Syntax Error according to these rules. This rule is recursively applied. + +---*/ + + +$DONOTEVALUATE(); + +class C { + #x; + g = this.f; + x = delete (g().#m); + f() { + return this; + } +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-covered-err-delete-call-expression-private-method-async.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-covered-err-delete-call-expression-private-method-async.js new file mode 100644 index 0000000000..b1680d7470 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-covered-err-delete-call-expression-private-method-async.js @@ -0,0 +1,42 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/err-delete-call-expression-private-method-async.case +// - src/class-elements/delete-error/cls-decl-field-delete-covered.template +/*--- +description: It's a SyntaxError if delete operator is applied to CallExpression.PrivateName async method (in field, covered) +esid: sec-class-definitions-static-semantics-early-errors +features: [class-methods-private, async-functions, class, class-fields-private, class-fields-public] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Static Semantics: Early Errors + + UnaryExpression : delete UnaryExpression + + It is a Syntax Error if the UnaryExpression is contained in strict mode + code and the derived UnaryExpression is + PrimaryExpression : IdentifierReference , + MemberExpression : MemberExpression.PrivateName , or + CallExpression : CallExpression.PrivateName . + + It is a Syntax Error if the derived UnaryExpression is + PrimaryExpression : CoverParenthesizedExpressionAndArrowParameterList and + CoverParenthesizedExpressionAndArrowParameterList ultimately derives a + phrase that, if used in place of UnaryExpression, would produce a + Syntax Error according to these rules. This rule is recursively applied. + +---*/ + + +$DONOTEVALUATE(); + +class C { + #x; + g = this.f; + x = delete (g().#m); + f() { + return this; + } +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-covered-err-delete-call-expression-private-method-gen.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-covered-err-delete-call-expression-private-method-gen.js new file mode 100644 index 0000000000..8bc33c89ba --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-covered-err-delete-call-expression-private-method-gen.js @@ -0,0 +1,42 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/err-delete-call-expression-private-method-gen.case +// - src/class-elements/delete-error/cls-decl-field-delete-covered.template +/*--- +description: It's a SyntaxError if delete operator is applied to CallExpression.PrivateName generator (in field, covered) +esid: sec-class-definitions-static-semantics-early-errors +features: [class-methods-private, generators, class, class-fields-private, class-fields-public] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Static Semantics: Early Errors + + UnaryExpression : delete UnaryExpression + + It is a Syntax Error if the UnaryExpression is contained in strict mode + code and the derived UnaryExpression is + PrimaryExpression : IdentifierReference , + MemberExpression : MemberExpression.PrivateName , or + CallExpression : CallExpression.PrivateName . + + It is a Syntax Error if the derived UnaryExpression is + PrimaryExpression : CoverParenthesizedExpressionAndArrowParameterList and + CoverParenthesizedExpressionAndArrowParameterList ultimately derives a + phrase that, if used in place of UnaryExpression, would produce a + Syntax Error according to these rules. This rule is recursively applied. + +---*/ + + +$DONOTEVALUATE(); + +class C { + #x; + g = this.f; + x = delete (g().#m); + f() { + return this; + } +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-covered-err-delete-call-expression-private-method.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-covered-err-delete-call-expression-private-method.js new file mode 100644 index 0000000000..792f66b899 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-covered-err-delete-call-expression-private-method.js @@ -0,0 +1,42 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/err-delete-call-expression-private-method.case +// - src/class-elements/delete-error/cls-decl-field-delete-covered.template +/*--- +description: It's a SyntaxError if delete operator is applied to CallExpression.PrivateName private ordinary method (in field, covered) +esid: sec-class-definitions-static-semantics-early-errors +features: [class-methods-private, class, class-fields-private, class-fields-public] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Static Semantics: Early Errors + + UnaryExpression : delete UnaryExpression + + It is a Syntax Error if the UnaryExpression is contained in strict mode + code and the derived UnaryExpression is + PrimaryExpression : IdentifierReference , + MemberExpression : MemberExpression.PrivateName , or + CallExpression : CallExpression.PrivateName . + + It is a Syntax Error if the derived UnaryExpression is + PrimaryExpression : CoverParenthesizedExpressionAndArrowParameterList and + CoverParenthesizedExpressionAndArrowParameterList ultimately derives a + phrase that, if used in place of UnaryExpression, would produce a + Syntax Error according to these rules. This rule is recursively applied. + +---*/ + + +$DONOTEVALUATE(); + +class C { + #x; + g = this.f; + x = delete (g().#m); + f() { + return this; + } +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-covered-err-delete-call-expression-private-no-reference.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-covered-err-delete-call-expression-private-no-reference.js new file mode 100644 index 0000000000..3a2f9fc0ec --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-covered-err-delete-call-expression-private-no-reference.js @@ -0,0 +1,42 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/err-delete-call-expression-private-no-reference.case +// - src/class-elements/delete-error/cls-decl-field-delete-covered.template +/*--- +description: It's a SyntaxError if delete operator is applied to CallExpression.PrivateName no referencing class element (in field, covered) +esid: sec-class-definitions-static-semantics-early-errors +features: [class, class-fields-private, class-fields-public] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Static Semantics: Early Errors + + UnaryExpression : delete UnaryExpression + + It is a Syntax Error if the UnaryExpression is contained in strict mode + code and the derived UnaryExpression is + PrimaryExpression : IdentifierReference , + MemberExpression : MemberExpression.PrivateName , or + CallExpression : CallExpression.PrivateName . + + It is a Syntax Error if the derived UnaryExpression is + PrimaryExpression : CoverParenthesizedExpressionAndArrowParameterList and + CoverParenthesizedExpressionAndArrowParameterList ultimately derives a + phrase that, if used in place of UnaryExpression, would produce a + Syntax Error according to these rules. This rule is recursively applied. + +---*/ + + +$DONOTEVALUATE(); + +class C { + #x; + g = this.f; + x = delete (g().#m); + f() { + return this; + } +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-covered-err-delete-call-expression-privatename.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-covered-err-delete-call-expression-privatename.js new file mode 100644 index 0000000000..adcb626c91 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-covered-err-delete-call-expression-privatename.js @@ -0,0 +1,42 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/err-delete-call-expression-privatename.case +// - src/class-elements/delete-error/cls-decl-field-delete-covered.template +/*--- +description: It's a SyntaxError if delete operator is applied to CallExpression.PrivateName private field (in field, covered) +esid: sec-class-definitions-static-semantics-early-errors +features: [class, class-fields-private, class-fields-public] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Static Semantics: Early Errors + + UnaryExpression : delete UnaryExpression + + It is a Syntax Error if the UnaryExpression is contained in strict mode + code and the derived UnaryExpression is + PrimaryExpression : IdentifierReference , + MemberExpression : MemberExpression.PrivateName , or + CallExpression : CallExpression.PrivateName . + + It is a Syntax Error if the derived UnaryExpression is + PrimaryExpression : CoverParenthesizedExpressionAndArrowParameterList and + CoverParenthesizedExpressionAndArrowParameterList ultimately derives a + phrase that, if used in place of UnaryExpression, would produce a + Syntax Error according to these rules. This rule is recursively applied. + +---*/ + + +$DONOTEVALUATE(); + +class C { + #x; + g = this.f; + x = delete (g().#x); + f() { + return this; + } +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-covered-err-delete-member-expression-private-method-accessor-get.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-covered-err-delete-member-expression-private-method-accessor-get.js new file mode 100644 index 0000000000..d95a5b6e45 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-covered-err-delete-member-expression-private-method-accessor-get.js @@ -0,0 +1,41 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/err-delete-member-expression-private-method-accessor-get.case +// - src/class-elements/delete-error/cls-decl-field-delete-covered.template +/*--- +description: It's a SyntaxError if delete operator is applied to MemberExpression.PrivateName accessor get method (in field, covered) +esid: sec-class-definitions-static-semantics-early-errors +features: [class-methods-private, class, class-fields-private, class-fields-public] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Static Semantics: Early Errors + + UnaryExpression : delete UnaryExpression + + It is a Syntax Error if the UnaryExpression is contained in strict mode + code and the derived UnaryExpression is + PrimaryExpression : IdentifierReference , + MemberExpression : MemberExpression.PrivateName , or + CallExpression : CallExpression.PrivateName . + + It is a Syntax Error if the derived UnaryExpression is + PrimaryExpression : CoverParenthesizedExpressionAndArrowParameterList and + CoverParenthesizedExpressionAndArrowParameterList ultimately derives a + phrase that, if used in place of UnaryExpression, would produce a + Syntax Error according to these rules. This rule is recursively applied. + +---*/ + + +$DONOTEVALUATE(); + +class C { + #x; + + x = delete (this.#m +); + +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-covered-err-delete-member-expression-private-method-accessor-set.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-covered-err-delete-member-expression-private-method-accessor-set.js new file mode 100644 index 0000000000..76c28d6d14 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-covered-err-delete-member-expression-private-method-accessor-set.js @@ -0,0 +1,41 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/err-delete-member-expression-private-method-accessor-set.case +// - src/class-elements/delete-error/cls-decl-field-delete-covered.template +/*--- +description: It's a SyntaxError if delete operator is applied to MemberExpression.PrivateName accessor set method (in field, covered) +esid: sec-class-definitions-static-semantics-early-errors +features: [class-methods-private, class, class-fields-private, class-fields-public] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Static Semantics: Early Errors + + UnaryExpression : delete UnaryExpression + + It is a Syntax Error if the UnaryExpression is contained in strict mode + code and the derived UnaryExpression is + PrimaryExpression : IdentifierReference , + MemberExpression : MemberExpression.PrivateName , or + CallExpression : CallExpression.PrivateName . + + It is a Syntax Error if the derived UnaryExpression is + PrimaryExpression : CoverParenthesizedExpressionAndArrowParameterList and + CoverParenthesizedExpressionAndArrowParameterList ultimately derives a + phrase that, if used in place of UnaryExpression, would produce a + Syntax Error according to these rules. This rule is recursively applied. + +---*/ + + +$DONOTEVALUATE(); + +class C { + #x; + + x = delete (this.#m +); + +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-covered-err-delete-member-expression-private-method-async-gen.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-covered-err-delete-member-expression-private-method-async-gen.js new file mode 100644 index 0000000000..6716eb230d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-covered-err-delete-member-expression-private-method-async-gen.js @@ -0,0 +1,41 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/err-delete-member-expression-private-method-async-gen.case +// - src/class-elements/delete-error/cls-decl-field-delete-covered.template +/*--- +description: It's a SyntaxError if delete operator is applied to MemberExpression.PrivateName async generator (in field, covered) +esid: sec-class-definitions-static-semantics-early-errors +features: [class-methods-private, async-iteration, class, class-fields-private, class-fields-public] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Static Semantics: Early Errors + + UnaryExpression : delete UnaryExpression + + It is a Syntax Error if the UnaryExpression is contained in strict mode + code and the derived UnaryExpression is + PrimaryExpression : IdentifierReference , + MemberExpression : MemberExpression.PrivateName , or + CallExpression : CallExpression.PrivateName . + + It is a Syntax Error if the derived UnaryExpression is + PrimaryExpression : CoverParenthesizedExpressionAndArrowParameterList and + CoverParenthesizedExpressionAndArrowParameterList ultimately derives a + phrase that, if used in place of UnaryExpression, would produce a + Syntax Error according to these rules. This rule is recursively applied. + +---*/ + + +$DONOTEVALUATE(); + +class C { + #x; + + x = delete (this.#m +); + async *#m() {} +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-covered-err-delete-member-expression-private-method-async.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-covered-err-delete-member-expression-private-method-async.js new file mode 100644 index 0000000000..6e0de9f02e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-covered-err-delete-member-expression-private-method-async.js @@ -0,0 +1,41 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/err-delete-member-expression-private-method-async.case +// - src/class-elements/delete-error/cls-decl-field-delete-covered.template +/*--- +description: It's a SyntaxError if delete operator is applied to MemberExpression.PrivateName async method (in field, covered) +esid: sec-class-definitions-static-semantics-early-errors +features: [class-methods-private, async-functions, class, class-fields-private, class-fields-public] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Static Semantics: Early Errors + + UnaryExpression : delete UnaryExpression + + It is a Syntax Error if the UnaryExpression is contained in strict mode + code and the derived UnaryExpression is + PrimaryExpression : IdentifierReference , + MemberExpression : MemberExpression.PrivateName , or + CallExpression : CallExpression.PrivateName . + + It is a Syntax Error if the derived UnaryExpression is + PrimaryExpression : CoverParenthesizedExpressionAndArrowParameterList and + CoverParenthesizedExpressionAndArrowParameterList ultimately derives a + phrase that, if used in place of UnaryExpression, would produce a + Syntax Error according to these rules. This rule is recursively applied. + +---*/ + + +$DONOTEVALUATE(); + +class C { + #x; + + x = delete (this.#m +); + async #m() {} +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-covered-err-delete-member-expression-private-method-gen.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-covered-err-delete-member-expression-private-method-gen.js new file mode 100644 index 0000000000..34b4efadd9 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-covered-err-delete-member-expression-private-method-gen.js @@ -0,0 +1,41 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/err-delete-member-expression-private-method-gen.case +// - src/class-elements/delete-error/cls-decl-field-delete-covered.template +/*--- +description: It's a SyntaxError if delete operator is applied to MemberExpression.PrivateName generator (in field, covered) +esid: sec-class-definitions-static-semantics-early-errors +features: [class-methods-private, generators, class, class-fields-private, class-fields-public] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Static Semantics: Early Errors + + UnaryExpression : delete UnaryExpression + + It is a Syntax Error if the UnaryExpression is contained in strict mode + code and the derived UnaryExpression is + PrimaryExpression : IdentifierReference , + MemberExpression : MemberExpression.PrivateName , or + CallExpression : CallExpression.PrivateName . + + It is a Syntax Error if the derived UnaryExpression is + PrimaryExpression : CoverParenthesizedExpressionAndArrowParameterList and + CoverParenthesizedExpressionAndArrowParameterList ultimately derives a + phrase that, if used in place of UnaryExpression, would produce a + Syntax Error according to these rules. This rule is recursively applied. + +---*/ + + +$DONOTEVALUATE(); + +class C { + #x; + + x = delete (this.#m +); + *#m() {} +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-covered-err-delete-member-expression-private-method.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-covered-err-delete-member-expression-private-method.js new file mode 100644 index 0000000000..2cfddf0c62 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-covered-err-delete-member-expression-private-method.js @@ -0,0 +1,41 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/err-delete-member-expression-private-method.case +// - src/class-elements/delete-error/cls-decl-field-delete-covered.template +/*--- +description: It's a SyntaxError if delete operator is applied to MemberExpression.PrivateName private ordinary method (in field, covered) +esid: sec-class-definitions-static-semantics-early-errors +features: [class-methods-private, class, class-fields-private, class-fields-public] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Static Semantics: Early Errors + + UnaryExpression : delete UnaryExpression + + It is a Syntax Error if the UnaryExpression is contained in strict mode + code and the derived UnaryExpression is + PrimaryExpression : IdentifierReference , + MemberExpression : MemberExpression.PrivateName , or + CallExpression : CallExpression.PrivateName . + + It is a Syntax Error if the derived UnaryExpression is + PrimaryExpression : CoverParenthesizedExpressionAndArrowParameterList and + CoverParenthesizedExpressionAndArrowParameterList ultimately derives a + phrase that, if used in place of UnaryExpression, would produce a + Syntax Error according to these rules. This rule is recursively applied. + +---*/ + + +$DONOTEVALUATE(); + +class C { + #x; + + x = delete (this.#m +); + +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-covered-err-delete-member-expression-private-no-reference.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-covered-err-delete-member-expression-private-no-reference.js new file mode 100644 index 0000000000..0b939313b7 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-covered-err-delete-member-expression-private-no-reference.js @@ -0,0 +1,40 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/err-delete-member-expression-private-no-reference.case +// - src/class-elements/delete-error/cls-decl-field-delete-covered.template +/*--- +description: It's a SyntaxError if delete operator is applied to MemberExpression.PrivateName no referencing class element (in field, covered) +esid: sec-class-definitions-static-semantics-early-errors +features: [class, class-fields-private, class-fields-public] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Static Semantics: Early Errors + + UnaryExpression : delete UnaryExpression + + It is a Syntax Error if the UnaryExpression is contained in strict mode + code and the derived UnaryExpression is + PrimaryExpression : IdentifierReference , + MemberExpression : MemberExpression.PrivateName , or + CallExpression : CallExpression.PrivateName . + + It is a Syntax Error if the derived UnaryExpression is + PrimaryExpression : CoverParenthesizedExpressionAndArrowParameterList and + CoverParenthesizedExpressionAndArrowParameterList ultimately derives a + phrase that, if used in place of UnaryExpression, would produce a + Syntax Error according to these rules. This rule is recursively applied. + +---*/ + + +$DONOTEVALUATE(); + +class C { + #x; + + x = delete (this.#m); + +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-covered-err-delete-member-expression-privatename.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-covered-err-delete-member-expression-privatename.js new file mode 100644 index 0000000000..c532a4fa2d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-covered-err-delete-member-expression-privatename.js @@ -0,0 +1,40 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/err-delete-member-expression-privatename.case +// - src/class-elements/delete-error/cls-decl-field-delete-covered.template +/*--- +description: It's a SyntaxError if delete operator is applied to MemberExpression.PrivateName private field (in field, covered) +esid: sec-class-definitions-static-semantics-early-errors +features: [class, class-fields-private, class-fields-public] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Static Semantics: Early Errors + + UnaryExpression : delete UnaryExpression + + It is a Syntax Error if the UnaryExpression is contained in strict mode + code and the derived UnaryExpression is + PrimaryExpression : IdentifierReference , + MemberExpression : MemberExpression.PrivateName , or + CallExpression : CallExpression.PrivateName . + + It is a Syntax Error if the derived UnaryExpression is + PrimaryExpression : CoverParenthesizedExpressionAndArrowParameterList and + CoverParenthesizedExpressionAndArrowParameterList ultimately derives a + phrase that, if used in place of UnaryExpression, would produce a + Syntax Error according to these rules. This rule is recursively applied. + +---*/ + + +$DONOTEVALUATE(); + +class C { + #x; + + x = delete (this.#x); + +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-err-delete-call-expression-private-method-accessor-get.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-err-delete-call-expression-private-method-accessor-get.js new file mode 100644 index 0000000000..375e2833c8 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-err-delete-call-expression-private-method-accessor-get.js @@ -0,0 +1,39 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/err-delete-call-expression-private-method-accessor-get.case +// - src/class-elements/delete-error/cls-decl-field-delete.template +/*--- +description: It's a SyntaxError if delete operator is applied to CallExpression.PrivateName accessor get method (in field) +esid: sec-class-definitions-static-semantics-early-errors +features: [class-methods-private, class-fields-public, class, class-fields-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + This file must never use the onlyStrict flag as the strict mode should always + be observed inside class bodies. + + Static Semantics: Early Errors + + UnaryExpression : delete UnaryExpression + + It is a Syntax Error if the UnaryExpression is contained in strict mode + code and the derived UnaryExpression is + PrimaryExpression : IdentifierReference , + MemberExpression : MemberExpression.PrivateName , or + CallExpression : CallExpression.PrivateName . + +---*/ + + +$DONOTEVALUATE(); + +class C { + #x; + g = this.f; + x = delete g().#m; + f() { + return this; + } +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-err-delete-call-expression-private-method-accessor-set.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-err-delete-call-expression-private-method-accessor-set.js new file mode 100644 index 0000000000..b339bee24d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-err-delete-call-expression-private-method-accessor-set.js @@ -0,0 +1,39 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/err-delete-call-expression-private-method-accessor-set.case +// - src/class-elements/delete-error/cls-decl-field-delete.template +/*--- +description: It's a SyntaxError if delete operator is applied to CallExpression.PrivateName accessor set method (in field) +esid: sec-class-definitions-static-semantics-early-errors +features: [class, class-fields-private, class-methods-private, class-fields-public] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + This file must never use the onlyStrict flag as the strict mode should always + be observed inside class bodies. + + Static Semantics: Early Errors + + UnaryExpression : delete UnaryExpression + + It is a Syntax Error if the UnaryExpression is contained in strict mode + code and the derived UnaryExpression is + PrimaryExpression : IdentifierReference , + MemberExpression : MemberExpression.PrivateName , or + CallExpression : CallExpression.PrivateName . + +---*/ + + +$DONOTEVALUATE(); + +class C { + #x; + g = this.f; + x = delete g().#m; + f() { + return this; + } +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-err-delete-call-expression-private-method-async-gen.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-err-delete-call-expression-private-method-async-gen.js new file mode 100644 index 0000000000..4d5768d06f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-err-delete-call-expression-private-method-async-gen.js @@ -0,0 +1,39 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/err-delete-call-expression-private-method-async-gen.case +// - src/class-elements/delete-error/cls-decl-field-delete.template +/*--- +description: It's a SyntaxError if delete operator is applied to CallExpression.PrivateName async generator (in field) +esid: sec-class-definitions-static-semantics-early-errors +features: [class-methods-private, async-iteration, class, class-fields-private, class-fields-public] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + This file must never use the onlyStrict flag as the strict mode should always + be observed inside class bodies. + + Static Semantics: Early Errors + + UnaryExpression : delete UnaryExpression + + It is a Syntax Error if the UnaryExpression is contained in strict mode + code and the derived UnaryExpression is + PrimaryExpression : IdentifierReference , + MemberExpression : MemberExpression.PrivateName , or + CallExpression : CallExpression.PrivateName . + +---*/ + + +$DONOTEVALUATE(); + +class C { + #x; + g = this.f; + x = delete g().#m; + f() { + return this; + } +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-err-delete-call-expression-private-method-async.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-err-delete-call-expression-private-method-async.js new file mode 100644 index 0000000000..65f6b800af --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-err-delete-call-expression-private-method-async.js @@ -0,0 +1,39 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/err-delete-call-expression-private-method-async.case +// - src/class-elements/delete-error/cls-decl-field-delete.template +/*--- +description: It's a SyntaxError if delete operator is applied to CallExpression.PrivateName async method (in field) +esid: sec-class-definitions-static-semantics-early-errors +features: [class-methods-private, async-functions, class, class-fields-private, class-fields-public] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + This file must never use the onlyStrict flag as the strict mode should always + be observed inside class bodies. + + Static Semantics: Early Errors + + UnaryExpression : delete UnaryExpression + + It is a Syntax Error if the UnaryExpression is contained in strict mode + code and the derived UnaryExpression is + PrimaryExpression : IdentifierReference , + MemberExpression : MemberExpression.PrivateName , or + CallExpression : CallExpression.PrivateName . + +---*/ + + +$DONOTEVALUATE(); + +class C { + #x; + g = this.f; + x = delete g().#m; + f() { + return this; + } +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-err-delete-call-expression-private-method-gen.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-err-delete-call-expression-private-method-gen.js new file mode 100644 index 0000000000..e06dbede59 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-err-delete-call-expression-private-method-gen.js @@ -0,0 +1,39 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/err-delete-call-expression-private-method-gen.case +// - src/class-elements/delete-error/cls-decl-field-delete.template +/*--- +description: It's a SyntaxError if delete operator is applied to CallExpression.PrivateName generator (in field) +esid: sec-class-definitions-static-semantics-early-errors +features: [class-methods-private, generators, class, class-fields-private, class-fields-public] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + This file must never use the onlyStrict flag as the strict mode should always + be observed inside class bodies. + + Static Semantics: Early Errors + + UnaryExpression : delete UnaryExpression + + It is a Syntax Error if the UnaryExpression is contained in strict mode + code and the derived UnaryExpression is + PrimaryExpression : IdentifierReference , + MemberExpression : MemberExpression.PrivateName , or + CallExpression : CallExpression.PrivateName . + +---*/ + + +$DONOTEVALUATE(); + +class C { + #x; + g = this.f; + x = delete g().#m; + f() { + return this; + } +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-err-delete-call-expression-private-method.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-err-delete-call-expression-private-method.js new file mode 100644 index 0000000000..8de8b86e6e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-err-delete-call-expression-private-method.js @@ -0,0 +1,39 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/err-delete-call-expression-private-method.case +// - src/class-elements/delete-error/cls-decl-field-delete.template +/*--- +description: It's a SyntaxError if delete operator is applied to CallExpression.PrivateName private ordinary method (in field) +esid: sec-class-definitions-static-semantics-early-errors +features: [class-methods-private, class, class-fields-private, class-fields-public] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + This file must never use the onlyStrict flag as the strict mode should always + be observed inside class bodies. + + Static Semantics: Early Errors + + UnaryExpression : delete UnaryExpression + + It is a Syntax Error if the UnaryExpression is contained in strict mode + code and the derived UnaryExpression is + PrimaryExpression : IdentifierReference , + MemberExpression : MemberExpression.PrivateName , or + CallExpression : CallExpression.PrivateName . + +---*/ + + +$DONOTEVALUATE(); + +class C { + #x; + g = this.f; + x = delete g().#m; + f() { + return this; + } +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-err-delete-call-expression-private-no-reference.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-err-delete-call-expression-private-no-reference.js new file mode 100644 index 0000000000..a4b681b2c0 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-err-delete-call-expression-private-no-reference.js @@ -0,0 +1,39 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/err-delete-call-expression-private-no-reference.case +// - src/class-elements/delete-error/cls-decl-field-delete.template +/*--- +description: It's a SyntaxError if delete operator is applied to CallExpression.PrivateName no referencing class element (in field) +esid: sec-class-definitions-static-semantics-early-errors +features: [class, class-fields-private, class-fields-public] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + This file must never use the onlyStrict flag as the strict mode should always + be observed inside class bodies. + + Static Semantics: Early Errors + + UnaryExpression : delete UnaryExpression + + It is a Syntax Error if the UnaryExpression is contained in strict mode + code and the derived UnaryExpression is + PrimaryExpression : IdentifierReference , + MemberExpression : MemberExpression.PrivateName , or + CallExpression : CallExpression.PrivateName . + +---*/ + + +$DONOTEVALUATE(); + +class C { + #x; + g = this.f; + x = delete g().#m; + f() { + return this; + } +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-err-delete-call-expression-privatename.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-err-delete-call-expression-privatename.js new file mode 100644 index 0000000000..23398a4b22 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-err-delete-call-expression-privatename.js @@ -0,0 +1,39 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/err-delete-call-expression-privatename.case +// - src/class-elements/delete-error/cls-decl-field-delete.template +/*--- +description: It's a SyntaxError if delete operator is applied to CallExpression.PrivateName private field (in field) +esid: sec-class-definitions-static-semantics-early-errors +features: [class, class-fields-private, class-fields-public] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + This file must never use the onlyStrict flag as the strict mode should always + be observed inside class bodies. + + Static Semantics: Early Errors + + UnaryExpression : delete UnaryExpression + + It is a Syntax Error if the UnaryExpression is contained in strict mode + code and the derived UnaryExpression is + PrimaryExpression : IdentifierReference , + MemberExpression : MemberExpression.PrivateName , or + CallExpression : CallExpression.PrivateName . + +---*/ + + +$DONOTEVALUATE(); + +class C { + #x; + g = this.f; + x = delete g().#x; + f() { + return this; + } +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-err-delete-member-expression-private-method-accessor-get.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-err-delete-member-expression-private-method-accessor-get.js new file mode 100644 index 0000000000..ff62273759 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-err-delete-member-expression-private-method-accessor-get.js @@ -0,0 +1,38 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/err-delete-member-expression-private-method-accessor-get.case +// - src/class-elements/delete-error/cls-decl-field-delete.template +/*--- +description: It's a SyntaxError if delete operator is applied to MemberExpression.PrivateName accessor get method (in field) +esid: sec-class-definitions-static-semantics-early-errors +features: [class-methods-private, class, class-fields-private, class-fields-public] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + This file must never use the onlyStrict flag as the strict mode should always + be observed inside class bodies. + + Static Semantics: Early Errors + + UnaryExpression : delete UnaryExpression + + It is a Syntax Error if the UnaryExpression is contained in strict mode + code and the derived UnaryExpression is + PrimaryExpression : IdentifierReference , + MemberExpression : MemberExpression.PrivateName , or + CallExpression : CallExpression.PrivateName . + +---*/ + + +$DONOTEVALUATE(); + +class C { + #x; + + x = delete this.#m +; + +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-err-delete-member-expression-private-method-accessor-set.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-err-delete-member-expression-private-method-accessor-set.js new file mode 100644 index 0000000000..443d044fe8 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-err-delete-member-expression-private-method-accessor-set.js @@ -0,0 +1,38 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/err-delete-member-expression-private-method-accessor-set.case +// - src/class-elements/delete-error/cls-decl-field-delete.template +/*--- +description: It's a SyntaxError if delete operator is applied to MemberExpression.PrivateName accessor set method (in field) +esid: sec-class-definitions-static-semantics-early-errors +features: [class-methods-private, class, class-fields-private, class-fields-public] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + This file must never use the onlyStrict flag as the strict mode should always + be observed inside class bodies. + + Static Semantics: Early Errors + + UnaryExpression : delete UnaryExpression + + It is a Syntax Error if the UnaryExpression is contained in strict mode + code and the derived UnaryExpression is + PrimaryExpression : IdentifierReference , + MemberExpression : MemberExpression.PrivateName , or + CallExpression : CallExpression.PrivateName . + +---*/ + + +$DONOTEVALUATE(); + +class C { + #x; + + x = delete this.#m +; + +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-err-delete-member-expression-private-method-async-gen.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-err-delete-member-expression-private-method-async-gen.js new file mode 100644 index 0000000000..957c608694 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-err-delete-member-expression-private-method-async-gen.js @@ -0,0 +1,38 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/err-delete-member-expression-private-method-async-gen.case +// - src/class-elements/delete-error/cls-decl-field-delete.template +/*--- +description: It's a SyntaxError if delete operator is applied to MemberExpression.PrivateName async generator (in field) +esid: sec-class-definitions-static-semantics-early-errors +features: [class-methods-private, async-iteration, class, class-fields-private, class-fields-public] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + This file must never use the onlyStrict flag as the strict mode should always + be observed inside class bodies. + + Static Semantics: Early Errors + + UnaryExpression : delete UnaryExpression + + It is a Syntax Error if the UnaryExpression is contained in strict mode + code and the derived UnaryExpression is + PrimaryExpression : IdentifierReference , + MemberExpression : MemberExpression.PrivateName , or + CallExpression : CallExpression.PrivateName . + +---*/ + + +$DONOTEVALUATE(); + +class C { + #x; + + x = delete this.#m +; + async *#m() {} +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-err-delete-member-expression-private-method-async.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-err-delete-member-expression-private-method-async.js new file mode 100644 index 0000000000..9d3045d1fe --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-err-delete-member-expression-private-method-async.js @@ -0,0 +1,38 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/err-delete-member-expression-private-method-async.case +// - src/class-elements/delete-error/cls-decl-field-delete.template +/*--- +description: It's a SyntaxError if delete operator is applied to MemberExpression.PrivateName async method (in field) +esid: sec-class-definitions-static-semantics-early-errors +features: [class-methods-private, async-functions, class, class-fields-private, class-fields-public] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + This file must never use the onlyStrict flag as the strict mode should always + be observed inside class bodies. + + Static Semantics: Early Errors + + UnaryExpression : delete UnaryExpression + + It is a Syntax Error if the UnaryExpression is contained in strict mode + code and the derived UnaryExpression is + PrimaryExpression : IdentifierReference , + MemberExpression : MemberExpression.PrivateName , or + CallExpression : CallExpression.PrivateName . + +---*/ + + +$DONOTEVALUATE(); + +class C { + #x; + + x = delete this.#m +; + async #m() {} +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-err-delete-member-expression-private-method-gen.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-err-delete-member-expression-private-method-gen.js new file mode 100644 index 0000000000..841b0e7a85 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-err-delete-member-expression-private-method-gen.js @@ -0,0 +1,38 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/err-delete-member-expression-private-method-gen.case +// - src/class-elements/delete-error/cls-decl-field-delete.template +/*--- +description: It's a SyntaxError if delete operator is applied to MemberExpression.PrivateName generator (in field) +esid: sec-class-definitions-static-semantics-early-errors +features: [class-methods-private, generators, class, class-fields-private, class-fields-public] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + This file must never use the onlyStrict flag as the strict mode should always + be observed inside class bodies. + + Static Semantics: Early Errors + + UnaryExpression : delete UnaryExpression + + It is a Syntax Error if the UnaryExpression is contained in strict mode + code and the derived UnaryExpression is + PrimaryExpression : IdentifierReference , + MemberExpression : MemberExpression.PrivateName , or + CallExpression : CallExpression.PrivateName . + +---*/ + + +$DONOTEVALUATE(); + +class C { + #x; + + x = delete this.#m +; + *#m() {} +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-err-delete-member-expression-private-method.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-err-delete-member-expression-private-method.js new file mode 100644 index 0000000000..75017d0272 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-err-delete-member-expression-private-method.js @@ -0,0 +1,38 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/err-delete-member-expression-private-method.case +// - src/class-elements/delete-error/cls-decl-field-delete.template +/*--- +description: It's a SyntaxError if delete operator is applied to MemberExpression.PrivateName private ordinary method (in field) +esid: sec-class-definitions-static-semantics-early-errors +features: [class-methods-private, class, class-fields-private, class-fields-public] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + This file must never use the onlyStrict flag as the strict mode should always + be observed inside class bodies. + + Static Semantics: Early Errors + + UnaryExpression : delete UnaryExpression + + It is a Syntax Error if the UnaryExpression is contained in strict mode + code and the derived UnaryExpression is + PrimaryExpression : IdentifierReference , + MemberExpression : MemberExpression.PrivateName , or + CallExpression : CallExpression.PrivateName . + +---*/ + + +$DONOTEVALUATE(); + +class C { + #x; + + x = delete this.#m +; + +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-err-delete-member-expression-private-no-reference.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-err-delete-member-expression-private-no-reference.js new file mode 100644 index 0000000000..b36c9bfe9d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-err-delete-member-expression-private-no-reference.js @@ -0,0 +1,37 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/err-delete-member-expression-private-no-reference.case +// - src/class-elements/delete-error/cls-decl-field-delete.template +/*--- +description: It's a SyntaxError if delete operator is applied to MemberExpression.PrivateName no referencing class element (in field) +esid: sec-class-definitions-static-semantics-early-errors +features: [class, class-fields-private, class-fields-public] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + This file must never use the onlyStrict flag as the strict mode should always + be observed inside class bodies. + + Static Semantics: Early Errors + + UnaryExpression : delete UnaryExpression + + It is a Syntax Error if the UnaryExpression is contained in strict mode + code and the derived UnaryExpression is + PrimaryExpression : IdentifierReference , + MemberExpression : MemberExpression.PrivateName , or + CallExpression : CallExpression.PrivateName . + +---*/ + + +$DONOTEVALUATE(); + +class C { + #x; + + x = delete this.#m; + +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-err-delete-member-expression-privatename.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-err-delete-member-expression-privatename.js new file mode 100644 index 0000000000..f2abd8f4df --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-err-delete-member-expression-privatename.js @@ -0,0 +1,37 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/err-delete-member-expression-privatename.case +// - src/class-elements/delete-error/cls-decl-field-delete.template +/*--- +description: It's a SyntaxError if delete operator is applied to MemberExpression.PrivateName private field (in field) +esid: sec-class-definitions-static-semantics-early-errors +features: [class, class-fields-private, class-fields-public] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + This file must never use the onlyStrict flag as the strict mode should always + be observed inside class bodies. + + Static Semantics: Early Errors + + UnaryExpression : delete UnaryExpression + + It is a Syntax Error if the UnaryExpression is contained in strict mode + code and the derived UnaryExpression is + PrimaryExpression : IdentifierReference , + MemberExpression : MemberExpression.PrivateName , or + CallExpression : CallExpression.PrivateName . + +---*/ + + +$DONOTEVALUATE(); + +class C { + #x; + + x = delete this.#x; + +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-twice-covered-err-delete-call-expression-private-method-accessor-get.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-twice-covered-err-delete-call-expression-private-method-accessor-get.js new file mode 100644 index 0000000000..b4cc315b32 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-twice-covered-err-delete-call-expression-private-method-accessor-get.js @@ -0,0 +1,43 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/err-delete-call-expression-private-method-accessor-get.case +// - src/class-elements/delete-error/cls-decl-field-delete-twice-covered.template +/*--- +description: It's a SyntaxError if delete operator is applied to CallExpression.PrivateName accessor get method (in field, recursively covered) +esid: sec-class-definitions-static-semantics-early-errors +features: [class-methods-private, class-fields-public, class, class-fields-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Static Semantics: Early Errors + + UnaryExpression : delete UnaryExpression + + It is a Syntax Error if the UnaryExpression is contained in strict mode + code and the derived UnaryExpression is + PrimaryExpression : IdentifierReference , + MemberExpression : MemberExpression.PrivateName , or + CallExpression : CallExpression.PrivateName . + + It is a Syntax Error if the derived UnaryExpression is + PrimaryExpression : CoverParenthesizedExpressionAndArrowParameterList and + CoverParenthesizedExpressionAndArrowParameterList ultimately derives a + phrase that, if used in place of UnaryExpression, would produce a + Syntax Error according to these rules. This rule is recursively applied. + +---*/ + + +$DONOTEVALUATE(); + +class C { + #x; + g = this.f; + x = delete ((g().#m)); + + f() { + return this; + } +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-twice-covered-err-delete-call-expression-private-method-accessor-set.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-twice-covered-err-delete-call-expression-private-method-accessor-set.js new file mode 100644 index 0000000000..439cc8f1b3 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-twice-covered-err-delete-call-expression-private-method-accessor-set.js @@ -0,0 +1,43 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/err-delete-call-expression-private-method-accessor-set.case +// - src/class-elements/delete-error/cls-decl-field-delete-twice-covered.template +/*--- +description: It's a SyntaxError if delete operator is applied to CallExpression.PrivateName accessor set method (in field, recursively covered) +esid: sec-class-definitions-static-semantics-early-errors +features: [class, class-fields-private, class-methods-private, class-fields-public] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Static Semantics: Early Errors + + UnaryExpression : delete UnaryExpression + + It is a Syntax Error if the UnaryExpression is contained in strict mode + code and the derived UnaryExpression is + PrimaryExpression : IdentifierReference , + MemberExpression : MemberExpression.PrivateName , or + CallExpression : CallExpression.PrivateName . + + It is a Syntax Error if the derived UnaryExpression is + PrimaryExpression : CoverParenthesizedExpressionAndArrowParameterList and + CoverParenthesizedExpressionAndArrowParameterList ultimately derives a + phrase that, if used in place of UnaryExpression, would produce a + Syntax Error according to these rules. This rule is recursively applied. + +---*/ + + +$DONOTEVALUATE(); + +class C { + #x; + g = this.f; + x = delete ((g().#m)); + + f() { + return this; + } +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-twice-covered-err-delete-call-expression-private-method-async-gen.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-twice-covered-err-delete-call-expression-private-method-async-gen.js new file mode 100644 index 0000000000..af61de31e4 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-twice-covered-err-delete-call-expression-private-method-async-gen.js @@ -0,0 +1,43 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/err-delete-call-expression-private-method-async-gen.case +// - src/class-elements/delete-error/cls-decl-field-delete-twice-covered.template +/*--- +description: It's a SyntaxError if delete operator is applied to CallExpression.PrivateName async generator (in field, recursively covered) +esid: sec-class-definitions-static-semantics-early-errors +features: [class-methods-private, async-iteration, class, class-fields-private, class-fields-public] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Static Semantics: Early Errors + + UnaryExpression : delete UnaryExpression + + It is a Syntax Error if the UnaryExpression is contained in strict mode + code and the derived UnaryExpression is + PrimaryExpression : IdentifierReference , + MemberExpression : MemberExpression.PrivateName , or + CallExpression : CallExpression.PrivateName . + + It is a Syntax Error if the derived UnaryExpression is + PrimaryExpression : CoverParenthesizedExpressionAndArrowParameterList and + CoverParenthesizedExpressionAndArrowParameterList ultimately derives a + phrase that, if used in place of UnaryExpression, would produce a + Syntax Error according to these rules. This rule is recursively applied. + +---*/ + + +$DONOTEVALUATE(); + +class C { + #x; + g = this.f; + x = delete ((g().#m)); + + f() { + return this; + } +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-twice-covered-err-delete-call-expression-private-method-async.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-twice-covered-err-delete-call-expression-private-method-async.js new file mode 100644 index 0000000000..793a100152 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-twice-covered-err-delete-call-expression-private-method-async.js @@ -0,0 +1,43 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/err-delete-call-expression-private-method-async.case +// - src/class-elements/delete-error/cls-decl-field-delete-twice-covered.template +/*--- +description: It's a SyntaxError if delete operator is applied to CallExpression.PrivateName async method (in field, recursively covered) +esid: sec-class-definitions-static-semantics-early-errors +features: [class-methods-private, async-functions, class, class-fields-private, class-fields-public] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Static Semantics: Early Errors + + UnaryExpression : delete UnaryExpression + + It is a Syntax Error if the UnaryExpression is contained in strict mode + code and the derived UnaryExpression is + PrimaryExpression : IdentifierReference , + MemberExpression : MemberExpression.PrivateName , or + CallExpression : CallExpression.PrivateName . + + It is a Syntax Error if the derived UnaryExpression is + PrimaryExpression : CoverParenthesizedExpressionAndArrowParameterList and + CoverParenthesizedExpressionAndArrowParameterList ultimately derives a + phrase that, if used in place of UnaryExpression, would produce a + Syntax Error according to these rules. This rule is recursively applied. + +---*/ + + +$DONOTEVALUATE(); + +class C { + #x; + g = this.f; + x = delete ((g().#m)); + + f() { + return this; + } +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-twice-covered-err-delete-call-expression-private-method-gen.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-twice-covered-err-delete-call-expression-private-method-gen.js new file mode 100644 index 0000000000..221b83ffa4 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-twice-covered-err-delete-call-expression-private-method-gen.js @@ -0,0 +1,43 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/err-delete-call-expression-private-method-gen.case +// - src/class-elements/delete-error/cls-decl-field-delete-twice-covered.template +/*--- +description: It's a SyntaxError if delete operator is applied to CallExpression.PrivateName generator (in field, recursively covered) +esid: sec-class-definitions-static-semantics-early-errors +features: [class-methods-private, generators, class, class-fields-private, class-fields-public] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Static Semantics: Early Errors + + UnaryExpression : delete UnaryExpression + + It is a Syntax Error if the UnaryExpression is contained in strict mode + code and the derived UnaryExpression is + PrimaryExpression : IdentifierReference , + MemberExpression : MemberExpression.PrivateName , or + CallExpression : CallExpression.PrivateName . + + It is a Syntax Error if the derived UnaryExpression is + PrimaryExpression : CoverParenthesizedExpressionAndArrowParameterList and + CoverParenthesizedExpressionAndArrowParameterList ultimately derives a + phrase that, if used in place of UnaryExpression, would produce a + Syntax Error according to these rules. This rule is recursively applied. + +---*/ + + +$DONOTEVALUATE(); + +class C { + #x; + g = this.f; + x = delete ((g().#m)); + + f() { + return this; + } +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-twice-covered-err-delete-call-expression-private-method.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-twice-covered-err-delete-call-expression-private-method.js new file mode 100644 index 0000000000..52f0c2e2bb --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-twice-covered-err-delete-call-expression-private-method.js @@ -0,0 +1,43 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/err-delete-call-expression-private-method.case +// - src/class-elements/delete-error/cls-decl-field-delete-twice-covered.template +/*--- +description: It's a SyntaxError if delete operator is applied to CallExpression.PrivateName private ordinary method (in field, recursively covered) +esid: sec-class-definitions-static-semantics-early-errors +features: [class-methods-private, class, class-fields-private, class-fields-public] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Static Semantics: Early Errors + + UnaryExpression : delete UnaryExpression + + It is a Syntax Error if the UnaryExpression is contained in strict mode + code and the derived UnaryExpression is + PrimaryExpression : IdentifierReference , + MemberExpression : MemberExpression.PrivateName , or + CallExpression : CallExpression.PrivateName . + + It is a Syntax Error if the derived UnaryExpression is + PrimaryExpression : CoverParenthesizedExpressionAndArrowParameterList and + CoverParenthesizedExpressionAndArrowParameterList ultimately derives a + phrase that, if used in place of UnaryExpression, would produce a + Syntax Error according to these rules. This rule is recursively applied. + +---*/ + + +$DONOTEVALUATE(); + +class C { + #x; + g = this.f; + x = delete ((g().#m)); + + f() { + return this; + } +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-twice-covered-err-delete-call-expression-private-no-reference.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-twice-covered-err-delete-call-expression-private-no-reference.js new file mode 100644 index 0000000000..4ef6ac94fa --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-twice-covered-err-delete-call-expression-private-no-reference.js @@ -0,0 +1,43 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/err-delete-call-expression-private-no-reference.case +// - src/class-elements/delete-error/cls-decl-field-delete-twice-covered.template +/*--- +description: It's a SyntaxError if delete operator is applied to CallExpression.PrivateName no referencing class element (in field, recursively covered) +esid: sec-class-definitions-static-semantics-early-errors +features: [class, class-fields-private, class-fields-public] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Static Semantics: Early Errors + + UnaryExpression : delete UnaryExpression + + It is a Syntax Error if the UnaryExpression is contained in strict mode + code and the derived UnaryExpression is + PrimaryExpression : IdentifierReference , + MemberExpression : MemberExpression.PrivateName , or + CallExpression : CallExpression.PrivateName . + + It is a Syntax Error if the derived UnaryExpression is + PrimaryExpression : CoverParenthesizedExpressionAndArrowParameterList and + CoverParenthesizedExpressionAndArrowParameterList ultimately derives a + phrase that, if used in place of UnaryExpression, would produce a + Syntax Error according to these rules. This rule is recursively applied. + +---*/ + + +$DONOTEVALUATE(); + +class C { + #x; + g = this.f; + x = delete ((g().#m)); + + f() { + return this; + } +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-twice-covered-err-delete-call-expression-privatename.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-twice-covered-err-delete-call-expression-privatename.js new file mode 100644 index 0000000000..5bcb6fb949 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-twice-covered-err-delete-call-expression-privatename.js @@ -0,0 +1,43 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/err-delete-call-expression-privatename.case +// - src/class-elements/delete-error/cls-decl-field-delete-twice-covered.template +/*--- +description: It's a SyntaxError if delete operator is applied to CallExpression.PrivateName private field (in field, recursively covered) +esid: sec-class-definitions-static-semantics-early-errors +features: [class, class-fields-private, class-fields-public] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Static Semantics: Early Errors + + UnaryExpression : delete UnaryExpression + + It is a Syntax Error if the UnaryExpression is contained in strict mode + code and the derived UnaryExpression is + PrimaryExpression : IdentifierReference , + MemberExpression : MemberExpression.PrivateName , or + CallExpression : CallExpression.PrivateName . + + It is a Syntax Error if the derived UnaryExpression is + PrimaryExpression : CoverParenthesizedExpressionAndArrowParameterList and + CoverParenthesizedExpressionAndArrowParameterList ultimately derives a + phrase that, if used in place of UnaryExpression, would produce a + Syntax Error according to these rules. This rule is recursively applied. + +---*/ + + +$DONOTEVALUATE(); + +class C { + #x; + g = this.f; + x = delete ((g().#x)); + + f() { + return this; + } +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-twice-covered-err-delete-member-expression-private-method-accessor-get.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-twice-covered-err-delete-member-expression-private-method-accessor-get.js new file mode 100644 index 0000000000..eaeb4e0774 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-twice-covered-err-delete-member-expression-private-method-accessor-get.js @@ -0,0 +1,42 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/err-delete-member-expression-private-method-accessor-get.case +// - src/class-elements/delete-error/cls-decl-field-delete-twice-covered.template +/*--- +description: It's a SyntaxError if delete operator is applied to MemberExpression.PrivateName accessor get method (in field, recursively covered) +esid: sec-class-definitions-static-semantics-early-errors +features: [class-methods-private, class, class-fields-private, class-fields-public] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Static Semantics: Early Errors + + UnaryExpression : delete UnaryExpression + + It is a Syntax Error if the UnaryExpression is contained in strict mode + code and the derived UnaryExpression is + PrimaryExpression : IdentifierReference , + MemberExpression : MemberExpression.PrivateName , or + CallExpression : CallExpression.PrivateName . + + It is a Syntax Error if the derived UnaryExpression is + PrimaryExpression : CoverParenthesizedExpressionAndArrowParameterList and + CoverParenthesizedExpressionAndArrowParameterList ultimately derives a + phrase that, if used in place of UnaryExpression, would produce a + Syntax Error according to these rules. This rule is recursively applied. + +---*/ + + +$DONOTEVALUATE(); + +class C { + #x; + + x = delete ((this.#m +)); + + +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-twice-covered-err-delete-member-expression-private-method-accessor-set.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-twice-covered-err-delete-member-expression-private-method-accessor-set.js new file mode 100644 index 0000000000..4db71f1625 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-twice-covered-err-delete-member-expression-private-method-accessor-set.js @@ -0,0 +1,42 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/err-delete-member-expression-private-method-accessor-set.case +// - src/class-elements/delete-error/cls-decl-field-delete-twice-covered.template +/*--- +description: It's a SyntaxError if delete operator is applied to MemberExpression.PrivateName accessor set method (in field, recursively covered) +esid: sec-class-definitions-static-semantics-early-errors +features: [class-methods-private, class, class-fields-private, class-fields-public] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Static Semantics: Early Errors + + UnaryExpression : delete UnaryExpression + + It is a Syntax Error if the UnaryExpression is contained in strict mode + code and the derived UnaryExpression is + PrimaryExpression : IdentifierReference , + MemberExpression : MemberExpression.PrivateName , or + CallExpression : CallExpression.PrivateName . + + It is a Syntax Error if the derived UnaryExpression is + PrimaryExpression : CoverParenthesizedExpressionAndArrowParameterList and + CoverParenthesizedExpressionAndArrowParameterList ultimately derives a + phrase that, if used in place of UnaryExpression, would produce a + Syntax Error according to these rules. This rule is recursively applied. + +---*/ + + +$DONOTEVALUATE(); + +class C { + #x; + + x = delete ((this.#m +)); + + +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-twice-covered-err-delete-member-expression-private-method-async-gen.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-twice-covered-err-delete-member-expression-private-method-async-gen.js new file mode 100644 index 0000000000..ef92e690b5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-twice-covered-err-delete-member-expression-private-method-async-gen.js @@ -0,0 +1,42 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/err-delete-member-expression-private-method-async-gen.case +// - src/class-elements/delete-error/cls-decl-field-delete-twice-covered.template +/*--- +description: It's a SyntaxError if delete operator is applied to MemberExpression.PrivateName async generator (in field, recursively covered) +esid: sec-class-definitions-static-semantics-early-errors +features: [class-methods-private, async-iteration, class, class-fields-private, class-fields-public] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Static Semantics: Early Errors + + UnaryExpression : delete UnaryExpression + + It is a Syntax Error if the UnaryExpression is contained in strict mode + code and the derived UnaryExpression is + PrimaryExpression : IdentifierReference , + MemberExpression : MemberExpression.PrivateName , or + CallExpression : CallExpression.PrivateName . + + It is a Syntax Error if the derived UnaryExpression is + PrimaryExpression : CoverParenthesizedExpressionAndArrowParameterList and + CoverParenthesizedExpressionAndArrowParameterList ultimately derives a + phrase that, if used in place of UnaryExpression, would produce a + Syntax Error according to these rules. This rule is recursively applied. + +---*/ + + +$DONOTEVALUATE(); + +class C { + #x; + + x = delete ((this.#m +)); + + async *#m() {} +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-twice-covered-err-delete-member-expression-private-method-async.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-twice-covered-err-delete-member-expression-private-method-async.js new file mode 100644 index 0000000000..22ad4c627c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-twice-covered-err-delete-member-expression-private-method-async.js @@ -0,0 +1,42 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/err-delete-member-expression-private-method-async.case +// - src/class-elements/delete-error/cls-decl-field-delete-twice-covered.template +/*--- +description: It's a SyntaxError if delete operator is applied to MemberExpression.PrivateName async method (in field, recursively covered) +esid: sec-class-definitions-static-semantics-early-errors +features: [class-methods-private, async-functions, class, class-fields-private, class-fields-public] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Static Semantics: Early Errors + + UnaryExpression : delete UnaryExpression + + It is a Syntax Error if the UnaryExpression is contained in strict mode + code and the derived UnaryExpression is + PrimaryExpression : IdentifierReference , + MemberExpression : MemberExpression.PrivateName , or + CallExpression : CallExpression.PrivateName . + + It is a Syntax Error if the derived UnaryExpression is + PrimaryExpression : CoverParenthesizedExpressionAndArrowParameterList and + CoverParenthesizedExpressionAndArrowParameterList ultimately derives a + phrase that, if used in place of UnaryExpression, would produce a + Syntax Error according to these rules. This rule is recursively applied. + +---*/ + + +$DONOTEVALUATE(); + +class C { + #x; + + x = delete ((this.#m +)); + + async #m() {} +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-twice-covered-err-delete-member-expression-private-method-gen.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-twice-covered-err-delete-member-expression-private-method-gen.js new file mode 100644 index 0000000000..f2fce899b8 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-twice-covered-err-delete-member-expression-private-method-gen.js @@ -0,0 +1,42 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/err-delete-member-expression-private-method-gen.case +// - src/class-elements/delete-error/cls-decl-field-delete-twice-covered.template +/*--- +description: It's a SyntaxError if delete operator is applied to MemberExpression.PrivateName generator (in field, recursively covered) +esid: sec-class-definitions-static-semantics-early-errors +features: [class-methods-private, generators, class, class-fields-private, class-fields-public] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Static Semantics: Early Errors + + UnaryExpression : delete UnaryExpression + + It is a Syntax Error if the UnaryExpression is contained in strict mode + code and the derived UnaryExpression is + PrimaryExpression : IdentifierReference , + MemberExpression : MemberExpression.PrivateName , or + CallExpression : CallExpression.PrivateName . + + It is a Syntax Error if the derived UnaryExpression is + PrimaryExpression : CoverParenthesizedExpressionAndArrowParameterList and + CoverParenthesizedExpressionAndArrowParameterList ultimately derives a + phrase that, if used in place of UnaryExpression, would produce a + Syntax Error according to these rules. This rule is recursively applied. + +---*/ + + +$DONOTEVALUATE(); + +class C { + #x; + + x = delete ((this.#m +)); + + *#m() {} +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-twice-covered-err-delete-member-expression-private-method.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-twice-covered-err-delete-member-expression-private-method.js new file mode 100644 index 0000000000..eaffab2464 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-twice-covered-err-delete-member-expression-private-method.js @@ -0,0 +1,42 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/err-delete-member-expression-private-method.case +// - src/class-elements/delete-error/cls-decl-field-delete-twice-covered.template +/*--- +description: It's a SyntaxError if delete operator is applied to MemberExpression.PrivateName private ordinary method (in field, recursively covered) +esid: sec-class-definitions-static-semantics-early-errors +features: [class-methods-private, class, class-fields-private, class-fields-public] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Static Semantics: Early Errors + + UnaryExpression : delete UnaryExpression + + It is a Syntax Error if the UnaryExpression is contained in strict mode + code and the derived UnaryExpression is + PrimaryExpression : IdentifierReference , + MemberExpression : MemberExpression.PrivateName , or + CallExpression : CallExpression.PrivateName . + + It is a Syntax Error if the derived UnaryExpression is + PrimaryExpression : CoverParenthesizedExpressionAndArrowParameterList and + CoverParenthesizedExpressionAndArrowParameterList ultimately derives a + phrase that, if used in place of UnaryExpression, would produce a + Syntax Error according to these rules. This rule is recursively applied. + +---*/ + + +$DONOTEVALUATE(); + +class C { + #x; + + x = delete ((this.#m +)); + + +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-twice-covered-err-delete-member-expression-private-no-reference.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-twice-covered-err-delete-member-expression-private-no-reference.js new file mode 100644 index 0000000000..a8c4055cb7 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-twice-covered-err-delete-member-expression-private-no-reference.js @@ -0,0 +1,41 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/err-delete-member-expression-private-no-reference.case +// - src/class-elements/delete-error/cls-decl-field-delete-twice-covered.template +/*--- +description: It's a SyntaxError if delete operator is applied to MemberExpression.PrivateName no referencing class element (in field, recursively covered) +esid: sec-class-definitions-static-semantics-early-errors +features: [class, class-fields-private, class-fields-public] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Static Semantics: Early Errors + + UnaryExpression : delete UnaryExpression + + It is a Syntax Error if the UnaryExpression is contained in strict mode + code and the derived UnaryExpression is + PrimaryExpression : IdentifierReference , + MemberExpression : MemberExpression.PrivateName , or + CallExpression : CallExpression.PrivateName . + + It is a Syntax Error if the derived UnaryExpression is + PrimaryExpression : CoverParenthesizedExpressionAndArrowParameterList and + CoverParenthesizedExpressionAndArrowParameterList ultimately derives a + phrase that, if used in place of UnaryExpression, would produce a + Syntax Error according to these rules. This rule is recursively applied. + +---*/ + + +$DONOTEVALUATE(); + +class C { + #x; + + x = delete ((this.#m)); + + +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-twice-covered-err-delete-member-expression-privatename.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-twice-covered-err-delete-member-expression-privatename.js new file mode 100644 index 0000000000..e8279b2f45 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/field-delete-twice-covered-err-delete-member-expression-privatename.js @@ -0,0 +1,41 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/err-delete-member-expression-privatename.case +// - src/class-elements/delete-error/cls-decl-field-delete-twice-covered.template +/*--- +description: It's a SyntaxError if delete operator is applied to MemberExpression.PrivateName private field (in field, recursively covered) +esid: sec-class-definitions-static-semantics-early-errors +features: [class, class-fields-private, class-fields-public] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Static Semantics: Early Errors + + UnaryExpression : delete UnaryExpression + + It is a Syntax Error if the UnaryExpression is contained in strict mode + code and the derived UnaryExpression is + PrimaryExpression : IdentifierReference , + MemberExpression : MemberExpression.PrivateName , or + CallExpression : CallExpression.PrivateName . + + It is a Syntax Error if the derived UnaryExpression is + PrimaryExpression : CoverParenthesizedExpressionAndArrowParameterList and + CoverParenthesizedExpressionAndArrowParameterList ultimately derives a + phrase that, if used in place of UnaryExpression, would produce a + Syntax Error according to these rules. This rule is recursively applied. + +---*/ + + +$DONOTEVALUATE(); + +class C { + #x; + + x = delete ((this.#x)); + + +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-covered-err-delete-call-expression-private-method-accessor-get.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-covered-err-delete-call-expression-private-method-accessor-get.js new file mode 100644 index 0000000000..2c5e260919 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-covered-err-delete-call-expression-private-method-accessor-get.js @@ -0,0 +1,49 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/err-delete-call-expression-private-method-accessor-get.case +// - src/class-elements/delete-error/cls-decl-method-delete-covered.template +/*--- +description: It's a SyntaxError if delete operator is applied to CallExpression.PrivateName accessor get method (in method, covered) +esid: sec-class-definitions-static-semantics-early-errors +features: [class-methods-private, class-fields-public, class, class-fields-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + This file must never use the onlyStrict flag as the strict mode should always + be observed inside class bodies. + + Static Semantics: Early Errors + + UnaryExpression : delete UnaryExpression + + It is a Syntax Error if the UnaryExpression is contained in strict mode + code and the derived UnaryExpression is + PrimaryExpression : IdentifierReference , + MemberExpression : MemberExpression.PrivateName , or + CallExpression : CallExpression.PrivateName . + + It is a Syntax Error if the derived UnaryExpression is + PrimaryExpression : CoverParenthesizedExpressionAndArrowParameterList and + CoverParenthesizedExpressionAndArrowParameterList ultimately derives a + phrase that, if used in place of UnaryExpression, would produce a + Syntax Error according to these rules. This rule is recursively applied. + +---*/ + + +$DONOTEVALUATE(); + +class C { + #x; + + x() { + var g = this.f; + delete (g().#m); + } + + f() { + return this; + } +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-covered-err-delete-call-expression-private-method-accessor-set.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-covered-err-delete-call-expression-private-method-accessor-set.js new file mode 100644 index 0000000000..851b778f9e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-covered-err-delete-call-expression-private-method-accessor-set.js @@ -0,0 +1,49 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/err-delete-call-expression-private-method-accessor-set.case +// - src/class-elements/delete-error/cls-decl-method-delete-covered.template +/*--- +description: It's a SyntaxError if delete operator is applied to CallExpression.PrivateName accessor set method (in method, covered) +esid: sec-class-definitions-static-semantics-early-errors +features: [class, class-fields-private, class-methods-private, class-fields-public] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + This file must never use the onlyStrict flag as the strict mode should always + be observed inside class bodies. + + Static Semantics: Early Errors + + UnaryExpression : delete UnaryExpression + + It is a Syntax Error if the UnaryExpression is contained in strict mode + code and the derived UnaryExpression is + PrimaryExpression : IdentifierReference , + MemberExpression : MemberExpression.PrivateName , or + CallExpression : CallExpression.PrivateName . + + It is a Syntax Error if the derived UnaryExpression is + PrimaryExpression : CoverParenthesizedExpressionAndArrowParameterList and + CoverParenthesizedExpressionAndArrowParameterList ultimately derives a + phrase that, if used in place of UnaryExpression, would produce a + Syntax Error according to these rules. This rule is recursively applied. + +---*/ + + +$DONOTEVALUATE(); + +class C { + #x; + + x() { + var g = this.f; + delete (g().#m); + } + + f() { + return this; + } +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-covered-err-delete-call-expression-private-method-async-gen.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-covered-err-delete-call-expression-private-method-async-gen.js new file mode 100644 index 0000000000..8c8f1c8757 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-covered-err-delete-call-expression-private-method-async-gen.js @@ -0,0 +1,49 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/err-delete-call-expression-private-method-async-gen.case +// - src/class-elements/delete-error/cls-decl-method-delete-covered.template +/*--- +description: It's a SyntaxError if delete operator is applied to CallExpression.PrivateName async generator (in method, covered) +esid: sec-class-definitions-static-semantics-early-errors +features: [class-methods-private, async-iteration, class, class-fields-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + This file must never use the onlyStrict flag as the strict mode should always + be observed inside class bodies. + + Static Semantics: Early Errors + + UnaryExpression : delete UnaryExpression + + It is a Syntax Error if the UnaryExpression is contained in strict mode + code and the derived UnaryExpression is + PrimaryExpression : IdentifierReference , + MemberExpression : MemberExpression.PrivateName , or + CallExpression : CallExpression.PrivateName . + + It is a Syntax Error if the derived UnaryExpression is + PrimaryExpression : CoverParenthesizedExpressionAndArrowParameterList and + CoverParenthesizedExpressionAndArrowParameterList ultimately derives a + phrase that, if used in place of UnaryExpression, would produce a + Syntax Error according to these rules. This rule is recursively applied. + +---*/ + + +$DONOTEVALUATE(); + +class C { + #x; + + x() { + var g = this.f; + delete (g().#m); + } + + f() { + return this; + } +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-covered-err-delete-call-expression-private-method-async.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-covered-err-delete-call-expression-private-method-async.js new file mode 100644 index 0000000000..cb2f115354 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-covered-err-delete-call-expression-private-method-async.js @@ -0,0 +1,49 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/err-delete-call-expression-private-method-async.case +// - src/class-elements/delete-error/cls-decl-method-delete-covered.template +/*--- +description: It's a SyntaxError if delete operator is applied to CallExpression.PrivateName async method (in method, covered) +esid: sec-class-definitions-static-semantics-early-errors +features: [class-methods-private, async-functions, class, class-fields-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + This file must never use the onlyStrict flag as the strict mode should always + be observed inside class bodies. + + Static Semantics: Early Errors + + UnaryExpression : delete UnaryExpression + + It is a Syntax Error if the UnaryExpression is contained in strict mode + code and the derived UnaryExpression is + PrimaryExpression : IdentifierReference , + MemberExpression : MemberExpression.PrivateName , or + CallExpression : CallExpression.PrivateName . + + It is a Syntax Error if the derived UnaryExpression is + PrimaryExpression : CoverParenthesizedExpressionAndArrowParameterList and + CoverParenthesizedExpressionAndArrowParameterList ultimately derives a + phrase that, if used in place of UnaryExpression, would produce a + Syntax Error according to these rules. This rule is recursively applied. + +---*/ + + +$DONOTEVALUATE(); + +class C { + #x; + + x() { + var g = this.f; + delete (g().#m); + } + + f() { + return this; + } +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-covered-err-delete-call-expression-private-method-gen.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-covered-err-delete-call-expression-private-method-gen.js new file mode 100644 index 0000000000..a43392bdfa --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-covered-err-delete-call-expression-private-method-gen.js @@ -0,0 +1,49 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/err-delete-call-expression-private-method-gen.case +// - src/class-elements/delete-error/cls-decl-method-delete-covered.template +/*--- +description: It's a SyntaxError if delete operator is applied to CallExpression.PrivateName generator (in method, covered) +esid: sec-class-definitions-static-semantics-early-errors +features: [class-methods-private, generators, class, class-fields-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + This file must never use the onlyStrict flag as the strict mode should always + be observed inside class bodies. + + Static Semantics: Early Errors + + UnaryExpression : delete UnaryExpression + + It is a Syntax Error if the UnaryExpression is contained in strict mode + code and the derived UnaryExpression is + PrimaryExpression : IdentifierReference , + MemberExpression : MemberExpression.PrivateName , or + CallExpression : CallExpression.PrivateName . + + It is a Syntax Error if the derived UnaryExpression is + PrimaryExpression : CoverParenthesizedExpressionAndArrowParameterList and + CoverParenthesizedExpressionAndArrowParameterList ultimately derives a + phrase that, if used in place of UnaryExpression, would produce a + Syntax Error according to these rules. This rule is recursively applied. + +---*/ + + +$DONOTEVALUATE(); + +class C { + #x; + + x() { + var g = this.f; + delete (g().#m); + } + + f() { + return this; + } +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-covered-err-delete-call-expression-private-method.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-covered-err-delete-call-expression-private-method.js new file mode 100644 index 0000000000..e72c2385fc --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-covered-err-delete-call-expression-private-method.js @@ -0,0 +1,49 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/err-delete-call-expression-private-method.case +// - src/class-elements/delete-error/cls-decl-method-delete-covered.template +/*--- +description: It's a SyntaxError if delete operator is applied to CallExpression.PrivateName private ordinary method (in method, covered) +esid: sec-class-definitions-static-semantics-early-errors +features: [class-methods-private, class, class-fields-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + This file must never use the onlyStrict flag as the strict mode should always + be observed inside class bodies. + + Static Semantics: Early Errors + + UnaryExpression : delete UnaryExpression + + It is a Syntax Error if the UnaryExpression is contained in strict mode + code and the derived UnaryExpression is + PrimaryExpression : IdentifierReference , + MemberExpression : MemberExpression.PrivateName , or + CallExpression : CallExpression.PrivateName . + + It is a Syntax Error if the derived UnaryExpression is + PrimaryExpression : CoverParenthesizedExpressionAndArrowParameterList and + CoverParenthesizedExpressionAndArrowParameterList ultimately derives a + phrase that, if used in place of UnaryExpression, would produce a + Syntax Error according to these rules. This rule is recursively applied. + +---*/ + + +$DONOTEVALUATE(); + +class C { + #x; + + x() { + var g = this.f; + delete (g().#m); + } + + f() { + return this; + } +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-covered-err-delete-call-expression-private-no-reference.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-covered-err-delete-call-expression-private-no-reference.js new file mode 100644 index 0000000000..6d0fba7c35 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-covered-err-delete-call-expression-private-no-reference.js @@ -0,0 +1,49 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/err-delete-call-expression-private-no-reference.case +// - src/class-elements/delete-error/cls-decl-method-delete-covered.template +/*--- +description: It's a SyntaxError if delete operator is applied to CallExpression.PrivateName no referencing class element (in method, covered) +esid: sec-class-definitions-static-semantics-early-errors +features: [class, class-fields-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + This file must never use the onlyStrict flag as the strict mode should always + be observed inside class bodies. + + Static Semantics: Early Errors + + UnaryExpression : delete UnaryExpression + + It is a Syntax Error if the UnaryExpression is contained in strict mode + code and the derived UnaryExpression is + PrimaryExpression : IdentifierReference , + MemberExpression : MemberExpression.PrivateName , or + CallExpression : CallExpression.PrivateName . + + It is a Syntax Error if the derived UnaryExpression is + PrimaryExpression : CoverParenthesizedExpressionAndArrowParameterList and + CoverParenthesizedExpressionAndArrowParameterList ultimately derives a + phrase that, if used in place of UnaryExpression, would produce a + Syntax Error according to these rules. This rule is recursively applied. + +---*/ + + +$DONOTEVALUATE(); + +class C { + #x; + + x() { + var g = this.f; + delete (g().#m); + } + + f() { + return this; + } +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-covered-err-delete-call-expression-privatename.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-covered-err-delete-call-expression-privatename.js new file mode 100644 index 0000000000..be6e92d1f8 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-covered-err-delete-call-expression-privatename.js @@ -0,0 +1,49 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/err-delete-call-expression-privatename.case +// - src/class-elements/delete-error/cls-decl-method-delete-covered.template +/*--- +description: It's a SyntaxError if delete operator is applied to CallExpression.PrivateName private field (in method, covered) +esid: sec-class-definitions-static-semantics-early-errors +features: [class, class-fields-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + This file must never use the onlyStrict flag as the strict mode should always + be observed inside class bodies. + + Static Semantics: Early Errors + + UnaryExpression : delete UnaryExpression + + It is a Syntax Error if the UnaryExpression is contained in strict mode + code and the derived UnaryExpression is + PrimaryExpression : IdentifierReference , + MemberExpression : MemberExpression.PrivateName , or + CallExpression : CallExpression.PrivateName . + + It is a Syntax Error if the derived UnaryExpression is + PrimaryExpression : CoverParenthesizedExpressionAndArrowParameterList and + CoverParenthesizedExpressionAndArrowParameterList ultimately derives a + phrase that, if used in place of UnaryExpression, would produce a + Syntax Error according to these rules. This rule is recursively applied. + +---*/ + + +$DONOTEVALUATE(); + +class C { + #x; + + x() { + var g = this.f; + delete (g().#x); + } + + f() { + return this; + } +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-covered-err-delete-member-expression-private-method-accessor-get.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-covered-err-delete-member-expression-private-method-accessor-get.js new file mode 100644 index 0000000000..64dc052956 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-covered-err-delete-member-expression-private-method-accessor-get.js @@ -0,0 +1,48 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/err-delete-member-expression-private-method-accessor-get.case +// - src/class-elements/delete-error/cls-decl-method-delete-covered.template +/*--- +description: It's a SyntaxError if delete operator is applied to MemberExpression.PrivateName accessor get method (in method, covered) +esid: sec-class-definitions-static-semantics-early-errors +features: [class-methods-private, class, class-fields-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + This file must never use the onlyStrict flag as the strict mode should always + be observed inside class bodies. + + Static Semantics: Early Errors + + UnaryExpression : delete UnaryExpression + + It is a Syntax Error if the UnaryExpression is contained in strict mode + code and the derived UnaryExpression is + PrimaryExpression : IdentifierReference , + MemberExpression : MemberExpression.PrivateName , or + CallExpression : CallExpression.PrivateName . + + It is a Syntax Error if the derived UnaryExpression is + PrimaryExpression : CoverParenthesizedExpressionAndArrowParameterList and + CoverParenthesizedExpressionAndArrowParameterList ultimately derives a + phrase that, if used in place of UnaryExpression, would produce a + Syntax Error according to these rules. This rule is recursively applied. + +---*/ + + +$DONOTEVALUATE(); + +class C { + #x; + + x() { + + delete (this.#m +); + } + + +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-covered-err-delete-member-expression-private-method-accessor-set.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-covered-err-delete-member-expression-private-method-accessor-set.js new file mode 100644 index 0000000000..d9459ce491 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-covered-err-delete-member-expression-private-method-accessor-set.js @@ -0,0 +1,48 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/err-delete-member-expression-private-method-accessor-set.case +// - src/class-elements/delete-error/cls-decl-method-delete-covered.template +/*--- +description: It's a SyntaxError if delete operator is applied to MemberExpression.PrivateName accessor set method (in method, covered) +esid: sec-class-definitions-static-semantics-early-errors +features: [class-methods-private, class, class-fields-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + This file must never use the onlyStrict flag as the strict mode should always + be observed inside class bodies. + + Static Semantics: Early Errors + + UnaryExpression : delete UnaryExpression + + It is a Syntax Error if the UnaryExpression is contained in strict mode + code and the derived UnaryExpression is + PrimaryExpression : IdentifierReference , + MemberExpression : MemberExpression.PrivateName , or + CallExpression : CallExpression.PrivateName . + + It is a Syntax Error if the derived UnaryExpression is + PrimaryExpression : CoverParenthesizedExpressionAndArrowParameterList and + CoverParenthesizedExpressionAndArrowParameterList ultimately derives a + phrase that, if used in place of UnaryExpression, would produce a + Syntax Error according to these rules. This rule is recursively applied. + +---*/ + + +$DONOTEVALUATE(); + +class C { + #x; + + x() { + + delete (this.#m +); + } + + +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-covered-err-delete-member-expression-private-method-async-gen.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-covered-err-delete-member-expression-private-method-async-gen.js new file mode 100644 index 0000000000..21a539de83 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-covered-err-delete-member-expression-private-method-async-gen.js @@ -0,0 +1,48 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/err-delete-member-expression-private-method-async-gen.case +// - src/class-elements/delete-error/cls-decl-method-delete-covered.template +/*--- +description: It's a SyntaxError if delete operator is applied to MemberExpression.PrivateName async generator (in method, covered) +esid: sec-class-definitions-static-semantics-early-errors +features: [class-methods-private, async-iteration, class, class-fields-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + This file must never use the onlyStrict flag as the strict mode should always + be observed inside class bodies. + + Static Semantics: Early Errors + + UnaryExpression : delete UnaryExpression + + It is a Syntax Error if the UnaryExpression is contained in strict mode + code and the derived UnaryExpression is + PrimaryExpression : IdentifierReference , + MemberExpression : MemberExpression.PrivateName , or + CallExpression : CallExpression.PrivateName . + + It is a Syntax Error if the derived UnaryExpression is + PrimaryExpression : CoverParenthesizedExpressionAndArrowParameterList and + CoverParenthesizedExpressionAndArrowParameterList ultimately derives a + phrase that, if used in place of UnaryExpression, would produce a + Syntax Error according to these rules. This rule is recursively applied. + +---*/ + + +$DONOTEVALUATE(); + +class C { + #x; + + x() { + + delete (this.#m +); + } + + async *#m() {} +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-covered-err-delete-member-expression-private-method-async.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-covered-err-delete-member-expression-private-method-async.js new file mode 100644 index 0000000000..a5094182f6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-covered-err-delete-member-expression-private-method-async.js @@ -0,0 +1,48 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/err-delete-member-expression-private-method-async.case +// - src/class-elements/delete-error/cls-decl-method-delete-covered.template +/*--- +description: It's a SyntaxError if delete operator is applied to MemberExpression.PrivateName async method (in method, covered) +esid: sec-class-definitions-static-semantics-early-errors +features: [class-methods-private, async-functions, class, class-fields-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + This file must never use the onlyStrict flag as the strict mode should always + be observed inside class bodies. + + Static Semantics: Early Errors + + UnaryExpression : delete UnaryExpression + + It is a Syntax Error if the UnaryExpression is contained in strict mode + code and the derived UnaryExpression is + PrimaryExpression : IdentifierReference , + MemberExpression : MemberExpression.PrivateName , or + CallExpression : CallExpression.PrivateName . + + It is a Syntax Error if the derived UnaryExpression is + PrimaryExpression : CoverParenthesizedExpressionAndArrowParameterList and + CoverParenthesizedExpressionAndArrowParameterList ultimately derives a + phrase that, if used in place of UnaryExpression, would produce a + Syntax Error according to these rules. This rule is recursively applied. + +---*/ + + +$DONOTEVALUATE(); + +class C { + #x; + + x() { + + delete (this.#m +); + } + + async #m() {} +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-covered-err-delete-member-expression-private-method-gen.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-covered-err-delete-member-expression-private-method-gen.js new file mode 100644 index 0000000000..9b60741fed --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-covered-err-delete-member-expression-private-method-gen.js @@ -0,0 +1,48 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/err-delete-member-expression-private-method-gen.case +// - src/class-elements/delete-error/cls-decl-method-delete-covered.template +/*--- +description: It's a SyntaxError if delete operator is applied to MemberExpression.PrivateName generator (in method, covered) +esid: sec-class-definitions-static-semantics-early-errors +features: [class-methods-private, generators, class, class-fields-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + This file must never use the onlyStrict flag as the strict mode should always + be observed inside class bodies. + + Static Semantics: Early Errors + + UnaryExpression : delete UnaryExpression + + It is a Syntax Error if the UnaryExpression is contained in strict mode + code and the derived UnaryExpression is + PrimaryExpression : IdentifierReference , + MemberExpression : MemberExpression.PrivateName , or + CallExpression : CallExpression.PrivateName . + + It is a Syntax Error if the derived UnaryExpression is + PrimaryExpression : CoverParenthesizedExpressionAndArrowParameterList and + CoverParenthesizedExpressionAndArrowParameterList ultimately derives a + phrase that, if used in place of UnaryExpression, would produce a + Syntax Error according to these rules. This rule is recursively applied. + +---*/ + + +$DONOTEVALUATE(); + +class C { + #x; + + x() { + + delete (this.#m +); + } + + *#m() {} +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-covered-err-delete-member-expression-private-method.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-covered-err-delete-member-expression-private-method.js new file mode 100644 index 0000000000..dcb09ae291 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-covered-err-delete-member-expression-private-method.js @@ -0,0 +1,48 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/err-delete-member-expression-private-method.case +// - src/class-elements/delete-error/cls-decl-method-delete-covered.template +/*--- +description: It's a SyntaxError if delete operator is applied to MemberExpression.PrivateName private ordinary method (in method, covered) +esid: sec-class-definitions-static-semantics-early-errors +features: [class-methods-private, class, class-fields-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + This file must never use the onlyStrict flag as the strict mode should always + be observed inside class bodies. + + Static Semantics: Early Errors + + UnaryExpression : delete UnaryExpression + + It is a Syntax Error if the UnaryExpression is contained in strict mode + code and the derived UnaryExpression is + PrimaryExpression : IdentifierReference , + MemberExpression : MemberExpression.PrivateName , or + CallExpression : CallExpression.PrivateName . + + It is a Syntax Error if the derived UnaryExpression is + PrimaryExpression : CoverParenthesizedExpressionAndArrowParameterList and + CoverParenthesizedExpressionAndArrowParameterList ultimately derives a + phrase that, if used in place of UnaryExpression, would produce a + Syntax Error according to these rules. This rule is recursively applied. + +---*/ + + +$DONOTEVALUATE(); + +class C { + #x; + + x() { + + delete (this.#m +); + } + + +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-covered-err-delete-member-expression-private-no-reference.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-covered-err-delete-member-expression-private-no-reference.js new file mode 100644 index 0000000000..ef2bbcd031 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-covered-err-delete-member-expression-private-no-reference.js @@ -0,0 +1,47 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/err-delete-member-expression-private-no-reference.case +// - src/class-elements/delete-error/cls-decl-method-delete-covered.template +/*--- +description: It's a SyntaxError if delete operator is applied to MemberExpression.PrivateName no referencing class element (in method, covered) +esid: sec-class-definitions-static-semantics-early-errors +features: [class, class-fields-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + This file must never use the onlyStrict flag as the strict mode should always + be observed inside class bodies. + + Static Semantics: Early Errors + + UnaryExpression : delete UnaryExpression + + It is a Syntax Error if the UnaryExpression is contained in strict mode + code and the derived UnaryExpression is + PrimaryExpression : IdentifierReference , + MemberExpression : MemberExpression.PrivateName , or + CallExpression : CallExpression.PrivateName . + + It is a Syntax Error if the derived UnaryExpression is + PrimaryExpression : CoverParenthesizedExpressionAndArrowParameterList and + CoverParenthesizedExpressionAndArrowParameterList ultimately derives a + phrase that, if used in place of UnaryExpression, would produce a + Syntax Error according to these rules. This rule is recursively applied. + +---*/ + + +$DONOTEVALUATE(); + +class C { + #x; + + x() { + + delete (this.#m); + } + + +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-covered-err-delete-member-expression-privatename.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-covered-err-delete-member-expression-privatename.js new file mode 100644 index 0000000000..07c1c079c6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-covered-err-delete-member-expression-privatename.js @@ -0,0 +1,47 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/err-delete-member-expression-privatename.case +// - src/class-elements/delete-error/cls-decl-method-delete-covered.template +/*--- +description: It's a SyntaxError if delete operator is applied to MemberExpression.PrivateName private field (in method, covered) +esid: sec-class-definitions-static-semantics-early-errors +features: [class, class-fields-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + This file must never use the onlyStrict flag as the strict mode should always + be observed inside class bodies. + + Static Semantics: Early Errors + + UnaryExpression : delete UnaryExpression + + It is a Syntax Error if the UnaryExpression is contained in strict mode + code and the derived UnaryExpression is + PrimaryExpression : IdentifierReference , + MemberExpression : MemberExpression.PrivateName , or + CallExpression : CallExpression.PrivateName . + + It is a Syntax Error if the derived UnaryExpression is + PrimaryExpression : CoverParenthesizedExpressionAndArrowParameterList and + CoverParenthesizedExpressionAndArrowParameterList ultimately derives a + phrase that, if used in place of UnaryExpression, would produce a + Syntax Error according to these rules. This rule is recursively applied. + +---*/ + + +$DONOTEVALUATE(); + +class C { + #x; + + x() { + + delete (this.#x); + } + + +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-err-delete-call-expression-private-method-accessor-get.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-err-delete-call-expression-private-method-accessor-get.js new file mode 100644 index 0000000000..53d75c453b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-err-delete-call-expression-private-method-accessor-get.js @@ -0,0 +1,43 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/err-delete-call-expression-private-method-accessor-get.case +// - src/class-elements/delete-error/cls-decl-method-delete.template +/*--- +description: It's a SyntaxError if delete operator is applied to CallExpression.PrivateName accessor get method (in method) +esid: sec-class-definitions-static-semantics-early-errors +features: [class-methods-private, class-fields-public, class, class-fields-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + This file must never use the onlyStrict flag as the strict mode should always + be observed inside class bodies. + + Static Semantics: Early Errors + + UnaryExpression : delete UnaryExpression + + It is a Syntax Error if the UnaryExpression is contained in strict mode + code and the derived UnaryExpression is + PrimaryExpression : IdentifierReference , + MemberExpression : MemberExpression.PrivateName , or + CallExpression : CallExpression.PrivateName . + +---*/ + + +$DONOTEVALUATE(); + +class C { + #x; + + x() { + var g = this.f; + delete g().#m; + } + + f() { + return this; + } +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-err-delete-call-expression-private-method-accessor-set.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-err-delete-call-expression-private-method-accessor-set.js new file mode 100644 index 0000000000..6f2aa7fd92 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-err-delete-call-expression-private-method-accessor-set.js @@ -0,0 +1,43 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/err-delete-call-expression-private-method-accessor-set.case +// - src/class-elements/delete-error/cls-decl-method-delete.template +/*--- +description: It's a SyntaxError if delete operator is applied to CallExpression.PrivateName accessor set method (in method) +esid: sec-class-definitions-static-semantics-early-errors +features: [class, class-fields-private, class-methods-private, class-fields-public] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + This file must never use the onlyStrict flag as the strict mode should always + be observed inside class bodies. + + Static Semantics: Early Errors + + UnaryExpression : delete UnaryExpression + + It is a Syntax Error if the UnaryExpression is contained in strict mode + code and the derived UnaryExpression is + PrimaryExpression : IdentifierReference , + MemberExpression : MemberExpression.PrivateName , or + CallExpression : CallExpression.PrivateName . + +---*/ + + +$DONOTEVALUATE(); + +class C { + #x; + + x() { + var g = this.f; + delete g().#m; + } + + f() { + return this; + } +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-err-delete-call-expression-private-method-async-gen.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-err-delete-call-expression-private-method-async-gen.js new file mode 100644 index 0000000000..7e393a5f54 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-err-delete-call-expression-private-method-async-gen.js @@ -0,0 +1,43 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/err-delete-call-expression-private-method-async-gen.case +// - src/class-elements/delete-error/cls-decl-method-delete.template +/*--- +description: It's a SyntaxError if delete operator is applied to CallExpression.PrivateName async generator (in method) +esid: sec-class-definitions-static-semantics-early-errors +features: [class-methods-private, async-iteration, class, class-fields-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + This file must never use the onlyStrict flag as the strict mode should always + be observed inside class bodies. + + Static Semantics: Early Errors + + UnaryExpression : delete UnaryExpression + + It is a Syntax Error if the UnaryExpression is contained in strict mode + code and the derived UnaryExpression is + PrimaryExpression : IdentifierReference , + MemberExpression : MemberExpression.PrivateName , or + CallExpression : CallExpression.PrivateName . + +---*/ + + +$DONOTEVALUATE(); + +class C { + #x; + + x() { + var g = this.f; + delete g().#m; + } + + f() { + return this; + } +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-err-delete-call-expression-private-method-async.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-err-delete-call-expression-private-method-async.js new file mode 100644 index 0000000000..d9e120e502 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-err-delete-call-expression-private-method-async.js @@ -0,0 +1,43 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/err-delete-call-expression-private-method-async.case +// - src/class-elements/delete-error/cls-decl-method-delete.template +/*--- +description: It's a SyntaxError if delete operator is applied to CallExpression.PrivateName async method (in method) +esid: sec-class-definitions-static-semantics-early-errors +features: [class-methods-private, async-functions, class, class-fields-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + This file must never use the onlyStrict flag as the strict mode should always + be observed inside class bodies. + + Static Semantics: Early Errors + + UnaryExpression : delete UnaryExpression + + It is a Syntax Error if the UnaryExpression is contained in strict mode + code and the derived UnaryExpression is + PrimaryExpression : IdentifierReference , + MemberExpression : MemberExpression.PrivateName , or + CallExpression : CallExpression.PrivateName . + +---*/ + + +$DONOTEVALUATE(); + +class C { + #x; + + x() { + var g = this.f; + delete g().#m; + } + + f() { + return this; + } +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-err-delete-call-expression-private-method-gen.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-err-delete-call-expression-private-method-gen.js new file mode 100644 index 0000000000..93c7464d97 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-err-delete-call-expression-private-method-gen.js @@ -0,0 +1,43 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/err-delete-call-expression-private-method-gen.case +// - src/class-elements/delete-error/cls-decl-method-delete.template +/*--- +description: It's a SyntaxError if delete operator is applied to CallExpression.PrivateName generator (in method) +esid: sec-class-definitions-static-semantics-early-errors +features: [class-methods-private, generators, class, class-fields-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + This file must never use the onlyStrict flag as the strict mode should always + be observed inside class bodies. + + Static Semantics: Early Errors + + UnaryExpression : delete UnaryExpression + + It is a Syntax Error if the UnaryExpression is contained in strict mode + code and the derived UnaryExpression is + PrimaryExpression : IdentifierReference , + MemberExpression : MemberExpression.PrivateName , or + CallExpression : CallExpression.PrivateName . + +---*/ + + +$DONOTEVALUATE(); + +class C { + #x; + + x() { + var g = this.f; + delete g().#m; + } + + f() { + return this; + } +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-err-delete-call-expression-private-method.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-err-delete-call-expression-private-method.js new file mode 100644 index 0000000000..c42ec89007 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-err-delete-call-expression-private-method.js @@ -0,0 +1,43 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/err-delete-call-expression-private-method.case +// - src/class-elements/delete-error/cls-decl-method-delete.template +/*--- +description: It's a SyntaxError if delete operator is applied to CallExpression.PrivateName private ordinary method (in method) +esid: sec-class-definitions-static-semantics-early-errors +features: [class-methods-private, class, class-fields-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + This file must never use the onlyStrict flag as the strict mode should always + be observed inside class bodies. + + Static Semantics: Early Errors + + UnaryExpression : delete UnaryExpression + + It is a Syntax Error if the UnaryExpression is contained in strict mode + code and the derived UnaryExpression is + PrimaryExpression : IdentifierReference , + MemberExpression : MemberExpression.PrivateName , or + CallExpression : CallExpression.PrivateName . + +---*/ + + +$DONOTEVALUATE(); + +class C { + #x; + + x() { + var g = this.f; + delete g().#m; + } + + f() { + return this; + } +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-err-delete-call-expression-private-no-reference.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-err-delete-call-expression-private-no-reference.js new file mode 100644 index 0000000000..195ace594a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-err-delete-call-expression-private-no-reference.js @@ -0,0 +1,43 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/err-delete-call-expression-private-no-reference.case +// - src/class-elements/delete-error/cls-decl-method-delete.template +/*--- +description: It's a SyntaxError if delete operator is applied to CallExpression.PrivateName no referencing class element (in method) +esid: sec-class-definitions-static-semantics-early-errors +features: [class, class-fields-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + This file must never use the onlyStrict flag as the strict mode should always + be observed inside class bodies. + + Static Semantics: Early Errors + + UnaryExpression : delete UnaryExpression + + It is a Syntax Error if the UnaryExpression is contained in strict mode + code and the derived UnaryExpression is + PrimaryExpression : IdentifierReference , + MemberExpression : MemberExpression.PrivateName , or + CallExpression : CallExpression.PrivateName . + +---*/ + + +$DONOTEVALUATE(); + +class C { + #x; + + x() { + var g = this.f; + delete g().#m; + } + + f() { + return this; + } +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-err-delete-call-expression-privatename.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-err-delete-call-expression-privatename.js new file mode 100644 index 0000000000..3b157abf71 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-err-delete-call-expression-privatename.js @@ -0,0 +1,43 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/err-delete-call-expression-privatename.case +// - src/class-elements/delete-error/cls-decl-method-delete.template +/*--- +description: It's a SyntaxError if delete operator is applied to CallExpression.PrivateName private field (in method) +esid: sec-class-definitions-static-semantics-early-errors +features: [class, class-fields-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + This file must never use the onlyStrict flag as the strict mode should always + be observed inside class bodies. + + Static Semantics: Early Errors + + UnaryExpression : delete UnaryExpression + + It is a Syntax Error if the UnaryExpression is contained in strict mode + code and the derived UnaryExpression is + PrimaryExpression : IdentifierReference , + MemberExpression : MemberExpression.PrivateName , or + CallExpression : CallExpression.PrivateName . + +---*/ + + +$DONOTEVALUATE(); + +class C { + #x; + + x() { + var g = this.f; + delete g().#x; + } + + f() { + return this; + } +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-err-delete-member-expression-private-method-accessor-get.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-err-delete-member-expression-private-method-accessor-get.js new file mode 100644 index 0000000000..145d32372d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-err-delete-member-expression-private-method-accessor-get.js @@ -0,0 +1,42 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/err-delete-member-expression-private-method-accessor-get.case +// - src/class-elements/delete-error/cls-decl-method-delete.template +/*--- +description: It's a SyntaxError if delete operator is applied to MemberExpression.PrivateName accessor get method (in method) +esid: sec-class-definitions-static-semantics-early-errors +features: [class-methods-private, class, class-fields-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + This file must never use the onlyStrict flag as the strict mode should always + be observed inside class bodies. + + Static Semantics: Early Errors + + UnaryExpression : delete UnaryExpression + + It is a Syntax Error if the UnaryExpression is contained in strict mode + code and the derived UnaryExpression is + PrimaryExpression : IdentifierReference , + MemberExpression : MemberExpression.PrivateName , or + CallExpression : CallExpression.PrivateName . + +---*/ + + +$DONOTEVALUATE(); + +class C { + #x; + + x() { + + delete this.#m +; + } + + +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-err-delete-member-expression-private-method-accessor-set.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-err-delete-member-expression-private-method-accessor-set.js new file mode 100644 index 0000000000..478d90b58e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-err-delete-member-expression-private-method-accessor-set.js @@ -0,0 +1,42 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/err-delete-member-expression-private-method-accessor-set.case +// - src/class-elements/delete-error/cls-decl-method-delete.template +/*--- +description: It's a SyntaxError if delete operator is applied to MemberExpression.PrivateName accessor set method (in method) +esid: sec-class-definitions-static-semantics-early-errors +features: [class-methods-private, class, class-fields-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + This file must never use the onlyStrict flag as the strict mode should always + be observed inside class bodies. + + Static Semantics: Early Errors + + UnaryExpression : delete UnaryExpression + + It is a Syntax Error if the UnaryExpression is contained in strict mode + code and the derived UnaryExpression is + PrimaryExpression : IdentifierReference , + MemberExpression : MemberExpression.PrivateName , or + CallExpression : CallExpression.PrivateName . + +---*/ + + +$DONOTEVALUATE(); + +class C { + #x; + + x() { + + delete this.#m +; + } + + +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-err-delete-member-expression-private-method-async-gen.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-err-delete-member-expression-private-method-async-gen.js new file mode 100644 index 0000000000..ed9a763511 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-err-delete-member-expression-private-method-async-gen.js @@ -0,0 +1,42 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/err-delete-member-expression-private-method-async-gen.case +// - src/class-elements/delete-error/cls-decl-method-delete.template +/*--- +description: It's a SyntaxError if delete operator is applied to MemberExpression.PrivateName async generator (in method) +esid: sec-class-definitions-static-semantics-early-errors +features: [class-methods-private, async-iteration, class, class-fields-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + This file must never use the onlyStrict flag as the strict mode should always + be observed inside class bodies. + + Static Semantics: Early Errors + + UnaryExpression : delete UnaryExpression + + It is a Syntax Error if the UnaryExpression is contained in strict mode + code and the derived UnaryExpression is + PrimaryExpression : IdentifierReference , + MemberExpression : MemberExpression.PrivateName , or + CallExpression : CallExpression.PrivateName . + +---*/ + + +$DONOTEVALUATE(); + +class C { + #x; + + x() { + + delete this.#m +; + } + + async *#m() {} +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-err-delete-member-expression-private-method-async.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-err-delete-member-expression-private-method-async.js new file mode 100644 index 0000000000..235ef7cafe --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-err-delete-member-expression-private-method-async.js @@ -0,0 +1,42 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/err-delete-member-expression-private-method-async.case +// - src/class-elements/delete-error/cls-decl-method-delete.template +/*--- +description: It's a SyntaxError if delete operator is applied to MemberExpression.PrivateName async method (in method) +esid: sec-class-definitions-static-semantics-early-errors +features: [class-methods-private, async-functions, class, class-fields-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + This file must never use the onlyStrict flag as the strict mode should always + be observed inside class bodies. + + Static Semantics: Early Errors + + UnaryExpression : delete UnaryExpression + + It is a Syntax Error if the UnaryExpression is contained in strict mode + code and the derived UnaryExpression is + PrimaryExpression : IdentifierReference , + MemberExpression : MemberExpression.PrivateName , or + CallExpression : CallExpression.PrivateName . + +---*/ + + +$DONOTEVALUATE(); + +class C { + #x; + + x() { + + delete this.#m +; + } + + async #m() {} +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-err-delete-member-expression-private-method-gen.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-err-delete-member-expression-private-method-gen.js new file mode 100644 index 0000000000..2fef15be78 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-err-delete-member-expression-private-method-gen.js @@ -0,0 +1,42 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/err-delete-member-expression-private-method-gen.case +// - src/class-elements/delete-error/cls-decl-method-delete.template +/*--- +description: It's a SyntaxError if delete operator is applied to MemberExpression.PrivateName generator (in method) +esid: sec-class-definitions-static-semantics-early-errors +features: [class-methods-private, generators, class, class-fields-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + This file must never use the onlyStrict flag as the strict mode should always + be observed inside class bodies. + + Static Semantics: Early Errors + + UnaryExpression : delete UnaryExpression + + It is a Syntax Error if the UnaryExpression is contained in strict mode + code and the derived UnaryExpression is + PrimaryExpression : IdentifierReference , + MemberExpression : MemberExpression.PrivateName , or + CallExpression : CallExpression.PrivateName . + +---*/ + + +$DONOTEVALUATE(); + +class C { + #x; + + x() { + + delete this.#m +; + } + + *#m() {} +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-err-delete-member-expression-private-method.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-err-delete-member-expression-private-method.js new file mode 100644 index 0000000000..baf9e90077 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-err-delete-member-expression-private-method.js @@ -0,0 +1,42 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/err-delete-member-expression-private-method.case +// - src/class-elements/delete-error/cls-decl-method-delete.template +/*--- +description: It's a SyntaxError if delete operator is applied to MemberExpression.PrivateName private ordinary method (in method) +esid: sec-class-definitions-static-semantics-early-errors +features: [class-methods-private, class, class-fields-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + This file must never use the onlyStrict flag as the strict mode should always + be observed inside class bodies. + + Static Semantics: Early Errors + + UnaryExpression : delete UnaryExpression + + It is a Syntax Error if the UnaryExpression is contained in strict mode + code and the derived UnaryExpression is + PrimaryExpression : IdentifierReference , + MemberExpression : MemberExpression.PrivateName , or + CallExpression : CallExpression.PrivateName . + +---*/ + + +$DONOTEVALUATE(); + +class C { + #x; + + x() { + + delete this.#m +; + } + + +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-err-delete-member-expression-private-no-reference.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-err-delete-member-expression-private-no-reference.js new file mode 100644 index 0000000000..eb8974ebbd --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-err-delete-member-expression-private-no-reference.js @@ -0,0 +1,41 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/err-delete-member-expression-private-no-reference.case +// - src/class-elements/delete-error/cls-decl-method-delete.template +/*--- +description: It's a SyntaxError if delete operator is applied to MemberExpression.PrivateName no referencing class element (in method) +esid: sec-class-definitions-static-semantics-early-errors +features: [class, class-fields-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + This file must never use the onlyStrict flag as the strict mode should always + be observed inside class bodies. + + Static Semantics: Early Errors + + UnaryExpression : delete UnaryExpression + + It is a Syntax Error if the UnaryExpression is contained in strict mode + code and the derived UnaryExpression is + PrimaryExpression : IdentifierReference , + MemberExpression : MemberExpression.PrivateName , or + CallExpression : CallExpression.PrivateName . + +---*/ + + +$DONOTEVALUATE(); + +class C { + #x; + + x() { + + delete this.#m; + } + + +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-err-delete-member-expression-privatename.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-err-delete-member-expression-privatename.js new file mode 100644 index 0000000000..452281c26f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-err-delete-member-expression-privatename.js @@ -0,0 +1,41 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/err-delete-member-expression-privatename.case +// - src/class-elements/delete-error/cls-decl-method-delete.template +/*--- +description: It's a SyntaxError if delete operator is applied to MemberExpression.PrivateName private field (in method) +esid: sec-class-definitions-static-semantics-early-errors +features: [class, class-fields-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + This file must never use the onlyStrict flag as the strict mode should always + be observed inside class bodies. + + Static Semantics: Early Errors + + UnaryExpression : delete UnaryExpression + + It is a Syntax Error if the UnaryExpression is contained in strict mode + code and the derived UnaryExpression is + PrimaryExpression : IdentifierReference , + MemberExpression : MemberExpression.PrivateName , or + CallExpression : CallExpression.PrivateName . + +---*/ + + +$DONOTEVALUATE(); + +class C { + #x; + + x() { + + delete this.#x; + } + + +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-twice-covered-err-delete-call-expression-private-method-accessor-get.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-twice-covered-err-delete-call-expression-private-method-accessor-get.js new file mode 100644 index 0000000000..92d223ff91 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-twice-covered-err-delete-call-expression-private-method-accessor-get.js @@ -0,0 +1,49 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/err-delete-call-expression-private-method-accessor-get.case +// - src/class-elements/delete-error/cls-decl-method-delete-twice-covered.template +/*--- +description: It's a SyntaxError if delete operator is applied to CallExpression.PrivateName accessor get method (in method, recursively covered) +esid: sec-class-definitions-static-semantics-early-errors +features: [class-methods-private, class-fields-public, class, class-fields-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + This file must never use the onlyStrict flag as the strict mode should always + be observed inside class bodies. + + Static Semantics: Early Errors + + UnaryExpression : delete UnaryExpression + + It is a Syntax Error if the UnaryExpression is contained in strict mode + code and the derived UnaryExpression is + PrimaryExpression : IdentifierReference , + MemberExpression : MemberExpression.PrivateName , or + CallExpression : CallExpression.PrivateName . + + It is a Syntax Error if the derived UnaryExpression is + PrimaryExpression : CoverParenthesizedExpressionAndArrowParameterList and + CoverParenthesizedExpressionAndArrowParameterList ultimately derives a + phrase that, if used in place of UnaryExpression, would produce a + Syntax Error according to these rules. This rule is recursively applied. + +---*/ + + +$DONOTEVALUATE(); + +class C { + #x; + + x() { + var g = this.f; + delete ((g().#m)); + } + + f() { + return this; + } +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-twice-covered-err-delete-call-expression-private-method-accessor-set.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-twice-covered-err-delete-call-expression-private-method-accessor-set.js new file mode 100644 index 0000000000..8ff0ddbe26 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-twice-covered-err-delete-call-expression-private-method-accessor-set.js @@ -0,0 +1,49 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/err-delete-call-expression-private-method-accessor-set.case +// - src/class-elements/delete-error/cls-decl-method-delete-twice-covered.template +/*--- +description: It's a SyntaxError if delete operator is applied to CallExpression.PrivateName accessor set method (in method, recursively covered) +esid: sec-class-definitions-static-semantics-early-errors +features: [class, class-fields-private, class-methods-private, class-fields-public] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + This file must never use the onlyStrict flag as the strict mode should always + be observed inside class bodies. + + Static Semantics: Early Errors + + UnaryExpression : delete UnaryExpression + + It is a Syntax Error if the UnaryExpression is contained in strict mode + code and the derived UnaryExpression is + PrimaryExpression : IdentifierReference , + MemberExpression : MemberExpression.PrivateName , or + CallExpression : CallExpression.PrivateName . + + It is a Syntax Error if the derived UnaryExpression is + PrimaryExpression : CoverParenthesizedExpressionAndArrowParameterList and + CoverParenthesizedExpressionAndArrowParameterList ultimately derives a + phrase that, if used in place of UnaryExpression, would produce a + Syntax Error according to these rules. This rule is recursively applied. + +---*/ + + +$DONOTEVALUATE(); + +class C { + #x; + + x() { + var g = this.f; + delete ((g().#m)); + } + + f() { + return this; + } +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-twice-covered-err-delete-call-expression-private-method-async-gen.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-twice-covered-err-delete-call-expression-private-method-async-gen.js new file mode 100644 index 0000000000..3416671362 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-twice-covered-err-delete-call-expression-private-method-async-gen.js @@ -0,0 +1,49 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/err-delete-call-expression-private-method-async-gen.case +// - src/class-elements/delete-error/cls-decl-method-delete-twice-covered.template +/*--- +description: It's a SyntaxError if delete operator is applied to CallExpression.PrivateName async generator (in method, recursively covered) +esid: sec-class-definitions-static-semantics-early-errors +features: [class-methods-private, async-iteration, class, class-fields-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + This file must never use the onlyStrict flag as the strict mode should always + be observed inside class bodies. + + Static Semantics: Early Errors + + UnaryExpression : delete UnaryExpression + + It is a Syntax Error if the UnaryExpression is contained in strict mode + code and the derived UnaryExpression is + PrimaryExpression : IdentifierReference , + MemberExpression : MemberExpression.PrivateName , or + CallExpression : CallExpression.PrivateName . + + It is a Syntax Error if the derived UnaryExpression is + PrimaryExpression : CoverParenthesizedExpressionAndArrowParameterList and + CoverParenthesizedExpressionAndArrowParameterList ultimately derives a + phrase that, if used in place of UnaryExpression, would produce a + Syntax Error according to these rules. This rule is recursively applied. + +---*/ + + +$DONOTEVALUATE(); + +class C { + #x; + + x() { + var g = this.f; + delete ((g().#m)); + } + + f() { + return this; + } +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-twice-covered-err-delete-call-expression-private-method-async.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-twice-covered-err-delete-call-expression-private-method-async.js new file mode 100644 index 0000000000..159cc68a91 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-twice-covered-err-delete-call-expression-private-method-async.js @@ -0,0 +1,49 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/err-delete-call-expression-private-method-async.case +// - src/class-elements/delete-error/cls-decl-method-delete-twice-covered.template +/*--- +description: It's a SyntaxError if delete operator is applied to CallExpression.PrivateName async method (in method, recursively covered) +esid: sec-class-definitions-static-semantics-early-errors +features: [class-methods-private, async-functions, class, class-fields-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + This file must never use the onlyStrict flag as the strict mode should always + be observed inside class bodies. + + Static Semantics: Early Errors + + UnaryExpression : delete UnaryExpression + + It is a Syntax Error if the UnaryExpression is contained in strict mode + code and the derived UnaryExpression is + PrimaryExpression : IdentifierReference , + MemberExpression : MemberExpression.PrivateName , or + CallExpression : CallExpression.PrivateName . + + It is a Syntax Error if the derived UnaryExpression is + PrimaryExpression : CoverParenthesizedExpressionAndArrowParameterList and + CoverParenthesizedExpressionAndArrowParameterList ultimately derives a + phrase that, if used in place of UnaryExpression, would produce a + Syntax Error according to these rules. This rule is recursively applied. + +---*/ + + +$DONOTEVALUATE(); + +class C { + #x; + + x() { + var g = this.f; + delete ((g().#m)); + } + + f() { + return this; + } +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-twice-covered-err-delete-call-expression-private-method-gen.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-twice-covered-err-delete-call-expression-private-method-gen.js new file mode 100644 index 0000000000..7b67503b9c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-twice-covered-err-delete-call-expression-private-method-gen.js @@ -0,0 +1,49 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/err-delete-call-expression-private-method-gen.case +// - src/class-elements/delete-error/cls-decl-method-delete-twice-covered.template +/*--- +description: It's a SyntaxError if delete operator is applied to CallExpression.PrivateName generator (in method, recursively covered) +esid: sec-class-definitions-static-semantics-early-errors +features: [class-methods-private, generators, class, class-fields-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + This file must never use the onlyStrict flag as the strict mode should always + be observed inside class bodies. + + Static Semantics: Early Errors + + UnaryExpression : delete UnaryExpression + + It is a Syntax Error if the UnaryExpression is contained in strict mode + code and the derived UnaryExpression is + PrimaryExpression : IdentifierReference , + MemberExpression : MemberExpression.PrivateName , or + CallExpression : CallExpression.PrivateName . + + It is a Syntax Error if the derived UnaryExpression is + PrimaryExpression : CoverParenthesizedExpressionAndArrowParameterList and + CoverParenthesizedExpressionAndArrowParameterList ultimately derives a + phrase that, if used in place of UnaryExpression, would produce a + Syntax Error according to these rules. This rule is recursively applied. + +---*/ + + +$DONOTEVALUATE(); + +class C { + #x; + + x() { + var g = this.f; + delete ((g().#m)); + } + + f() { + return this; + } +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-twice-covered-err-delete-call-expression-private-method.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-twice-covered-err-delete-call-expression-private-method.js new file mode 100644 index 0000000000..e42ca69e69 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-twice-covered-err-delete-call-expression-private-method.js @@ -0,0 +1,49 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/err-delete-call-expression-private-method.case +// - src/class-elements/delete-error/cls-decl-method-delete-twice-covered.template +/*--- +description: It's a SyntaxError if delete operator is applied to CallExpression.PrivateName private ordinary method (in method, recursively covered) +esid: sec-class-definitions-static-semantics-early-errors +features: [class-methods-private, class, class-fields-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + This file must never use the onlyStrict flag as the strict mode should always + be observed inside class bodies. + + Static Semantics: Early Errors + + UnaryExpression : delete UnaryExpression + + It is a Syntax Error if the UnaryExpression is contained in strict mode + code and the derived UnaryExpression is + PrimaryExpression : IdentifierReference , + MemberExpression : MemberExpression.PrivateName , or + CallExpression : CallExpression.PrivateName . + + It is a Syntax Error if the derived UnaryExpression is + PrimaryExpression : CoverParenthesizedExpressionAndArrowParameterList and + CoverParenthesizedExpressionAndArrowParameterList ultimately derives a + phrase that, if used in place of UnaryExpression, would produce a + Syntax Error according to these rules. This rule is recursively applied. + +---*/ + + +$DONOTEVALUATE(); + +class C { + #x; + + x() { + var g = this.f; + delete ((g().#m)); + } + + f() { + return this; + } +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-twice-covered-err-delete-call-expression-private-no-reference.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-twice-covered-err-delete-call-expression-private-no-reference.js new file mode 100644 index 0000000000..894e6dec11 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-twice-covered-err-delete-call-expression-private-no-reference.js @@ -0,0 +1,49 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/err-delete-call-expression-private-no-reference.case +// - src/class-elements/delete-error/cls-decl-method-delete-twice-covered.template +/*--- +description: It's a SyntaxError if delete operator is applied to CallExpression.PrivateName no referencing class element (in method, recursively covered) +esid: sec-class-definitions-static-semantics-early-errors +features: [class, class-fields-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + This file must never use the onlyStrict flag as the strict mode should always + be observed inside class bodies. + + Static Semantics: Early Errors + + UnaryExpression : delete UnaryExpression + + It is a Syntax Error if the UnaryExpression is contained in strict mode + code and the derived UnaryExpression is + PrimaryExpression : IdentifierReference , + MemberExpression : MemberExpression.PrivateName , or + CallExpression : CallExpression.PrivateName . + + It is a Syntax Error if the derived UnaryExpression is + PrimaryExpression : CoverParenthesizedExpressionAndArrowParameterList and + CoverParenthesizedExpressionAndArrowParameterList ultimately derives a + phrase that, if used in place of UnaryExpression, would produce a + Syntax Error according to these rules. This rule is recursively applied. + +---*/ + + +$DONOTEVALUATE(); + +class C { + #x; + + x() { + var g = this.f; + delete ((g().#m)); + } + + f() { + return this; + } +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-twice-covered-err-delete-call-expression-privatename.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-twice-covered-err-delete-call-expression-privatename.js new file mode 100644 index 0000000000..3369ed7036 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-twice-covered-err-delete-call-expression-privatename.js @@ -0,0 +1,49 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/err-delete-call-expression-privatename.case +// - src/class-elements/delete-error/cls-decl-method-delete-twice-covered.template +/*--- +description: It's a SyntaxError if delete operator is applied to CallExpression.PrivateName private field (in method, recursively covered) +esid: sec-class-definitions-static-semantics-early-errors +features: [class, class-fields-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + This file must never use the onlyStrict flag as the strict mode should always + be observed inside class bodies. + + Static Semantics: Early Errors + + UnaryExpression : delete UnaryExpression + + It is a Syntax Error if the UnaryExpression is contained in strict mode + code and the derived UnaryExpression is + PrimaryExpression : IdentifierReference , + MemberExpression : MemberExpression.PrivateName , or + CallExpression : CallExpression.PrivateName . + + It is a Syntax Error if the derived UnaryExpression is + PrimaryExpression : CoverParenthesizedExpressionAndArrowParameterList and + CoverParenthesizedExpressionAndArrowParameterList ultimately derives a + phrase that, if used in place of UnaryExpression, would produce a + Syntax Error according to these rules. This rule is recursively applied. + +---*/ + + +$DONOTEVALUATE(); + +class C { + #x; + + x() { + var g = this.f; + delete ((g().#x)); + } + + f() { + return this; + } +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-twice-covered-err-delete-member-expression-private-method-accessor-get.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-twice-covered-err-delete-member-expression-private-method-accessor-get.js new file mode 100644 index 0000000000..f2d177b212 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-twice-covered-err-delete-member-expression-private-method-accessor-get.js @@ -0,0 +1,48 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/err-delete-member-expression-private-method-accessor-get.case +// - src/class-elements/delete-error/cls-decl-method-delete-twice-covered.template +/*--- +description: It's a SyntaxError if delete operator is applied to MemberExpression.PrivateName accessor get method (in method, recursively covered) +esid: sec-class-definitions-static-semantics-early-errors +features: [class-methods-private, class, class-fields-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + This file must never use the onlyStrict flag as the strict mode should always + be observed inside class bodies. + + Static Semantics: Early Errors + + UnaryExpression : delete UnaryExpression + + It is a Syntax Error if the UnaryExpression is contained in strict mode + code and the derived UnaryExpression is + PrimaryExpression : IdentifierReference , + MemberExpression : MemberExpression.PrivateName , or + CallExpression : CallExpression.PrivateName . + + It is a Syntax Error if the derived UnaryExpression is + PrimaryExpression : CoverParenthesizedExpressionAndArrowParameterList and + CoverParenthesizedExpressionAndArrowParameterList ultimately derives a + phrase that, if used in place of UnaryExpression, would produce a + Syntax Error according to these rules. This rule is recursively applied. + +---*/ + + +$DONOTEVALUATE(); + +class C { + #x; + + x() { + + delete ((this.#m +)); + } + + +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-twice-covered-err-delete-member-expression-private-method-accessor-set.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-twice-covered-err-delete-member-expression-private-method-accessor-set.js new file mode 100644 index 0000000000..5dc1a2ce6b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-twice-covered-err-delete-member-expression-private-method-accessor-set.js @@ -0,0 +1,48 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/err-delete-member-expression-private-method-accessor-set.case +// - src/class-elements/delete-error/cls-decl-method-delete-twice-covered.template +/*--- +description: It's a SyntaxError if delete operator is applied to MemberExpression.PrivateName accessor set method (in method, recursively covered) +esid: sec-class-definitions-static-semantics-early-errors +features: [class-methods-private, class, class-fields-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + This file must never use the onlyStrict flag as the strict mode should always + be observed inside class bodies. + + Static Semantics: Early Errors + + UnaryExpression : delete UnaryExpression + + It is a Syntax Error if the UnaryExpression is contained in strict mode + code and the derived UnaryExpression is + PrimaryExpression : IdentifierReference , + MemberExpression : MemberExpression.PrivateName , or + CallExpression : CallExpression.PrivateName . + + It is a Syntax Error if the derived UnaryExpression is + PrimaryExpression : CoverParenthesizedExpressionAndArrowParameterList and + CoverParenthesizedExpressionAndArrowParameterList ultimately derives a + phrase that, if used in place of UnaryExpression, would produce a + Syntax Error according to these rules. This rule is recursively applied. + +---*/ + + +$DONOTEVALUATE(); + +class C { + #x; + + x() { + + delete ((this.#m +)); + } + + +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-twice-covered-err-delete-member-expression-private-method-async-gen.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-twice-covered-err-delete-member-expression-private-method-async-gen.js new file mode 100644 index 0000000000..587b65efaa --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-twice-covered-err-delete-member-expression-private-method-async-gen.js @@ -0,0 +1,48 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/err-delete-member-expression-private-method-async-gen.case +// - src/class-elements/delete-error/cls-decl-method-delete-twice-covered.template +/*--- +description: It's a SyntaxError if delete operator is applied to MemberExpression.PrivateName async generator (in method, recursively covered) +esid: sec-class-definitions-static-semantics-early-errors +features: [class-methods-private, async-iteration, class, class-fields-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + This file must never use the onlyStrict flag as the strict mode should always + be observed inside class bodies. + + Static Semantics: Early Errors + + UnaryExpression : delete UnaryExpression + + It is a Syntax Error if the UnaryExpression is contained in strict mode + code and the derived UnaryExpression is + PrimaryExpression : IdentifierReference , + MemberExpression : MemberExpression.PrivateName , or + CallExpression : CallExpression.PrivateName . + + It is a Syntax Error if the derived UnaryExpression is + PrimaryExpression : CoverParenthesizedExpressionAndArrowParameterList and + CoverParenthesizedExpressionAndArrowParameterList ultimately derives a + phrase that, if used in place of UnaryExpression, would produce a + Syntax Error according to these rules. This rule is recursively applied. + +---*/ + + +$DONOTEVALUATE(); + +class C { + #x; + + x() { + + delete ((this.#m +)); + } + + async *#m() {} +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-twice-covered-err-delete-member-expression-private-method-async.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-twice-covered-err-delete-member-expression-private-method-async.js new file mode 100644 index 0000000000..f76f8015b9 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-twice-covered-err-delete-member-expression-private-method-async.js @@ -0,0 +1,48 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/err-delete-member-expression-private-method-async.case +// - src/class-elements/delete-error/cls-decl-method-delete-twice-covered.template +/*--- +description: It's a SyntaxError if delete operator is applied to MemberExpression.PrivateName async method (in method, recursively covered) +esid: sec-class-definitions-static-semantics-early-errors +features: [class-methods-private, async-functions, class, class-fields-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + This file must never use the onlyStrict flag as the strict mode should always + be observed inside class bodies. + + Static Semantics: Early Errors + + UnaryExpression : delete UnaryExpression + + It is a Syntax Error if the UnaryExpression is contained in strict mode + code and the derived UnaryExpression is + PrimaryExpression : IdentifierReference , + MemberExpression : MemberExpression.PrivateName , or + CallExpression : CallExpression.PrivateName . + + It is a Syntax Error if the derived UnaryExpression is + PrimaryExpression : CoverParenthesizedExpressionAndArrowParameterList and + CoverParenthesizedExpressionAndArrowParameterList ultimately derives a + phrase that, if used in place of UnaryExpression, would produce a + Syntax Error according to these rules. This rule is recursively applied. + +---*/ + + +$DONOTEVALUATE(); + +class C { + #x; + + x() { + + delete ((this.#m +)); + } + + async #m() {} +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-twice-covered-err-delete-member-expression-private-method-gen.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-twice-covered-err-delete-member-expression-private-method-gen.js new file mode 100644 index 0000000000..573901042b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-twice-covered-err-delete-member-expression-private-method-gen.js @@ -0,0 +1,48 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/err-delete-member-expression-private-method-gen.case +// - src/class-elements/delete-error/cls-decl-method-delete-twice-covered.template +/*--- +description: It's a SyntaxError if delete operator is applied to MemberExpression.PrivateName generator (in method, recursively covered) +esid: sec-class-definitions-static-semantics-early-errors +features: [class-methods-private, generators, class, class-fields-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + This file must never use the onlyStrict flag as the strict mode should always + be observed inside class bodies. + + Static Semantics: Early Errors + + UnaryExpression : delete UnaryExpression + + It is a Syntax Error if the UnaryExpression is contained in strict mode + code and the derived UnaryExpression is + PrimaryExpression : IdentifierReference , + MemberExpression : MemberExpression.PrivateName , or + CallExpression : CallExpression.PrivateName . + + It is a Syntax Error if the derived UnaryExpression is + PrimaryExpression : CoverParenthesizedExpressionAndArrowParameterList and + CoverParenthesizedExpressionAndArrowParameterList ultimately derives a + phrase that, if used in place of UnaryExpression, would produce a + Syntax Error according to these rules. This rule is recursively applied. + +---*/ + + +$DONOTEVALUATE(); + +class C { + #x; + + x() { + + delete ((this.#m +)); + } + + *#m() {} +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-twice-covered-err-delete-member-expression-private-method.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-twice-covered-err-delete-member-expression-private-method.js new file mode 100644 index 0000000000..e5467a13e3 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-twice-covered-err-delete-member-expression-private-method.js @@ -0,0 +1,48 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/err-delete-member-expression-private-method.case +// - src/class-elements/delete-error/cls-decl-method-delete-twice-covered.template +/*--- +description: It's a SyntaxError if delete operator is applied to MemberExpression.PrivateName private ordinary method (in method, recursively covered) +esid: sec-class-definitions-static-semantics-early-errors +features: [class-methods-private, class, class-fields-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + This file must never use the onlyStrict flag as the strict mode should always + be observed inside class bodies. + + Static Semantics: Early Errors + + UnaryExpression : delete UnaryExpression + + It is a Syntax Error if the UnaryExpression is contained in strict mode + code and the derived UnaryExpression is + PrimaryExpression : IdentifierReference , + MemberExpression : MemberExpression.PrivateName , or + CallExpression : CallExpression.PrivateName . + + It is a Syntax Error if the derived UnaryExpression is + PrimaryExpression : CoverParenthesizedExpressionAndArrowParameterList and + CoverParenthesizedExpressionAndArrowParameterList ultimately derives a + phrase that, if used in place of UnaryExpression, would produce a + Syntax Error according to these rules. This rule is recursively applied. + +---*/ + + +$DONOTEVALUATE(); + +class C { + #x; + + x() { + + delete ((this.#m +)); + } + + +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-twice-covered-err-delete-member-expression-private-no-reference.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-twice-covered-err-delete-member-expression-private-no-reference.js new file mode 100644 index 0000000000..568d177eaf --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-twice-covered-err-delete-member-expression-private-no-reference.js @@ -0,0 +1,47 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/err-delete-member-expression-private-no-reference.case +// - src/class-elements/delete-error/cls-decl-method-delete-twice-covered.template +/*--- +description: It's a SyntaxError if delete operator is applied to MemberExpression.PrivateName no referencing class element (in method, recursively covered) +esid: sec-class-definitions-static-semantics-early-errors +features: [class, class-fields-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + This file must never use the onlyStrict flag as the strict mode should always + be observed inside class bodies. + + Static Semantics: Early Errors + + UnaryExpression : delete UnaryExpression + + It is a Syntax Error if the UnaryExpression is contained in strict mode + code and the derived UnaryExpression is + PrimaryExpression : IdentifierReference , + MemberExpression : MemberExpression.PrivateName , or + CallExpression : CallExpression.PrivateName . + + It is a Syntax Error if the derived UnaryExpression is + PrimaryExpression : CoverParenthesizedExpressionAndArrowParameterList and + CoverParenthesizedExpressionAndArrowParameterList ultimately derives a + phrase that, if used in place of UnaryExpression, would produce a + Syntax Error according to these rules. This rule is recursively applied. + +---*/ + + +$DONOTEVALUATE(); + +class C { + #x; + + x() { + + delete ((this.#m)); + } + + +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-twice-covered-err-delete-member-expression-privatename.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-twice-covered-err-delete-member-expression-privatename.js new file mode 100644 index 0000000000..60ba271d21 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/method-delete-twice-covered-err-delete-member-expression-privatename.js @@ -0,0 +1,47 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/err-delete-member-expression-privatename.case +// - src/class-elements/delete-error/cls-decl-method-delete-twice-covered.template +/*--- +description: It's a SyntaxError if delete operator is applied to MemberExpression.PrivateName private field (in method, recursively covered) +esid: sec-class-definitions-static-semantics-early-errors +features: [class, class-fields-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + This file must never use the onlyStrict flag as the strict mode should always + be observed inside class bodies. + + Static Semantics: Early Errors + + UnaryExpression : delete UnaryExpression + + It is a Syntax Error if the UnaryExpression is contained in strict mode + code and the derived UnaryExpression is + PrimaryExpression : IdentifierReference , + MemberExpression : MemberExpression.PrivateName , or + CallExpression : CallExpression.PrivateName . + + It is a Syntax Error if the derived UnaryExpression is + PrimaryExpression : CoverParenthesizedExpressionAndArrowParameterList and + CoverParenthesizedExpressionAndArrowParameterList ultimately derives a + phrase that, if used in place of UnaryExpression, would produce a + Syntax Error according to these rules. This rule is recursively applied. + +---*/ + + +$DONOTEVALUATE(); + +class C { + #x; + + x() { + + delete ((this.#x)); + } + + +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/shell.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/delete/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-class-body-ctor-duplicate.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-class-body-ctor-duplicate.js new file mode 100644 index 0000000000..db30575dd6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-class-body-ctor-duplicate.js @@ -0,0 +1,26 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-class-body-ctor-duplicate.case +// - src/class-elements/syntax/invalid/cls-decl-elements-invalid-syntax.template +/*--- +description: It is a SyntaxError if the class body has more than one constructor (class declaration) +esid: prod-ClassElement +features: [class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassBody : ClassElementList + It is a Syntax Error if PrototypePropertyNameList of ClassElementList contains more + than one occurrence of "constructor". + +---*/ + + +$DONOTEVALUATE(); + +class C { + constructor() {} + constructor() {} +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-ctor-super-no-heritage.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-ctor-super-no-heritage.js new file mode 100644 index 0000000000..70fbce6ef2 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-ctor-super-no-heritage.js @@ -0,0 +1,30 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-ctor-super-no-heritage.case +// - src/class-elements/syntax/invalid/cls-decl-elements-invalid-syntax.template +/*--- +description: It is a SyntaxError if class has no heritage and constructor has a direct super (class declaration) +esid: prod-ClassElement +features: [class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassTail : ClassHeritageopt { ClassBody } + + It is a Syntax Error if ClassHeritage is not present and the following algorithm evaluates to true: + 1. Let constructor be ConstructorMethod of ClassBody. + 2. If constructor is empty, return false. + 3. Return HasDirectSuper of constructor. + +---*/ + + +$DONOTEVALUATE(); + +class C { + constructor() { + super(); + } +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-field-identifier-invalid-ues-error.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-field-identifier-invalid-ues-error.js new file mode 100644 index 0000000000..8da16c9904 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-field-identifier-invalid-ues-error.js @@ -0,0 +1,71 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-field-identifier-invalid-ues-error.case +// - src/class-elements/syntax/invalid/cls-decl-elements-invalid-syntax.template +/*--- +description: Invalid FieldDefinition, ClassElementName, PropertyName Syntax (class declaration) +esid: prod-ClassElement +features: [class-fields-public, class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PropertyName : + LiteralPropertyName + ComputedPropertyName + + LiteralPropertyName : + IdentifierName + StringLiteral + NumericLiteral + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart :: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart :: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue :: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +$DONOTEVALUATE(); + +class C { + \u0000; +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-field-identifier-invalid-zwj-error.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-field-identifier-invalid-zwj-error.js new file mode 100644 index 0000000000..6b445d097d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-field-identifier-invalid-zwj-error.js @@ -0,0 +1,71 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-field-identifier-invalid-zwj-error.case +// - src/class-elements/syntax/invalid/cls-decl-elements-invalid-syntax.template +/*--- +description: Invalid FieldDefinition, ClassElementName, PropertyName Syntax (class declaration) +esid: prod-ClassElement +features: [class-fields-public, class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PropertyName : + LiteralPropertyName + ComputedPropertyName + + LiteralPropertyName : + IdentifierName + StringLiteral + NumericLiteral + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart :: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart :: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue :: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +$DONOTEVALUATE(); + +class C { + \u200D_ZWJ; +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-field-identifier-invalid-zwnj-error.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-field-identifier-invalid-zwnj-error.js new file mode 100644 index 0000000000..da49b2eddb --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-field-identifier-invalid-zwnj-error.js @@ -0,0 +1,71 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-field-identifier-invalid-zwnj-error.case +// - src/class-elements/syntax/invalid/cls-decl-elements-invalid-syntax.template +/*--- +description: Invalid FieldDefinition, ClassElementName, PropertyName Syntax (class declaration) +esid: prod-ClassElement +features: [class-fields-public, class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PropertyName : + LiteralPropertyName + ComputedPropertyName + + LiteralPropertyName : + IdentifierName + StringLiteral + NumericLiteral + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart :: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart :: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue :: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +$DONOTEVALUATE(); + +class C { + \u200C_ZWNJ; +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-fields-same-line-error.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-fields-same-line-error.js new file mode 100644 index 0000000000..be7608def1 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-fields-same-line-error.js @@ -0,0 +1,34 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-fields-same-line-error.case +// - src/class-elements/syntax/invalid/cls-decl-elements-invalid-syntax.template +/*--- +description: SyntaxError (class declaration) +esid: prod-ClassElement +features: [class-fields-public, class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + +---*/ + + +$DONOTEVALUATE(); + +class C { + x y +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-private-environment-on-class-heritage-array-literal.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-private-environment-on-class-heritage-array-literal.js new file mode 100644 index 0000000000..de14f96cd7 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-private-environment-on-class-heritage-array-literal.js @@ -0,0 +1,40 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-private-environment-on-class-heritage-array-literal.case +// - src/class-elements/syntax/invalid/cls-decl-elements-invalid-syntax.template +/*--- +description: It's a SyntaxError if an array literal evaluated on ClassHeritage uses a private name. (class declaration) +esid: prod-ClassElement +features: [class-fields-private, class-fields-public, class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Runtime Semantics: ClassDefinitionEvaluation + + ClassTail : ClassHeritage { ClassBody } + ... + 5. Let outerPrivateEnvironment be the PrivateEnvironment of the running execution context. + 6. Let classPrivateEnvironment be NewDeclarativeEnvironment(outerPrivateEnvironment). + 7. Let classPrivateEnvRec be classPrivateEnvironment's EnvironmentRecord. + 8. If ClassBodyopt is present, then + a. For each element dn of the PrivateBoundIdentifiers of ClassBodyopt, + i. Perform classPrivateEnvRec.CreateImmutableBinding(dn, true). + 9. If ClassHeritageopt is not present, then + a. Let protoParent be the intrinsic object %ObjectPrototype%. + b. Let constructorParent be the intrinsic object %FunctionPrototype%. + 10. Else, + a. Set the running execution context's LexicalEnvironment to classScope. + b. NOTE: The running execution context's PrivateEnvironment is outerPrivateEnvironment when evaluating ClassHeritage. + ... + +---*/ + + +$DONOTEVALUATE(); + +class C extends (o) => [o.#foo] +{ + #foo; +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-private-environment-on-class-heritage-chained-usage.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-private-environment-on-class-heritage-chained-usage.js new file mode 100644 index 0000000000..94986520f9 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-private-environment-on-class-heritage-chained-usage.js @@ -0,0 +1,40 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-private-environment-on-class-heritage-chained-usage.case +// - src/class-elements/syntax/invalid/cls-decl-elements-invalid-syntax.template +/*--- +description: It's a SyntaxError if a class expression evaluated on ClassHeritage uses an private name declared on subclass. (class declaration) +esid: prod-ClassElement +features: [class-fields-private, class-fields-public, class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Runtime Semantics: ClassDefinitionEvaluation + + ClassTail : ClassHeritage { ClassBody } + ... + 5. Let outerPrivateEnvironment be the PrivateEnvironment of the running execution context. + 6. Let classPrivateEnvironment be NewDeclarativeEnvironment(outerPrivateEnvironment). + 7. Let classPrivateEnvRec be classPrivateEnvironment's EnvironmentRecord. + 8. If ClassBodyopt is present, then + a. For each element dn of the PrivateBoundIdentifiers of ClassBodyopt, + i. Perform classPrivateEnvRec.CreateImmutableBinding(dn, true). + 9. If ClassHeritageopt is not present, then + a. Let protoParent be the intrinsic object %ObjectPrototype%. + b. Let constructorParent be the intrinsic object %FunctionPrototype%. + 10. Else, + a. Set the running execution context's LexicalEnvironment to classScope. + b. NOTE: The running execution context's PrivateEnvironment is outerPrivateEnvironment when evaluating ClassHeritage. + ... + +---*/ + + +$DONOTEVALUATE(); + +class C extends class extends class extends class { x = this.#foo; } { #foo; x = this.#bar; } { #bar; x = this.#fuz; } +{ + #fuz; +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-private-environment-on-class-heritage-function-expression.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-private-environment-on-class-heritage-function-expression.js new file mode 100644 index 0000000000..2d65e00933 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-private-environment-on-class-heritage-function-expression.js @@ -0,0 +1,40 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-private-environment-on-class-heritage-function-expression.case +// - src/class-elements/syntax/invalid/cls-decl-elements-invalid-syntax.template +/*--- +description: It's a SyntaxError if a function expression evaluated on ClassHeritage uses a private name. (class declaration) +esid: prod-ClassElement +features: [class-fields-private, class-fields-public, class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Runtime Semantics: ClassDefinitionEvaluation + + ClassTail : ClassHeritage { ClassBody } + ... + 5. Let outerPrivateEnvironment be the PrivateEnvironment of the running execution context. + 6. Let classPrivateEnvironment be NewDeclarativeEnvironment(outerPrivateEnvironment). + 7. Let classPrivateEnvRec be classPrivateEnvironment's EnvironmentRecord. + 8. If ClassBodyopt is present, then + a. For each element dn of the PrivateBoundIdentifiers of ClassBodyopt, + i. Perform classPrivateEnvRec.CreateImmutableBinding(dn, true). + 9. If ClassHeritageopt is not present, then + a. Let protoParent be the intrinsic object %ObjectPrototype%. + b. Let constructorParent be the intrinsic object %FunctionPrototype%. + 10. Else, + a. Set the running execution context's LexicalEnvironment to classScope. + b. NOTE: The running execution context's PrivateEnvironment is outerPrivateEnvironment when evaluating ClassHeritage. + ... + +---*/ + + +$DONOTEVALUATE(); + +class C extends function() { x = this.#foo; } +{ + #foo; +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-private-environment-on-class-heritage-obj-literal.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-private-environment-on-class-heritage-obj-literal.js new file mode 100644 index 0000000000..014716a774 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-private-environment-on-class-heritage-obj-literal.js @@ -0,0 +1,40 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-private-environment-on-class-heritage-obj-literal.case +// - src/class-elements/syntax/invalid/cls-decl-elements-invalid-syntax.template +/*--- +description: It's a SyntaxError if a object literal evaluated on ClassHeritage uses a private name. (class declaration) +esid: prod-ClassElement +features: [class-fields-private, class-fields-public, class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Runtime Semantics: ClassDefinitionEvaluation + + ClassTail : ClassHeritage { ClassBody } + ... + 5. Let outerPrivateEnvironment be the PrivateEnvironment of the running execution context. + 6. Let classPrivateEnvironment be NewDeclarativeEnvironment(outerPrivateEnvironment). + 7. Let classPrivateEnvRec be classPrivateEnvironment's EnvironmentRecord. + 8. If ClassBodyopt is present, then + a. For each element dn of the PrivateBoundIdentifiers of ClassBodyopt, + i. Perform classPrivateEnvRec.CreateImmutableBinding(dn, true). + 9. If ClassHeritageopt is not present, then + a. Let protoParent be the intrinsic object %ObjectPrototype%. + b. Let constructorParent be the intrinsic object %FunctionPrototype%. + 10. Else, + a. Set the running execution context's LexicalEnvironment to classScope. + b. NOTE: The running execution context's PrivateEnvironment is outerPrivateEnvironment when evaluating ClassHeritage. + ... + +---*/ + + +$DONOTEVALUATE(); + +class C extends (o) => {x: o.#foo} +{ + #foo; +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-private-environment-on-class-heritage-recursive.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-private-environment-on-class-heritage-recursive.js new file mode 100644 index 0000000000..0b8435a1a0 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-private-environment-on-class-heritage-recursive.js @@ -0,0 +1,40 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-private-environment-on-class-heritage-recursive.case +// - src/class-elements/syntax/invalid/cls-decl-elements-invalid-syntax.template +/*--- +description: It's a SyntaxError if a class expression evaluated on ClassHeritage of a ClassHeritage uses an undeclared private name. (class declaration) +esid: prod-ClassElement +features: [class-fields-private, class-fields-public, class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Runtime Semantics: ClassDefinitionEvaluation + + ClassTail : ClassHeritage { ClassBody } + ... + 5. Let outerPrivateEnvironment be the PrivateEnvironment of the running execution context. + 6. Let classPrivateEnvironment be NewDeclarativeEnvironment(outerPrivateEnvironment). + 7. Let classPrivateEnvRec be classPrivateEnvironment's EnvironmentRecord. + 8. If ClassBodyopt is present, then + a. For each element dn of the PrivateBoundIdentifiers of ClassBodyopt, + i. Perform classPrivateEnvRec.CreateImmutableBinding(dn, true). + 9. If ClassHeritageopt is not present, then + a. Let protoParent be the intrinsic object %ObjectPrototype%. + b. Let constructorParent be the intrinsic object %FunctionPrototype%. + 10. Else, + a. Set the running execution context's LexicalEnvironment to classScope. + b. NOTE: The running execution context's PrivateEnvironment is outerPrivateEnvironment when evaluating ClassHeritage. + ... + +---*/ + + +$DONOTEVALUATE(); + +class C extends class extends class { x = this.#foo; } {} +{ + #foo; +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-private-environment-on-class-heritage.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-private-environment-on-class-heritage.js new file mode 100644 index 0000000000..b981b75d32 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-private-environment-on-class-heritage.js @@ -0,0 +1,40 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-private-environment-on-class-heritage.case +// - src/class-elements/syntax/invalid/cls-decl-elements-invalid-syntax.template +/*--- +description: It's a SyntaxError if a class expression evaluated on ClassHeritage uses an undeclared private name. (class declaration) +esid: prod-ClassElement +features: [class-fields-private, class-fields-public, class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Runtime Semantics: ClassDefinitionEvaluation + + ClassTail : ClassHeritage { ClassBody } + ... + 5. Let outerPrivateEnvironment be the PrivateEnvironment of the running execution context. + 6. Let classPrivateEnvironment be NewDeclarativeEnvironment(outerPrivateEnvironment). + 7. Let classPrivateEnvRec be classPrivateEnvironment's EnvironmentRecord. + 8. If ClassBodyopt is present, then + a. For each element dn of the PrivateBoundIdentifiers of ClassBodyopt, + i. Perform classPrivateEnvRec.CreateImmutableBinding(dn, true). + 9. If ClassHeritageopt is not present, then + a. Let protoParent be the intrinsic object %ObjectPrototype%. + b. Let constructorParent be the intrinsic object %FunctionPrototype%. + 10. Else, + a. Set the running execution context's LexicalEnvironment to classScope. + b. NOTE: The running execution context's PrivateEnvironment is outerPrivateEnvironment when evaluating ClassHeritage. + ... + +---*/ + + +$DONOTEVALUATE(); + +class C extends class { x = this.#foo; } +{ + #foo; +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-private-field-on-object-destructuring.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-private-field-on-object-destructuring.js new file mode 100644 index 0000000000..8254217109 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-private-field-on-object-destructuring.js @@ -0,0 +1,33 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-private-field-on-object-destructuring.case +// - src/class-elements/syntax/invalid/cls-decl-elements-invalid-syntax.template +/*--- +description: Acessing private field from object destructuring pattern is not a valid syntax (class declaration) +esid: prod-ClassElement +features: [class-fields-private, destructuring-binding, class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Updated Productions + + ObjectAssignmentPattern[Yield, Await]: + {} + {AssignmentRestProperty[?Yield, ?Await]} + {AssignmentPropertyList[?Yield, ?Await]} + {AssignmentPropertyList[?Yield, ?Await],AssignmentRestProperty[?Yield, ?Await]opt} + +---*/ + + +$DONOTEVALUATE(); + +class C { + #x = 1; + + destructureX() { + const { #x: x } = this; + } +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-private-field-super-access.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-private-field-super-access.js new file mode 100644 index 0000000000..e690edec34 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-private-field-super-access.js @@ -0,0 +1,36 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-private-field-super-access.case +// - src/class-elements/syntax/invalid/cls-decl-elements-invalid-syntax.template +/*--- +description: Acessing private field from super is not a valid syntax (class declaration) +esid: prod-ClassElement +features: [class-fields-private, class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Updated Productions + + MemberExpression[Yield]: + MemberExpression[?Yield].PrivateName + +---*/ + + +$DONOTEVALUATE(); + +class C { + #m = function() { return 'test262'; }; + + Child = class extends C { + access() { + return super.#m; + } + + method() { + return super.#m(); + } + } +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatemeth-duplicate-async-gen.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatemeth-duplicate-async-gen.js new file mode 100644 index 0000000000..2e03782e03 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatemeth-duplicate-async-gen.js @@ -0,0 +1,27 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-privatemeth-duplicate-async-gen.case +// - src/class-elements/syntax/invalid/cls-decl-elements-invalid-syntax.template +/*--- +description: It's a SyntaxError if a class contains a private async generator and a private field with the same name (class declaration) +esid: prod-ClassElement +features: [class-methods-private, class-fields-private, async-iteration, class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Static Semantics: Early Errors + + ClassBody : ClassElementList + It is a Syntax Error if PrivateBoundNames of ClassBody contains any duplicate entries, unless the name is used once for a getter and once for a setter and in no other entries. + +---*/ + + +$DONOTEVALUATE(); + +class C { + #m; + async * #m() {} +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatemeth-duplicate-async.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatemeth-duplicate-async.js new file mode 100644 index 0000000000..17162a0fa1 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatemeth-duplicate-async.js @@ -0,0 +1,27 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-privatemeth-duplicate-async.case +// - src/class-elements/syntax/invalid/cls-decl-elements-invalid-syntax.template +/*--- +description: It's a SyntaxError if a class contains a private async function and a private field with the same name (class declaration) +esid: prod-ClassElement +features: [class-methods-private, class-fields-private, async-functions, class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Static Semantics: Early Errors + + ClassBody : ClassElementList + It is a Syntax Error if PrivateBoundNames of ClassBody contains any duplicate entries, unless the name is used once for a getter and once for a setter and in no other entries. + +---*/ + + +$DONOTEVALUATE(); + +class C { + #m; + async #m() {} +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatemeth-duplicate-gen.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatemeth-duplicate-gen.js new file mode 100644 index 0000000000..446d1695c8 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatemeth-duplicate-gen.js @@ -0,0 +1,27 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-privatemeth-duplicate-gen.case +// - src/class-elements/syntax/invalid/cls-decl-elements-invalid-syntax.template +/*--- +description: It's a SyntaxError if a class contains a private generator and a private field with the same name (class declaration) +esid: prod-ClassElement +features: [class-methods-private, class-fields-private, generators, class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Static Semantics: Early Errors + + ClassBody : ClassElementList + It is a Syntax Error if PrivateBoundNames of ClassBody contains any duplicate entries, unless the name is used once for a getter and once for a setter and in no other entries. + +---*/ + + +$DONOTEVALUATE(); + +class C { + #m; + * #m() {} +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatemeth-duplicate-get-field.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatemeth-duplicate-get-field.js new file mode 100644 index 0000000000..a8f957f57a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatemeth-duplicate-get-field.js @@ -0,0 +1,27 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-privatemeth-duplicate-get-field.case +// - src/class-elements/syntax/invalid/cls-decl-elements-invalid-syntax.template +/*--- +description: It's a SyntaxError if a class contains a private getter and a private field with the same name (class declaration) +esid: prod-ClassElement +features: [class-methods-private, class-fields-private, class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Static Semantics: Early Errors + + ClassBody : ClassElementList + It is a Syntax Error if PrivateBoundNames of ClassBody contains any duplicate entries, unless the name is used once for a getter and once for a setter and in no other entries. + +---*/ + + +$DONOTEVALUATE(); + +class C { + #m; + get #m() {} +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatemeth-duplicate-get-get.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatemeth-duplicate-get-get.js new file mode 100644 index 0000000000..e9267a0cb9 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatemeth-duplicate-get-get.js @@ -0,0 +1,27 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-privatemeth-duplicate-get-get.case +// - src/class-elements/syntax/invalid/cls-decl-elements-invalid-syntax.template +/*--- +description: It's a SyntaxError if a class contains multiple private getters with the same name (class declaration) +esid: prod-ClassElement +features: [class-methods-private, class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Static Semantics: Early Errors + + ClassBody : ClassElementList + It is a Syntax Error if PrivateBoundNames of ClassBody contains any duplicate entries, unless the name is used once for a getter and once for a setter and in no other entries. + +---*/ + + +$DONOTEVALUATE(); + +class C { + get #m() {} + get #m() {} +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatemeth-duplicate-meth-field.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatemeth-duplicate-meth-field.js new file mode 100644 index 0000000000..063ae79cf2 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatemeth-duplicate-meth-field.js @@ -0,0 +1,27 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-privatemeth-duplicate-meth-field.case +// - src/class-elements/syntax/invalid/cls-decl-elements-invalid-syntax.template +/*--- +description: It's a SyntaxError if a class contains a private method and a private field with the same name (class declaration) +esid: prod-ClassElement +features: [class-methods-private, class-fields-private, class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Static Semantics: Early Errors + + ClassBody : ClassElementList + It is a Syntax Error if PrivateBoundNames of ClassBody contains any duplicate entries, unless the name is used once for a getter and once for a setter and in no other entries. + +---*/ + + +$DONOTEVALUATE(); + +class C { + #m; + #m() {} +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatemeth-duplicate-meth-get.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatemeth-duplicate-meth-get.js new file mode 100644 index 0000000000..e7ceedf914 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatemeth-duplicate-meth-get.js @@ -0,0 +1,27 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-privatemeth-duplicate-meth-get.case +// - src/class-elements/syntax/invalid/cls-decl-elements-invalid-syntax.template +/*--- +description: It's a SyntaxError if a class contains a private method and a private getter with the same name (class declaration) +esid: prod-ClassElement +features: [class-methods-private, class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Static Semantics: Early Errors + + ClassBody : ClassElementList + It is a Syntax Error if PrivateBoundNames of ClassBody contains any duplicate entries, unless the name is used once for a getter and once for a setter and in no other entries. + +---*/ + + +$DONOTEVALUATE(); + +class C { + get #m() {} + #m() {} +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatemeth-duplicate-meth-meth.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatemeth-duplicate-meth-meth.js new file mode 100644 index 0000000000..9b67e895f7 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatemeth-duplicate-meth-meth.js @@ -0,0 +1,27 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-privatemeth-duplicate-meth-meth.case +// - src/class-elements/syntax/invalid/cls-decl-elements-invalid-syntax.template +/*--- +description: It's a SyntaxError if a class contains multiple private methods with the same name (class declaration) +esid: prod-ClassElement +features: [class-methods-private, class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Static Semantics: Early Errors + + ClassBody : ClassElementList + It is a Syntax Error if PrivateBoundNames of ClassBody contains any duplicate entries, unless the name is used once for a getter and once for a setter and in no other entries. + +---*/ + + +$DONOTEVALUATE(); + +class C { + #m() {} + #m() {} +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatemeth-duplicate-meth-set.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatemeth-duplicate-meth-set.js new file mode 100644 index 0000000000..732c8f0717 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatemeth-duplicate-meth-set.js @@ -0,0 +1,27 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-privatemeth-duplicate-meth-set.case +// - src/class-elements/syntax/invalid/cls-decl-elements-invalid-syntax.template +/*--- +description: It's a SyntaxError if a class contains a private method and a private setter with the same name (class declaration) +esid: prod-ClassElement +features: [class-methods-private, class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Static Semantics: Early Errors + + ClassBody : ClassElementList + It is a Syntax Error if PrivateBoundNames of ClassBody contains any duplicate entries, unless the name is used once for a getter and once for a setter and in no other entries. + +---*/ + + +$DONOTEVALUATE(); + +class C { + set #m(_) {} + #m() {} +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatemeth-duplicate-meth-staticfield.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatemeth-duplicate-meth-staticfield.js new file mode 100644 index 0000000000..2a4f444bb7 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatemeth-duplicate-meth-staticfield.js @@ -0,0 +1,27 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-privatemeth-duplicate-meth-staticfield.case +// - src/class-elements/syntax/invalid/cls-decl-elements-invalid-syntax.template +/*--- +description: It's a SyntaxError if a class contains a private method and a private static field with the same name (class declaration) +esid: prod-ClassElement +features: [class-methods-private, class-static-fields-private, class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Static Semantics: Early Errors + + ClassBody : ClassElementList + It is a Syntax Error if PrivateBoundNames of ClassBody contains any duplicate entries, unless the name is used once for a getter and once for a setter and in no other entries. + +---*/ + + +$DONOTEVALUATE(); + +class C { + static #m; + #m() {} +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatemeth-duplicate-meth-staticmeth.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatemeth-duplicate-meth-staticmeth.js new file mode 100644 index 0000000000..c505a7eac5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatemeth-duplicate-meth-staticmeth.js @@ -0,0 +1,27 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-privatemeth-duplicate-meth-staticmeth.case +// - src/class-elements/syntax/invalid/cls-decl-elements-invalid-syntax.template +/*--- +description: It's a SyntaxError if a class contains a private method and a private static method with the same name (class declaration) +esid: prod-ClassElement +features: [class-methods-private, class-static-methods-private, class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Static Semantics: Early Errors + + ClassBody : ClassElementList + It is a Syntax Error if PrivateBoundNames of ClassBody contains any duplicate entries, unless the name is used once for a getter and once for a setter and in no other entries. + +---*/ + + +$DONOTEVALUATE(); + +class C { + static #m() {} + #m() {} +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatemeth-duplicate-set-field.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatemeth-duplicate-set-field.js new file mode 100644 index 0000000000..42710bd0d7 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatemeth-duplicate-set-field.js @@ -0,0 +1,27 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-privatemeth-duplicate-set-field.case +// - src/class-elements/syntax/invalid/cls-decl-elements-invalid-syntax.template +/*--- +description: It's a SyntaxError if a class contains a private setter and a private field with the same name (class declaration) +esid: prod-ClassElement +features: [class-methods-private, class-fields-private, class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Static Semantics: Early Errors + + ClassBody : ClassElementList + It is a Syntax Error if PrivateBoundNames of ClassBody contains any duplicate entries, unless the name is used once for a getter and once for a setter and in no other entries. + +---*/ + + +$DONOTEVALUATE(); + +class C { + #m; + set #m(_) {} +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatemeth-duplicate-set-set.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatemeth-duplicate-set-set.js new file mode 100644 index 0000000000..209cf3c7be --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatemeth-duplicate-set-set.js @@ -0,0 +1,27 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-privatemeth-duplicate-set-set.case +// - src/class-elements/syntax/invalid/cls-decl-elements-invalid-syntax.template +/*--- +description: It's a SyntaxError if a class contains multiple private setters with the same name (class declaration) +esid: prod-ClassElement +features: [class-methods-private, class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Static Semantics: Early Errors + + ClassBody : ClassElementList + It is a Syntax Error if PrivateBoundNames of ClassBody contains any duplicate entries, unless the name is used once for a getter and once for a setter and in no other entries. + +---*/ + + +$DONOTEVALUATE(); + +class C { + set #m(_) {} + set #m(_) {} +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatename-constructor.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatename-constructor.js new file mode 100644 index 0000000000..2662c8dc9a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatename-constructor.js @@ -0,0 +1,26 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-privatename-constructor.case +// - src/class-elements/syntax/invalid/cls-decl-elements-invalid-syntax.template +/*--- +description: Private Fields cannot be named constructor (class declaration) +esid: prod-ClassElement +features: [class-fields-private, class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Class Definitions / Static Semantics: Early Errors + + ClassElementName : PrivateName ; + It is a Syntax Error if StringValue of PrivateName is "#constructor" + +---*/ + + +$DONOTEVALUATE(); + +class C { + #constructor +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatename-error.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatename-error.js new file mode 100644 index 0000000000..1dd4589a4a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatename-error.js @@ -0,0 +1,37 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-privatename-error.case +// - src/class-elements/syntax/invalid/cls-decl-elements-invalid-syntax.template +/*--- +description: No space allowed between sigial and IdentifierName (class declaration) +esid: prod-ClassElement +features: [class-fields-private, class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + +---*/ + + +$DONOTEVALUATE(); + +class C { + # x +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatename-identifier-invalid-ues.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatename-identifier-invalid-ues.js new file mode 100644 index 0000000000..a30cc3819d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatename-identifier-invalid-ues.js @@ -0,0 +1,65 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-privatename-identifier-invalid-ues.case +// - src/class-elements/syntax/invalid/cls-decl-elements-invalid-syntax.template +/*--- +description: Valid PrivateName Syntax (class declaration) +esid: prod-ClassElement +features: [class-fields-private, class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +$DONOTEVALUATE(); + +class C { + #\u0000; +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatename-identifier-invalid-zwj-error.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatename-identifier-invalid-zwj-error.js new file mode 100644 index 0000000000..03d1346bc9 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatename-identifier-invalid-zwj-error.js @@ -0,0 +1,66 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-privatename-identifier-invalid-zwj-error.case +// - src/class-elements/syntax/invalid/cls-decl-elements-invalid-syntax.template +/*--- +description: Valid PrivateName Syntax (class declaration) +esid: prod-ClassElement +features: [class-fields-private, class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +$DONOTEVALUATE(); + +class C { + #\u200D_ZWJ; + +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatename-identifier-invalid-zwnj-error.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatename-identifier-invalid-zwnj-error.js new file mode 100644 index 0000000000..d08d92b990 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatename-identifier-invalid-zwnj-error.js @@ -0,0 +1,66 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-privatename-identifier-invalid-zwnj-error.case +// - src/class-elements/syntax/invalid/cls-decl-elements-invalid-syntax.template +/*--- +description: Valid PrivateName Syntax (class declaration) +esid: prod-ClassElement +features: [class-fields-private, class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +$DONOTEVALUATE(); + +class C { + #\u200C_ZWNJ; + +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatename-in-computed-property-missing.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatename-in-computed-property-missing.js new file mode 100644 index 0000000000..ea4682b234 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatename-in-computed-property-missing.js @@ -0,0 +1,53 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-privatename-in-computed-property-missing.case +// - src/class-elements/syntax/invalid/cls-decl-elements-invalid-syntax.template +/*--- +description: Use of undeclared PrivateName in ComputedProperty is a syntax error (class declaration) +esid: prod-ClassElement +features: [class-fields-private, class-fields-public, class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElementName: + PropertyName + PrivateIdentifier + + PropertyName: + LiteralPropertyName + ComputedPropertyName + + ComputedPropertyName: + [ AssignmentExpression ] + + AssignmentExpression ... MemberExpression + + MemberExpression: + MemberExpression . PrivateName + + Static Semantics: AllPrivateIdentifiersValid + AllPrivateIdentifiersValid is an abstract operation which takes names as an argument. + + MemberExpression : MemberExpression . PrivateIdentifier + 1. If StringValue of PrivateIdentifier is in names, return true. + 2. Return false. + + ClassBody : ClassElementList + 1. Let newNames be the concatenation of names with PrivateBoundIdentifiers of ClassBody. + 2. Return AllPrivateIdentifiersValid of ClassElementList with the argument newNames. + + Static Semantics: Early Errors + + ScriptBody : StatementList + It is a Syntax Error if AllPrivateIdentifiersValid of StatementList with an empty List as an argument is false unless the source code is eval code that is being processed by a direct eval. + +---*/ + + +$DONOTEVALUATE(); + +class C { + [this.#f] = 'Test262' +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatename-whitespace-error-accessor-get-meth.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatename-whitespace-error-accessor-get-meth.js new file mode 100644 index 0000000000..cff10054a3 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatename-whitespace-error-accessor-get-meth.js @@ -0,0 +1,30 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-privatename-whitespace-error-accessor-get-meth.case +// - src/class-elements/syntax/invalid/cls-decl-elements-invalid-syntax.template +/*--- +description: No space allowed between sigil and IdentifierName () (class declaration) +esid: prod-ClassElement +features: [class-methods-private, class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Updated Productions + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + +---*/ + + +$DONOTEVALUATE(); + +class C { + get # m() {} +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatename-whitespace-error-accessor-set-meth.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatename-whitespace-error-accessor-set-meth.js new file mode 100644 index 0000000000..0868afc3c9 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatename-whitespace-error-accessor-set-meth.js @@ -0,0 +1,30 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-privatename-whitespace-error-accessor-set-meth.case +// - src/class-elements/syntax/invalid/cls-decl-elements-invalid-syntax.template +/*--- +description: No space allowed between sigil and IdentifierName (Accessor set Method) (class declaration) +esid: prod-ClassElement +features: [class-methods-private, class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Updated Productions + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + +---*/ + + +$DONOTEVALUATE(); + +class C { + set # m(_) {} +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatename-whitespace-error-async-gen-meth.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatename-whitespace-error-async-gen-meth.js new file mode 100644 index 0000000000..0eb87b2265 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatename-whitespace-error-async-gen-meth.js @@ -0,0 +1,30 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-privatename-whitespace-error-async-gen-meth.case +// - src/class-elements/syntax/invalid/cls-decl-elements-invalid-syntax.template +/*--- +description: No space allowed between sigil and IdentifierName (Async Generator Method) (class declaration) +esid: prod-ClassElement +features: [async-iteration, class-methods-private, class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Updated Productions + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + +---*/ + + +$DONOTEVALUATE(); + +class C { + async * # m() {} +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatename-whitespace-error-async-meth.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatename-whitespace-error-async-meth.js new file mode 100644 index 0000000000..4faf4f22df --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatename-whitespace-error-async-meth.js @@ -0,0 +1,30 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-privatename-whitespace-error-async-meth.case +// - src/class-elements/syntax/invalid/cls-decl-elements-invalid-syntax.template +/*--- +description: No space allowed between sigil and IdentifierName (Async Method) (class declaration) +esid: prod-ClassElement +features: [async-functions, class-methods-private, class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Updated Productions + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + +---*/ + + +$DONOTEVALUATE(); + +class C { + async # m() {} +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatename-whitespace-error-call-expr.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatename-whitespace-error-call-expr.js new file mode 100644 index 0000000000..a458dfd915 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatename-whitespace-error-call-expr.js @@ -0,0 +1,40 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-privatename-whitespace-error-call-expr.case +// - src/class-elements/syntax/invalid/cls-decl-elements-invalid-syntax.template +/*--- +description: No space allowed between sigil and IdentifierName (CallExpression) (class declaration) +esid: prod-ClassElement +features: [class-fields-private, class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Updated Productions + + MemberExpression : + MemberExpression . PrivateName + + CallExpression : + CallExpression . PrivateName + + PrivateName :: + # IdentifierName + +---*/ + + +$DONOTEVALUATE(); + +class C { + #x; + + f() { + return this; + } + + m() { + this.f().# x; + } +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatename-whitespace-error-field-init.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatename-whitespace-error-field-init.js new file mode 100644 index 0000000000..4dc6ea1095 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatename-whitespace-error-field-init.js @@ -0,0 +1,30 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-privatename-whitespace-error-field-init.case +// - src/class-elements/syntax/invalid/cls-decl-elements-invalid-syntax.template +/*--- +description: No space allowed between sigil and IdentifierName (Field with Initializer) (class declaration) +esid: prod-ClassElement +features: [class-fields-private, class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Updated Productions + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + +---*/ + + +$DONOTEVALUATE(); + +class C { + # x = 1; +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatename-whitespace-error-field.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatename-whitespace-error-field.js new file mode 100644 index 0000000000..ca62d39397 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatename-whitespace-error-field.js @@ -0,0 +1,30 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-privatename-whitespace-error-field.case +// - src/class-elements/syntax/invalid/cls-decl-elements-invalid-syntax.template +/*--- +description: No space allowed between sigil and IdentifierName (Field) (class declaration) +esid: prod-ClassElement +features: [class-fields-private, class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Updated Productions + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + +---*/ + + +$DONOTEVALUATE(); + +class C { + # x; +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatename-whitespace-error-gen-meth.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatename-whitespace-error-gen-meth.js new file mode 100644 index 0000000000..d16e23ef6f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatename-whitespace-error-gen-meth.js @@ -0,0 +1,30 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-privatename-whitespace-error-gen-meth.case +// - src/class-elements/syntax/invalid/cls-decl-elements-invalid-syntax.template +/*--- +description: No space allowed between sigil and IdentifierName (Generator Method) (class declaration) +esid: prod-ClassElement +features: [generators, class-methods-private, class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Updated Productions + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + +---*/ + + +$DONOTEVALUATE(); + +class C { + * # m() {} +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatename-whitespace-error-member-expr.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatename-whitespace-error-member-expr.js new file mode 100644 index 0000000000..34dd6ab17d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatename-whitespace-error-member-expr.js @@ -0,0 +1,35 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-privatename-whitespace-error-member-expr.case +// - src/class-elements/syntax/invalid/cls-decl-elements-invalid-syntax.template +/*--- +description: No space allowed between sigil and IdentifierName (MemberExpression) (class declaration) +esid: prod-ClassElement +features: [class-fields-private, class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Updated Productions + + MemberExpression : + MemberExpression . PrivateName + + CallExpression : + CallExpression . PrivateName + + PrivateName :: + # IdentifierName + +---*/ + + +$DONOTEVALUATE(); + +class C { + #x; + m() { + this.# x; + } +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatename-whitespace-error-meth.case.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatename-whitespace-error-meth.case.js new file mode 100644 index 0000000000..b43126fdf4 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatename-whitespace-error-meth.case.js @@ -0,0 +1,30 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-privatename-whitespace-error-meth.case.case +// - src/class-elements/syntax/invalid/cls-decl-elements-invalid-syntax.template +/*--- +description: No space allowed between sigil and IdentifierName (Method) (class declaration) +esid: prod-ClassElement +features: [class-methods-private, class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Updated Productions + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + +---*/ + + +$DONOTEVALUATE(); + +class C { + # m() {} +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatename-whitespace-error-static-accessor-get-meth.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatename-whitespace-error-static-accessor-get-meth.js new file mode 100644 index 0000000000..baf73f5c4c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatename-whitespace-error-static-accessor-get-meth.js @@ -0,0 +1,30 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-privatename-whitespace-error-static-accessor-get-meth.case +// - src/class-elements/syntax/invalid/cls-decl-elements-invalid-syntax.template +/*--- +description: No space allowed between sigil and IdentifierName (Static Accessor get Method) (class declaration) +esid: prod-ClassElement +features: [class-static-methods-private, class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Updated Productions + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + +---*/ + + +$DONOTEVALUATE(); + +class C { + static get # m() {} +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatename-whitespace-error-static-accessor-set-meth.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatename-whitespace-error-static-accessor-set-meth.js new file mode 100644 index 0000000000..1bdb780ff9 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatename-whitespace-error-static-accessor-set-meth.js @@ -0,0 +1,30 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-privatename-whitespace-error-static-accessor-set-meth.case +// - src/class-elements/syntax/invalid/cls-decl-elements-invalid-syntax.template +/*--- +description: No space allowed between sigil and IdentifierName (Static Accessor set Method) (class declaration) +esid: prod-ClassElement +features: [class-static-methods-private, class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Updated Productions + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + +---*/ + + +$DONOTEVALUATE(); + +class C { + static set # m(_) {} +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatename-whitespace-error-static-async-gen-meth.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatename-whitespace-error-static-async-gen-meth.js new file mode 100644 index 0000000000..dba900b549 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatename-whitespace-error-static-async-gen-meth.js @@ -0,0 +1,30 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-privatename-whitespace-error-static-async-gen-meth.case +// - src/class-elements/syntax/invalid/cls-decl-elements-invalid-syntax.template +/*--- +description: No space allowed between sigil and IdentifierName (Static Async Generator Method) (class declaration) +esid: prod-ClassElement +features: [async-iteration, class-static-methods-private, class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Updated Productions + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + +---*/ + + +$DONOTEVALUATE(); + +class C { + static async * # m() {} +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatename-whitespace-error-static-async-meth.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatename-whitespace-error-static-async-meth.js new file mode 100644 index 0000000000..9f6173efa6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatename-whitespace-error-static-async-meth.js @@ -0,0 +1,30 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-privatename-whitespace-error-static-async-meth.case +// - src/class-elements/syntax/invalid/cls-decl-elements-invalid-syntax.template +/*--- +description: No space allowed between sigil and IdentifierName (Async Method) (class declaration) +esid: prod-ClassElement +features: [class-static-methods-private, class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Updated Productions + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + +---*/ + + +$DONOTEVALUATE(); + +class C { + static async # m() {} +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatename-whitespace-error-static-field-init.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatename-whitespace-error-static-field-init.js new file mode 100644 index 0000000000..0ad5d4d5ad --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatename-whitespace-error-static-field-init.js @@ -0,0 +1,30 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-privatename-whitespace-error-static-field-init.case +// - src/class-elements/syntax/invalid/cls-decl-elements-invalid-syntax.template +/*--- +description: No space allowed between sigil and IdentifierName (Static Field with Initializer) (class declaration) +esid: prod-ClassElement +features: [class-static-fields-private, class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Updated Productions + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + +---*/ + + +$DONOTEVALUATE(); + +class C { + static # x = 1; +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatename-whitespace-error-static-field.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatename-whitespace-error-static-field.js new file mode 100644 index 0000000000..eb8f843799 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatename-whitespace-error-static-field.js @@ -0,0 +1,30 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-privatename-whitespace-error-static-field.case +// - src/class-elements/syntax/invalid/cls-decl-elements-invalid-syntax.template +/*--- +description: No space allowed between sigil and IdentifierName (Static Field) (class declaration) +esid: prod-ClassElement +features: [class-static-fields-private, class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Updated Productions + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + +---*/ + + +$DONOTEVALUATE(); + +class C { + static # x; +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatename-whitespace-error-static-gen-meth.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatename-whitespace-error-static-gen-meth.js new file mode 100644 index 0000000000..54b6ecabcc --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatename-whitespace-error-static-gen-meth.js @@ -0,0 +1,30 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-privatename-whitespace-error-static-gen-meth.case +// - src/class-elements/syntax/invalid/cls-decl-elements-invalid-syntax.template +/*--- +description: No space allowed between sigil and IdentifierName (Static Generator Method) (class declaration) +esid: prod-ClassElement +features: [generators, class-static-methods-private, class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Updated Productions + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + +---*/ + + +$DONOTEVALUATE(); + +class C { + static * # m() {} +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatename-whitespace-error-static-meth.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatename-whitespace-error-static-meth.js new file mode 100644 index 0000000000..36eeb8909e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatename-whitespace-error-static-meth.js @@ -0,0 +1,30 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-privatename-whitespace-error-static-meth.case +// - src/class-elements/syntax/invalid/cls-decl-elements-invalid-syntax.template +/*--- +description: No space allowed between sigil and IdentifierName (Static Method) (class declaration) +esid: prod-ClassElement +features: [class-static-methods-private, class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Updated Productions + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + +---*/ + + +$DONOTEVALUATE(); + +class C { + static # m() {} +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatenames-same-line-error.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatenames-same-line-error.js new file mode 100644 index 0000000000..c8864ba6d1 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-privatenames-same-line-error.js @@ -0,0 +1,37 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-privatenames-same-line-error.case +// - src/class-elements/syntax/invalid/cls-decl-elements-invalid-syntax.template +/*--- +description: SyntaxError (class declaration) +esid: prod-ClassElement +features: [class-fields-private, class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + +---*/ + + +$DONOTEVALUATE(); + +class C { + #x #y +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-special-meth-contains-super-async-gen.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-special-meth-contains-super-async-gen.js new file mode 100644 index 0000000000..aab8077de5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-special-meth-contains-super-async-gen.js @@ -0,0 +1,28 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-special-meth-contains-super-async-gen.case +// - src/class-elements/syntax/invalid/cls-decl-elements-invalid-syntax.template +/*--- +description: Async Generator Methods cannot contain direct super (class declaration) +esid: prod-ClassElement +features: [async-iteration, class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Class Definitions / Static Semantics: Early Errors + + ClassElement : MethodDefinition + It is a Syntax Error if PropName of MethodDefinition is not "constructor" and HasDirectSuper of MethodDefinition is true. + +---*/ + + +$DONOTEVALUATE(); + +class C extends Function{ + async * method() { + super(); + } +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-special-meth-contains-super-async.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-special-meth-contains-super-async.js new file mode 100644 index 0000000000..747a8d620c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-special-meth-contains-super-async.js @@ -0,0 +1,28 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-special-meth-contains-super-async.case +// - src/class-elements/syntax/invalid/cls-decl-elements-invalid-syntax.template +/*--- +description: Async Methods cannot contain direct super (class declaration) +esid: prod-ClassElement +features: [async-functions, class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Class Definitions / Static Semantics: Early Errors + + ClassElement : MethodDefinition + It is a Syntax Error if PropName of MethodDefinition is not "constructor" and HasDirectSuper of MethodDefinition is true. + +---*/ + + +$DONOTEVALUATE(); + +class C extends Function{ + async method() { + super(); + } +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-special-meth-contains-super-gen.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-special-meth-contains-super-gen.js new file mode 100644 index 0000000000..99f1e7063c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-special-meth-contains-super-gen.js @@ -0,0 +1,28 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-special-meth-contains-super-gen.case +// - src/class-elements/syntax/invalid/cls-decl-elements-invalid-syntax.template +/*--- +description: Generator Methods cannot contain direct super (class declaration) +esid: prod-ClassElement +features: [generators, class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Class Definitions / Static Semantics: Early Errors + + ClassElement : MethodDefinition + It is a Syntax Error if PropName of MethodDefinition is not "constructor" and HasDirectSuper of MethodDefinition is true. + +---*/ + + +$DONOTEVALUATE(); + +class C extends Function{ + * method() { + super(); + } +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-special-meth-contains-super-get.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-special-meth-contains-super-get.js new file mode 100644 index 0000000000..a048d184b3 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-special-meth-contains-super-get.js @@ -0,0 +1,28 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-special-meth-contains-super-get.case +// - src/class-elements/syntax/invalid/cls-decl-elements-invalid-syntax.template +/*--- +description: Accessor get Methods cannot contain direct super (class declaration) +esid: prod-ClassElement +features: [class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Class Definitions / Static Semantics: Early Errors + + ClassElement : MethodDefinition + It is a Syntax Error if PropName of MethodDefinition is not "constructor" and HasDirectSuper of MethodDefinition is true. + +---*/ + + +$DONOTEVALUATE(); + +class C extends Function{ + get method() { + super(); + } +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-special-meth-contains-super-method.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-special-meth-contains-super-method.js new file mode 100644 index 0000000000..0875eaebee --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-special-meth-contains-super-method.js @@ -0,0 +1,28 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-special-meth-contains-super-method.case +// - src/class-elements/syntax/invalid/cls-decl-elements-invalid-syntax.template +/*--- +description: Methods cannot contain direct super (class declaration) +esid: prod-ClassElement +features: [class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Class Definitions / Static Semantics: Early Errors + + ClassElement : MethodDefinition + It is a Syntax Error if PropName of MethodDefinition is not "constructor" and HasDirectSuper of MethodDefinition is true. + +---*/ + + +$DONOTEVALUATE(); + +class C extends Function{ + method() { + super(); + } +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-special-meth-contains-super-private-async-gen.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-special-meth-contains-super-private-async-gen.js new file mode 100644 index 0000000000..3e917f35d0 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-special-meth-contains-super-private-async-gen.js @@ -0,0 +1,28 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-special-meth-contains-super-private-async-gen.case +// - src/class-elements/syntax/invalid/cls-decl-elements-invalid-syntax.template +/*--- +description: Private Async Generators Methods cannot contain direct super (class declaration) +esid: prod-ClassElement +features: [async-iteration, class-methods-private, class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Class Definitions / Static Semantics: Early Errors + + ClassElement : MethodDefinition + It is a Syntax Error if PropName of MethodDefinition is not "constructor" and HasDirectSuper of MethodDefinition is true. + +---*/ + + +$DONOTEVALUATE(); + +class C extends Function{ + async * #method() { + super(); + } +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-special-meth-contains-super-private-async.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-special-meth-contains-super-private-async.js new file mode 100644 index 0000000000..fc85b76c65 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-special-meth-contains-super-private-async.js @@ -0,0 +1,28 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-special-meth-contains-super-private-async.case +// - src/class-elements/syntax/invalid/cls-decl-elements-invalid-syntax.template +/*--- +description: Private Async Methods cannot contain direct super (class declaration) +esid: prod-ClassElement +features: [async-functions, class-methods-private, class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Class Definitions / Static Semantics: Early Errors + + ClassElement : MethodDefinition + It is a Syntax Error if PropName of MethodDefinition is not "constructor" and HasDirectSuper of MethodDefinition is true. + +---*/ + + +$DONOTEVALUATE(); + +class C extends Function{ + async #method() { + super(); + } +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-special-meth-contains-super-private-gen.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-special-meth-contains-super-private-gen.js new file mode 100644 index 0000000000..fedbf4f537 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-special-meth-contains-super-private-gen.js @@ -0,0 +1,28 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-special-meth-contains-super-private-gen.case +// - src/class-elements/syntax/invalid/cls-decl-elements-invalid-syntax.template +/*--- +description: Private Generators Methods cannot contain direct super (class declaration) +esid: prod-ClassElement +features: [generators, class-methods-private, class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Class Definitions / Static Semantics: Early Errors + + ClassElement : MethodDefinition + It is a Syntax Error if PropName of MethodDefinition is not "constructor" and HasDirectSuper of MethodDefinition is true. + +---*/ + + +$DONOTEVALUATE(); + +class C extends Function{ + * #method() { + super(); + } +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-special-meth-contains-super-private-method.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-special-meth-contains-super-private-method.js new file mode 100644 index 0000000000..225be8c596 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-special-meth-contains-super-private-method.js @@ -0,0 +1,28 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-special-meth-contains-super-private-method.case +// - src/class-elements/syntax/invalid/cls-decl-elements-invalid-syntax.template +/*--- +description: Private Methods cannot contain direct super (class declaration) +esid: prod-ClassElement +features: [class-methods-private, class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Class Definitions / Static Semantics: Early Errors + + ClassElement : MethodDefinition + It is a Syntax Error if PropName of MethodDefinition is not "constructor" and HasDirectSuper of MethodDefinition is true. + +---*/ + + +$DONOTEVALUATE(); + +class C extends Function{ + #method() { + super(); + } +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-special-meth-contains-super-set.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-special-meth-contains-super-set.js new file mode 100644 index 0000000000..61e1a5822d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-special-meth-contains-super-set.js @@ -0,0 +1,28 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-special-meth-contains-super-set.case +// - src/class-elements/syntax/invalid/cls-decl-elements-invalid-syntax.template +/*--- +description: Accessor set Methods cannot contain direct super (class declaration) +esid: prod-ClassElement +features: [class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Class Definitions / Static Semantics: Early Errors + + ClassElement : MethodDefinition + It is a Syntax Error if PropName of MethodDefinition is not "constructor" and HasDirectSuper of MethodDefinition is true. + +---*/ + + +$DONOTEVALUATE(); + +class C extends Function{ + set method(_) { + super(); + } +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-special-meth-ctor-async-gen.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-special-meth-ctor-async-gen.js new file mode 100644 index 0000000000..dd194f37ca --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-special-meth-ctor-async-gen.js @@ -0,0 +1,26 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-special-meth-ctor-async-gen.case +// - src/class-elements/syntax/invalid/cls-decl-elements-invalid-syntax.template +/*--- +description: Async Generator Methods cannot be named "constructor" (class declaration) +esid: prod-ClassElement +features: [async-iteration, class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Class Definitions / Static Semantics: Early Errors + + ClassElement : MethodDefinition + It is a Syntax Error if PropName of MethodDefinition is "constructor" and SpecialMethod of MethodDefinition is true. + +---*/ + + +$DONOTEVALUATE(); + +class C { + async * constructor() {} +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-special-meth-ctor-async-meth.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-special-meth-ctor-async-meth.js new file mode 100644 index 0000000000..060b9ba43b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-special-meth-ctor-async-meth.js @@ -0,0 +1,26 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-special-meth-ctor-async-meth.case +// - src/class-elements/syntax/invalid/cls-decl-elements-invalid-syntax.template +/*--- +description: Async Methods cannot be named "constructor" (class declaration) +esid: prod-ClassElement +features: [async-functions, class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Class Definitions / Static Semantics: Early Errors + + ClassElement : MethodDefinition + It is a Syntax Error if PropName of MethodDefinition is "constructor" and SpecialMethod of MethodDefinition is true. + +---*/ + + +$DONOTEVALUATE(); + +class C { + async constructor() {} +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-special-meth-ctor-gen.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-special-meth-ctor-gen.js new file mode 100644 index 0000000000..450de53c77 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-special-meth-ctor-gen.js @@ -0,0 +1,26 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-special-meth-ctor-gen.case +// - src/class-elements/syntax/invalid/cls-decl-elements-invalid-syntax.template +/*--- +description: Generator Methods cannot be named "constructor" (class declaration) +esid: prod-ClassElement +features: [generators, class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Class Definitions / Static Semantics: Early Errors + + ClassElement : MethodDefinition + It is a Syntax Error if PropName of MethodDefinition is "constructor" and SpecialMethod of MethodDefinition is true. + +---*/ + + +$DONOTEVALUATE(); + +class C { + * constructor() {} +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-special-meth-ctor-get.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-special-meth-ctor-get.js new file mode 100644 index 0000000000..00c65e6241 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-special-meth-ctor-get.js @@ -0,0 +1,26 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-special-meth-ctor-get.case +// - src/class-elements/syntax/invalid/cls-decl-elements-invalid-syntax.template +/*--- +description: Accessor get Methods cannot be named "constructor" (class declaration) +esid: prod-ClassElement +features: [class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Class Definitions / Static Semantics: Early Errors + + ClassElement : MethodDefinition + It is a Syntax Error if PropName of MethodDefinition is "constructor" and SpecialMethod of MethodDefinition is true. + +---*/ + + +$DONOTEVALUATE(); + +class C { + get constructor() {} +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-special-meth-ctor-set.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-special-meth-ctor-set.js new file mode 100644 index 0000000000..8f256e51c3 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-special-meth-ctor-set.js @@ -0,0 +1,26 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-special-meth-ctor-set.case +// - src/class-elements/syntax/invalid/cls-decl-elements-invalid-syntax.template +/*--- +description: Accessor set Methods cannot be named "constructor" (class declaration) +esid: prod-ClassElement +features: [class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Class Definitions / Static Semantics: Early Errors + + ClassElement : MethodDefinition + It is a Syntax Error if PropName of MethodDefinition is "constructor" and SpecialMethod of MethodDefinition is true. + +---*/ + + +$DONOTEVALUATE(); + +class C { + set constructor(_) {} +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-static-async-gen-meth-prototype.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-static-async-gen-meth-prototype.js new file mode 100644 index 0000000000..2441d89e52 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-static-async-gen-meth-prototype.js @@ -0,0 +1,26 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-static-async-gen-meth-prototype.case +// - src/class-elements/syntax/invalid/cls-decl-elements-invalid-syntax.template +/*--- +description: Static Async Generator Methods cannot be named prototype (class declaration) +esid: prod-ClassElement +features: [async-iteration, class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Class Definitions / Static Semantics: Early Errors + + ClassElement : static MethodDefinition + It is a Syntax Error if PropName of MethodDefinition is "prototype" + +---*/ + + +$DONOTEVALUATE(); + +class C { + static async * prototype() {} +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-static-async-gen-meth-super.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-static-async-gen-meth-super.js new file mode 100644 index 0000000000..25c654dfb0 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-static-async-gen-meth-super.js @@ -0,0 +1,28 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-static-async-gen-meth-super.case +// - src/class-elements/syntax/invalid/cls-decl-elements-invalid-syntax.template +/*--- +description: Static Async Generator Methods cannot contain direct super (class declaration) +esid: prod-ClassElement +features: [async-iteration, class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Class Definitions / Static Semantics: Early Errors + + ClassElement : static MethodDefinition + It is a Syntax Error if HasDirectSuper of MethodDefinition is true. + +---*/ + + +$DONOTEVALUATE(); + +class C extends Function{ + static async * method() { + super(); + } +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-static-async-meth-prototype.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-static-async-meth-prototype.js new file mode 100644 index 0000000000..dc9adf1f87 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-static-async-meth-prototype.js @@ -0,0 +1,26 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-static-async-meth-prototype.case +// - src/class-elements/syntax/invalid/cls-decl-elements-invalid-syntax.template +/*--- +description: Static Async Methods cannot be named prototype (class declaration) +esid: prod-ClassElement +features: [async-functions, class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Class Definitions / Static Semantics: Early Errors + + ClassElement : static MethodDefinition + It is a Syntax Error if PropName of MethodDefinition is "prototype" + +---*/ + + +$DONOTEVALUATE(); + +class C { + static async prototype() {} +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-static-async-meth-super.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-static-async-meth-super.js new file mode 100644 index 0000000000..04d2fce7c7 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-static-async-meth-super.js @@ -0,0 +1,28 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-static-async-meth-super.case +// - src/class-elements/syntax/invalid/cls-decl-elements-invalid-syntax.template +/*--- +description: Static Async Methods cannot contain direct super (class declaration) +esid: prod-ClassElement +features: [async-functions, class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Class Definitions / Static Semantics: Early Errors + + ClassElement : static MethodDefinition + It is a Syntax Error if HasDirectSuper of MethodDefinition is true. + +---*/ + + +$DONOTEVALUATE(); + +class C extends Function{ + static async method() { + super(); + } +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-static-gen-meth-prototype.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-static-gen-meth-prototype.js new file mode 100644 index 0000000000..9b9c8652eb --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-static-gen-meth-prototype.js @@ -0,0 +1,26 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-static-gen-meth-prototype.case +// - src/class-elements/syntax/invalid/cls-decl-elements-invalid-syntax.template +/*--- +description: Static Generator Methods cannot be named prototype (class declaration) +esid: prod-ClassElement +features: [generators, class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Class Definitions / Static Semantics: Early Errors + + ClassElement : static MethodDefinition + It is a Syntax Error if PropName of MethodDefinition is "prototype" + +---*/ + + +$DONOTEVALUATE(); + +class C { + static * prototype() {} +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-static-gen-meth-super.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-static-gen-meth-super.js new file mode 100644 index 0000000000..d24645e094 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-static-gen-meth-super.js @@ -0,0 +1,28 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-static-gen-meth-super.case +// - src/class-elements/syntax/invalid/cls-decl-elements-invalid-syntax.template +/*--- +description: Static Generator Methods cannot contain direct super (class declaration) +esid: prod-ClassElement +features: [generators, class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Class Definitions / Static Semantics: Early Errors + + ClassElement : static MethodDefinition + It is a Syntax Error if HasDirectSuper of MethodDefinition is true. + +---*/ + + +$DONOTEVALUATE(); + +class C extends Function{ + static * method() { + super(); + } +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-static-get-meth-prototype.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-static-get-meth-prototype.js new file mode 100644 index 0000000000..bec83f9f53 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-static-get-meth-prototype.js @@ -0,0 +1,26 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-static-get-meth-prototype.case +// - src/class-elements/syntax/invalid/cls-decl-elements-invalid-syntax.template +/*--- +description: Static Accessor get Methods cannot be named prototype (class declaration) +esid: prod-ClassElement +features: [class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Class Definitions / Static Semantics: Early Errors + + ClassElement : static MethodDefinition + It is a Syntax Error if PropName of MethodDefinition is "prototype" + +---*/ + + +$DONOTEVALUATE(); + +class C { + static get prototype() {} +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-static-get-meth-super.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-static-get-meth-super.js new file mode 100644 index 0000000000..9512bc196d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-static-get-meth-super.js @@ -0,0 +1,28 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-static-get-meth-super.case +// - src/class-elements/syntax/invalid/cls-decl-elements-invalid-syntax.template +/*--- +description: Static Accessor get Methods cannot contain direct super (class declaration) +esid: prod-ClassElement +features: [class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Class Definitions / Static Semantics: Early Errors + + ClassElement : static MethodDefinition + It is a Syntax Error if HasDirectSuper of MethodDefinition is true. + +---*/ + + +$DONOTEVALUATE(); + +class C extends Function{ + static get method() { + super(); + } +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-static-meth-prototype.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-static-meth-prototype.js new file mode 100644 index 0000000000..1266ed80d5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-static-meth-prototype.js @@ -0,0 +1,26 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-static-meth-prototype.case +// - src/class-elements/syntax/invalid/cls-decl-elements-invalid-syntax.template +/*--- +description: Static Methods cannot be named prototype (class declaration) +esid: prod-ClassElement +features: [class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Class Definitions / Static Semantics: Early Errors + + ClassElement : static MethodDefinition + It is a Syntax Error if PropName of MethodDefinition is "prototype" + +---*/ + + +$DONOTEVALUATE(); + +class C { + static prototype() {} +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-static-meth-super.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-static-meth-super.js new file mode 100644 index 0000000000..8ae98066f7 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-static-meth-super.js @@ -0,0 +1,28 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-static-meth-super.case +// - src/class-elements/syntax/invalid/cls-decl-elements-invalid-syntax.template +/*--- +description: Static Methods cannot contain direct super (class declaration) +esid: prod-ClassElement +features: [class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Class Definitions / Static Semantics: Early Errors + + ClassElement : static MethodDefinition + It is a Syntax Error if HasDirectSuper of MethodDefinition is true. + +---*/ + + +$DONOTEVALUATE(); + +class C extends Function{ + static method() { + super(); + } +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-static-private-async-gen-meth-constructor.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-static-private-async-gen-meth-constructor.js new file mode 100644 index 0000000000..758ef67cb1 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-static-private-async-gen-meth-constructor.js @@ -0,0 +1,26 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-static-private-async-gen-meth-constructor.case +// - src/class-elements/syntax/invalid/cls-decl-elements-invalid-syntax.template +/*--- +description: Static Async Generator Private Methods cannot be named constructor (class declaration) +esid: prod-ClassElement +features: [async-iteration, class-static-methods-private, class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Class Definitions / Static Semantics: Early Errors + + ClassElementName : PrivateName ; + It is a Syntax Error if StringValue of PrivateName is "#constructor" + +---*/ + + +$DONOTEVALUATE(); + +class C { + static async * #constructor() {} +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-static-private-async-gen-meth-super.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-static-private-async-gen-meth-super.js new file mode 100644 index 0000000000..19b6d5b5d8 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-static-private-async-gen-meth-super.js @@ -0,0 +1,28 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-static-private-async-gen-meth-super.case +// - src/class-elements/syntax/invalid/cls-decl-elements-invalid-syntax.template +/*--- +description: Static Async Generator Private Methods cannot contain direct super (class declaration) +esid: prod-ClassElement +features: [async-iteration, class-static-methods-private, class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Class Definitions / Static Semantics: Early Errors + + ClassElement : static MethodDefinition + It is a Syntax Error if HasDirectSuper of MethodDefinition is true. + +---*/ + + +$DONOTEVALUATE(); + +class C extends Function{ + static async * #method() { + super(); + } +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-static-private-async-meth-constructor.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-static-private-async-meth-constructor.js new file mode 100644 index 0000000000..da9f303bc8 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-static-private-async-meth-constructor.js @@ -0,0 +1,26 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-static-private-async-meth-constructor.case +// - src/class-elements/syntax/invalid/cls-decl-elements-invalid-syntax.template +/*--- +description: Static Async Private Methods cannot be named constructor (class declaration) +esid: prod-ClassElement +features: [async-functions, class-static-methods-private, class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Class Definitions / Static Semantics: Early Errors + + ClassElementName : PrivateName ; + It is a Syntax Error if StringValue of PrivateName is "#constructor" + +---*/ + + +$DONOTEVALUATE(); + +class C { + static async #constructor() {} +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-static-private-async-meth-super.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-static-private-async-meth-super.js new file mode 100644 index 0000000000..cf74261edd --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-static-private-async-meth-super.js @@ -0,0 +1,28 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-static-private-async-meth-super.case +// - src/class-elements/syntax/invalid/cls-decl-elements-invalid-syntax.template +/*--- +description: Static Async Private Methods cannot contain direct super (class declaration) +esid: prod-ClassElement +features: [async-functions, class-static-methods-private, class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Class Definitions / Static Semantics: Early Errors + + ClassElement : static MethodDefinition + It is a Syntax Error if HasDirectSuper of MethodDefinition is true. + +---*/ + + +$DONOTEVALUATE(); + +class C extends Function{ + static async #method() { + super(); + } +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-static-private-gen-meth-constructor.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-static-private-gen-meth-constructor.js new file mode 100644 index 0000000000..4f5d06c598 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-static-private-gen-meth-constructor.js @@ -0,0 +1,26 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-static-private-gen-meth-constructor.case +// - src/class-elements/syntax/invalid/cls-decl-elements-invalid-syntax.template +/*--- +description: Static Generator Private Methods cannot be named constructor (class declaration) +esid: prod-ClassElement +features: [generators, class-static-methods-private, class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Class Definitions / Static Semantics: Early Errors + + ClassElementName : PrivateName ; + It is a Syntax Error if StringValue of PrivateName is "#constructor" + +---*/ + + +$DONOTEVALUATE(); + +class C { + static * #constructor() {} +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-static-private-gen-meth-super.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-static-private-gen-meth-super.js new file mode 100644 index 0000000000..e325b10007 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-static-private-gen-meth-super.js @@ -0,0 +1,28 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-static-private-gen-meth-super.case +// - src/class-elements/syntax/invalid/cls-decl-elements-invalid-syntax.template +/*--- +description: Static Generator Private Methods cannot contain direct super (class declaration) +esid: prod-ClassElement +features: [generators, class-static-methods-private, class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Class Definitions / Static Semantics: Early Errors + + ClassElement : static MethodDefinition + It is a Syntax Error if HasDirectSuper of MethodDefinition is true. + +---*/ + + +$DONOTEVALUATE(); + +class C extends Function{ + static * #method() { + super(); + } +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-static-private-meth-constructor.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-static-private-meth-constructor.js new file mode 100644 index 0000000000..e1631c7cf4 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-static-private-meth-constructor.js @@ -0,0 +1,26 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-static-private-meth-constructor.case +// - src/class-elements/syntax/invalid/cls-decl-elements-invalid-syntax.template +/*--- +description: Static Private Methods cannot be named constructor (class declaration) +esid: prod-ClassElement +features: [class-static-methods-private, class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Class Definitions / Static Semantics: Early Errors + + ClassElementName : PrivateName ; + It is a Syntax Error if StringValue of PrivateName is "#constructor" + +---*/ + + +$DONOTEVALUATE(); + +class C { + static #constructor() {} +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-static-private-meth-super.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-static-private-meth-super.js new file mode 100644 index 0000000000..9518ab56ff --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-static-private-meth-super.js @@ -0,0 +1,28 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-static-private-meth-super.case +// - src/class-elements/syntax/invalid/cls-decl-elements-invalid-syntax.template +/*--- +description: Static Private Methods cannot contain direct super (class declaration) +esid: prod-ClassElement +features: [class-static-methods-private, class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Class Definitions / Static Semantics: Early Errors + + ClassElement : static MethodDefinition + It is a Syntax Error if HasDirectSuper of MethodDefinition is true. + +---*/ + + +$DONOTEVALUATE(); + +class C extends Function{ + static #method() { + super(); + } +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-static-privatename-constructor.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-static-privatename-constructor.js new file mode 100644 index 0000000000..5384df5dfe --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-static-privatename-constructor.js @@ -0,0 +1,26 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-static-privatename-constructor.case +// - src/class-elements/syntax/invalid/cls-decl-elements-invalid-syntax.template +/*--- +description: Static Private Fields cannot be named constructor (class declaration) +esid: prod-ClassElement +features: [class-static-fields-private, class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Class Definitions / Static Semantics: Early Errors + + ClassElementName : PrivateName ; + It is a Syntax Error if StringValue of PrivateName is "#constructor" + +---*/ + + +$DONOTEVALUATE(); + +class C { + static #constructor +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-static-set-meth-prototype.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-static-set-meth-prototype.js new file mode 100644 index 0000000000..24c099802d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-static-set-meth-prototype.js @@ -0,0 +1,26 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-static-set-meth-prototype.case +// - src/class-elements/syntax/invalid/cls-decl-elements-invalid-syntax.template +/*--- +description: Static Accessor set Methods cannot be named prototype (class declaration) +esid: prod-ClassElement +features: [class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Class Definitions / Static Semantics: Early Errors + + ClassElement : static MethodDefinition + It is a Syntax Error if PropName of MethodDefinition is "prototype" + +---*/ + + +$DONOTEVALUATE(); + +class C { + static set prototype(_) {} +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-static-set-meth-super.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-static-set-meth-super.js new file mode 100644 index 0000000000..66475a758c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/grammar-static-set-meth-super.js @@ -0,0 +1,28 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-static-set-meth-super.case +// - src/class-elements/syntax/invalid/cls-decl-elements-invalid-syntax.template +/*--- +description: Static Accessor set Methods cannot contain direct super (class declaration) +esid: prod-ClassElement +features: [class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Class Definitions / Static Semantics: Early Errors + + ClassElement : static MethodDefinition + It is a Syntax Error if HasDirectSuper of MethodDefinition is true. + +---*/ + + +$DONOTEVALUATE(); + +class C extends Function{ + static set method(_) { + super(); + } +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/invalid-names/browser.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/invalid-names/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/invalid-names/field-init-call-expression-bad-reference.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/invalid-names/field-init-call-expression-bad-reference.js new file mode 100644 index 0000000000..40c53ece98 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/invalid-names/field-init-call-expression-bad-reference.js @@ -0,0 +1,43 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/invalid-private-names/call-expression-bad-reference.case +// - src/invalid-private-names/default/cls-decl-field-initializer.template +/*--- +description: bad reference in call expression (Invalid private names should throw a SyntaxError, class field initializer in class declaration) +esid: sec-static-semantics-early-errors +features: [class-fields-private, class, class-fields-public] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ScriptBody:StatementList + It is a Syntax Error if AllPrivateNamesValid of StatementList with an empty List + as an argument is false unless the source code is eval code that is being + processed by a direct eval. + + ModuleBody:ModuleItemList + It is a Syntax Error if AllPrivateNamesValid of ModuleItemList with an empty List + as an argument is false. + + + Static Semantics: AllPrivateNamesValid + + MemberExpression : MemberExpression . PrivateName + + 1. If StringValue of PrivateName is in names, return true. + 2. Return false. + + CallExpression : CallExpression . PrivateName + + 1. If StringValue of PrivateName is in names, return true. + 2. Return false. + +---*/ + + +$DONOTEVALUATE(); + +class C { + f = (() => {})().#x +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/invalid-names/field-init-call-expression-this.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/invalid-names/field-init-call-expression-this.js new file mode 100644 index 0000000000..68341532c1 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/invalid-names/field-init-call-expression-this.js @@ -0,0 +1,43 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/invalid-private-names/call-expression-this.case +// - src/invalid-private-names/default/cls-decl-field-initializer.template +/*--- +description: this evaluated in call expression (Invalid private names should throw a SyntaxError, class field initializer in class declaration) +esid: sec-static-semantics-early-errors +features: [class-fields-private, class, class-fields-public] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ScriptBody:StatementList + It is a Syntax Error if AllPrivateNamesValid of StatementList with an empty List + as an argument is false unless the source code is eval code that is being + processed by a direct eval. + + ModuleBody:ModuleItemList + It is a Syntax Error if AllPrivateNamesValid of ModuleItemList with an empty List + as an argument is false. + + + Static Semantics: AllPrivateNamesValid + + MemberExpression : MemberExpression . PrivateName + + 1. If StringValue of PrivateName is in names, return true. + 2. Return false. + + CallExpression : CallExpression . PrivateName + + 1. If StringValue of PrivateName is in names, return true. + 2. Return false. + +---*/ + + +$DONOTEVALUATE(); + +class C { + f = (() => this)().#x +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/invalid-names/field-init-fn-call-expression-bad-reference.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/invalid-names/field-init-fn-call-expression-bad-reference.js new file mode 100644 index 0000000000..615c5a91d8 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/invalid-names/field-init-fn-call-expression-bad-reference.js @@ -0,0 +1,43 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/invalid-private-names/call-expression-bad-reference.case +// - src/invalid-private-names/default/cls-decl-field-initializer-fn.template +/*--- +description: bad reference in call expression (Invalid private names should throw a SyntaxError, function in class field initializer in class declaration) +esid: sec-static-semantics-early-errors +features: [class-fields-private, class, class-fields-public] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ScriptBody:StatementList + It is a Syntax Error if AllPrivateNamesValid of StatementList with an empty List + as an argument is false unless the source code is eval code that is being + processed by a direct eval. + + ModuleBody:ModuleItemList + It is a Syntax Error if AllPrivateNamesValid of ModuleItemList with an empty List + as an argument is false. + + + Static Semantics: AllPrivateNamesValid + + MemberExpression : MemberExpression . PrivateName + + 1. If StringValue of PrivateName is in names, return true. + 2. Return false. + + CallExpression : CallExpression . PrivateName + + 1. If StringValue of PrivateName is in names, return true. + 2. Return false. + +---*/ + + +$DONOTEVALUATE(); + +class C { + f = function() { (() => {})().#x } +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/invalid-names/field-init-fn-call-expression-this.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/invalid-names/field-init-fn-call-expression-this.js new file mode 100644 index 0000000000..953d7c6f8f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/invalid-names/field-init-fn-call-expression-this.js @@ -0,0 +1,43 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/invalid-private-names/call-expression-this.case +// - src/invalid-private-names/default/cls-decl-field-initializer-fn.template +/*--- +description: this evaluated in call expression (Invalid private names should throw a SyntaxError, function in class field initializer in class declaration) +esid: sec-static-semantics-early-errors +features: [class-fields-private, class, class-fields-public] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ScriptBody:StatementList + It is a Syntax Error if AllPrivateNamesValid of StatementList with an empty List + as an argument is false unless the source code is eval code that is being + processed by a direct eval. + + ModuleBody:ModuleItemList + It is a Syntax Error if AllPrivateNamesValid of ModuleItemList with an empty List + as an argument is false. + + + Static Semantics: AllPrivateNamesValid + + MemberExpression : MemberExpression . PrivateName + + 1. If StringValue of PrivateName is in names, return true. + 2. Return false. + + CallExpression : CallExpression . PrivateName + + 1. If StringValue of PrivateName is in names, return true. + 2. Return false. + +---*/ + + +$DONOTEVALUATE(); + +class C { + f = function() { (() => this)().#x } +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/invalid-names/field-init-fn-member-expression-bad-reference.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/invalid-names/field-init-fn-member-expression-bad-reference.js new file mode 100644 index 0000000000..060ba0152f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/invalid-names/field-init-fn-member-expression-bad-reference.js @@ -0,0 +1,43 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/invalid-private-names/member-expression-bad-reference.case +// - src/invalid-private-names/default/cls-decl-field-initializer-fn.template +/*--- +description: bad reference in member expression (Invalid private names should throw a SyntaxError, function in class field initializer in class declaration) +esid: sec-static-semantics-early-errors +features: [class-fields-private, class, class-fields-public] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ScriptBody:StatementList + It is a Syntax Error if AllPrivateNamesValid of StatementList with an empty List + as an argument is false unless the source code is eval code that is being + processed by a direct eval. + + ModuleBody:ModuleItemList + It is a Syntax Error if AllPrivateNamesValid of ModuleItemList with an empty List + as an argument is false. + + + Static Semantics: AllPrivateNamesValid + + MemberExpression : MemberExpression . PrivateName + + 1. If StringValue of PrivateName is in names, return true. + 2. Return false. + + CallExpression : CallExpression . PrivateName + + 1. If StringValue of PrivateName is in names, return true. + 2. Return false. + +---*/ + + +$DONOTEVALUATE(); + +class C { + f = function() { something.#x } +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/invalid-names/field-init-fn-member-expression-this.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/invalid-names/field-init-fn-member-expression-this.js new file mode 100644 index 0000000000..c2852bb8a7 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/invalid-names/field-init-fn-member-expression-this.js @@ -0,0 +1,43 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/invalid-private-names/member-expression-this.case +// - src/invalid-private-names/default/cls-decl-field-initializer-fn.template +/*--- +description: this reference in member expression (Invalid private names should throw a SyntaxError, function in class field initializer in class declaration) +esid: sec-static-semantics-early-errors +features: [class-fields-private, class, class-fields-public] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ScriptBody:StatementList + It is a Syntax Error if AllPrivateNamesValid of StatementList with an empty List + as an argument is false unless the source code is eval code that is being + processed by a direct eval. + + ModuleBody:ModuleItemList + It is a Syntax Error if AllPrivateNamesValid of ModuleItemList with an empty List + as an argument is false. + + + Static Semantics: AllPrivateNamesValid + + MemberExpression : MemberExpression . PrivateName + + 1. If StringValue of PrivateName is in names, return true. + 2. Return false. + + CallExpression : CallExpression . PrivateName + + 1. If StringValue of PrivateName is in names, return true. + 2. Return false. + +---*/ + + +$DONOTEVALUATE(); + +class C { + f = function() { this.#x } +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/invalid-names/field-init-member-expression-bad-reference.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/invalid-names/field-init-member-expression-bad-reference.js new file mode 100644 index 0000000000..4db6d17b25 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/invalid-names/field-init-member-expression-bad-reference.js @@ -0,0 +1,43 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/invalid-private-names/member-expression-bad-reference.case +// - src/invalid-private-names/default/cls-decl-field-initializer.template +/*--- +description: bad reference in member expression (Invalid private names should throw a SyntaxError, class field initializer in class declaration) +esid: sec-static-semantics-early-errors +features: [class-fields-private, class, class-fields-public] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ScriptBody:StatementList + It is a Syntax Error if AllPrivateNamesValid of StatementList with an empty List + as an argument is false unless the source code is eval code that is being + processed by a direct eval. + + ModuleBody:ModuleItemList + It is a Syntax Error if AllPrivateNamesValid of ModuleItemList with an empty List + as an argument is false. + + + Static Semantics: AllPrivateNamesValid + + MemberExpression : MemberExpression . PrivateName + + 1. If StringValue of PrivateName is in names, return true. + 2. Return false. + + CallExpression : CallExpression . PrivateName + + 1. If StringValue of PrivateName is in names, return true. + 2. Return false. + +---*/ + + +$DONOTEVALUATE(); + +class C { + f = something.#x +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/invalid-names/field-init-member-expression-this.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/invalid-names/field-init-member-expression-this.js new file mode 100644 index 0000000000..cec95a1460 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/invalid-names/field-init-member-expression-this.js @@ -0,0 +1,43 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/invalid-private-names/member-expression-this.case +// - src/invalid-private-names/default/cls-decl-field-initializer.template +/*--- +description: this reference in member expression (Invalid private names should throw a SyntaxError, class field initializer in class declaration) +esid: sec-static-semantics-early-errors +features: [class-fields-private, class, class-fields-public] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ScriptBody:StatementList + It is a Syntax Error if AllPrivateNamesValid of StatementList with an empty List + as an argument is false unless the source code is eval code that is being + processed by a direct eval. + + ModuleBody:ModuleItemList + It is a Syntax Error if AllPrivateNamesValid of ModuleItemList with an empty List + as an argument is false. + + + Static Semantics: AllPrivateNamesValid + + MemberExpression : MemberExpression . PrivateName + + 1. If StringValue of PrivateName is in names, return true. + 2. Return false. + + CallExpression : CallExpression . PrivateName + + 1. If StringValue of PrivateName is in names, return true. + 2. Return false. + +---*/ + + +$DONOTEVALUATE(); + +class C { + f = this.#x +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/invalid-names/fields-init-heritage-call-expression-bad-reference.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/invalid-names/fields-init-heritage-call-expression-bad-reference.js new file mode 100644 index 0000000000..06d1a91584 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/invalid-names/fields-init-heritage-call-expression-bad-reference.js @@ -0,0 +1,58 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/invalid-private-names/call-expression-bad-reference.case +// - src/invalid-private-names/default/cls-decl-field-initializer-heritage.template +/*--- +description: bad reference in call expression (Invalid private names should throw a SyntaxError, class field initializer in class declaration) +esid: sec-static-semantics-early-errors +features: [class-fields-private, class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ScriptBody:StatementList + It is a Syntax Error if AllPrivateNamesValid of StatementList with an empty List + as an argument is false unless the source code is eval code that is being + processed by a direct eval. + + ModuleBody:ModuleItemList + It is a Syntax Error if AllPrivateNamesValid of ModuleItemList with an empty List + as an argument is false. + + Static Semantics: AllPrivateNamesValid + + ClassBody : ClassElementList + 1. Let newNames be the concatenation of names with PrivateBoundNames of ClassBody. + 2. Return AllPrivateNamesValid of ClassElementList with the argument newNames. + + For all other grammatical productions, recurse on subexpressions/substatements, + passing in the names of the caller. If all pieces return true, then return true. + If any returns false, return false. + + + Static Semantics: AllPrivateNamesValid + + MemberExpression : MemberExpression . PrivateName + + 1. If StringValue of PrivateName is in names, return true. + 2. Return false. + + CallExpression : CallExpression . PrivateName + + 1. If StringValue of PrivateName is in names, return true. + 2. Return false. + +---*/ + + + +$DONOTEVALUATE(); + +class Parent { + #x = 42; +} + +class C extends Parent { + f = (() => {})().#x +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/invalid-names/fields-init-heritage-call-expression-this.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/invalid-names/fields-init-heritage-call-expression-this.js new file mode 100644 index 0000000000..483a835d70 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/invalid-names/fields-init-heritage-call-expression-this.js @@ -0,0 +1,58 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/invalid-private-names/call-expression-this.case +// - src/invalid-private-names/default/cls-decl-field-initializer-heritage.template +/*--- +description: this evaluated in call expression (Invalid private names should throw a SyntaxError, class field initializer in class declaration) +esid: sec-static-semantics-early-errors +features: [class-fields-private, class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ScriptBody:StatementList + It is a Syntax Error if AllPrivateNamesValid of StatementList with an empty List + as an argument is false unless the source code is eval code that is being + processed by a direct eval. + + ModuleBody:ModuleItemList + It is a Syntax Error if AllPrivateNamesValid of ModuleItemList with an empty List + as an argument is false. + + Static Semantics: AllPrivateNamesValid + + ClassBody : ClassElementList + 1. Let newNames be the concatenation of names with PrivateBoundNames of ClassBody. + 2. Return AllPrivateNamesValid of ClassElementList with the argument newNames. + + For all other grammatical productions, recurse on subexpressions/substatements, + passing in the names of the caller. If all pieces return true, then return true. + If any returns false, return false. + + + Static Semantics: AllPrivateNamesValid + + MemberExpression : MemberExpression . PrivateName + + 1. If StringValue of PrivateName is in names, return true. + 2. Return false. + + CallExpression : CallExpression . PrivateName + + 1. If StringValue of PrivateName is in names, return true. + 2. Return false. + +---*/ + + + +$DONOTEVALUATE(); + +class Parent { + #x = 42; +} + +class C extends Parent { + f = (() => this)().#x +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/invalid-names/fields-init-heritage-member-expression-bad-reference.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/invalid-names/fields-init-heritage-member-expression-bad-reference.js new file mode 100644 index 0000000000..dce5883462 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/invalid-names/fields-init-heritage-member-expression-bad-reference.js @@ -0,0 +1,58 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/invalid-private-names/member-expression-bad-reference.case +// - src/invalid-private-names/default/cls-decl-field-initializer-heritage.template +/*--- +description: bad reference in member expression (Invalid private names should throw a SyntaxError, class field initializer in class declaration) +esid: sec-static-semantics-early-errors +features: [class-fields-private, class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ScriptBody:StatementList + It is a Syntax Error if AllPrivateNamesValid of StatementList with an empty List + as an argument is false unless the source code is eval code that is being + processed by a direct eval. + + ModuleBody:ModuleItemList + It is a Syntax Error if AllPrivateNamesValid of ModuleItemList with an empty List + as an argument is false. + + Static Semantics: AllPrivateNamesValid + + ClassBody : ClassElementList + 1. Let newNames be the concatenation of names with PrivateBoundNames of ClassBody. + 2. Return AllPrivateNamesValid of ClassElementList with the argument newNames. + + For all other grammatical productions, recurse on subexpressions/substatements, + passing in the names of the caller. If all pieces return true, then return true. + If any returns false, return false. + + + Static Semantics: AllPrivateNamesValid + + MemberExpression : MemberExpression . PrivateName + + 1. If StringValue of PrivateName is in names, return true. + 2. Return false. + + CallExpression : CallExpression . PrivateName + + 1. If StringValue of PrivateName is in names, return true. + 2. Return false. + +---*/ + + + +$DONOTEVALUATE(); + +class Parent { + #x = 42; +} + +class C extends Parent { + f = something.#x +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/invalid-names/fields-init-heritage-member-expression-this.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/invalid-names/fields-init-heritage-member-expression-this.js new file mode 100644 index 0000000000..fb8dceaf2f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/invalid-names/fields-init-heritage-member-expression-this.js @@ -0,0 +1,58 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/invalid-private-names/member-expression-this.case +// - src/invalid-private-names/default/cls-decl-field-initializer-heritage.template +/*--- +description: this reference in member expression (Invalid private names should throw a SyntaxError, class field initializer in class declaration) +esid: sec-static-semantics-early-errors +features: [class-fields-private, class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ScriptBody:StatementList + It is a Syntax Error if AllPrivateNamesValid of StatementList with an empty List + as an argument is false unless the source code is eval code that is being + processed by a direct eval. + + ModuleBody:ModuleItemList + It is a Syntax Error if AllPrivateNamesValid of ModuleItemList with an empty List + as an argument is false. + + Static Semantics: AllPrivateNamesValid + + ClassBody : ClassElementList + 1. Let newNames be the concatenation of names with PrivateBoundNames of ClassBody. + 2. Return AllPrivateNamesValid of ClassElementList with the argument newNames. + + For all other grammatical productions, recurse on subexpressions/substatements, + passing in the names of the caller. If all pieces return true, then return true. + If any returns false, return false. + + + Static Semantics: AllPrivateNamesValid + + MemberExpression : MemberExpression . PrivateName + + 1. If StringValue of PrivateName is in names, return true. + 2. Return false. + + CallExpression : CallExpression . PrivateName + + 1. If StringValue of PrivateName is in names, return true. + 2. Return false. + +---*/ + + + +$DONOTEVALUATE(); + +class Parent { + #x = 42; +} + +class C extends Parent { + f = this.#x +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/invalid-names/method-call-expression-bad-reference.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/invalid-names/method-call-expression-bad-reference.js new file mode 100644 index 0000000000..a3b8d6b0f4 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/invalid-names/method-call-expression-bad-reference.js @@ -0,0 +1,43 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/invalid-private-names/call-expression-bad-reference.case +// - src/invalid-private-names/default/cls-decl-method.template +/*--- +description: bad reference in call expression (Invalid private names should throw a SyntaxError, method in class declaration) +esid: sec-static-semantics-early-errors +features: [class-fields-private, class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ScriptBody:StatementList + It is a Syntax Error if AllPrivateNamesValid of StatementList with an empty List + as an argument is false unless the source code is eval code that is being + processed by a direct eval. + + ModuleBody:ModuleItemList + It is a Syntax Error if AllPrivateNamesValid of ModuleItemList with an empty List + as an argument is false. + + + Static Semantics: AllPrivateNamesValid + + MemberExpression : MemberExpression . PrivateName + + 1. If StringValue of PrivateName is in names, return true. + 2. Return false. + + CallExpression : CallExpression . PrivateName + + 1. If StringValue of PrivateName is in names, return true. + 2. Return false. + +---*/ + + +$DONOTEVALUATE(); + +class C { + m() { (() => {})().#x } +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/invalid-names/method-call-expression-this.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/invalid-names/method-call-expression-this.js new file mode 100644 index 0000000000..6596ef5dc0 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/invalid-names/method-call-expression-this.js @@ -0,0 +1,43 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/invalid-private-names/call-expression-this.case +// - src/invalid-private-names/default/cls-decl-method.template +/*--- +description: this evaluated in call expression (Invalid private names should throw a SyntaxError, method in class declaration) +esid: sec-static-semantics-early-errors +features: [class-fields-private, class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ScriptBody:StatementList + It is a Syntax Error if AllPrivateNamesValid of StatementList with an empty List + as an argument is false unless the source code is eval code that is being + processed by a direct eval. + + ModuleBody:ModuleItemList + It is a Syntax Error if AllPrivateNamesValid of ModuleItemList with an empty List + as an argument is false. + + + Static Semantics: AllPrivateNamesValid + + MemberExpression : MemberExpression . PrivateName + + 1. If StringValue of PrivateName is in names, return true. + 2. Return false. + + CallExpression : CallExpression . PrivateName + + 1. If StringValue of PrivateName is in names, return true. + 2. Return false. + +---*/ + + +$DONOTEVALUATE(); + +class C { + m() { (() => this)().#x } +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/invalid-names/method-fn-call-expression-bad-reference.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/invalid-names/method-fn-call-expression-bad-reference.js new file mode 100644 index 0000000000..7296cac6a2 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/invalid-names/method-fn-call-expression-bad-reference.js @@ -0,0 +1,45 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/invalid-private-names/call-expression-bad-reference.case +// - src/invalid-private-names/default/cls-decl-method-fn.template +/*--- +description: bad reference in call expression (Invalid private names should throw a SyntaxError, inner function in method in class declaration) +esid: sec-static-semantics-early-errors +features: [class-fields-private, class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ScriptBody:StatementList + It is a Syntax Error if AllPrivateNamesValid of StatementList with an empty List + as an argument is false unless the source code is eval code that is being + processed by a direct eval. + + ModuleBody:ModuleItemList + It is a Syntax Error if AllPrivateNamesValid of ModuleItemList with an empty List + as an argument is false. + + + Static Semantics: AllPrivateNamesValid + + MemberExpression : MemberExpression . PrivateName + + 1. If StringValue of PrivateName is in names, return true. + 2. Return false. + + CallExpression : CallExpression . PrivateName + + 1. If StringValue of PrivateName is in names, return true. + 2. Return false. + +---*/ + + +$DONOTEVALUATE(); + +class C { + m() { + function fn() { (() => {})().#x } + } +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/invalid-names/method-fn-call-expression-this.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/invalid-names/method-fn-call-expression-this.js new file mode 100644 index 0000000000..13559da5b6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/invalid-names/method-fn-call-expression-this.js @@ -0,0 +1,45 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/invalid-private-names/call-expression-this.case +// - src/invalid-private-names/default/cls-decl-method-fn.template +/*--- +description: this evaluated in call expression (Invalid private names should throw a SyntaxError, inner function in method in class declaration) +esid: sec-static-semantics-early-errors +features: [class-fields-private, class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ScriptBody:StatementList + It is a Syntax Error if AllPrivateNamesValid of StatementList with an empty List + as an argument is false unless the source code is eval code that is being + processed by a direct eval. + + ModuleBody:ModuleItemList + It is a Syntax Error if AllPrivateNamesValid of ModuleItemList with an empty List + as an argument is false. + + + Static Semantics: AllPrivateNamesValid + + MemberExpression : MemberExpression . PrivateName + + 1. If StringValue of PrivateName is in names, return true. + 2. Return false. + + CallExpression : CallExpression . PrivateName + + 1. If StringValue of PrivateName is in names, return true. + 2. Return false. + +---*/ + + +$DONOTEVALUATE(); + +class C { + m() { + function fn() { (() => this)().#x } + } +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/invalid-names/method-fn-member-expression-bad-reference.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/invalid-names/method-fn-member-expression-bad-reference.js new file mode 100644 index 0000000000..023631b29a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/invalid-names/method-fn-member-expression-bad-reference.js @@ -0,0 +1,45 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/invalid-private-names/member-expression-bad-reference.case +// - src/invalid-private-names/default/cls-decl-method-fn.template +/*--- +description: bad reference in member expression (Invalid private names should throw a SyntaxError, inner function in method in class declaration) +esid: sec-static-semantics-early-errors +features: [class-fields-private, class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ScriptBody:StatementList + It is a Syntax Error if AllPrivateNamesValid of StatementList with an empty List + as an argument is false unless the source code is eval code that is being + processed by a direct eval. + + ModuleBody:ModuleItemList + It is a Syntax Error if AllPrivateNamesValid of ModuleItemList with an empty List + as an argument is false. + + + Static Semantics: AllPrivateNamesValid + + MemberExpression : MemberExpression . PrivateName + + 1. If StringValue of PrivateName is in names, return true. + 2. Return false. + + CallExpression : CallExpression . PrivateName + + 1. If StringValue of PrivateName is in names, return true. + 2. Return false. + +---*/ + + +$DONOTEVALUATE(); + +class C { + m() { + function fn() { something.#x } + } +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/invalid-names/method-fn-member-expression-this.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/invalid-names/method-fn-member-expression-this.js new file mode 100644 index 0000000000..7ea61ba52a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/invalid-names/method-fn-member-expression-this.js @@ -0,0 +1,45 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/invalid-private-names/member-expression-this.case +// - src/invalid-private-names/default/cls-decl-method-fn.template +/*--- +description: this reference in member expression (Invalid private names should throw a SyntaxError, inner function in method in class declaration) +esid: sec-static-semantics-early-errors +features: [class-fields-private, class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ScriptBody:StatementList + It is a Syntax Error if AllPrivateNamesValid of StatementList with an empty List + as an argument is false unless the source code is eval code that is being + processed by a direct eval. + + ModuleBody:ModuleItemList + It is a Syntax Error if AllPrivateNamesValid of ModuleItemList with an empty List + as an argument is false. + + + Static Semantics: AllPrivateNamesValid + + MemberExpression : MemberExpression . PrivateName + + 1. If StringValue of PrivateName is in names, return true. + 2. Return false. + + CallExpression : CallExpression . PrivateName + + 1. If StringValue of PrivateName is in names, return true. + 2. Return false. + +---*/ + + +$DONOTEVALUATE(); + +class C { + m() { + function fn() { this.#x } + } +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/invalid-names/method-heritage-call-expression-bad-reference.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/invalid-names/method-heritage-call-expression-bad-reference.js new file mode 100644 index 0000000000..e43b5446e5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/invalid-names/method-heritage-call-expression-bad-reference.js @@ -0,0 +1,59 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/invalid-private-names/call-expression-bad-reference.case +// - src/invalid-private-names/default/cls-decl-method-heritage.template +/*--- +description: bad reference in call expression (Invalid private names should throw a SyntaxError, method in class declaration) +esid: sec-static-semantics-early-errors +features: [class-fields-private, class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ScriptBody:StatementList + It is a Syntax Error if AllPrivateNamesValid of StatementList with an empty List + as an argument is false unless the source code is eval code that is being + processed by a direct eval. + + ModuleBody:ModuleItemList + It is a Syntax Error if AllPrivateNamesValid of ModuleItemList with an empty List + as an argument is false. + + Static Semantics: AllPrivateNamesValid + + ClassBody : ClassElementList + 1. Let newNames be the concatenation of names with PrivateBoundNames of ClassBody. + 2. Return AllPrivateNamesValid of ClassElementList with the argument newNames. + + For all other grammatical productions, recurse on subexpressions/substatements, + passing in the names of the caller. If all pieces return true, then return true. + If any returns false, return false. + + + Static Semantics: AllPrivateNamesValid + + MemberExpression : MemberExpression . PrivateName + + 1. If StringValue of PrivateName is in names, return true. + 2. Return false. + + CallExpression : CallExpression . PrivateName + + 1. If StringValue of PrivateName is in names, return true. + 2. Return false. + +---*/ + + +$DONOTEVALUATE(); + +class Parent { + #x = 42; +} + +class C extends Parent { + m() { + (() => {})().#x + } +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/invalid-names/method-heritage-call-expression-this.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/invalid-names/method-heritage-call-expression-this.js new file mode 100644 index 0000000000..ce7669e83f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/invalid-names/method-heritage-call-expression-this.js @@ -0,0 +1,59 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/invalid-private-names/call-expression-this.case +// - src/invalid-private-names/default/cls-decl-method-heritage.template +/*--- +description: this evaluated in call expression (Invalid private names should throw a SyntaxError, method in class declaration) +esid: sec-static-semantics-early-errors +features: [class-fields-private, class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ScriptBody:StatementList + It is a Syntax Error if AllPrivateNamesValid of StatementList with an empty List + as an argument is false unless the source code is eval code that is being + processed by a direct eval. + + ModuleBody:ModuleItemList + It is a Syntax Error if AllPrivateNamesValid of ModuleItemList with an empty List + as an argument is false. + + Static Semantics: AllPrivateNamesValid + + ClassBody : ClassElementList + 1. Let newNames be the concatenation of names with PrivateBoundNames of ClassBody. + 2. Return AllPrivateNamesValid of ClassElementList with the argument newNames. + + For all other grammatical productions, recurse on subexpressions/substatements, + passing in the names of the caller. If all pieces return true, then return true. + If any returns false, return false. + + + Static Semantics: AllPrivateNamesValid + + MemberExpression : MemberExpression . PrivateName + + 1. If StringValue of PrivateName is in names, return true. + 2. Return false. + + CallExpression : CallExpression . PrivateName + + 1. If StringValue of PrivateName is in names, return true. + 2. Return false. + +---*/ + + +$DONOTEVALUATE(); + +class Parent { + #x = 42; +} + +class C extends Parent { + m() { + (() => this)().#x + } +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/invalid-names/method-heritage-member-expression-bad-reference.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/invalid-names/method-heritage-member-expression-bad-reference.js new file mode 100644 index 0000000000..0eeb130e09 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/invalid-names/method-heritage-member-expression-bad-reference.js @@ -0,0 +1,59 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/invalid-private-names/member-expression-bad-reference.case +// - src/invalid-private-names/default/cls-decl-method-heritage.template +/*--- +description: bad reference in member expression (Invalid private names should throw a SyntaxError, method in class declaration) +esid: sec-static-semantics-early-errors +features: [class-fields-private, class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ScriptBody:StatementList + It is a Syntax Error if AllPrivateNamesValid of StatementList with an empty List + as an argument is false unless the source code is eval code that is being + processed by a direct eval. + + ModuleBody:ModuleItemList + It is a Syntax Error if AllPrivateNamesValid of ModuleItemList with an empty List + as an argument is false. + + Static Semantics: AllPrivateNamesValid + + ClassBody : ClassElementList + 1. Let newNames be the concatenation of names with PrivateBoundNames of ClassBody. + 2. Return AllPrivateNamesValid of ClassElementList with the argument newNames. + + For all other grammatical productions, recurse on subexpressions/substatements, + passing in the names of the caller. If all pieces return true, then return true. + If any returns false, return false. + + + Static Semantics: AllPrivateNamesValid + + MemberExpression : MemberExpression . PrivateName + + 1. If StringValue of PrivateName is in names, return true. + 2. Return false. + + CallExpression : CallExpression . PrivateName + + 1. If StringValue of PrivateName is in names, return true. + 2. Return false. + +---*/ + + +$DONOTEVALUATE(); + +class Parent { + #x = 42; +} + +class C extends Parent { + m() { + something.#x + } +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/invalid-names/method-heritage-member-expression-this.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/invalid-names/method-heritage-member-expression-this.js new file mode 100644 index 0000000000..dea9d1d473 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/invalid-names/method-heritage-member-expression-this.js @@ -0,0 +1,59 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/invalid-private-names/member-expression-this.case +// - src/invalid-private-names/default/cls-decl-method-heritage.template +/*--- +description: this reference in member expression (Invalid private names should throw a SyntaxError, method in class declaration) +esid: sec-static-semantics-early-errors +features: [class-fields-private, class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ScriptBody:StatementList + It is a Syntax Error if AllPrivateNamesValid of StatementList with an empty List + as an argument is false unless the source code is eval code that is being + processed by a direct eval. + + ModuleBody:ModuleItemList + It is a Syntax Error if AllPrivateNamesValid of ModuleItemList with an empty List + as an argument is false. + + Static Semantics: AllPrivateNamesValid + + ClassBody : ClassElementList + 1. Let newNames be the concatenation of names with PrivateBoundNames of ClassBody. + 2. Return AllPrivateNamesValid of ClassElementList with the argument newNames. + + For all other grammatical productions, recurse on subexpressions/substatements, + passing in the names of the caller. If all pieces return true, then return true. + If any returns false, return false. + + + Static Semantics: AllPrivateNamesValid + + MemberExpression : MemberExpression . PrivateName + + 1. If StringValue of PrivateName is in names, return true. + 2. Return false. + + CallExpression : CallExpression . PrivateName + + 1. If StringValue of PrivateName is in names, return true. + 2. Return false. + +---*/ + + +$DONOTEVALUATE(); + +class Parent { + #x = 42; +} + +class C extends Parent { + m() { + this.#x + } +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/invalid-names/method-member-expression-bad-reference.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/invalid-names/method-member-expression-bad-reference.js new file mode 100644 index 0000000000..bae36e873a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/invalid-names/method-member-expression-bad-reference.js @@ -0,0 +1,43 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/invalid-private-names/member-expression-bad-reference.case +// - src/invalid-private-names/default/cls-decl-method.template +/*--- +description: bad reference in member expression (Invalid private names should throw a SyntaxError, method in class declaration) +esid: sec-static-semantics-early-errors +features: [class-fields-private, class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ScriptBody:StatementList + It is a Syntax Error if AllPrivateNamesValid of StatementList with an empty List + as an argument is false unless the source code is eval code that is being + processed by a direct eval. + + ModuleBody:ModuleItemList + It is a Syntax Error if AllPrivateNamesValid of ModuleItemList with an empty List + as an argument is false. + + + Static Semantics: AllPrivateNamesValid + + MemberExpression : MemberExpression . PrivateName + + 1. If StringValue of PrivateName is in names, return true. + 2. Return false. + + CallExpression : CallExpression . PrivateName + + 1. If StringValue of PrivateName is in names, return true. + 2. Return false. + +---*/ + + +$DONOTEVALUATE(); + +class C { + m() { something.#x } +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/invalid-names/method-member-expression-this.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/invalid-names/method-member-expression-this.js new file mode 100644 index 0000000000..baf7573389 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/invalid-names/method-member-expression-this.js @@ -0,0 +1,43 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/invalid-private-names/member-expression-this.case +// - src/invalid-private-names/default/cls-decl-method.template +/*--- +description: this reference in member expression (Invalid private names should throw a SyntaxError, method in class declaration) +esid: sec-static-semantics-early-errors +features: [class-fields-private, class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ScriptBody:StatementList + It is a Syntax Error if AllPrivateNamesValid of StatementList with an empty List + as an argument is false unless the source code is eval code that is being + processed by a direct eval. + + ModuleBody:ModuleItemList + It is a Syntax Error if AllPrivateNamesValid of ModuleItemList with an empty List + as an argument is false. + + + Static Semantics: AllPrivateNamesValid + + MemberExpression : MemberExpression . PrivateName + + 1. If StringValue of PrivateName is in names, return true. + 2. Return false. + + CallExpression : CallExpression . PrivateName + + 1. If StringValue of PrivateName is in names, return true. + 2. Return false. + +---*/ + + +$DONOTEVALUATE(); + +class C { + m() { this.#x } +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/invalid-names/method-outter-call-expression-bad-reference.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/invalid-names/method-outter-call-expression-bad-reference.js new file mode 100644 index 0000000000..b66bdcf9fd --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/invalid-names/method-outter-call-expression-bad-reference.js @@ -0,0 +1,59 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/invalid-private-names/call-expression-bad-reference.case +// - src/invalid-private-names/default/cls-decl-outter-method.template +/*--- +description: bad reference in call expression (Invalid private names should throw a SyntaxError, method in outter class declaration) +esid: sec-static-semantics-early-errors +features: [class-fields-private, class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ScriptBody:StatementList + It is a Syntax Error if AllPrivateNamesValid of StatementList with an empty List + as an argument is false unless the source code is eval code that is being + processed by a direct eval. + + ModuleBody:ModuleItemList + It is a Syntax Error if AllPrivateNamesValid of ModuleItemList with an empty List + as an argument is false. + + Static Semantics: AllPrivateNamesValid + + ClassBody : ClassElementList + 1. Let newNames be the concatenation of names with PrivateBoundNames of ClassBody. + 2. Return AllPrivateNamesValid of ClassElementList with the argument newNames. + + For all other grammatical productions, recurse on subexpressions/substatements, + passing in the names of the caller. If all pieces return true, then return true. + If any returns false, return false. + + + Static Semantics: AllPrivateNamesValid + + MemberExpression : MemberExpression . PrivateName + + 1. If StringValue of PrivateName is in names, return true. + 2. Return false. + + CallExpression : CallExpression . PrivateName + + 1. If StringValue of PrivateName is in names, return true. + 2. Return false. + +---*/ + + +$DONOTEVALUATE(); + +class C { + m() { + class Outter { + #x = 42; + } + + this.#x; + } +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/invalid-names/method-outter-call-expression-this.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/invalid-names/method-outter-call-expression-this.js new file mode 100644 index 0000000000..7d989a3e74 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/invalid-names/method-outter-call-expression-this.js @@ -0,0 +1,59 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/invalid-private-names/call-expression-this.case +// - src/invalid-private-names/default/cls-decl-outter-method.template +/*--- +description: this evaluated in call expression (Invalid private names should throw a SyntaxError, method in outter class declaration) +esid: sec-static-semantics-early-errors +features: [class-fields-private, class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ScriptBody:StatementList + It is a Syntax Error if AllPrivateNamesValid of StatementList with an empty List + as an argument is false unless the source code is eval code that is being + processed by a direct eval. + + ModuleBody:ModuleItemList + It is a Syntax Error if AllPrivateNamesValid of ModuleItemList with an empty List + as an argument is false. + + Static Semantics: AllPrivateNamesValid + + ClassBody : ClassElementList + 1. Let newNames be the concatenation of names with PrivateBoundNames of ClassBody. + 2. Return AllPrivateNamesValid of ClassElementList with the argument newNames. + + For all other grammatical productions, recurse on subexpressions/substatements, + passing in the names of the caller. If all pieces return true, then return true. + If any returns false, return false. + + + Static Semantics: AllPrivateNamesValid + + MemberExpression : MemberExpression . PrivateName + + 1. If StringValue of PrivateName is in names, return true. + 2. Return false. + + CallExpression : CallExpression . PrivateName + + 1. If StringValue of PrivateName is in names, return true. + 2. Return false. + +---*/ + + +$DONOTEVALUATE(); + +class C { + m() { + class Outter { + #x = 42; + } + + this.#x; + } +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/invalid-names/method-outter-member-expression-bad-reference.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/invalid-names/method-outter-member-expression-bad-reference.js new file mode 100644 index 0000000000..8c6ffeb17a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/invalid-names/method-outter-member-expression-bad-reference.js @@ -0,0 +1,59 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/invalid-private-names/member-expression-bad-reference.case +// - src/invalid-private-names/default/cls-decl-outter-method.template +/*--- +description: bad reference in member expression (Invalid private names should throw a SyntaxError, method in outter class declaration) +esid: sec-static-semantics-early-errors +features: [class-fields-private, class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ScriptBody:StatementList + It is a Syntax Error if AllPrivateNamesValid of StatementList with an empty List + as an argument is false unless the source code is eval code that is being + processed by a direct eval. + + ModuleBody:ModuleItemList + It is a Syntax Error if AllPrivateNamesValid of ModuleItemList with an empty List + as an argument is false. + + Static Semantics: AllPrivateNamesValid + + ClassBody : ClassElementList + 1. Let newNames be the concatenation of names with PrivateBoundNames of ClassBody. + 2. Return AllPrivateNamesValid of ClassElementList with the argument newNames. + + For all other grammatical productions, recurse on subexpressions/substatements, + passing in the names of the caller. If all pieces return true, then return true. + If any returns false, return false. + + + Static Semantics: AllPrivateNamesValid + + MemberExpression : MemberExpression . PrivateName + + 1. If StringValue of PrivateName is in names, return true. + 2. Return false. + + CallExpression : CallExpression . PrivateName + + 1. If StringValue of PrivateName is in names, return true. + 2. Return false. + +---*/ + + +$DONOTEVALUATE(); + +class C { + m() { + class Outter { + #x = 42; + } + + this.#x; + } +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/invalid-names/method-outter-member-expression-this.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/invalid-names/method-outter-member-expression-this.js new file mode 100644 index 0000000000..41926b597c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/invalid-names/method-outter-member-expression-this.js @@ -0,0 +1,59 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/invalid-private-names/member-expression-this.case +// - src/invalid-private-names/default/cls-decl-outter-method.template +/*--- +description: this reference in member expression (Invalid private names should throw a SyntaxError, method in outter class declaration) +esid: sec-static-semantics-early-errors +features: [class-fields-private, class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ScriptBody:StatementList + It is a Syntax Error if AllPrivateNamesValid of StatementList with an empty List + as an argument is false unless the source code is eval code that is being + processed by a direct eval. + + ModuleBody:ModuleItemList + It is a Syntax Error if AllPrivateNamesValid of ModuleItemList with an empty List + as an argument is false. + + Static Semantics: AllPrivateNamesValid + + ClassBody : ClassElementList + 1. Let newNames be the concatenation of names with PrivateBoundNames of ClassBody. + 2. Return AllPrivateNamesValid of ClassElementList with the argument newNames. + + For all other grammatical productions, recurse on subexpressions/substatements, + passing in the names of the caller. If all pieces return true, then return true. + If any returns false, return false. + + + Static Semantics: AllPrivateNamesValid + + MemberExpression : MemberExpression . PrivateName + + 1. If StringValue of PrivateName is in names, return true. + 2. Return false. + + CallExpression : CallExpression . PrivateName + + 1. If StringValue of PrivateName is in names, return true. + 2. Return false. + +---*/ + + +$DONOTEVALUATE(); + +class C { + m() { + class Outter { + #x = 42; + } + + this.#x; + } +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/invalid-names/shell.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/invalid-names/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/private-async-generator-cannot-escape-token.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/private-async-generator-cannot-escape-token.js new file mode 100644 index 0000000000..f152b5758b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/private-async-generator-cannot-escape-token.js @@ -0,0 +1,26 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/private-async-generator-cannot-escape-token.case +// - src/class-elements/syntax/invalid/cls-decl-elements-invalid-syntax.template +/*--- +description: The pound signal in the private async generator cannot be escaped (class declaration) +esid: prod-ClassElement +features: [class-methods-private, async-iteration, class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + PrivateName:: + # IdentifierName + + U+0023 is the escape sequence for # + +---*/ + + +$DONOTEVALUATE(); + +class C { + async * \u0023m() { return 42; } +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/private-async-method-cannot-escape-token.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/private-async-method-cannot-escape-token.js new file mode 100644 index 0000000000..cd8caf5df0 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/private-async-method-cannot-escape-token.js @@ -0,0 +1,26 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/private-async-method-cannot-escape-token.case +// - src/class-elements/syntax/invalid/cls-decl-elements-invalid-syntax.template +/*--- +description: The pound signal in the private async method cannot be escaped (class declaration) +esid: prod-ClassElement +features: [class-methods-private, async-functions, class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + PrivateName:: + # IdentifierName + + U+0023 is the escape sequence for # + +---*/ + + +$DONOTEVALUATE(); + +class C { + async \u0023m() { return 42; } +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/private-call-exp-cannot-escape-token.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/private-call-exp-cannot-escape-token.js new file mode 100644 index 0000000000..b949e50764 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/private-call-exp-cannot-escape-token.js @@ -0,0 +1,34 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/private-call-exp-cannot-escape-token.case +// - src/class-elements/syntax/invalid/cls-decl-elements-invalid-syntax.template +/*--- +description: The pound signal in the private reference cannot be escaped (class declaration) +esid: prod-ClassElement +features: [class-fields-private, class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + PrivateName :: + # IdentifierName + + MemberExpression : + MemberExpression . PrivateName + + CallExpression : + CallExpression . PrivateName + + U+0023 is the escape sequence for # + +---*/ + + +$DONOTEVALUATE(); + +class C { + method() { + foo().\u0023field; + } +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/private-field-cannot-escape-token.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/private-field-cannot-escape-token.js new file mode 100644 index 0000000000..8be2cdca1c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/private-field-cannot-escape-token.js @@ -0,0 +1,26 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/private-field-cannot-escape-token.case +// - src/class-elements/syntax/invalid/cls-decl-elements-invalid-syntax.template +/*--- +description: The pound signal in the private field cannot be escaped (class declaration) +esid: prod-ClassElement +features: [class-fields-private, class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + PrivateName:: + # IdentifierName + + U+0023 is the escape sequence for # + +---*/ + + +$DONOTEVALUATE(); + +class C { + \u0023field; +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/private-generator-cannot-escape-token.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/private-generator-cannot-escape-token.js new file mode 100644 index 0000000000..facd9e48c6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/private-generator-cannot-escape-token.js @@ -0,0 +1,26 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/private-generator-cannot-escape-token.case +// - src/class-elements/syntax/invalid/cls-decl-elements-invalid-syntax.template +/*--- +description: The pound signal in the private generator cannot be escaped (class declaration) +esid: prod-ClassElement +features: [class-methods-private, generators, class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + PrivateName:: + # IdentifierName + + U+0023 is the escape sequence for # + +---*/ + + +$DONOTEVALUATE(); + +class C { + * \u0023m() { return 42; } +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/private-member-exp-cannot-escape-token.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/private-member-exp-cannot-escape-token.js new file mode 100644 index 0000000000..61d2b6282c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/private-member-exp-cannot-escape-token.js @@ -0,0 +1,34 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/private-member-exp-cannot-escape-token.case +// - src/class-elements/syntax/invalid/cls-decl-elements-invalid-syntax.template +/*--- +description: The pound signal in the private reference cannot be escaped (class declaration) +esid: prod-ClassElement +features: [class-fields-private, class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + PrivateName :: + # IdentifierName + + MemberExpression : + MemberExpression . PrivateName + + CallExpression : + CallExpression . PrivateName + + U+0023 is the escape sequence for # + +---*/ + + +$DONOTEVALUATE(); + +class C { + method() { + this.\u0023field; + } +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/private-method-cannot-escape-token.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/private-method-cannot-escape-token.js new file mode 100644 index 0000000000..8084f90cc1 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/private-method-cannot-escape-token.js @@ -0,0 +1,26 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/private-method-cannot-escape-token.case +// - src/class-elements/syntax/invalid/cls-decl-elements-invalid-syntax.template +/*--- +description: The pound signal in the private method cannot be escaped (class declaration) +esid: prod-ClassElement +features: [class-methods-private, class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + PrivateName:: + # IdentifierName + + U+0023 is the escape sequence for # + +---*/ + + +$DONOTEVALUATE(); + +class C { + \u0023m() { return 42; } +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/shell.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/super-private-access-invalid.js b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/super-private-access-invalid.js new file mode 100644 index 0000000000..dffad30511 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/early-errors/super-private-access-invalid.js @@ -0,0 +1,37 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/super-private-access-invalid.case +// - src/class-elements/syntax/invalid/cls-decl-elements-invalid-syntax.template +/*--- +description: It is syntax error if PrivateName IdentifierName is accessed on SuperProperty (class declaration) +esid: prod-ClassElement +features: [class-methods-private, class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + SuperProperty: + super[Expression] + super.IdentifierName + +---*/ + + +$DONOTEVALUATE(); + +class C extends B +{ + #x() {} + + method() { + super.#x(); + } +} diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/shell.js b/js/src/tests/test262/language/statements/class/elements/syntax/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/valid/browser.js b/js/src/tests/test262/language/statements/class/elements/syntax/valid/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/valid/grammar-class-body-ctor-no-heritage.js b/js/src/tests/test262/language/statements/class/elements/syntax/valid/grammar-class-body-ctor-no-heritage.js new file mode 100644 index 0000000000..fdf55541d9 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/valid/grammar-class-body-ctor-no-heritage.js @@ -0,0 +1,24 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-class-body-ctor-no-heritage.case +// - src/class-elements/syntax/valid/cls-decl-elements-valid-syntax.template +/*--- +description: A constructor is valid without a super call in the constructor and heritage (class declaration) +esid: prod-ClassElement +features: [class] +flags: [generated] +info: | + ClassTail : ClassHeritageopt { ClassBody } + + It is a Syntax Error if ClassHeritage is not present and the following algorithm evaluates to true: + 1. Let constructor be ConstructorMethod of ClassBody. + 2. If constructor is empty, return false. + 3. Return HasDirectSuper of constructor. + +---*/ + + +class C { + constructor() {} +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/valid/grammar-field-accessor.js b/js/src/tests/test262/language/statements/class/elements/syntax/valid/grammar-field-accessor.js new file mode 100644 index 0000000000..eafce8744d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/valid/grammar-field-accessor.js @@ -0,0 +1,27 @@ +// |reftest| skip -- decorators is not supported +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-field-accessor.case +// - src/class-elements/syntax/valid/cls-decl-elements-valid-syntax.template +/*--- +description: Valid accessor FieldDefinition, ClassElementName, PropertyName Syntax (class declaration) +esid: prod-ClassElement +features: [decorators, class] +flags: [generated] +info: | + FieldDefinition[Yield, Await] : + ClassElementName[?Yield, ?Await] Initializer[+In, ?Yield, ?Await]opt + accessor [no LineTerminator here] ClassElementName[?Yield, ?Await] Initializer[+In, ?Yield, ?Await]opt + +---*/ + + +class C { + accessor $; + accessor _; + accessor \u{6F}; + accessor \u2118; + accessor ZW_\u200C_NJ; + accessor ZW_\u200D_J; +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/valid/grammar-field-classelementname-initializer-alt.js b/js/src/tests/test262/language/statements/class/elements/syntax/valid/grammar-field-classelementname-initializer-alt.js new file mode 100644 index 0000000000..d0b8f03ba4 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/valid/grammar-field-classelementname-initializer-alt.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-field-classelementname-initializer-alt.case +// - src/class-elements/syntax/valid/cls-decl-elements-valid-syntax.template +/*--- +description: FieldDefinition, ClassElementName, PropertyName = Initializer Syntax (class declaration) +esid: prod-ClassElement +features: [class-fields-public, class] +flags: [generated] +info: | + ClassElement : + ... + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PropertyName : + LiteralPropertyName + ComputedPropertyName + + LiteralPropertyName : + IdentifierName + + Initializer : + = AssignmentExpression + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart :: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart :: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue :: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + $ = 1; + _ = 2; + \u{6F} = 3; + ℘ = 4; // DO NOT CHANGE THE NAME OF THIS FIELD + ZW_‌_NJ = 5; // DO NOT CHANGE THE NAME OF THIS FIELD + ZW_‍_J = 6; // DO NOT CHANGE THE NAME OF THIS FIELD +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/valid/grammar-field-classelementname-initializer.js b/js/src/tests/test262/language/statements/class/elements/syntax/valid/grammar-field-classelementname-initializer.js new file mode 100644 index 0000000000..143e21ced4 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/valid/grammar-field-classelementname-initializer.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-field-classelementname-initializer.case +// - src/class-elements/syntax/valid/cls-decl-elements-valid-syntax.template +/*--- +description: FieldDefinition, ClassElementName, PropertyName = Initializer Syntax (class declaration) +esid: prod-ClassElement +features: [class-fields-public, class] +flags: [generated] +info: | + ClassElement : + ... + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PropertyName : + LiteralPropertyName + ComputedPropertyName + + LiteralPropertyName : + IdentifierName + + Initializer : + = AssignmentExpression + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart :: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart :: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue :: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + $ = 1; + _ = 2; + \u{6F} = 3; + \u2118 = 4; + ZW_\u200C_NJ = 5; + ZW_\u200D_J = 6; +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/valid/grammar-field-identifier-alt.js b/js/src/tests/test262/language/statements/class/elements/syntax/valid/grammar-field-identifier-alt.js new file mode 100644 index 0000000000..37c11e23d8 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/valid/grammar-field-identifier-alt.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-field-identifier-alt.case +// - src/class-elements/syntax/valid/cls-decl-elements-valid-syntax.template +/*--- +description: Valid FieldDefinition, ClassElementName, PropertyName Syntax (class declaration) +esid: prod-ClassElement +features: [class-fields-public, class] +flags: [generated] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PropertyName : + LiteralPropertyName + ComputedPropertyName + + LiteralPropertyName : + IdentifierName + StringLiteral + NumericLiteral + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart :: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart :: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue :: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + $; + _; + \u{6F}; + ℘; // DO NOT CHANGE THE NAME OF THIS FIELD + ZW_‌_NJ; // DO NOT CHANGE THE NAME OF THIS FIELD + ZW_‍_J; // DO NOT CHANGE THE NAME OF THIS FIELD +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/valid/grammar-field-identifier.js b/js/src/tests/test262/language/statements/class/elements/syntax/valid/grammar-field-identifier.js new file mode 100644 index 0000000000..0151ed8286 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/valid/grammar-field-identifier.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-field-identifier.case +// - src/class-elements/syntax/valid/cls-decl-elements-valid-syntax.template +/*--- +description: Valid FieldDefinition, ClassElementName, PropertyName Syntax (class declaration) +esid: prod-ClassElement +features: [class-fields-public, class] +flags: [generated] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PropertyName : + LiteralPropertyName + ComputedPropertyName + + LiteralPropertyName : + IdentifierName + StringLiteral + NumericLiteral + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart :: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart :: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue :: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + $; + _; + \u{6F}; + \u2118; + ZW_\u200C_NJ; + ZW_\u200D_J; +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/valid/grammar-fields-multi-line.js b/js/src/tests/test262/language/statements/class/elements/syntax/valid/grammar-fields-multi-line.js new file mode 100644 index 0000000000..73bde20af2 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/valid/grammar-fields-multi-line.js @@ -0,0 +1,31 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-fields-multi-line.case +// - src/class-elements/syntax/valid/cls-decl-elements-valid-syntax.template +/*--- +description: Valid multi-line, multi-field (class declaration) +esid: prod-ClassElement +features: [class-fields-public, class] +flags: [generated] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + +---*/ + + +class C { + x + y +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/valid/grammar-privatemeth-duplicate-get-set.js b/js/src/tests/test262/language/statements/class/elements/syntax/valid/grammar-privatemeth-duplicate-get-set.js new file mode 100644 index 0000000000..482b6920dd --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/valid/grammar-privatemeth-duplicate-get-set.js @@ -0,0 +1,23 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-privatemeth-duplicate-get-set.case +// - src/class-elements/syntax/valid/cls-decl-elements-valid-syntax.template +/*--- +description: It's valid if a class contains a private getter and a private setter with the same name (class declaration) +esid: prod-ClassElement +features: [class-methods-private, class] +flags: [generated] +info: | + Static Semantics: Early Errors + + ClassBody : ClassElementList + It is a Syntax Error if PrivateBoundNames of ClassBody contains any duplicate entries, unless the name is used once for a getter and once for a setter and in no other entries. + +---*/ + + +class C { + get #m() {} + set #m(_) {} +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/valid/grammar-privatemeth-duplicate-meth-nestedclassmeth.js b/js/src/tests/test262/language/statements/class/elements/syntax/valid/grammar-privatemeth-duplicate-meth-nestedclassmeth.js new file mode 100644 index 0000000000..ef9ea621c2 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/valid/grammar-privatemeth-duplicate-meth-nestedclassmeth.js @@ -0,0 +1,28 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-privatemeth-duplicate-meth-nestedclassmeth.case +// - src/class-elements/syntax/valid/cls-decl-elements-valid-syntax.template +/*--- +description: It's valid if a nested class shadows a private method (class declaration) +esid: prod-ClassElement +features: [class-methods-private, class] +flags: [generated] +info: | + Static Semantics: Early Errors + + ClassBody : ClassElementList + It is a Syntax Error if PrivateBoundNames of ClassBody contains any duplicate entries, unless the name is used once for a getter and once for a setter and in no other entries. + +---*/ + + +class C { + constructor() { + class B { + #m() {} + } + } + + #m() {} +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/valid/grammar-privatename-classelementname-initializer-alt.js b/js/src/tests/test262/language/statements/class/elements/syntax/valid/grammar-privatename-classelementname-initializer-alt.js new file mode 100644 index 0000000000..c741b7755d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/valid/grammar-privatename-classelementname-initializer-alt.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-privatename-classelementname-initializer-alt.case +// - src/class-elements/syntax/valid/cls-decl-elements-valid-syntax.template +/*--- +description: Valid PrivateName = Initializer Syntax (class declaration) +esid: prod-ClassElement +features: [class-fields-private, class] +flags: [generated] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + Initializer : + = AssignmentExpression + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + #$ = 1; + #_ = 2; + #\u{6F} = 3; + #℘ = 4; // DO NOT CHANGE THE NAME OF THIS FIELD + #ZW_‌_NJ = 5; // DO NOT CHANGE THE NAME OF THIS FIELD + #ZW_‍_J = 6; // DO NOT CHANGE THE NAME OF THIS FIELD +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/valid/grammar-privatename-classelementname-initializer.js b/js/src/tests/test262/language/statements/class/elements/syntax/valid/grammar-privatename-classelementname-initializer.js new file mode 100644 index 0000000000..e80e425b7e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/valid/grammar-privatename-classelementname-initializer.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-privatename-classelementname-initializer.case +// - src/class-elements/syntax/valid/cls-decl-elements-valid-syntax.template +/*--- +description: Valid PrivateName = Initializer Syntax (class declaration) +esid: prod-ClassElement +features: [class-fields-private, class] +flags: [generated] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + Initializer : + = AssignmentExpression + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + #$ = 1; + #_ = 2; + #\u{6F} = 3; + #\u2118 = 4; + #ZW_\u200C_NJ = 5; + #ZW_\u200D_J = 6; +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/valid/grammar-privatename-identifier.js b/js/src/tests/test262/language/statements/class/elements/syntax/valid/grammar-privatename-identifier.js new file mode 100644 index 0000000000..d0166b4b60 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/valid/grammar-privatename-identifier.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-privatename-identifier.case +// - src/class-elements/syntax/valid/cls-decl-elements-valid-syntax.template +/*--- +description: Valid PrivateName Syntax (class declaration) +esid: prod-ClassElement +features: [class-fields-private, class] +flags: [generated] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + #$; + #_; + #\u{6F}; + #\u2118; + #ZW_\u200C_NJ; + #ZW_\u200D_J; +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/valid/grammar-privatename-no-initializer-with-method.js b/js/src/tests/test262/language/statements/class/elements/syntax/valid/grammar-privatename-no-initializer-with-method.js new file mode 100644 index 0000000000..200f8b280e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/valid/grammar-privatename-no-initializer-with-method.js @@ -0,0 +1,34 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-privatename-no-initializer-with-method.case +// - src/class-elements/syntax/valid/cls-decl-elements-valid-syntax.template +/*--- +description: SyntaxError (class declaration) +esid: prod-ClassElement +features: [class-fields-private, class] +flags: [generated] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + +---*/ + + +class C { + #x + m() {} +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/valid/grammar-privatenames-multi-line.js b/js/src/tests/test262/language/statements/class/elements/syntax/valid/grammar-privatenames-multi-line.js new file mode 100644 index 0000000000..e00ef3ed47 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/valid/grammar-privatenames-multi-line.js @@ -0,0 +1,34 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-privatenames-multi-line.case +// - src/class-elements/syntax/valid/cls-decl-elements-valid-syntax.template +/*--- +description: SyntaxError (class declaration) +esid: prod-ClassElement +features: [class-fields-private, class] +flags: [generated] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + +---*/ + + +class C { + #x + #y +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/valid/grammar-special-prototype-accessor-meth-valid.js b/js/src/tests/test262/language/statements/class/elements/syntax/valid/grammar-special-prototype-accessor-meth-valid.js new file mode 100644 index 0000000000..d3cb1b1ce1 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/valid/grammar-special-prototype-accessor-meth-valid.js @@ -0,0 +1,58 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-special-prototype-accessor-meth-valid.case +// - src/class-elements/syntax/valid/cls-decl-elements-valid-syntax.template +/*--- +description: Accessor Methods can be named "prototype" (class declaration) +esid: prod-ClassElement +features: [class] +flags: [generated] +includes: [propertyHelper.js] +info: | + Runtime Semantics: ClassDefinitionEvaluation + + ClassTail : ClassHeritage_opt { ClassBody_opt } + + [...] + 6. Let proto be OrdinaryObjectCreate(protoParent). + [...] + 14. Perform MakeConstructor(F, false, proto). + [...] + 20. For each ClassElement m in order from methods, do + a. If IsStatic of m is false, then + i. Let status be PropertyDefinitionEvaluation of m with arguments proto and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + With parameters object and enumerable. + + MethodDefinition : get PropertyName ( ) { FunctionBody } + + [...] + 9. Let desc be the PropertyDescriptor { [[Get]]: closure, [[Enumerable]]: enumerable, [[Configurable]]: true }. + 10. Return ? DefinePropertyOrThrow(object, propKey, desc). + + MethodDefinition : set PropertyName ( PropertySetParameterList ) { FunctionBody } + + [...] + 8. Let desc be the PropertyDescriptor { [[Set]]: closure, [[Enumerable]]: enumerable, [[Configurable]]: true }. + 9. Return ? DefinePropertyOrThrow(object, propKey, desc). + +---*/ + + +class C { + get prototype() { return 13; } + set prototype(_) {} +} + +assert(C.hasOwnProperty('prototype')); +assert(C.prototype.hasOwnProperty('prototype')); +assert.notSameValue(C.prototype.prototype, C.prototype); +assert.sameValue(C.prototype.prototype, 13); +verifyProperty(C.prototype, 'prototype', { + enumerable: false, + configurable: true, +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/valid/grammar-special-prototype-async-gen-meth-valid.js b/js/src/tests/test262/language/statements/class/elements/syntax/valid/grammar-special-prototype-async-gen-meth-valid.js new file mode 100644 index 0000000000..2c7e0c8f6d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/valid/grammar-special-prototype-async-gen-meth-valid.js @@ -0,0 +1,51 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-special-prototype-async-gen-meth-valid.case +// - src/class-elements/syntax/valid/cls-decl-elements-valid-syntax.template +/*--- +description: Async Generator Methods can be named "prototype" (class declaration) +esid: prod-ClassElement +features: [async-iteration, class] +flags: [generated] +includes: [propertyHelper.js] +info: | + Runtime Semantics: ClassDefinitionEvaluation + + ClassTail : ClassHeritage_opt { ClassBody_opt } + + [...] + 6. Let proto be OrdinaryObjectCreate(protoParent). + [...] + 14. Perform MakeConstructor(F, false, proto). + [...] + 20. For each ClassElement m in order from methods, do + a. If IsStatic of m is false, then + i. Let status be PropertyDefinitionEvaluation of m with arguments proto and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + With parameters object and enumerable. + + AsyncGeneratorMethod : async * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + [...] + 10. Let desc be PropertyDescriptor { [[Value]]: closure, [[Writable]]: true, [[Enumerable]]: enumerable, [[Configurable]]: true }. + 11. Return ? DefinePropertyOrThrow(object, propKey, desc). + +---*/ + + +class C { + async * prototype() {} +} + +assert(C.hasOwnProperty('prototype')); +assert(C.prototype.hasOwnProperty('prototype')); +assert.notSameValue(C.prototype.prototype, C.prototype); +verifyProperty(C.prototype, 'prototype', { + writable: true, + enumerable: false, + configurable: true, +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/valid/grammar-special-prototype-async-meth-valid.js b/js/src/tests/test262/language/statements/class/elements/syntax/valid/grammar-special-prototype-async-meth-valid.js new file mode 100644 index 0000000000..17fa1970f5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/valid/grammar-special-prototype-async-meth-valid.js @@ -0,0 +1,51 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-special-prototype-async-meth-valid.case +// - src/class-elements/syntax/valid/cls-decl-elements-valid-syntax.template +/*--- +description: Async Methods can be named "prototype" (class declaration) +esid: prod-ClassElement +features: [async-functions, class] +flags: [generated] +includes: [propertyHelper.js] +info: | + Runtime Semantics: ClassDefinitionEvaluation + + ClassTail : ClassHeritage_opt { ClassBody_opt } + + [...] + 6. Let proto be OrdinaryObjectCreate(protoParent). + [...] + 14. Perform MakeConstructor(F, false, proto). + [...] + 20. For each ClassElement m in order from methods, do + a. If IsStatic of m is false, then + i. Let status be PropertyDefinitionEvaluation of m with arguments proto and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + With parameters object and enumerable. + + AsyncMethod : async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + [...] + 8. Let desc be the PropertyDescriptor { [[Value]]: closure, [[Writable]]: true, [[Enumerable]]: enumerable, [[Configurable]]: true }. + 9. Return ? DefinePropertyOrThrow(object, propKey, desc). + +---*/ + + +class C { + async prototype() {} +} + +assert(C.hasOwnProperty('prototype')); +assert(C.prototype.hasOwnProperty('prototype')); +assert.notSameValue(C.prototype.prototype, C.prototype); +verifyProperty(C.prototype, 'prototype', { + writable: true, + enumerable: false, + configurable: true, +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/valid/grammar-special-prototype-gen-meth-valid.js b/js/src/tests/test262/language/statements/class/elements/syntax/valid/grammar-special-prototype-gen-meth-valid.js new file mode 100644 index 0000000000..ac18e1f825 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/valid/grammar-special-prototype-gen-meth-valid.js @@ -0,0 +1,51 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-special-prototype-gen-meth-valid.case +// - src/class-elements/syntax/valid/cls-decl-elements-valid-syntax.template +/*--- +description: Generator Methods can be named "prototype" (class declaration) +esid: prod-ClassElement +features: [generators, class] +flags: [generated] +includes: [propertyHelper.js] +info: | + Runtime Semantics: ClassDefinitionEvaluation + + ClassTail : ClassHeritage_opt { ClassBody_opt } + + [...] + 6. Let proto be OrdinaryObjectCreate(protoParent). + [...] + 14. Perform MakeConstructor(F, false, proto). + [...] + 20. For each ClassElement m in order from methods, do + a. If IsStatic of m is false, then + i. Let status be PropertyDefinitionEvaluation of m with arguments proto and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + With parameters object and enumerable. + + GeneratorMethod : * PropertyName ( UniqueFormalParameters ) { GeneratorBody } + + [...] + 10. Let desc be the PropertyDescriptor { [[Value]]: closure, [[Writable]]: true, [[Enumerable]]: enumerable, [[Configurable]]: true }. + 11. Return ? DefinePropertyOrThrow(object, propKey, desc). + +---*/ + + +class C { + * prototype() {} +} + +assert(C.hasOwnProperty('prototype')); +assert(C.prototype.hasOwnProperty('prototype')); +assert.notSameValue(C.prototype.prototype, C.prototype); +verifyProperty(C.prototype, 'prototype', { + writable: true, + enumerable: false, + configurable: true, +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/valid/grammar-special-prototype-meth-valid.js b/js/src/tests/test262/language/statements/class/elements/syntax/valid/grammar-special-prototype-meth-valid.js new file mode 100644 index 0000000000..04ecfae0a3 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/valid/grammar-special-prototype-meth-valid.js @@ -0,0 +1,51 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-special-prototype-meth-valid.case +// - src/class-elements/syntax/valid/cls-decl-elements-valid-syntax.template +/*--- +description: Methods can be named "prototype" (class declaration) +esid: prod-ClassElement +features: [class] +flags: [generated] +includes: [propertyHelper.js] +info: | + Runtime Semantics: ClassDefinitionEvaluation + + ClassTail : ClassHeritage_opt { ClassBody_opt } + + [...] + 6. Let proto be OrdinaryObjectCreate(protoParent). + [...] + 14. Perform MakeConstructor(F, false, proto). + [...] + 20. For each ClassElement m in order from methods, do + a. If IsStatic of m is false, then + i. Let status be PropertyDefinitionEvaluation of m with arguments proto and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + With parameters object and enumerable. + + MethodDefinition : PropertyName ( UniqueFormalParameters ) { FunctionBody } + + [...] + 3. Let desc be the PropertyDescriptor { [[Value]]: methodDef.[[Closure]], [[Writable]]: true, [[Enumerable]]: enumerable, [[Configurable]]: true }. + 4. Return ? DefinePropertyOrThrow(object, methodDef.[[Key]], desc). + +---*/ + + +class C { + prototype() {} +} + +assert(C.hasOwnProperty('prototype')); +assert(C.prototype.hasOwnProperty('prototype')); +assert.notSameValue(C.prototype.prototype, C.prototype); +verifyProperty(C.prototype, 'prototype', { + writable: true, + enumerable: false, + configurable: true, +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/valid/grammar-static-ctor-accessor-meth-valid.js b/js/src/tests/test262/language/statements/class/elements/syntax/valid/grammar-static-ctor-accessor-meth-valid.js new file mode 100644 index 0000000000..50394530b3 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/valid/grammar-static-ctor-accessor-meth-valid.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-static-ctor-accessor-meth-valid.case +// - src/class-elements/syntax/valid/cls-decl-elements-valid-syntax.template +/*--- +description: Static Accessor Methods can be named constructor (class declaration) +esid: prod-ClassElement +features: [class] +flags: [generated] +info: | + Class Definitions / Static Semantics: Early Errors + + ClassElement : MethodDefinition + It is a Syntax Error if PropName of MethodDefinition is not "constructor" and HasDirectSuper of MethodDefinition is true. + It is a Syntax Error if PropName of MethodDefinition is "constructor" and SpecialMethod of MethodDefinition is true. + ClassElement : static MethodDefinition + It is a Syntax Error if HasDirectSuper of MethodDefinition is true. + It is a Syntax Error if PropName of MethodDefinition is "prototype". + +---*/ + + +class C { + static get constructor() {} + static set constructor(_) {} + constructor() {} // stacks with a valid constructor +} + +assert(C.hasOwnProperty('constructor')); +assert(C.prototype.hasOwnProperty('constructor')); +assert.notSameValue(C.prototype.constructor, C.constructor); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/valid/grammar-static-ctor-async-gen-meth-valid.js b/js/src/tests/test262/language/statements/class/elements/syntax/valid/grammar-static-ctor-async-gen-meth-valid.js new file mode 100644 index 0000000000..59d173ff32 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/valid/grammar-static-ctor-async-gen-meth-valid.js @@ -0,0 +1,31 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-static-ctor-async-gen-meth-valid.case +// - src/class-elements/syntax/valid/cls-decl-elements-valid-syntax.template +/*--- +description: Static Async Generator Methods can be named constructor (class declaration) +esid: prod-ClassElement +features: [async-iteration, class] +flags: [generated] +info: | + Class Definitions / Static Semantics: Early Errors + + ClassElement : MethodDefinition + It is a Syntax Error if PropName of MethodDefinition is not "constructor" and HasDirectSuper of MethodDefinition is true. + It is a Syntax Error if PropName of MethodDefinition is "constructor" and SpecialMethod of MethodDefinition is true. + ClassElement : static MethodDefinition + It is a Syntax Error if HasDirectSuper of MethodDefinition is true. + It is a Syntax Error if PropName of MethodDefinition is "prototype". + +---*/ + + +class C { + static async * constructor() {} + constructor() {} // stacks with a valid constructor +} + +assert(C.hasOwnProperty('constructor')); +assert(C.prototype.hasOwnProperty('constructor')); +assert.notSameValue(C.prototype.constructor, C.constructor); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/valid/grammar-static-ctor-async-meth-valid.js b/js/src/tests/test262/language/statements/class/elements/syntax/valid/grammar-static-ctor-async-meth-valid.js new file mode 100644 index 0000000000..47fbf0c78f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/valid/grammar-static-ctor-async-meth-valid.js @@ -0,0 +1,31 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-static-ctor-async-meth-valid.case +// - src/class-elements/syntax/valid/cls-decl-elements-valid-syntax.template +/*--- +description: Static Methods can be named constructor (class declaration) +esid: prod-ClassElement +features: [async-functions, class] +flags: [generated] +info: | + Class Definitions / Static Semantics: Early Errors + + ClassElement : MethodDefinition + It is a Syntax Error if PropName of MethodDefinition is not "constructor" and HasDirectSuper of MethodDefinition is true. + It is a Syntax Error if PropName of MethodDefinition is "constructor" and SpecialMethod of MethodDefinition is true. + ClassElement : static MethodDefinition + It is a Syntax Error if HasDirectSuper of MethodDefinition is true. + It is a Syntax Error if PropName of MethodDefinition is "prototype". + +---*/ + + +class C { + static async constructor() {} + constructor() {} // stacks with a valid constructor +} + +assert(C.hasOwnProperty('constructor')); +assert(C.prototype.hasOwnProperty('constructor')); +assert.notSameValue(C.prototype.constructor, C.constructor); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/valid/grammar-static-ctor-gen-meth-valid.js b/js/src/tests/test262/language/statements/class/elements/syntax/valid/grammar-static-ctor-gen-meth-valid.js new file mode 100644 index 0000000000..24f54213ef --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/valid/grammar-static-ctor-gen-meth-valid.js @@ -0,0 +1,31 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-static-ctor-gen-meth-valid.case +// - src/class-elements/syntax/valid/cls-decl-elements-valid-syntax.template +/*--- +description: Static Generator Methods can be named constructor (class declaration) +esid: prod-ClassElement +features: [generators, class] +flags: [generated] +info: | + Class Definitions / Static Semantics: Early Errors + + ClassElement : MethodDefinition + It is a Syntax Error if PropName of MethodDefinition is not "constructor" and HasDirectSuper of MethodDefinition is true. + It is a Syntax Error if PropName of MethodDefinition is "constructor" and SpecialMethod of MethodDefinition is true. + ClassElement : static MethodDefinition + It is a Syntax Error if HasDirectSuper of MethodDefinition is true. + It is a Syntax Error if PropName of MethodDefinition is "prototype". + +---*/ + + +class C { + static * constructor() {} + constructor() {} // stacks with a valid constructor +} + +assert(C.hasOwnProperty('constructor')); +assert(C.prototype.hasOwnProperty('constructor')); +assert.notSameValue(C.prototype.constructor, C.constructor); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/valid/grammar-static-ctor-meth-valid.js b/js/src/tests/test262/language/statements/class/elements/syntax/valid/grammar-static-ctor-meth-valid.js new file mode 100644 index 0000000000..7b778bc72b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/valid/grammar-static-ctor-meth-valid.js @@ -0,0 +1,31 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-static-ctor-meth-valid.case +// - src/class-elements/syntax/valid/cls-decl-elements-valid-syntax.template +/*--- +description: Static Methods can be named constructor (class declaration) +esid: prod-ClassElement +features: [class] +flags: [generated] +info: | + Class Definitions / Static Semantics: Early Errors + + ClassElement : MethodDefinition + It is a Syntax Error if PropName of MethodDefinition is not "constructor" and HasDirectSuper of MethodDefinition is true. + It is a Syntax Error if PropName of MethodDefinition is "constructor" and SpecialMethod of MethodDefinition is true. + ClassElement : static MethodDefinition + It is a Syntax Error if HasDirectSuper of MethodDefinition is true. + It is a Syntax Error if PropName of MethodDefinition is "prototype". + +---*/ + + +class C { + static constructor() {} + constructor() {} // stacks with a valid constructor +} + +assert(C.hasOwnProperty('constructor')); +assert(C.prototype.hasOwnProperty('constructor')); +assert.notSameValue(C.prototype.constructor, C.constructor); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/valid/grammar-static-private-async-gen-meth-prototype.js b/js/src/tests/test262/language/statements/class/elements/syntax/valid/grammar-static-private-async-gen-meth-prototype.js new file mode 100644 index 0000000000..7c7b26a27d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/valid/grammar-static-private-async-gen-meth-prototype.js @@ -0,0 +1,22 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-static-private-async-gen-meth-prototype.case +// - src/class-elements/syntax/valid/cls-decl-elements-valid-syntax.template +/*--- +description: Static Async Generator Private Methods can be named "#prototype" (class declaration) +esid: prod-ClassElement +features: [async-iteration, class-static-methods-private, class] +flags: [generated] +info: | + Class Definitions / Static Semantics: Early Errors + + ClassElement : static MethodDefinition + It is a Syntax Error if PropName of MethodDefinition is "prototype" + +---*/ + + +class C { + static async * #prototype() {} +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/valid/grammar-static-private-async-meth-prototype.js b/js/src/tests/test262/language/statements/class/elements/syntax/valid/grammar-static-private-async-meth-prototype.js new file mode 100644 index 0000000000..445dea39c6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/valid/grammar-static-private-async-meth-prototype.js @@ -0,0 +1,22 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-static-private-async-meth-prototype.case +// - src/class-elements/syntax/valid/cls-decl-elements-valid-syntax.template +/*--- +description: Static Async Private Methods can be named "#prototype" (class declaration) +esid: prod-ClassElement +features: [async-functions, class-static-methods-private, class] +flags: [generated] +info: | + Class Definitions / Static Semantics: Early Errors + + ClassElement : static MethodDefinition + It is a Syntax Error if PropName of MethodDefinition is "prototype" + +---*/ + + +class C { + static async #prototype() {} +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/valid/grammar-static-private-gen-meth-prototype.js b/js/src/tests/test262/language/statements/class/elements/syntax/valid/grammar-static-private-gen-meth-prototype.js new file mode 100644 index 0000000000..5a15aae437 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/valid/grammar-static-private-gen-meth-prototype.js @@ -0,0 +1,22 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-static-private-gen-meth-prototype.case +// - src/class-elements/syntax/valid/cls-decl-elements-valid-syntax.template +/*--- +description: Static Generator Private Methods can be named "#prototype" (class declaration) +esid: prod-ClassElement +features: [generators, class-static-methods-private, class] +flags: [generated] +info: | + Class Definitions / Static Semantics: Early Errors + + ClassElement : static MethodDefinition + It is a Syntax Error if PropName of MethodDefinition is "prototype" + +---*/ + + +class C { + static * #prototype() {} +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/valid/grammar-static-private-meth-prototype.js b/js/src/tests/test262/language/statements/class/elements/syntax/valid/grammar-static-private-meth-prototype.js new file mode 100644 index 0000000000..6907ef0886 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/syntax/valid/grammar-static-private-meth-prototype.js @@ -0,0 +1,22 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-static-private-meth-prototype.case +// - src/class-elements/syntax/valid/cls-decl-elements-valid-syntax.template +/*--- +description: Static Private Methods can be named "#prototype" (class declaration) +esid: prod-ClassElement +features: [class-static-methods-private, class] +flags: [generated] +info: | + Class Definitions / Static Semantics: Early Errors + + ClassElement : static MethodDefinition + It is a Syntax Error if PropName of MethodDefinition is "prototype" + +---*/ + + +class C { + static #prototype() {} +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/syntax/valid/shell.js b/js/src/tests/test262/language/statements/class/elements/syntax/valid/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/elements/ternary-init-err-contains-arguments.js b/js/src/tests/test262/language/statements/class/elements/ternary-init-err-contains-arguments.js new file mode 100644 index 0000000000..6d238dc7d7 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/ternary-init-err-contains-arguments.js @@ -0,0 +1,35 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/init-err-contains-arguments.case +// - src/class-elements/initializer-error/cls-decl-fields-ternary.template +/*--- +description: Syntax error if `arguments` used in class field (ternary expression) +esid: sec-class-definitions-static-semantics-early-errors +features: [class, class-fields-public] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Static Semantics: Early Errors + + FieldDefinition: + PropertyNameInitializeropt + + - It is a Syntax Error if ContainsArguments of Initializer is true. + + Static Semantics: ContainsArguments + IdentifierReference : Identifier + + 1. If the StringValue of Identifier is "arguments", return true. + ... + For all other grammatical productions, recurse on all nonterminals. If any piece returns true, then return true. Otherwise return false. + +---*/ + + +$DONOTEVALUATE(); + +class C { + x = false ? {} : arguments; +} diff --git a/js/src/tests/test262/language/statements/class/elements/ternary-init-err-contains-super.js b/js/src/tests/test262/language/statements/class/elements/ternary-init-err-contains-super.js new file mode 100644 index 0000000000..daff75a0a5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/ternary-init-err-contains-super.js @@ -0,0 +1,28 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/init-err-contains-super.case +// - src/class-elements/initializer-error/cls-decl-fields-ternary.template +/*--- +description: Syntax error if `super()` used in class field (ternary expression) +esid: sec-class-definitions-static-semantics-early-errors +features: [class, class-fields-public] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Static Semantics: Early Errors + + FieldDefinition: + PropertyNameInitializeropt + + - It is a Syntax Error if Initializer is present and Initializer Contains SuperCall is true. + +---*/ + + +$DONOTEVALUATE(); + +class C { + x = false ? {} : super(); +} diff --git a/js/src/tests/test262/language/statements/class/elements/typeof-init-err-contains-arguments.js b/js/src/tests/test262/language/statements/class/elements/typeof-init-err-contains-arguments.js new file mode 100644 index 0000000000..008897003f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/typeof-init-err-contains-arguments.js @@ -0,0 +1,35 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/init-err-contains-arguments.case +// - src/class-elements/initializer-error/cls-decl-fields-typeof.template +/*--- +description: Syntax error if `arguments` used in class field (typeof expression) +esid: sec-class-definitions-static-semantics-early-errors +features: [class, class-fields-public] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Static Semantics: Early Errors + + FieldDefinition: + PropertyNameInitializeropt + + - It is a Syntax Error if ContainsArguments of Initializer is true. + + Static Semantics: ContainsArguments + IdentifierReference : Identifier + + 1. If the StringValue of Identifier is "arguments", return true. + ... + For all other grammatical productions, recurse on all nonterminals. If any piece returns true, then return true. Otherwise return false. + +---*/ + + +$DONOTEVALUATE(); + +class C { + x = typeof arguments; +} diff --git a/js/src/tests/test262/language/statements/class/elements/typeof-init-err-contains-super.js b/js/src/tests/test262/language/statements/class/elements/typeof-init-err-contains-super.js new file mode 100644 index 0000000000..ac76975da2 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/typeof-init-err-contains-super.js @@ -0,0 +1,28 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/class-elements/init-err-contains-super.case +// - src/class-elements/initializer-error/cls-decl-fields-typeof.template +/*--- +description: Syntax error if `super()` used in class field (typeof expression) +esid: sec-class-definitions-static-semantics-early-errors +features: [class, class-fields-public] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Static Semantics: Early Errors + + FieldDefinition: + PropertyNameInitializeropt + + - It is a Syntax Error if Initializer is present and Initializer Contains SuperCall is true. + +---*/ + + +$DONOTEVALUATE(); + +class C { + x = typeof super(); +} diff --git a/js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-computed-names.js b/js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-computed-names.js new file mode 100644 index 0000000000..30e6024dba --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-computed-names.js @@ -0,0 +1,96 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/computed-names.case +// - src/class-elements/productions/cls-decl-wrapped-in-sc.template +/*--- +description: Computed property names (fields definition wrapped in semicolons) +esid: prod-FieldDefinition +features: [class-fields-public, computed-property-names, class] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PropertyName + +---*/ +var x = "b"; + + + +class C { + ;;;; + ;;;;;;[x] = 42; [10] = "meep"; ["not initialized"];;;;;;; + ;;;; + +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "b"), + "b doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "b"), + "b doesn't appear as an own property on C constructor" +); + +verifyProperty(c, "b", { + value: 42, + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "x"), + "x doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "x"), + "x doesn't appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "x"), + "x doesn't appear as an own property on C instance" +); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "10"), + "10 doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "10"), + "10 doesn't appear as an own property on C constructor" +); + +verifyProperty(c, "10", { + value: "meep", + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "not initialized"), + "'not initialized' doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "not initialized"), + "'not initialized' doesn't appear as an own property on C constructor" +); + +verifyProperty(c, "not initialized", { + value: undefined, + enumerable: true, + writable: true, + configurable: true +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-computed-symbol-names.js b/js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-computed-symbol-names.js new file mode 100644 index 0000000000..ce1ebcd921 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-computed-symbol-names.js @@ -0,0 +1,94 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/computed-symbol-names.case +// - src/class-elements/productions/cls-decl-wrapped-in-sc.template +/*--- +description: Computed property symbol names (fields definition wrapped in semicolons) +esid: prod-FieldDefinition +features: [class-fields-public, Symbol, computed-property-names, class] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PropertyName + +---*/ +var x = Symbol(); +var y = Symbol(); + + + +class C { + ;;;; + ;;;;;;[x]; [y] = 42;;;;;;; + ;;;; + +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, x), + "Symbol x doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, x), + "Symbol x doesn't appear as an own property on C constructor" +); + +verifyProperty(c, x, { + value: undefined, + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, y), + "Symbol y doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, y), + "Symbol y doesn't appear as an own property on C constructor" +); + +verifyProperty(c, y, { + value: 42, + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "x"), + "x doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "x"), + "x doesn't appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "x"), + "x doesn't appear as an own property on C instance" +); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "y"), + "y doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "y"), + "y doesn't appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "y"), + "y doesn't appear as an own property on C instance" +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-grammar-privatename-identifier-semantics-stringvalue.js b/js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-grammar-privatename-identifier-semantics-stringvalue.js new file mode 100644 index 0000000000..662df262e2 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-grammar-privatename-identifier-semantics-stringvalue.js @@ -0,0 +1,97 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-privatename-identifier-semantics-stringvalue.case +// - src/class-elements/productions/cls-decl-wrapped-in-sc.template +/*--- +description: PrivateName Static Semantics, StringValue (fields definition wrapped in semicolons) +esid: prod-FieldDefinition +features: [class-fields-private, class, class-fields-public] +flags: [generated] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + + + 1. Return the String value consisting of the sequence of code + units corresponding to PrivateName. In determining the sequence + any occurrences of \ UnicodeEscapeSequence are first replaced + with the code point represented by the UnicodeEscapeSequence + and then the code points of the entire PrivateName are converted + to code units by UTF16Encoding (10.1.1) each code point. + +---*/ + + +class C { + ;;;; + ;;;;;;#\u{6F}; + #\u2118; + #ZW_\u200C_NJ; + #ZW_\u200D_J;;;;;;;; + ;;;; + o(value) { + this.#o = value; + return this.#o; + } + ℘(value) { + this.#℘ = value; + return this.#℘; + } + ZW_‌_NJ(value) { // DO NOT CHANGE THE NAME OF THIS METHOD + this.#ZW_‌_NJ = value; + return this.#ZW_‌_NJ; + } + ZW_‍_J(value) { // DO NOT CHANGE THE NAME OF THIS METHOD + this.#ZW_‍_J = value; + return this.#ZW_‍_J; + } +} + +var c = new C(); + +assert.sameValue(c.o(1), 1); +assert.sameValue(c.℘(1), 1); +assert.sameValue(c.ZW_‌_NJ(1), 1); +assert.sameValue(c.ZW_‍_J(1), 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-literal-names-asi.js b/js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-literal-names-asi.js new file mode 100644 index 0000000000..b7c8cba4af --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-literal-names-asi.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/literal-names-asi.case +// - src/class-elements/productions/cls-decl-wrapped-in-sc.template +/*--- +description: Literal property names with ASI (fields definition wrapped in semicolons) +esid: prod-FieldDefinition +features: [class-fields-public, class] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PropertyName + +---*/ + + +class C { + ;;;; + ;;;;;;a + b = 42;;;;;;;; + ;;;; + +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "a"), + "a doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "a"), + "a doesn't appear as an own property on C constructor" +); + +verifyProperty(c, "a", { + value: undefined, + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "b"), + "b doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "b"), + "b doesn't appear as an own property on C constructor" +); + +verifyProperty(c, "b", { + value: 42, + enumerable: true, + writable: true, + configurable: true +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-literal-names.js b/js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-literal-names.js new file mode 100644 index 0000000000..14874fa1aa --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-literal-names.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/literal-names.case +// - src/class-elements/productions/cls-decl-wrapped-in-sc.template +/*--- +description: Literal property names (fields definition wrapped in semicolons) +esid: prod-FieldDefinition +features: [class-fields-public, class] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PropertyName + +---*/ +const fn = function() {} + + + +class C { + ;;;; + ;;;;;;a; b = 42; + c = fn;;;;;;; + ;;;; + +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "a"), + "a doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "a"), + "a doesn't appear as an own property on C constructor" +); + +verifyProperty(c, "a", { + value: undefined, + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "b"), + "b doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "b"), + "b doesn't appear as an own property on C constructor" +); + +verifyProperty(c, "b", { + value: 42, + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "c"), + "c doesn't appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "c"), + "c doesn't appear as an own property on C constructor" +); + +verifyProperty(c, "c", { + value: fn, + enumerable: true, + writable: true, + configurable: true +}); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-private-field-usage.js b/js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-private-field-usage.js new file mode 100644 index 0000000000..250732f70e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-private-field-usage.js @@ -0,0 +1,37 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/private-field-usage.case +// - src/class-elements/productions/cls-decl-wrapped-in-sc.template +/*--- +description: PrivateName CallExpression usage (private field) (fields definition wrapped in semicolons) +esid: prod-FieldDefinition +features: [class-fields-private, class, class-fields-public] +flags: [generated] +info: | + Updated Productions + + CallExpression[Yield, Await]: + CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await] + SuperCall[?Yield, ?Await] + CallExpression[?Yield, ?Await]Arguments[?Yield, ?Await] + CallExpression[?Yield, ?Await][Expression[+In, ?Yield, ?Await]] + CallExpression[?Yield, ?Await].IdentifierName + CallExpression[?Yield, ?Await]TemplateLiteral[?Yield, ?Await] + CallExpression[?Yield, ?Await].PrivateName + +---*/ + + +class C { + ;;;; + ;;;;;;#m = 'test262';;;;;;;; + ;;;; + method() { + return this.#m; + } +} + +var c = new C(); + +assert.sameValue(c.method(), 'test262'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-private-method-getter-usage.js b/js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-private-method-getter-usage.js new file mode 100644 index 0000000000..96dc07fce4 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-private-method-getter-usage.js @@ -0,0 +1,37 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/private-method-getter-usage.case +// - src/class-elements/productions/cls-decl-wrapped-in-sc.template +/*--- +description: PrivateName CallExpression usage (Accesor get method) (fields definition wrapped in semicolons) +esid: prod-FieldDefinition +features: [class-methods-private, class, class-fields-public] +flags: [generated] +info: | + Updated Productions + + CallExpression[Yield, Await]: + CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await] + SuperCall[?Yield, ?Await] + CallExpression[?Yield, ?Await]Arguments[?Yield, ?Await] + CallExpression[?Yield, ?Await][Expression[+In, ?Yield, ?Await]] + CallExpression[?Yield, ?Await].IdentifierName + CallExpression[?Yield, ?Await]TemplateLiteral[?Yield, ?Await] + CallExpression[?Yield, ?Await].PrivateName + +---*/ + + +class C { + ;;;; + ;;;;;;get #m() { return 'test262'; };;;;;;; + ;;;; + method() { + return this.#m; + } +} + +var c = new C(); + +assert.sameValue(c.method(), 'test262'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-private-method-usage.js b/js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-private-method-usage.js new file mode 100644 index 0000000000..f40a7674dc --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-private-method-usage.js @@ -0,0 +1,37 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/private-method-usage.case +// - src/class-elements/productions/cls-decl-wrapped-in-sc.template +/*--- +description: PrivateName CallExpression usage (private method) (fields definition wrapped in semicolons) +esid: prod-FieldDefinition +features: [class-methods-private, class, class-fields-public] +flags: [generated] +info: | + Updated Productions + + CallExpression[Yield, Await]: + CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await] + SuperCall[?Yield, ?Await] + CallExpression[?Yield, ?Await]Arguments[?Yield, ?Await] + CallExpression[?Yield, ?Await][Expression[+In, ?Yield, ?Await]] + CallExpression[?Yield, ?Await].IdentifierName + CallExpression[?Yield, ?Await]TemplateLiteral[?Yield, ?Await] + CallExpression[?Yield, ?Await].PrivateName + +---*/ + + +class C { + ;;;; + ;;;;;;#m() { return 'test262'; };;;;;;; + ;;;; + method() { + return this.#m(); + } +} + +var c = new C(); + +assert.sameValue(c.method(), 'test262'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-private-names.js b/js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-private-names.js new file mode 100644 index 0000000000..cd5fdb0d9f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-private-names.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/private-names.case +// - src/class-elements/productions/cls-decl-wrapped-in-sc.template +/*--- +description: private names (fields definition wrapped in semicolons) +esid: prod-FieldDefinition +features: [class-fields-private, class, class-fields-public] +flags: [generated] +info: | + ClassElement : + ... + FieldDefinition ; + + FieldDefinition : + ClassElementName Initializer_opt + + ClassElementName : + PrivateName + + PrivateName : + # IdentifierName + +---*/ + + +class C { + ;;;; + ;;;;;;#x; #y;;;;;;; + ;;;; + x() { + this.#x = 42; + return this.#x; + } + y() { + this.#y = 43; + return this.#y; + } +} + +var c = new C(); + +// Test the private fields do not appear as properties before set to value +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#x"), "test 1"); +assert(!Object.prototype.hasOwnProperty.call(C, "#x"), "test 2"); +assert(!Object.prototype.hasOwnProperty.call(c, "#x"), "test 3"); + +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#y"), "test 4"); +assert(!Object.prototype.hasOwnProperty.call(C, "#y"), "test 5"); +assert(!Object.prototype.hasOwnProperty.call(c, "#y"), "test 6"); + +// Test if private fields can be sucessfully accessed and set to value +assert.sameValue(c.x(), 42, "test 7"); +assert.sameValue(c.y(), 43, "test 8"); + +// Test the private fields do not appear as properties before after set to value +assert(!Object.prototype.hasOwnProperty.call(c, "#x"), "test 9"); +assert(!Object.prototype.hasOwnProperty.call(c, "#y"), "test 10"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-rs-field-identifier-initializer.js b/js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-rs-field-identifier-initializer.js new file mode 100644 index 0000000000..b73e3b18f6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-rs-field-identifier-initializer.js @@ -0,0 +1,75 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-field-identifier-initializer.case +// - src/class-elements/productions/cls-decl-wrapped-in-sc.template +/*--- +description: Valid FieldDefinition (fields definition wrapped in semicolons) +esid: prod-FieldDefinition +features: [class-fields-public, class] +flags: [generated] +info: | + ClassElement : + ... + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + + PropertyName : + LiteralPropertyName + ComputedPropertyName + + LiteralPropertyName : + IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + ;;;; + ;;;;;;$ = 1; _ = 1; \u{6F} = 1; \u2118 = 1; ZW_\u200C_NJ = 1; ZW_\u200D_J = 1;;;;;;; + ;;;; + +} + +var c = new C(); + +assert.sameValue(c.$, 1); +assert.sameValue(c._, 1); +assert.sameValue(c.\u{6F}, 1); +assert.sameValue(c.\u2118, 1); +assert.sameValue(c.ZW_\u200C_NJ, 1); +assert.sameValue(c.ZW_\u200D_J, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-rs-field-identifier.js b/js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-rs-field-identifier.js new file mode 100644 index 0000000000..258d3a90fe --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-rs-field-identifier.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-field-identifier.case +// - src/class-elements/productions/cls-decl-wrapped-in-sc.template +/*--- +description: Valid FieldDefinition (fields definition wrapped in semicolons) +esid: prod-FieldDefinition +features: [class-fields-public, class] +flags: [generated] +info: | + ClassElement : + ... + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + + PropertyName : + LiteralPropertyName + ComputedPropertyName + + LiteralPropertyName : + IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + ;;;; + ;;;;;;$; _; \u{6F}; \u2118; ZW_\u200C_NJ; ZW_\u200D_J;;;;;;; + ;;;; + +} + +var c = new C(); + +c.$ = 1; +c._ = 1; +c.\u{6F} = 1; +c.\u2118 = 1; +c.ZW_\u200C_NJ = 1; +c.ZW_\u200D_J = 1; + +assert.sameValue(c.$, 1); +assert.sameValue(c._, 1); +assert.sameValue(c.\u{6F}, 1); +assert.sameValue(c.\u2118, 1); +assert.sameValue(c.ZW_\u200C_NJ, 1); +assert.sameValue(c.ZW_\u200D_J, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-rs-private-getter-alt.js b/js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-rs-private-getter-alt.js new file mode 100644 index 0000000000..596acd77f1 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-rs-private-getter-alt.js @@ -0,0 +1,116 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-private-getter-alt.case +// - src/class-elements/productions/cls-decl-wrapped-in-sc.template +/*--- +description: Valid PrivateName as private getter (fields definition wrapped in semicolons) +esid: prod-FieldDefinition +features: [class-methods-private, class-fields-private, class, class-fields-public] +flags: [generated] +info: | + ClassElement : + MethodDefinition + ... + ; + + MethodDefinition : + ... + get ClassElementName ( ){ FunctionBody } + ... + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + ;;;; + ;;;;;;#$_; #__; #\u{6F}_; #℘_; #ZW_‌_NJ_; #ZW_‍_J_; + get #$() { + return this.#$_; + } + get #_() { + return this.#__; + } + get #\u{6F}() { + return this.#\u{6F}_; + } + get #℘() { + return this.#℘_; + } + get #ZW_‌_NJ() { + return this.#ZW_‌_NJ_; + } + get #ZW_‍_J() { + return this.#ZW_‍_J_; + } +;;;;;;; + ;;;; + $(value) { + this.#$_ = value; + return this.#$; + } + _(value) { + this.#__ = value; + return this.#_; + } + \u{6F}(value) { + this.#\u{6F}_ = value; + return this.#\u{6F}; + } + ℘(value) { + this.#℘_ = value; + return this.#℘; + } + ZW_‌_NJ(value) { + this.#ZW_‌_NJ_ = value; + return this.#ZW_‌_NJ; + } + ZW_‍_J(value) { + this.#ZW_‍_J_ = value; + return this.#ZW_‍_J; + } + +} + +var c = new C(); + +assert.sameValue(c.$(1), 1); +assert.sameValue(c._(1), 1); +assert.sameValue(c.\u{6F}(1), 1); +assert.sameValue(c.℘(1), 1); +assert.sameValue(c.ZW_‌_NJ(1), 1); +assert.sameValue(c.ZW_‍_J(1), 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-rs-private-getter.js b/js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-rs-private-getter.js new file mode 100644 index 0000000000..3dc72041ab --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-rs-private-getter.js @@ -0,0 +1,116 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-private-getter.case +// - src/class-elements/productions/cls-decl-wrapped-in-sc.template +/*--- +description: Valid PrivateName as private getter (fields definition wrapped in semicolons) +esid: prod-FieldDefinition +features: [class-methods-private, class-fields-private, class, class-fields-public] +flags: [generated] +info: | + ClassElement : + MethodDefinition + ... + ; + + MethodDefinition : + ... + get ClassElementName ( ){ FunctionBody } + ... + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + ;;;; + ;;;;;;#$_; #__; #\u{6F}_; #\u2118_; #ZW_\u200C_NJ_; #ZW_\u200D_J_; + get #$() { + return this.#$_; + } + get #_() { + return this.#__; + } + get #\u{6F}() { + return this.#\u{6F}_; + } + get #\u2118() { + return this.#\u2118_; + } + get #ZW_\u200C_NJ() { + return this.#ZW_\u200C_NJ_; + } + get #ZW_\u200D_J() { + return this.#ZW_\u200D_J_; + } +;;;;;;; + ;;;; + $(value) { + this.#$_ = value; + return this.#$; + } + _(value) { + this.#__ = value; + return this.#_; + } + \u{6F}(value) { + this.#\u{6F}_ = value; + return this.#\u{6F}; + } + \u2118(value) { + this.#\u2118_ = value; + return this.#\u2118; + } + ZW_\u200C_NJ(value) { + this.#ZW_\u200C_NJ_ = value; + return this.#ZW_\u200C_NJ; + } + ZW_\u200D_J(value) { + this.#ZW_\u200D_J_ = value; + return this.#ZW_\u200D_J; + } + +} + +var c = new C(); + +assert.sameValue(c.$(1), 1); +assert.sameValue(c._(1), 1); +assert.sameValue(c.\u{6F}(1), 1); +assert.sameValue(c.\u2118(1), 1); +assert.sameValue(c.ZW_\u200C_NJ(1), 1); +assert.sameValue(c.ZW_\u200D_J(1), 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-rs-private-method-alt.js b/js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-rs-private-method-alt.js new file mode 100644 index 0000000000..b62a4f7d4b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-rs-private-method-alt.js @@ -0,0 +1,115 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-private-method-alt.case +// - src/class-elements/productions/cls-decl-wrapped-in-sc.template +/*--- +description: Valid PrivateName as private method (fields definition wrapped in semicolons) +esid: prod-FieldDefinition +features: [class-methods-private, class-fields-private, class, class-fields-public] +flags: [generated] +info: | + ClassElement : + MethodDefinition + ... + ; + + MethodDefinition : + ClassElementName ( UniqueFormalParameters ) { FunctionBody } + ... + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + ;;;; + ;;;;;;#$_; #__; #\u{6F}_; #℘_; #ZW_‌_NJ_; #ZW_‍_J_; + #$() { + return this.#$_; + } + #_() { + return this.#__; + } + #\u{6F}() { + return this.#\u{6F}_; + } + #℘() { + return this.#℘_; + } + #ZW_‌_NJ() { + return this.#ZW_‌_NJ_; + } + #ZW_‍_J() { + return this.#ZW_‍_J_; + } +;;;;;;; + ;;;; + $(value) { + this.#$_ = value; + return this.#$(); + } + _(value) { + this.#__ = value; + return this.#_(); + } + \u{6F}(value) { + this.#\u{6F}_ = value; + return this.#\u{6F}(); + } + ℘(value) { + this.#℘_ = value; + return this.#℘(); + } + ZW_‌_NJ(value) { + this.#ZW_‌_NJ_ = value; + return this.#ZW_‌_NJ(); + } + ZW_‍_J(value) { + this.#ZW_‍_J_ = value; + return this.#ZW_‍_J(); + } + +} + +var c = new C(); + +assert.sameValue(c.$(1), 1); +assert.sameValue(c._(1), 1); +assert.sameValue(c.\u{6F}(1), 1); +assert.sameValue(c.℘(1), 1); +assert.sameValue(c.ZW_‌_NJ(1), 1); +assert.sameValue(c.ZW_‍_J(1), 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-rs-private-method.js b/js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-rs-private-method.js new file mode 100644 index 0000000000..64e147f00e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-rs-private-method.js @@ -0,0 +1,115 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-private-method.case +// - src/class-elements/productions/cls-decl-wrapped-in-sc.template +/*--- +description: Valid PrivateName as private method (fields definition wrapped in semicolons) +esid: prod-FieldDefinition +features: [class-methods-private, class-fields-private, class, class-fields-public] +flags: [generated] +info: | + ClassElement : + MethodDefinition + ... + ; + + MethodDefinition : + ClassElementName ( UniqueFormalParameters ) { FunctionBody } + ... + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + ;;;; + ;;;;;;#$_; #__; #\u{6F}_; #\u2118_; #ZW_\u200C_NJ_; #ZW_\u200D_J_; + #$() { + return this.#$_; + } + #_() { + return this.#__; + } + #\u{6F}() { + return this.#\u{6F}_; + } + #\u2118() { + return this.#\u2118_; + } + #ZW_\u200C_NJ() { + return this.#ZW_\u200C_NJ_; + } + #ZW_\u200D_J() { + return this.#ZW_\u200D_J_; + } +;;;;;;; + ;;;; + $(value) { + this.#$_ = value; + return this.#$(); + } + _(value) { + this.#__ = value; + return this.#_(); + } + \u{6F}(value) { + this.#\u{6F}_ = value; + return this.#\u{6F}(); + } + \u2118(value) { + this.#\u2118_ = value; + return this.#\u2118(); + } + ZW_\u200C_NJ(value) { + this.#ZW_\u200C_NJ_ = value; + return this.#ZW_\u200C_NJ(); + } + ZW_\u200D_J(value) { + this.#ZW_\u200D_J_ = value; + return this.#ZW_\u200D_J(); + } + +} + +var c = new C(); + +assert.sameValue(c.$(1), 1); +assert.sameValue(c._(1), 1); +assert.sameValue(c.\u{6F}(1), 1); +assert.sameValue(c.\u2118(1), 1); +assert.sameValue(c.ZW_\u200C_NJ(1), 1); +assert.sameValue(c.ZW_\u200D_J(1), 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-rs-private-setter-alt.js b/js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-rs-private-setter-alt.js new file mode 100644 index 0000000000..293cb94806 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-rs-private-setter-alt.js @@ -0,0 +1,115 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-private-setter-alt.case +// - src/class-elements/productions/cls-decl-wrapped-in-sc.template +/*--- +description: Valid PrivateName as private setter (fields definition wrapped in semicolons) +esid: prod-FieldDefinition +features: [class-methods-private, class-fields-private, class, class-fields-public] +flags: [generated] +info: | + ClassElement : + MethodDefinition + ... + ; + + MethodDefinition : + ... + set ClassElementName ( PropertySetParameterList ) { FunctionBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + ;;;; + ;;;;;;#$_; #__; #\u{6F}_; #℘_; #ZW_‌_NJ_; #ZW_‍_J_; + set #$(value) { + this.#$_ = value; + } + set #_(value) { + this.#__ = value; + } + set #\u{6F}(value) { + this.#\u{6F}_ = value; + } + set #℘(value) { + this.#℘_ = value; + } + set #ZW_‌_NJ(value) { + this.#ZW_‌_NJ_ = value; + } + set #ZW_‍_J(value) { + this.#ZW_‍_J_ = value; + } +;;;;;;; + ;;;; + $(value) { + this.#$ = value; + return this.#$_; + } + _(value) { + this.#_ = value; + return this.#__; + } + \u{6F}(value) { + this.#\u{6F} = value; + return this.#\u{6F}_; + } + ℘(value) { + this.#℘ = value; + return this.#℘_; + } + ZW_‌_NJ(value) { + this.#ZW_‌_NJ = value; + return this.#ZW_‌_NJ_; + } + ZW_‍_J(value) { + this.#ZW_‍_J = value; + return this.#ZW_‍_J_; + } + +} + +var c = new C(); + +assert.sameValue(c.$(1), 1); +assert.sameValue(c._(1), 1); +assert.sameValue(c.\u{6F}(1), 1); +assert.sameValue(c.℘(1), 1); +assert.sameValue(c.ZW_‌_NJ(1), 1); +assert.sameValue(c.ZW_‍_J(1), 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-rs-private-setter.js b/js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-rs-private-setter.js new file mode 100644 index 0000000000..e199eac710 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-rs-private-setter.js @@ -0,0 +1,115 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-private-setter.case +// - src/class-elements/productions/cls-decl-wrapped-in-sc.template +/*--- +description: Valid PrivateName as private setter (fields definition wrapped in semicolons) +esid: prod-FieldDefinition +features: [class-methods-private, class-fields-private, class, class-fields-public] +flags: [generated] +info: | + ClassElement : + MethodDefinition + ... + ; + + MethodDefinition : + ... + set ClassElementName ( PropertySetParameterList ) { FunctionBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + ;;;; + ;;;;;;#$_; #__; #\u{6F}_; #\u2118_; #ZW_\u200C_NJ_; #ZW_\u200D_J_; + set #$(value) { + this.#$_ = value; + } + set #_(value) { + this.#__ = value; + } + set #\u{6F}(value) { + this.#\u{6F}_ = value; + } + set #\u2118(value) { + this.#\u2118_ = value; + } + set #ZW_\u200C_NJ(value) { + this.#ZW_\u200C_NJ_ = value; + } + set #ZW_\u200D_J(value) { + this.#ZW_\u200D_J_ = value; + } +;;;;;;; + ;;;; + $(value) { + this.#$ = value; + return this.#$_; + } + _(value) { + this.#_ = value; + return this.#__; + } + \u{6F}(value) { + this.#\u{6F} = value; + return this.#\u{6F}_; + } + \u2118(value) { + this.#\u2118 = value; + return this.#\u2118_; + } + ZW_\u200C_NJ(value) { + this.#ZW_\u200C_NJ = value; + return this.#ZW_\u200C_NJ_; + } + ZW_\u200D_J(value) { + this.#ZW_\u200D_J = value; + return this.#ZW_\u200D_J_; + } + +} + +var c = new C(); + +assert.sameValue(c.$(1), 1); +assert.sameValue(c._(1), 1); +assert.sameValue(c.\u{6F}(1), 1); +assert.sameValue(c.\u2118(1), 1); +assert.sameValue(c.ZW_\u200C_NJ(1), 1); +assert.sameValue(c.ZW_\u200D_J(1), 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-rs-privatename-identifier-alt.js b/js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-rs-privatename-identifier-alt.js new file mode 100644 index 0000000000..d54f48af3c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-rs-privatename-identifier-alt.js @@ -0,0 +1,97 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-privatename-identifier-alt.case +// - src/class-elements/productions/cls-decl-wrapped-in-sc.template +/*--- +description: Valid PrivateName (fields definition wrapped in semicolons) +esid: prod-FieldDefinition +features: [class-fields-private, class, class-fields-public] +flags: [generated] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + ;;;; + ;;;;;;#$; #_; #\u{6F}; #℘; #ZW_‌_NJ; #ZW_‍_J;;;;;;; + ;;;; + $(value) { + this.#$ = value; + return this.#$; + } + _(value) { + this.#_ = value; + return this.#_; + } + \u{6F}(value) { + this.#\u{6F} = value; + return this.#\u{6F}; + } + ℘(value) { + this.#℘ = value; + return this.#℘; + } + ZW_‌_NJ(value) { + this.#ZW_‌_NJ = value; + return this.#ZW_‌_NJ; + } + ZW_‍_J(value) { + this.#ZW_‍_J = value; + return this.#ZW_‍_J; + } +} + +var c = new C(); + +assert.sameValue(c.$(1), 1); +assert.sameValue(c._(1), 1); +assert.sameValue(c.\u{6F}(1), 1); +assert.sameValue(c.℘(1), 1); +assert.sameValue(c.ZW_‌_NJ(1), 1); +assert.sameValue(c.ZW_‍_J(1), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-rs-privatename-identifier-initializer-alt.js b/js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-rs-privatename-identifier-initializer-alt.js new file mode 100644 index 0000000000..dfce12d03b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-rs-privatename-identifier-initializer-alt.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-privatename-identifier-initializer-alt.case +// - src/class-elements/productions/cls-decl-wrapped-in-sc.template +/*--- +description: Valid PrivateName (fields definition wrapped in semicolons) +esid: prod-FieldDefinition +features: [class-fields-private, class, class-fields-public] +flags: [generated] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + ;;;; + ;;;;;;#$ = 1; #_ = 1; #\u{6F} = 1; #℘ = 1; #ZW_‌_NJ = 1; #ZW_‍_J = 1;;;;;;; + ;;;; + $() { + return this.#$; + } + _() { + return this.#_; + } + \u{6F}() { + return this.#\u{6F}; + } + ℘() { + return this.#℘; + } + ZW_‌_NJ() { + return this.#ZW_‌_NJ; + } + ZW_‍_J() { + return this.#ZW_‍_J; + } +} + +var c = new C(); + +assert.sameValue(c.$(), 1); +assert.sameValue(c._(), 1); +assert.sameValue(c.\u{6F}(), 1); +assert.sameValue(c.℘(), 1); +assert.sameValue(c.ZW_‌_NJ(), 1); +assert.sameValue(c.ZW_‍_J(), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-rs-privatename-identifier-initializer.js b/js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-rs-privatename-identifier-initializer.js new file mode 100644 index 0000000000..c8ca2df9b5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-rs-privatename-identifier-initializer.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-privatename-identifier-initializer.case +// - src/class-elements/productions/cls-decl-wrapped-in-sc.template +/*--- +description: Valid PrivateName (fields definition wrapped in semicolons) +esid: prod-FieldDefinition +features: [class-fields-private, class, class-fields-public] +flags: [generated] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + ;;;; + ;;;;;;#$ = 1; #_ = 1; #\u{6F} = 1; #\u2118 = 1; #ZW_\u200C_NJ = 1; #ZW_\u200D_J = 1;;;;;;; + ;;;; + $() { + return this.#$; + } + _() { + return this.#_; + } + \u{6F}() { + return this.#\u{6F}; + } + \u2118() { + return this.#\u2118; + } + ZW_\u200C_NJ() { + return this.#ZW_\u200C_NJ; + } + ZW_\u200D_J() { + return this.#ZW_\u200D_J; + } +} + +var c = new C(); + +assert.sameValue(c.$(), 1); +assert.sameValue(c._(), 1); +assert.sameValue(c.\u{6F}(), 1); +assert.sameValue(c.\u2118(), 1); +assert.sameValue(c.ZW_\u200C_NJ(), 1); +assert.sameValue(c.ZW_\u200D_J(), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-rs-privatename-identifier.js b/js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-rs-privatename-identifier.js new file mode 100644 index 0000000000..33698474f6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-rs-privatename-identifier.js @@ -0,0 +1,97 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-privatename-identifier.case +// - src/class-elements/productions/cls-decl-wrapped-in-sc.template +/*--- +description: Valid PrivateName (fields definition wrapped in semicolons) +esid: prod-FieldDefinition +features: [class-fields-private, class, class-fields-public] +flags: [generated] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + ;;;; + ;;;;;;#$; #_; #\u{6F}; #\u2118; #ZW_\u200C_NJ; #ZW_\u200D_J;;;;;;; + ;;;; + $(value) { + this.#$ = value; + return this.#$; + } + _(value) { + this.#_ = value; + return this.#_; + } + \u{6F}(value) { + this.#\u{6F} = value; + return this.#\u{6F}; + } + \u2118(value) { + this.#\u2118 = value; + return this.#\u2118; + } + ZW_\u200C_NJ(value) { + this.#ZW_\u200C_NJ = value; + return this.#ZW_\u200C_NJ; + } + ZW_\u200D_J(value) { + this.#ZW_\u200D_J = value; + return this.#ZW_\u200D_J; + } +} + +var c = new C(); + +assert.sameValue(c.$(1), 1); +assert.sameValue(c._(1), 1); +assert.sameValue(c.\u{6F}(1), 1); +assert.sameValue(c.\u2118(1), 1); +assert.sameValue(c.ZW_\u200C_NJ(1), 1); +assert.sameValue(c.ZW_\u200D_J(1), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-rs-static-async-generator-method-privatename-identifier-alt.js b/js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-rs-static-async-generator-method-privatename-identifier-alt.js new file mode 100644 index 0000000000..af07c42679 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-rs-static-async-generator-method-privatename-identifier-alt.js @@ -0,0 +1,122 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-async-generator-method-privatename-identifier-alt.case +// - src/class-elements/productions/cls-decl-wrapped-in-sc.template +/*--- +description: Valid Static AsyncGeneratorMethod PrivateName (fields definition wrapped in semicolons) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + AsyncGeneratorMethod + + AsyncGeneratorMethod : + async [no LineTerminator here] * ClassElementName ( UniqueFormalParameters){ AsyncGeneratorBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + ;;;; + ;;;;;;static async * #$(value) { + yield * await value; + } + static async * #_(value) { + yield * await value; + } + static async * #o(value) { + yield * await value; + } + static async * #℘(value) { + yield * await value; + } + static async * #ZW_‌_NJ(value) { + yield * await value; + } + static async * #ZW_‍_J(value) { + yield * await value; + };;;;;;; + ;;;; + static get $() { + return this.#$; + } + static get _() { + return this.#_; + } + static get o() { + return this.#o; + } + static get ℘() { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#℘; + } + static get ZW_‌_NJ() { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#ZW_‌_NJ; + } + static get ZW_‍_J() { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#ZW_‍_J; + } + +} + +var c = new C(); + +Promise.all([ + C.$([1]).next(), + C._([1]).next(), + C.o([1]).next(), + C.℘([1]).next(), // DO NOT CHANGE THE NAME OF THIS FIELD + C.ZW_‌_NJ([1]).next(), // DO NOT CHANGE THE NAME OF THIS FIELD + C.ZW_‍_J([1]).next(), // DO NOT CHANGE THE NAME OF THIS FIELD +]).then(results => { + + assert.sameValue(results[0].value, 1); + assert.sameValue(results[1].value, 1); + assert.sameValue(results[2].value, 1); + assert.sameValue(results[3].value, 1); + assert.sameValue(results[4].value, 1); + assert.sameValue(results[5].value, 1); + +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-rs-static-async-generator-method-privatename-identifier.js b/js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-rs-static-async-generator-method-privatename-identifier.js new file mode 100644 index 0000000000..f4b1e4b5e7 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-rs-static-async-generator-method-privatename-identifier.js @@ -0,0 +1,123 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-async-generator-method-privatename-identifier.case +// - src/class-elements/productions/cls-decl-wrapped-in-sc.template +/*--- +description: Valid Static AsyncGeneratorMethod PrivateName (fields definition wrapped in semicolons) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + AsyncGeneratorMethod + + AsyncGeneratorMethod : + async [no LineTerminator here] * ClassElementName ( UniqueFormalParameters){ AsyncGeneratorBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + ;;;; + ;;;;;;static async * #$(value) { + yield * await value; + } + static async * #_(value) { + yield * await value; + } + static async * #\u{6F}(value) { + yield * await value; + } + static async * #\u2118(value) { + yield * await value; + } + static async * #ZW_\u200C_NJ(value) { + yield * await value; + } + static async * #ZW_\u200D_J(value) { + yield * await value; + };;;;;;; + ;;;; + static get $() { + return this.#$; + } + static get _() { + return this.#_; + } + static get \u{6F}() { + return this.#\u{6F}; + } + static get \u2118() { + return this.#\u2118; + } + static get ZW_\u200C_NJ() { + return this.#ZW_\u200C_NJ; + } + static get ZW_\u200D_J() { + return this.#ZW_\u200D_J; + } + +} + +var c = new C(); + +Promise.all([ + C.$([1]).next(), + C._([1]).next(), + C.\u{6F}([1]).next(), + C.\u2118([1]).next(), + C.ZW_\u200C_NJ([1]).next(), + C.ZW_\u200D_J([1]).next(), +]).then(results => { + + assert.sameValue(results[0].value, 1); + assert.sameValue(results[1].value, 1); + assert.sameValue(results[2].value, 1); + assert.sameValue(results[3].value, 1); + assert.sameValue(results[4].value, 1); + assert.sameValue(results[5].value, 1); + +}).then($DONE, $DONE); + diff --git a/js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-rs-static-async-method-privatename-identifier-alt.js b/js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-rs-static-async-method-privatename-identifier-alt.js new file mode 100644 index 0000000000..71adbfab98 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-rs-static-async-method-privatename-identifier-alt.js @@ -0,0 +1,122 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-async-method-privatename-identifier-alt.case +// - src/class-elements/productions/cls-decl-wrapped-in-sc.template +/*--- +description: Valid Static AsyncMethod PrivateName (fields definition wrapped in semicolons) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + AsyncMethod + + AsyncMethod : + async [no LineTerminator here] ClassElementName ( UniqueFormalParameters ){ AsyncFunctionBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + ;;;; + ;;;;;;static async #$(value) { + return await value; + } + static async #_(value) { + return await value; + } + static async #o(value) { + return await value; + } + static async #℘(value) { + return await value; + } + static async #ZW_‌_NJ(value) { + return await value; + } + static async #ZW_‍_J(value) { + return await value; + };;;;;;; + ;;;; + static async $(value) { + return await this.#$(value); + } + static async _(value) { + return await this.#_(value); + } + static async o(value) { + return await this.#o(value); + } + static async ℘(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + return await this.#℘(value); + } + static async ZW_‌_NJ(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + return await this.#ZW_‌_NJ(value); + } + static async ZW_‍_J(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + return await this.#ZW_‍_J(value); + } + +} + +var c = new C(); + +Promise.all([ + C.$(1), + C._(1), + C.o(1), + C.℘(1), // DO NOT CHANGE THE NAME OF THIS FIELD + C.ZW_‌_NJ(1), // DO NOT CHANGE THE NAME OF THIS FIELD + C.ZW_‍_J(1), // DO NOT CHANGE THE NAME OF THIS FIELD +]).then(results => { + + assert.sameValue(results[0], 1); + assert.sameValue(results[1], 1); + assert.sameValue(results[2], 1); + assert.sameValue(results[3], 1); + assert.sameValue(results[4], 1); + assert.sameValue(results[5], 1); + +}).then($DONE, $DONE); diff --git a/js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-rs-static-async-method-privatename-identifier.js b/js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-rs-static-async-method-privatename-identifier.js new file mode 100644 index 0000000000..c8900b18e9 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-rs-static-async-method-privatename-identifier.js @@ -0,0 +1,123 @@ +// |reftest| async +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-async-method-privatename-identifier.case +// - src/class-elements/productions/cls-decl-wrapped-in-sc.template +/*--- +description: Valid Static AsyncMethod PrivateName (fields definition wrapped in semicolons) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public] +flags: [generated, async] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + AsyncMethod + + AsyncMethod : + async [no LineTerminator here] ClassElementName ( UniqueFormalParameters ){ AsyncFunctionBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + ;;;; + ;;;;;;static async #$(value) { + return await value; + } + static async #_(value) { + return await value; + } + static async #\u{6F}(value) { + return await value; + } + static async #\u2118(value) { + return await value; + } + static async #ZW_\u200C_NJ(value) { + return await value; + } + static async #ZW_\u200D_J(value) { + return await value; + };;;;;;; + ;;;; + static async $(value) { + return await this.#$(value); + } + static async _(value) { + return await this.#_(value); + } + static async \u{6F}(value) { + return await this.#\u{6F}(value); + } + static async \u2118(value) { + return await this.#\u2118(value); + } + static async ZW_\u200C_NJ(value) { + return await this.#ZW_\u200C_NJ(value); + } + static async ZW_\u200D_J(value) { + return await this.#ZW_\u200D_J(value); + } + +} + +var c = new C(); + +Promise.all([ + C.$(1), + C._(1), + C.\u{6F}(1), + C.\u2118(1), + C.ZW_\u200C_NJ(1), + C.ZW_\u200D_J(1), +]).then(results => { + + assert.sameValue(results[0], 1); + assert.sameValue(results[1], 1); + assert.sameValue(results[2], 1); + assert.sameValue(results[3], 1); + assert.sameValue(results[4], 1); + assert.sameValue(results[5], 1); + +}).then($DONE, $DONE); + diff --git a/js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-rs-static-generator-method-privatename-identifier-alt.js b/js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-rs-static-generator-method-privatename-identifier-alt.js new file mode 100644 index 0000000000..639550053b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-rs-static-generator-method-privatename-identifier-alt.js @@ -0,0 +1,112 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-generator-method-privatename-identifier-alt.case +// - src/class-elements/productions/cls-decl-wrapped-in-sc.template +/*--- +description: Valid Static GeneratorMethod PrivateName (fields definition wrapped in semicolons) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public] +flags: [generated] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + GeneratorMethod + + GeneratorMethod : + * ClassElementName ( UniqueFormalParameters ){ GeneratorBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + ;;;; + ;;;;;;static * #$(value) { + yield * value; + } + static * #_(value) { + yield * value; + } + static * #o(value) { + yield * value; + } + static * #℘(value) { + yield * value; + } + static * #ZW_‌_NJ(value) { + yield * value; + } + static * #ZW_‍_J(value) { + yield * value; + };;;;;;; + ;;;; + static get $() { + return this.#$; + } + static get _() { + return this.#_; + } + static get o() { + return this.#o; + } + static get ℘() { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#℘; + } + static get ZW_‌_NJ() { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#ZW_‌_NJ; + } + static get ZW_‍_J() { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#ZW_‍_J; + } + +} + +var c = new C(); + +assert.sameValue(C.$([1]).next().value, 1); +assert.sameValue(C._([1]).next().value, 1); +assert.sameValue(C.o([1]).next().value, 1); +assert.sameValue(C.℘([1]).next().value, 1); +assert.sameValue(C.ZW_‌_NJ([1]).next().value, 1); +assert.sameValue(C.ZW_‍_J([1]).next().value, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-rs-static-generator-method-privatename-identifier.js b/js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-rs-static-generator-method-privatename-identifier.js new file mode 100644 index 0000000000..d32b781a06 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-rs-static-generator-method-privatename-identifier.js @@ -0,0 +1,113 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-generator-method-privatename-identifier.case +// - src/class-elements/productions/cls-decl-wrapped-in-sc.template +/*--- +description: Valid Static GeneratorMethod PrivateName (fields definition wrapped in semicolons) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public] +flags: [generated] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + GeneratorMethod + + GeneratorMethod : + * ClassElementName ( UniqueFormalParameters ){ GeneratorBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + ;;;; + ;;;;;;static * #$(value) { + yield * value; + } + static * #_(value) { + yield * value; + } + static * #\u{6F}(value) { + yield * value; + } + static * #\u2118(value) { + yield * value; + } + static * #ZW_\u200C_NJ(value) { + yield * value; + } + static * #ZW_\u200D_J(value) { + yield * value; + };;;;;;; + ;;;; + static get $() { + return this.#$; + } + static get _() { + return this.#_; + } + static get \u{6F}() { + return this.#\u{6F}; + } + static get \u2118() { + return this.#\u2118; + } + static get ZW_\u200C_NJ() { + return this.#ZW_\u200C_NJ; + } + static get ZW_\u200D_J() { + return this.#ZW_\u200D_J; + } + +} + +var c = new C(); + +assert.sameValue(C.$([1]).next().value, 1); +assert.sameValue(C._([1]).next().value, 1); +assert.sameValue(C.\u{6F}([1]).next().value, 1); +assert.sameValue(C.\u2118([1]).next().value, 1); +assert.sameValue(C.ZW_\u200C_NJ([1]).next().value, 1); +assert.sameValue(C.ZW_\u200D_J([1]).next().value, 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-rs-static-method-privatename-identifier-alt.js b/js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-rs-static-method-privatename-identifier-alt.js new file mode 100644 index 0000000000..bf440f11f0 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-rs-static-method-privatename-identifier-alt.js @@ -0,0 +1,110 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-method-privatename-identifier-alt.case +// - src/class-elements/productions/cls-decl-wrapped-in-sc.template +/*--- +description: Valid Static Method PrivateName (fields definition wrapped in semicolons) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public] +flags: [generated] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + ClassElementName ( UniqueFormalParameters ){ FunctionBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + ;;;; + ;;;;;;static #$(value) { + return value; + } + static #_(value) { + return value; + } + static #o(value) { + return value; + } + static #℘(value) { + return value; + } + static #ZW_‌_NJ(value) { + return value; + } + static #ZW_‍_J(value) { + return value; + };;;;;;; + ;;;; + static $(value) { + return this.#$(value); + } + static _(value) { + return this.#_(value); + } + static o(value) { + return this.#o(value); + } + static ℘(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#℘(value); + } + static ZW_‌_NJ(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#ZW_‌_NJ(value); + } + static ZW_‍_J(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + return this.#ZW_‍_J(value); + } + +} + +var c = new C(); + +assert.sameValue(C.$(1), 1); +assert.sameValue(C._(1), 1); +assert.sameValue(C.o(1), 1); +assert.sameValue(C.℘(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD +assert.sameValue(C.ZW_‌_NJ(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD +assert.sameValue(C.ZW_‍_J(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-rs-static-method-privatename-identifier.js b/js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-rs-static-method-privatename-identifier.js new file mode 100644 index 0000000000..7e20ca05ea --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-rs-static-method-privatename-identifier.js @@ -0,0 +1,110 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-method-privatename-identifier.case +// - src/class-elements/productions/cls-decl-wrapped-in-sc.template +/*--- +description: Valid Static Method PrivateName (fields definition wrapped in semicolons) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public] +flags: [generated] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + MethodDefinition : + ClassElementName ( UniqueFormalParameters ){ FunctionBody } + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + ;;;; + ;;;;;;static #$(value) { + return value; + } + static #_(value) { + return value; + } + static #\u{6F}(value) { + return value; + } + static #\u2118(value) { + return value; + } + static #ZW_\u200C_NJ(value) { + return value; + } + static #ZW_\u200D_J(value) { + return value; + };;;;;;; + ;;;; + static $(value) { + return this.#$(value); + } + static _(value) { + return this.#_(value); + } + static \u{6F}(value) { + return this.#\u{6F}(value); + } + static \u2118(value) { + return this.#\u2118(value); + } + static ZW_\u200C_NJ(value) { + return this.#ZW_\u200C_NJ(value); + } + static ZW_\u200D_J(value) { + return this.#ZW_\u200D_J(value); + } + +} + +var c = new C(); + +assert.sameValue(C.$(1), 1); +assert.sameValue(C._(1), 1); +assert.sameValue(C.\u{6F}(1), 1); +assert.sameValue(C.\u2118(1), 1); +assert.sameValue(C.ZW_\u200C_NJ(1), 1); +assert.sameValue(C.ZW_\u200D_J(1), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-rs-static-privatename-identifier-alt-by-classname.js b/js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-rs-static-privatename-identifier-alt-by-classname.js new file mode 100644 index 0000000000..53c919ff36 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-rs-static-privatename-identifier-alt-by-classname.js @@ -0,0 +1,98 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-privatename-identifier-alt-by-classname.case +// - src/class-elements/productions/cls-decl-wrapped-in-sc.template +/*--- +description: Valid Static PrivateName (fields definition wrapped in semicolons) +esid: prod-FieldDefinition +features: [class-static-fields-private, class, class-fields-public] +flags: [generated] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + ;;;; + ;;;;;;static #$; static #_; static #\u{6F}; static #℘; static #ZW_‌_NJ; static #ZW_‍_J;;;;;;; + ;;;; + static $(value) { + C.#$ = value; + return C.#$; + } + static _(value) { + C.#_ = value; + return C.#_; + } + static o(value) { + C.#\u{6F} = value; + return C.#\u{6F}; + } + static ℘(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + C.#℘ = value; + return C.#℘; + } + static ZW_‌_NJ(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + C.#ZW_‌_NJ = value; + return C.#ZW_‌_NJ; + } + static ZW_‍_J(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + C.#ZW_‍_J = value; + return C.#ZW_‍_J; + } +} + +var c = new C(); + +assert.sameValue(C.$(1), 1); +assert.sameValue(C._(1), 1); +assert.sameValue(C.o(1), 1); +assert.sameValue(C.℘(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD +assert.sameValue(C.ZW_‌_NJ(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD +assert.sameValue(C.ZW_‍_J(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-rs-static-privatename-identifier-alt.js b/js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-rs-static-privatename-identifier-alt.js new file mode 100644 index 0000000000..c71bcea7df --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-rs-static-privatename-identifier-alt.js @@ -0,0 +1,98 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-privatename-identifier-alt.case +// - src/class-elements/productions/cls-decl-wrapped-in-sc.template +/*--- +description: Valid Static PrivateName (fields definition wrapped in semicolons) +esid: prod-FieldDefinition +features: [class-static-fields-private, class, class-fields-public] +flags: [generated] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + ;;;; + ;;;;;;static #$; static #_; static #\u{6F}; static #℘; static #ZW_‌_NJ; static #ZW_‍_J;;;;;;; + ;;;; + static $(value) { + this.#$ = value; + return this.#$; + } + static _(value) { + this.#_ = value; + return this.#_; + } + static o(value) { + this.#\u{6F} = value; + return this.#\u{6F}; + } + static ℘(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + this.#℘ = value; + return this.#℘; + } + static ZW_‌_NJ(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + this.#ZW_‌_NJ = value; + return this.#ZW_‌_NJ; + } + static ZW_‍_J(value) { // DO NOT CHANGE THE NAME OF THIS FIELD + this.#ZW_‍_J = value; + return this.#ZW_‍_J; + } +} + +var c = new C(); + +assert.sameValue(C.$(1), 1); +assert.sameValue(C._(1), 1); +assert.sameValue(C.o(1), 1); +assert.sameValue(C.℘(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD +assert.sameValue(C.ZW_‌_NJ(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD +assert.sameValue(C.ZW_‍_J(1), 1); // DO NOT CHANGE THE NAME OF THIS FIELD + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-rs-static-privatename-identifier-by-classname.js b/js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-rs-static-privatename-identifier-by-classname.js new file mode 100644 index 0000000000..88b4fa5341 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-rs-static-privatename-identifier-by-classname.js @@ -0,0 +1,98 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-privatename-identifier-by-classname.case +// - src/class-elements/productions/cls-decl-wrapped-in-sc.template +/*--- +description: Valid Static PrivateName (fields definition wrapped in semicolons) +esid: prod-FieldDefinition +features: [class-static-fields-private, class, class-fields-public] +flags: [generated] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + ;;;; + ;;;;;;static #$; static #_; static #\u{6F}; static #\u2118; static #ZW_\u200C_NJ; static #ZW_\u200D_J;;;;;;; + ;;;; + static $(value) { + C.#$ = value; + return C.#$; + } + static _(value) { + C.#_ = value; + return C.#_; + } + static \u{6F}(value) { + C.#\u{6F} = value; + return C.#\u{6F}; + } + static \u2118(value) { + C.#\u2118 = value; + return C.#\u2118; + } + static ZW_\u200C_NJ(value) { + C.#ZW_\u200C_NJ = value; + return C.#ZW_\u200C_NJ; + } + static ZW_\u200D_J(value) { + C.#ZW_\u200D_J = value; + return C.#ZW_\u200D_J; + } +} + +var c = new C(); + +assert.sameValue(C.$(1), 1); +assert.sameValue(C._(1), 1); +assert.sameValue(C.\u{6F}(1), 1); +assert.sameValue(C.\u2118(1), 1); +assert.sameValue(C.ZW_\u200C_NJ(1), 1); +assert.sameValue(C.ZW_\u200D_J(1), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-rs-static-privatename-identifier-initializer-alt-by-classname.js b/js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-rs-static-privatename-identifier-initializer-alt-by-classname.js new file mode 100644 index 0000000000..c05a55b679 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-rs-static-privatename-identifier-initializer-alt-by-classname.js @@ -0,0 +1,92 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-privatename-identifier-initializer-alt-by-classname.case +// - src/class-elements/productions/cls-decl-wrapped-in-sc.template +/*--- +description: Valid Static PrivateName (fields definition wrapped in semicolons) +esid: prod-FieldDefinition +features: [class-static-fields-private, class, class-fields-public] +flags: [generated] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + ;;;; + ;;;;;;static #$ = 1; static #_ = 1; static #\u{6F} = 1; static #℘ = 1; static #ZW_‌_NJ = 1; static #ZW_‍_J = 1;;;;;;; + ;;;; + static $() { + return C.#$; + } + static _() { + return C.#_; + } + static \u{6F}() { + return C.#\u{6F}; + } + static ℘() { + return C.#℘; + } + static ZW_‌_NJ() { + return C.#ZW_‌_NJ; + } + static ZW_‍_J() { + return C.#ZW_‍_J; + } +} + +var c = new C(); + +assert.sameValue(C.$(), 1); +assert.sameValue(C._(), 1); +assert.sameValue(C.\u{6F}(), 1); +assert.sameValue(C.℘(), 1); +assert.sameValue(C.ZW_‌_NJ(), 1); +assert.sameValue(C.ZW_‍_J(), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-rs-static-privatename-identifier-initializer-alt.js b/js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-rs-static-privatename-identifier-initializer-alt.js new file mode 100644 index 0000000000..ed638fd79a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-rs-static-privatename-identifier-initializer-alt.js @@ -0,0 +1,92 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-privatename-identifier-initializer-alt.case +// - src/class-elements/productions/cls-decl-wrapped-in-sc.template +/*--- +description: Valid Static PrivateName (fields definition wrapped in semicolons) +esid: prod-FieldDefinition +features: [class-static-fields-private, class, class-fields-public] +flags: [generated] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + ;;;; + ;;;;;;static #$ = 1; static #_ = 1; static #\u{6F} = 1; static #℘ = 1; static #ZW_‌_NJ = 1; static #ZW_‍_J = 1;;;;;;; + ;;;; + static $() { + return this.#$; + } + static _() { + return this.#_; + } + static \u{6F}() { + return this.#\u{6F}; + } + static ℘() { + return this.#℘; + } + static ZW_‌_NJ() { + return this.#ZW_‌_NJ; + } + static ZW_‍_J() { + return this.#ZW_‍_J; + } +} + +var c = new C(); + +assert.sameValue(C.$(), 1); +assert.sameValue(C._(), 1); +assert.sameValue(C.\u{6F}(), 1); +assert.sameValue(C.℘(), 1); +assert.sameValue(C.ZW_‌_NJ(), 1); +assert.sameValue(C.ZW_‍_J(), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-rs-static-privatename-identifier-initializer.js b/js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-rs-static-privatename-identifier-initializer.js new file mode 100644 index 0000000000..34b301ccfe --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-rs-static-privatename-identifier-initializer.js @@ -0,0 +1,92 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-privatename-identifier-initializer.case +// - src/class-elements/productions/cls-decl-wrapped-in-sc.template +/*--- +description: Valid Static PrivateName (fields definition wrapped in semicolons) +esid: prod-FieldDefinition +features: [class-static-fields-private, class, class-fields-public] +flags: [generated] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + ;;;; + ;;;;;;static #$ = 1; static #_ = 1; static #\u{6F} = 1; static #\u2118 = 1; static #ZW_\u200C_NJ = 1; static #ZW_\u200D_J = 1;;;;;;; + ;;;; + static $() { + return this.#$; + } + static _() { + return this.#_; + } + static \u{6F}() { + return this.#\u{6F}; + } + static \u2118() { + return this.#\u2118; + } + static ZW_\u200C_NJ() { + return this.#ZW_\u200C_NJ; + } + static ZW_\u200D_J() { + return this.#ZW_\u200D_J; + } +} + +var c = new C(); + +assert.sameValue(C.$(), 1); +assert.sameValue(C._(), 1); +assert.sameValue(C.\u{6F}(), 1); +assert.sameValue(C.\u2118(), 1); +assert.sameValue(C.ZW_\u200C_NJ(), 1); +assert.sameValue(C.ZW_\u200D_J(), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-rs-static-privatename-identifier.js b/js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-rs-static-privatename-identifier.js new file mode 100644 index 0000000000..92a8097f2c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-rs-static-privatename-identifier.js @@ -0,0 +1,98 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/rs-static-privatename-identifier.case +// - src/class-elements/productions/cls-decl-wrapped-in-sc.template +/*--- +description: Valid Static PrivateName (fields definition wrapped in semicolons) +esid: prod-FieldDefinition +features: [class-static-fields-private, class, class-fields-public] +flags: [generated] +info: | + ClassElement : + MethodDefinition + static MethodDefinition + FieldDefinition ; + static FieldDefinition ; + ; + + FieldDefinition : + ClassElementName Initializer _opt + + ClassElementName : + PropertyName + PrivateName + + PrivateName :: + # IdentifierName + + IdentifierName :: + IdentifierStart + IdentifierName IdentifierPart + + IdentifierStart :: + UnicodeIDStart + $ + _ + \ UnicodeEscapeSequence + + IdentifierPart:: + UnicodeIDContinue + $ + \ UnicodeEscapeSequence + + + UnicodeIDStart:: + any Unicode code point with the Unicode property "ID_Start" + + UnicodeIDContinue:: + any Unicode code point with the Unicode property "ID_Continue" + + + NOTE 3 + The sets of code points with Unicode properties "ID_Start" and + "ID_Continue" include, respectively, the code points with Unicode + properties "Other_ID_Start" and "Other_ID_Continue". + +---*/ + + +class C { + ;;;; + ;;;;;;static #$; static #_; static #\u{6F}; static #\u2118; static #ZW_\u200C_NJ; static #ZW_\u200D_J;;;;;;; + ;;;; + static $(value) { + this.#$ = value; + return this.#$; + } + static _(value) { + this.#_ = value; + return this.#_; + } + static \u{6F}(value) { + this.#\u{6F} = value; + return this.#\u{6F}; + } + static \u2118(value) { + this.#\u2118 = value; + return this.#\u2118; + } + static ZW_\u200C_NJ(value) { + this.#ZW_\u200C_NJ = value; + return this.#ZW_\u200C_NJ; + } + static ZW_\u200D_J(value) { + this.#ZW_\u200D_J = value; + return this.#ZW_\u200D_J; + } +} + +var c = new C(); + +assert.sameValue(C.$(1), 1); +assert.sameValue(C._(1), 1); +assert.sameValue(C.\u{6F}(1), 1); +assert.sameValue(C.\u2118(1), 1); +assert.sameValue(C.ZW_\u200C_NJ(1), 1); +assert.sameValue(C.ZW_\u200D_J(1), 1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-static-private-fields.js b/js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-static-private-fields.js new file mode 100644 index 0000000000..2c8f938c1c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-static-private-fields.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/static-private-fields.case +// - src/class-elements/productions/cls-decl-wrapped-in-sc.template +/*--- +description: static private fields (fields definition wrapped in semicolons) +esid: prod-FieldDefinition +features: [class-static-fields-private, class, class-fields-public] +flags: [generated] +info: | + ClassElement : + ... + static FieldDefinition ; + + FieldDefinition : + ClassElementName Initializer_opt + + ClassElementName : + PrivateName + + PrivateName : + # IdentifierName + +---*/ + + +class C { + ;;;; + ;;;;;;static #x; static #y;;;;;;; + ;;;; + static x() { + this.#x = 42; + return this.#x; + } + static y() { + this.#y = 43; + return this.#y; + } +} + +var c = new C(); + +// Test the private fields do not appear as properties before set to value +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#x"), "test 1"); +assert(!Object.prototype.hasOwnProperty.call(C, "#x"), "test 2"); +assert(!Object.prototype.hasOwnProperty.call(c, "#x"), "test 3"); + +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#y"), "test 4"); +assert(!Object.prototype.hasOwnProperty.call(C, "#y"), "test 5"); +assert(!Object.prototype.hasOwnProperty.call(c, "#y"), "test 6"); + +// Test if private fields can be sucessfully accessed and set to value +assert.sameValue(C.x(), 42, "test 7"); +assert.sameValue(C.y(), 43, "test 8"); + +// Test the private fields do not appear as properties before after set to value +assert(!Object.prototype.hasOwnProperty.call(C, "#x"), "test 9"); +assert(!Object.prototype.hasOwnProperty.call(C, "#y"), "test 10"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-static-private-methods-with-fields.js b/js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-static-private-methods-with-fields.js new file mode 100644 index 0000000000..366df0d7b8 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-static-private-methods-with-fields.js @@ -0,0 +1,76 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/static-private-methods-with-fields.case +// - src/class-elements/productions/cls-decl-wrapped-in-sc.template +/*--- +description: static private methods with fields (fields definition wrapped in semicolons) +esid: prod-FieldDefinition +features: [class-static-methods-private, class-static-fields-private, class, class-fields-public] +flags: [generated] +info: | + ClassElement : + ... + static FieldDefinition ; + + FieldDefinition : + ClassElementName Initializer_opt + + ClassElementName : + PrivateName + + PrivateName : + # IdentifierName + +---*/ + + +class C { + ;;;; + ;;;;;;static #xVal; static #yVal;;;;;;; + ;;;; + static #x(value) { + this.#xVal = value; + return this.#xVal; + } + static #y(value) { + this.#yVal = value; + return this.#yVal; + } + static x() { + return this.#x(42); + } + static y() { + return this.#y(43); + } +} + +var c = new C(); + +// Test the private methods do not appear as properties before set to value +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#x"), "test 1"); +assert(!Object.prototype.hasOwnProperty.call(C, "#x"), "test 2"); +assert(!Object.prototype.hasOwnProperty.call(c, "#x"), "test 3"); + +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#y"), "test 4"); +assert(!Object.prototype.hasOwnProperty.call(C, "#y"), "test 5"); +assert(!Object.prototype.hasOwnProperty.call(c, "#y"), "test 6"); + +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#xVal"), "test 7"); +assert(!Object.prototype.hasOwnProperty.call(C, "#xVal"), "test 8"); +assert(!Object.prototype.hasOwnProperty.call(c, "#xVal"), "test 9"); + +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#yVal"), "test 10"); +assert(!Object.prototype.hasOwnProperty.call(C, "#yVal"), "test 11"); +assert(!Object.prototype.hasOwnProperty.call(c, "#yVal"), "test 12"); + +// Test if private fields can be sucessfully accessed and set to value +assert.sameValue(C.x(), 42, "test 13"); +assert.sameValue(C.y(), 43, "test 14"); + +// Test the private fields do not appear as properties before after set to value +assert(!Object.prototype.hasOwnProperty.call(C, "#x"), "test 15"); +assert(!Object.prototype.hasOwnProperty.call(C, "#y"), "test 16"); + +assert(!Object.prototype.hasOwnProperty.call(C, "#xVal"), "test 17"); +assert(!Object.prototype.hasOwnProperty.call(C, "#yVal"), "test 18"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-static-private-methods.js b/js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-static-private-methods.js new file mode 100644 index 0000000000..e2276b3a20 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-static-private-methods.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/static-private-methods.case +// - src/class-elements/productions/cls-decl-wrapped-in-sc.template +/*--- +description: static private methods (fields definition wrapped in semicolons) +esid: prod-FieldDefinition +features: [class-static-methods-private, class, class-fields-public] +flags: [generated] +info: | + ClassElement : + ... + static FieldDefinition ; + + FieldDefinition : + ClassElementName Initializer_opt + + ClassElementName : + PrivateName + + PrivateName : + # IdentifierName + +---*/ + + +class C { + ;;;; + ;;;;;;;;;;;;; + ;;;; + static #x(value) { + return value / 2; + } + static #y(value) { + return value * 2; + } + static x() { + return this.#x(84); + } + static y() { + return this.#y(43); + } +} + +var c = new C(); + +// Test the private methods do not appear as properties before set to value +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#x"), "test 1"); +assert(!Object.prototype.hasOwnProperty.call(C, "#x"), "test 2"); +assert(!Object.prototype.hasOwnProperty.call(c, "#x"), "test 3"); + +assert(!Object.prototype.hasOwnProperty.call(C.prototype, "#y"), "test 4"); +assert(!Object.prototype.hasOwnProperty.call(C, "#y"), "test 5"); +assert(!Object.prototype.hasOwnProperty.call(c, "#y"), "test 6"); + +// Test if private fields can be sucessfully accessed and set to value +assert.sameValue(C.x(), 42, "test 7"); +assert.sameValue(C.y(), 86, "test 8"); + +// Test the private fields do not appear as properties before after set to value +assert(!Object.prototype.hasOwnProperty.call(C, "#x"), "test 9"); +assert(!Object.prototype.hasOwnProperty.call(C, "#y"), "test 10"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-string-literal-names.js b/js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-string-literal-names.js new file mode 100644 index 0000000000..adbc00ec7e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/wrapped-in-sc-string-literal-names.js @@ -0,0 +1,98 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/string-literal-names.case +// - src/class-elements/productions/cls-decl-wrapped-in-sc.template +/*--- +description: String literal names (fields definition wrapped in semicolons) +esid: prod-FieldDefinition +features: [class-fields-public, class] +flags: [generated] +includes: [propertyHelper.js] +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PropertyName + +---*/ + + +class C { + ;;;; + ;;;;;;'a'; "b"; 'c' = 39; + "d" = 42;;;;;;; + ;;;; + +} + +var c = new C(); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "a"), + "a does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "a"), + "a does not appear as an own property on C constructor" +); + +verifyProperty(c, "a", { + value: undefined, + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "b"), + "b does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "b"), + "b does not appear as an own property on C constructor" +); + +verifyProperty(c, "b", { + value: undefined, + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "c"), + "c does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "c"), + "c does not appear as an own property on C constructor" +); + +verifyProperty(c, "c", { + value: 39, + enumerable: true, + writable: true, + configurable: true +}); + +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "d"), + "d does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "d"), + "d does not appear as an own property on C constructor" +); + +verifyProperty(c, "d", { + value: 42, + enumerable: true, + writable: true, + configurable: true +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/gen-method-length-dflt.js b/js/src/tests/test262/language/statements/class/gen-method-length-dflt.js new file mode 100644 index 0000000000..d3e00887d4 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/gen-method-length-dflt.js @@ -0,0 +1,69 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.1.6 +description: > + Default parameters' effect on function length +info: | + Function length is counted by the non initialized parameters in the left. + + 9.2.4 FunctionInitialize (F, kind, ParameterList, Body, Scope) + + [...] + 2. Let len be the ExpectedArgumentCount of ParameterList. + 3. Perform ! DefinePropertyOrThrow(F, "length", PropertyDescriptor{[[Value]]: + len, [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true}). + [...] + + FormalsList : FormalParameter + + 1. If HasInitializer of FormalParameter is true return 0 + 2. Return 1. + + FormalsList : FormalsList , FormalParameter + + 1. Let count be the ExpectedArgumentCount of FormalsList. + 2. If HasInitializer of FormalsList is true or HasInitializer of + FormalParameter is true, return count. + 3. Return count+1. +features: [generators, default-parameters] +includes: [propertyHelper.js] +---*/ + +class C1 { *m(x = 42) {} } + +var m1 = C1.prototype.m; + +assert.sameValue(m1.length, 0, 'formalslist: x = 42'); +verifyNotEnumerable(m1, 'length'); +verifyNotWritable(m1, 'length'); +verifyConfigurable(m1, 'length'); + +class C2 { *m(x = 42, y) {} } + +var m2 = C2.prototype.m; + +assert.sameValue(m2.length, 0, 'formalslist: x = 42, y'); +verifyNotEnumerable(m2, 'length'); +verifyNotWritable(m2, 'length'); +verifyConfigurable(m2, 'length'); + +class C3 { *m(x, y = 42) {} } + +var m3 = C3.prototype.m; + +assert.sameValue(m3.length, 1, 'formalslist: x, y = 42'); +verifyNotEnumerable(m3, 'length'); +verifyNotWritable(m3, 'length'); +verifyConfigurable(m3, 'length'); + +class C4 { *m(x, y = 42, z) {} } + +var m4 = C4.prototype.m; + +assert.sameValue(m4.length, 1, 'formalslist: x, y = 42, z'); +verifyNotEnumerable(m4, 'length'); +verifyNotWritable(m4, 'length'); +verifyConfigurable(m4, 'length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/gen-method-param-dflt-yield.js b/js/src/tests/test262/language/statements/class/gen-method-param-dflt-yield.js new file mode 100644 index 0000000000..0cb2a793e5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/gen-method-param-dflt-yield.js @@ -0,0 +1,28 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-generator-function-definitions +es6id: 14.4 +description: > + YieldExpression cannot be used within the FormalParameters of a generator + function +info: | + GeneratorMethod[Yield]: + + * PropertyName[?Yield] ( StrictFormalParameters[Yield] ) { GeneratorBody } + + YieldExpression cannot be used within the FormalParameters of a generator + function because any expressions that are part of FormalParameters are + evaluated before the resulting generator object is in a resumable state. +features: [generators, default-parameters] +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +class C { + *g(x = yield) {} +} diff --git a/js/src/tests/test262/language/statements/class/gen-method-static/array-destructuring-param-strict-body.js b/js/src/tests/test262/language/statements/class/gen-method-static/array-destructuring-param-strict-body.js new file mode 100644 index 0000000000..22204bdbf1 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/gen-method-static/array-destructuring-param-strict-body.js @@ -0,0 +1,157 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/function-forms/array-destructuring-param-strict-body.case +// - src/function-forms/syntax/cls-decl-gen-meth-static.template +/*--- +description: ArrayBindingPattern and Use Strict Directive are not allowed to coexist for the same function. (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [rest-parameters, generators] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + + 13.3.3.4 Static Semantics: IsSimpleParameterList + + BindingElement : BindingPattern + + 1. Return false. + + 14.1.2 Static Semantics: Early Errors + + FunctionDeclaration : function BindingIdentifier ( FormalParameters ) { FunctionBody } + FunctionDeclaration : function ( FormalParameters ) { FunctionBody } + FunctionExpression : function BindingIdentifier ( FormalParameters ) { FunctionBody } + + - It is a Syntax Error if ContainsUseStrict of FunctionBody is true and + IsSimpleParameterList of FormalParameters is false. + + 14.2.1 Static Semantics: Early Errors + + ArrowFunction : ArrowParameters => ConciseBody + + - It is a Syntax Error if ContainsUseStrict of ConciseBody is true and + IsSimpleParameterList of ArrowParameters is false. + + 14.3.1 Static Semantics: Early Errors + + MethodDefinition : PropertyName ( UniqueFormalParameters ) { FunctionBody } + + - It is a Syntax Error if ContainsUseStrict of FunctionBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + MethodDefinition : set PropertyName ( PropertySetParameterList ) { FunctionBody } + + - It is a Syntax Error if ContainsUseStrict of FunctionBody is true and + IsSimpleParameterList of PropertySetParameterList is false. + + 14.4.1 Static Semantics: Early Errors + + GeneratorMethod : * PropertyName ( UniqueFormalParameters ) { GeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of GeneratorBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + GeneratorDeclaration : function * BindingIdentifier ( FormalParameters ) { GeneratorBody } + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + GeneratorExpression : function * BindingIdentifier ( FormalParameters ) { GeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of GeneratorBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + 14.5.1 Static Semantics: Early Errors + + AsyncGeneratorMethod : async * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncGeneratorBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + AsyncGeneratorDeclaration : async function * BindingIdentifier ( FormalParameters ) { AsyncGeneratorBody } + AsyncGeneratorDeclaration : async function * ( FormalParameters ) { AsyncGeneratorBody } + AsyncGeneratorExpression : async function * BindingIdentifier ( FormalParameters ) { AsyncGeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncGeneratorBody is true and + IsSimpleParameterList of FormalParameters is false. + + 14.7.1 Static Semantics: Early Errors + + AsyncMethod : async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncFunctionBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + AsyncFunctionDeclaration : async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody } + AsyncFunctionDeclaration : async function ( FormalParameters ) { AsyncFunctionBody } + AsyncFunctionExpression : async function ( FormalParameters ) { AsyncFunctionBody } + AsyncFunctionExpression : async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncFunctionBody is true and + IsSimpleParameterList of FormalParameters is false. + + 14.8.1 Static Semantics: Early Errors + + AsyncArrowFunction : CoverCallExpressionAndAsyncArrowHead => AsyncConciseBody + + - It is a Syntax Error if ContainsUseStrict of AsyncConciseBody is true and + IsSimpleParameterList of CoverCallExpressionAndAsyncArrowHead is false. + +---*/ +$DONOTEVALUATE(); + +class C { + static *method([element]) { + "use strict"; + } +} diff --git a/js/src/tests/test262/language/statements/class/gen-method-static/browser.js b/js/src/tests/test262/language/statements/class/gen-method-static/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/gen-method-static/dflt-params-abrupt.js b/js/src/tests/test262/language/statements/class/gen-method-static/dflt-params-abrupt.js new file mode 100644 index 0000000000..ec9286935c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/gen-method-static/dflt-params-abrupt.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-abrupt.case +// - src/function-forms/error/cls-decl-gen-meth-static.template +/*--- +description: Abrupt completion returned by evaluation of initializer (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [default-parameters, generators] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. + +---*/ + +var callCount = 0; +class C { + static *method(_ = (function() { throw new Test262Error(); }())) { + + callCount = callCount + 1; + } +} + +assert.throws(Test262Error, function() { + C.method(); +}); + +assert.sameValue(callCount, 0, 'method body not evaluated'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/gen-method-static/dflt-params-arg-val-not-undefined.js b/js/src/tests/test262/language/statements/class/gen-method-static/dflt-params-arg-val-not-undefined.js new file mode 100644 index 0000000000..2c7bfbc71f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/gen-method-static/dflt-params-arg-val-not-undefined.js @@ -0,0 +1,112 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-arg-val-not-undefined.case +// - src/function-forms/default/cls-decl-gen-meth-static.template +/*--- +description: Use of initializer when argument value is not `undefined` (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [default-parameters, generators] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + [...] + 23. Let iteratorRecord be Record {[[Iterator]]: + CreateListIterator(argumentsList), [[Done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + a. Perform ? IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + +---*/ +var obj = {}; +var falseCount = 0; +var stringCount = 0; +var nanCount = 0; +var zeroCount = 0; +var nullCount = 0; +var objCount = 0; + +var callCount = 0; +class C { + static *method(aFalse = falseCount +=1, aString = stringCount += 1, aNaN = nanCount += 1, a0 = zeroCount += 1, aNull = nullCount += 1, aObj = objCount +=1) { + assert.sameValue(aFalse, false); + assert.sameValue(aString, ''); + assert.sameValue(aNaN, NaN); + assert.sameValue(a0, 0); + assert.sameValue(aNull, null); + assert.sameValue(aObj, obj); + callCount = callCount + 1; + } +} + +C.method(false, '', NaN, 0, null, obj).next(); + +// Stores a reference `ref` for case evaluation +var ref = C.method; + +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +assert.sameValue(falseCount, 0, 'initializer not evaluated: false'); +assert.sameValue(stringCount, 0, 'initializer not evaluated: string'); +assert.sameValue(nanCount, 0, 'initializer not evaluated: NaN'); +assert.sameValue(zeroCount, 0, 'initializer not evaluated: 0'); +assert.sameValue(nullCount, 0, 'initializer not evaluated: null'); +assert.sameValue(objCount, 0, 'initializer not evaluated: object'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/gen-method-static/dflt-params-arg-val-undefined.js b/js/src/tests/test262/language/statements/class/gen-method-static/dflt-params-arg-val-undefined.js new file mode 100644 index 0000000000..403b8151bc --- /dev/null +++ b/js/src/tests/test262/language/statements/class/gen-method-static/dflt-params-arg-val-undefined.js @@ -0,0 +1,95 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-arg-val-undefined.case +// - src/function-forms/default/cls-decl-gen-meth-static.template +/*--- +description: Use of initializer when argument value is `undefined` (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [default-parameters, generators] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + [...] + 23. Let iteratorRecord be Record {[[Iterator]]: + CreateListIterator(argumentsList), [[Done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + a. Perform ? IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + +---*/ + +var callCount = 0; +class C { + static *method(fromLiteral = 23, fromExpr = 45, fromHole = 99) { + assert.sameValue(fromLiteral, 23); + assert.sameValue(fromExpr, 45); + assert.sameValue(fromHole, 99); + callCount = callCount + 1; + } +} + +C.method(undefined, void 0).next(); + +// Stores a reference `ref` for case evaluation +var ref = C.method; + +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/gen-method-static/dflt-params-duplicates.js b/js/src/tests/test262/language/statements/class/gen-method-static/dflt-params-duplicates.js new file mode 100644 index 0000000000..9346b39d9a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/gen-method-static/dflt-params-duplicates.js @@ -0,0 +1,86 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-duplicates.case +// - src/function-forms/syntax/cls-decl-gen-meth-static.template +/*--- +description: It is a Syntax Error if BoundNames of FormalParameters contains any duplicate elements. (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [default-parameters, generators] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + + 14.1.2 Static Semantics: Early Errors + + StrictFormalParameters : FormalParameters + + - It is a Syntax Error if BoundNames of FormalParameters contains any + duplicate elements. + + FormalParameters : FormalParameterList + + - It is a Syntax Error if IsSimpleParameterList of FormalParameterList is + false and BoundNames of FormalParameterList contains any duplicate + elements. + +---*/ +$DONOTEVALUATE(); + +class C { + static *method(x = 0, x) { + + } +} diff --git a/js/src/tests/test262/language/statements/class/gen-method-static/dflt-params-ref-later.js b/js/src/tests/test262/language/statements/class/gen-method-static/dflt-params-ref-later.js new file mode 100644 index 0000000000..e13e551a92 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/gen-method-static/dflt-params-ref-later.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-ref-later.case +// - src/function-forms/error/cls-decl-gen-meth-static.template +/*--- +description: Referencing a parameter that occurs later in the ParameterList (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [default-parameters, generators] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. + +---*/ +var x = 0; + +var callCount = 0; +class C { + static *method(x = y, y) { + + callCount = callCount + 1; + } +} + +assert.throws(ReferenceError, function() { + C.method(); +}); + +assert.sameValue(callCount, 0, 'method body not evaluated'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/gen-method-static/dflt-params-ref-prior.js b/js/src/tests/test262/language/statements/class/gen-method-static/dflt-params-ref-prior.js new file mode 100644 index 0000000000..b023781640 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/gen-method-static/dflt-params-ref-prior.js @@ -0,0 +1,92 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-ref-prior.case +// - src/function-forms/default/cls-decl-gen-meth-static.template +/*--- +description: Referencing a parameter that occurs earlier in the ParameterList (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [default-parameters, generators] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. + +---*/ +var x = 0; + +var callCount = 0; +class C { + static *method(x, y = x, z = y) { + assert.sameValue(x, 3, 'first argument value'); + assert.sameValue(y, 3, 'second argument value'); + assert.sameValue(z, 3, 'third argument value'); + callCount = callCount + 1; + } +} + +C.method(3).next(); + +// Stores a reference `ref` for case evaluation +var ref = C.method; + +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/gen-method-static/dflt-params-ref-self.js b/js/src/tests/test262/language/statements/class/gen-method-static/dflt-params-ref-self.js new file mode 100644 index 0000000000..0841078cde --- /dev/null +++ b/js/src/tests/test262/language/statements/class/gen-method-static/dflt-params-ref-self.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-ref-self.case +// - src/function-forms/error/cls-decl-gen-meth-static.template +/*--- +description: Referencing a parameter from within its own initializer (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [default-parameters, generators] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. + +---*/ +var x = 0; + +var callCount = 0; +class C { + static *method(x = x) { + + callCount = callCount + 1; + } +} + +assert.throws(ReferenceError, function() { + C.method(); +}); + +assert.sameValue(callCount, 0, 'method body not evaluated'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/gen-method-static/dflt-params-rest.js b/js/src/tests/test262/language/statements/class/gen-method-static/dflt-params-rest.js new file mode 100644 index 0000000000..8b0fb0dd3c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/gen-method-static/dflt-params-rest.js @@ -0,0 +1,90 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-rest.case +// - src/function-forms/syntax/cls-decl-gen-meth-static.template +/*--- +description: RestParameter does not support an initializer (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [default-parameters, generators] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + + 14.1 Function Definitions + + Syntax + + FunctionRestParameter[Yield] : + + BindingRestElement[?Yield] + + 13.3.3 Destructuring Binding Patterns + + Syntax + + BindingRestElement[Yield] : + + ...BindingIdentifier[?Yield] + ...BindingPattern[?Yield] + +---*/ +$DONOTEVALUATE(); + +class C { + static *method(...x = []) { + + } +} diff --git a/js/src/tests/test262/language/statements/class/gen-method-static/dflt-params-trailing-comma.js b/js/src/tests/test262/language/statements/class/gen-method-static/dflt-params-trailing-comma.js new file mode 100644 index 0000000000..d9f4fe5b57 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/gen-method-static/dflt-params-trailing-comma.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-trailing-comma.case +// - src/function-forms/default/cls-decl-gen-meth-static.template +/*--- +description: A trailing comma should not increase the respective length, using default parameters (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + + Trailing comma in the parameters list + + 14.1 Function Definitions + + FormalParameters[Yield, Await] : FormalParameterList[?Yield, ?Await] , +---*/ + +var callCount = 0; +class C { + static *method(a, b = 39,) { + assert.sameValue(a, 42); + assert.sameValue(b, 39); + callCount = callCount + 1; + } +} + +C.method(42, undefined, 1).next(); + +// Stores a reference `ref` for case evaluation +var ref = C.method; + +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +assert.sameValue(ref.length, 1, 'length is properly set'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/gen-method-static/forbidden-ext/b1/browser.js b/js/src/tests/test262/language/statements/class/gen-method-static/forbidden-ext/b1/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/gen-method-static/forbidden-ext/b1/cls-decl-gen-meth-static-forbidden-ext-direct-access-prop-arguments.js b/js/src/tests/test262/language/statements/class/gen-method-static/forbidden-ext/b1/cls-decl-gen-meth-static-forbidden-ext-direct-access-prop-arguments.js new file mode 100644 index 0000000000..6377a89f1b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/gen-method-static/forbidden-ext/b1/cls-decl-gen-meth-static-forbidden-ext-direct-access-prop-arguments.js @@ -0,0 +1,38 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/forbidden-ext-direct-access-prop-arguments.case +// - src/function-forms/forbidden-extensions/bullet-one/cls-decl-gen-meth-static.template +/*--- +description: Forbidden extension, f.arguments (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, generators] +flags: [generated, noStrict] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + + ECMAScript function objects defined using syntactic constructors in strict mode code must + not be created with own properties named "caller" or "arguments". Such own properties also + must not be created for function objects defined using an ArrowFunction, MethodDefinition, + GeneratorDeclaration, GeneratorExpression, AsyncGeneratorDeclaration, AsyncGeneratorExpression, + ClassDeclaration, ClassExpression, AsyncFunctionDeclaration, AsyncFunctionExpression, or + AsyncArrowFunction regardless of whether the definition is contained in strict mode code. + Built-in functions, strict functions created using the Function constructor, generator functions + created using the Generator constructor, async functions created using the AsyncFunction + constructor, and functions created using the bind method also must not be created with such own + properties. + +---*/ + +var callCount = 0; +class C { + static *method() { + assert.sameValue(this.method.hasOwnProperty("arguments"), false); + callCount++; + } +} + +C.method().next(); +assert.sameValue(callCount, 1, 'method body evaluated'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/gen-method-static/forbidden-ext/b1/cls-decl-gen-meth-static-forbidden-ext-direct-access-prop-caller.js b/js/src/tests/test262/language/statements/class/gen-method-static/forbidden-ext/b1/cls-decl-gen-meth-static-forbidden-ext-direct-access-prop-caller.js new file mode 100644 index 0000000000..1bbbb759e6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/gen-method-static/forbidden-ext/b1/cls-decl-gen-meth-static-forbidden-ext-direct-access-prop-caller.js @@ -0,0 +1,38 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/forbidden-ext-direct-access-prop-caller.case +// - src/function-forms/forbidden-extensions/bullet-one/cls-decl-gen-meth-static.template +/*--- +description: Forbidden extension, o.caller (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, generators] +flags: [generated, noStrict] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + + ECMAScript function objects defined using syntactic constructors in strict mode code must + not be created with own properties named "caller" or "arguments". Such own properties also + must not be created for function objects defined using an ArrowFunction, MethodDefinition, + GeneratorDeclaration, GeneratorExpression, AsyncGeneratorDeclaration, AsyncGeneratorExpression, + ClassDeclaration, ClassExpression, AsyncFunctionDeclaration, AsyncFunctionExpression, or + AsyncArrowFunction regardless of whether the definition is contained in strict mode code. + Built-in functions, strict functions created using the Function constructor, generator functions + created using the Generator constructor, async functions created using the AsyncFunction + constructor, and functions created using the bind method also must not be created with such own + properties. + +---*/ + +var callCount = 0; +class C { + static *method() { + assert.sameValue(this.method.hasOwnProperty("caller"), false); + callCount++; + } +} + +C.method().next(); +assert.sameValue(callCount, 1, 'method body evaluated'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/gen-method-static/forbidden-ext/b1/shell.js b/js/src/tests/test262/language/statements/class/gen-method-static/forbidden-ext/b1/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/gen-method-static/forbidden-ext/b2/browser.js b/js/src/tests/test262/language/statements/class/gen-method-static/forbidden-ext/b2/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/gen-method-static/forbidden-ext/b2/cls-decl-gen-meth-static-forbidden-ext-indirect-access-own-prop-caller-get.js b/js/src/tests/test262/language/statements/class/gen-method-static/forbidden-ext/b2/cls-decl-gen-meth-static-forbidden-ext-indirect-access-own-prop-caller-get.js new file mode 100644 index 0000000000..dbaa9c2c0a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/gen-method-static/forbidden-ext/b2/cls-decl-gen-meth-static-forbidden-ext-indirect-access-own-prop-caller-get.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/forbidden-ext-indirect-access-own-prop-caller-get.case +// - src/function-forms/forbidden-extensions/bullet-two/cls-decl-gen-meth-static.template +/*--- +description: Forbidden extension, o.caller (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, generators] +flags: [generated, noStrict] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + + If an implementation extends any function object with an own property named "caller" the value of + that property, as observed using [[Get]] or [[GetOwnProperty]], must not be a strict function + object. If it is an accessor property, the function that is the value of the property's [[Get]] + attribute must never return a strict function when called. + +---*/ +var CALLER_OWN_PROPERTY_DOES_NOT_EXIST = Symbol(); +function inner() { + // This property may exist, but is forbidden from having a value that is a strict function object + return inner.hasOwnProperty("caller") + ? inner.caller + : CALLER_OWN_PROPERTY_DOES_NOT_EXIST; +} + +var callCount = 0; +class C { + static *method() { + /* implicit strict */ + // This and the following conditional value is set in the test's .case file. + // For every test that has a "true" value here, there is a + // corresponding test that has a "false" value here. + // They are generated from two different case files, which use + let descriptor = Object.getOwnPropertyDescriptor(inner, "caller"); + if (descriptor && descriptor.configurable && true) { + Object.defineProperty(inner, "caller", {get(){return 1}}); + } + var result = inner(); + if (descriptor && descriptor.configurable && true) { + assert.sameValue(result, 1, 'If this test defined an own "caller" property on the inner function, then it should be accessible and should return the value it was set to.'); + } + + // "CALLER_OWN_PROPERTY_DOES_NOT_EXIST" is from + // forbidden-ext-indirect-access-prop-caller.case + // + // If the function object "inner" has an own property + // named "caller", then its value will be returned. + // + // If the function object "inner" DOES NOT have an + // own property named "caller", then the symbol + // CALLER_OWN_PROPERTY_DOES_NOT_EXIST will be returned. + if (result !== CALLER_OWN_PROPERTY_DOES_NOT_EXIST) { + assert.notSameValue(result, this.method); + } + callCount++; + } +} + +C.method().next(); + +assert.sameValue(callCount, 1, 'method body evaluated'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/gen-method-static/forbidden-ext/b2/cls-decl-gen-meth-static-forbidden-ext-indirect-access-own-prop-caller-value.js b/js/src/tests/test262/language/statements/class/gen-method-static/forbidden-ext/b2/cls-decl-gen-meth-static-forbidden-ext-indirect-access-own-prop-caller-value.js new file mode 100644 index 0000000000..10d70f4670 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/gen-method-static/forbidden-ext/b2/cls-decl-gen-meth-static-forbidden-ext-indirect-access-own-prop-caller-value.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/forbidden-ext-indirect-access-own-prop-caller-value.case +// - src/function-forms/forbidden-extensions/bullet-two/cls-decl-gen-meth-static.template +/*--- +description: Forbidden extension, o.caller (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, generators] +flags: [generated, noStrict] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + + If an implementation extends any function object with an own property named "caller" the value of + that property, as observed using [[Get]] or [[GetOwnProperty]], must not be a strict function + object. If it is an accessor property, the function that is the value of the property's [[Get]] + attribute must never return a strict function when called. + +---*/ +var CALLER_OWN_PROPERTY_DOES_NOT_EXIST = Symbol(); +function inner() { + // This property may exist, but is forbidden from having a value that is a strict function object + return inner.hasOwnProperty("caller") + ? inner.caller + : CALLER_OWN_PROPERTY_DOES_NOT_EXIST; +} + +var callCount = 0; +class C { + static *method() { + /* implicit strict */ + // This and the following conditional value is set in the test's .case file. + // For every test that has a "true" value here, there is a + // corresponding test that has a "false" value here. + // They are generated from two different case files, which use + let descriptor = Object.getOwnPropertyDescriptor(inner, "caller"); + if (descriptor && descriptor.configurable && true) { + Object.defineProperty(inner, "caller", {value: 1}); + } + var result = inner(); + if (descriptor && descriptor.configurable && true) { + assert.sameValue(result, 1, 'If this test defined an own "caller" property on the inner function, then it should be accessible and should return the value it was set to.'); + } + + // "CALLER_OWN_PROPERTY_DOES_NOT_EXIST" is from + // forbidden-ext-indirect-access-prop-caller.case + // + // If the function object "inner" has an own property + // named "caller", then its value will be returned. + // + // If the function object "inner" DOES NOT have an + // own property named "caller", then the symbol + // CALLER_OWN_PROPERTY_DOES_NOT_EXIST will be returned. + if (result !== CALLER_OWN_PROPERTY_DOES_NOT_EXIST) { + assert.notSameValue(result, this.method); + } + callCount++; + } +} + +C.method().next(); + +assert.sameValue(callCount, 1, 'method body evaluated'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/gen-method-static/forbidden-ext/b2/cls-decl-gen-meth-static-forbidden-ext-indirect-access-prop-caller.js b/js/src/tests/test262/language/statements/class/gen-method-static/forbidden-ext/b2/cls-decl-gen-meth-static-forbidden-ext-indirect-access-prop-caller.js new file mode 100644 index 0000000000..33a95f63b2 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/gen-method-static/forbidden-ext/b2/cls-decl-gen-meth-static-forbidden-ext-indirect-access-prop-caller.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/forbidden-ext-indirect-access-prop-caller.case +// - src/function-forms/forbidden-extensions/bullet-two/cls-decl-gen-meth-static.template +/*--- +description: Forbidden extension, o.caller (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class, generators] +flags: [generated, noStrict] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + + If an implementation extends any function object with an own property named "caller" the value of + that property, as observed using [[Get]] or [[GetOwnProperty]], must not be a strict function + object. If it is an accessor property, the function that is the value of the property's [[Get]] + attribute must never return a strict function when called. + +---*/ +var CALLER_OWN_PROPERTY_DOES_NOT_EXIST = Symbol(); +function inner() { + // This property may exist, but is forbidden from having a value that is a strict function object + return inner.hasOwnProperty("caller") + ? inner.caller + : CALLER_OWN_PROPERTY_DOES_NOT_EXIST; +} + +var callCount = 0; +class C { + static *method() { + /* implicit strict */ + // This and the following conditional value is set in the test's .case file. + // For every test that has a "true" value here, there is a + // corresponding test that has a "false" value here. + // They are generated from two different case files, which use + let descriptor = Object.getOwnPropertyDescriptor(inner, "caller"); + if (descriptor && descriptor.configurable && false) { + Object.defineProperty(inner, "caller", {}); + } + var result = inner(); + if (descriptor && descriptor.configurable && false) { + assert.sameValue(result, 1, 'If this test defined an own "caller" property on the inner function, then it should be accessible and should return the value it was set to.'); + } + + // "CALLER_OWN_PROPERTY_DOES_NOT_EXIST" is from + // forbidden-ext-indirect-access-prop-caller.case + // + // If the function object "inner" has an own property + // named "caller", then its value will be returned. + // + // If the function object "inner" DOES NOT have an + // own property named "caller", then the symbol + // CALLER_OWN_PROPERTY_DOES_NOT_EXIST will be returned. + if (result !== CALLER_OWN_PROPERTY_DOES_NOT_EXIST) { + assert.notSameValue(result, this.method); + } + callCount++; + } +} + +C.method().next(); + +assert.sameValue(callCount, 1, 'method body evaluated'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/gen-method-static/forbidden-ext/b2/shell.js b/js/src/tests/test262/language/statements/class/gen-method-static/forbidden-ext/b2/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/gen-method-static/forbidden-ext/browser.js b/js/src/tests/test262/language/statements/class/gen-method-static/forbidden-ext/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/gen-method-static/forbidden-ext/shell.js b/js/src/tests/test262/language/statements/class/gen-method-static/forbidden-ext/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/gen-method-static/object-destructuring-param-strict-body.js b/js/src/tests/test262/language/statements/class/gen-method-static/object-destructuring-param-strict-body.js new file mode 100644 index 0000000000..bf4ccd839e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/gen-method-static/object-destructuring-param-strict-body.js @@ -0,0 +1,157 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/function-forms/object-destructuring-param-strict-body.case +// - src/function-forms/syntax/cls-decl-gen-meth-static.template +/*--- +description: ObjectBindingPattern and Use Strict Directive are not allowed to coexist for the same function. (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [rest-parameters, generators] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + + 13.3.3.4 Static Semantics: IsSimpleParameterList + + BindingElement : BindingPattern + + 1. Return false. + + 14.1.2 Static Semantics: Early Errors + + FunctionDeclaration : function BindingIdentifier ( FormalParameters ) { FunctionBody } + FunctionDeclaration : function ( FormalParameters ) { FunctionBody } + FunctionExpression : function BindingIdentifier ( FormalParameters ) { FunctionBody } + + - It is a Syntax Error if ContainsUseStrict of FunctionBody is true and + IsSimpleParameterList of FormalParameters is false. + + 14.2.1 Static Semantics: Early Errors + + ArrowFunction : ArrowParameters => ConciseBody + + - It is a Syntax Error if ContainsUseStrict of ConciseBody is true and + IsSimpleParameterList of ArrowParameters is false. + + 14.3.1 Static Semantics: Early Errors + + MethodDefinition : PropertyName ( UniqueFormalParameters ) { FunctionBody } + + - It is a Syntax Error if ContainsUseStrict of FunctionBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + MethodDefinition : set PropertyName ( PropertySetParameterList ) { FunctionBody } + + - It is a Syntax Error if ContainsUseStrict of FunctionBody is true and + IsSimpleParameterList of PropertySetParameterList is false. + + 14.4.1 Static Semantics: Early Errors + + GeneratorMethod : * PropertyName ( UniqueFormalParameters ) { GeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of GeneratorBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + GeneratorDeclaration : function * BindingIdentifier ( FormalParameters ) { GeneratorBody } + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + GeneratorExpression : function * BindingIdentifier ( FormalParameters ) { GeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of GeneratorBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + 14.5.1 Static Semantics: Early Errors + + AsyncGeneratorMethod : async * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncGeneratorBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + AsyncGeneratorDeclaration : async function * BindingIdentifier ( FormalParameters ) { AsyncGeneratorBody } + AsyncGeneratorDeclaration : async function * ( FormalParameters ) { AsyncGeneratorBody } + AsyncGeneratorExpression : async function * BindingIdentifier ( FormalParameters ) { AsyncGeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncGeneratorBody is true and + IsSimpleParameterList of FormalParameters is false. + + 14.7.1 Static Semantics: Early Errors + + AsyncMethod : async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncFunctionBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + AsyncFunctionDeclaration : async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody } + AsyncFunctionDeclaration : async function ( FormalParameters ) { AsyncFunctionBody } + AsyncFunctionExpression : async function ( FormalParameters ) { AsyncFunctionBody } + AsyncFunctionExpression : async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncFunctionBody is true and + IsSimpleParameterList of FormalParameters is false. + + 14.8.1 Static Semantics: Early Errors + + AsyncArrowFunction : CoverCallExpressionAndAsyncArrowHead => AsyncConciseBody + + - It is a Syntax Error if ContainsUseStrict of AsyncConciseBody is true and + IsSimpleParameterList of CoverCallExpressionAndAsyncArrowHead is false. + +---*/ +$DONOTEVALUATE(); + +class C { + static *method({property}) { + "use strict"; + } +} diff --git a/js/src/tests/test262/language/statements/class/gen-method-static/params-trailing-comma-multiple.js b/js/src/tests/test262/language/statements/class/gen-method-static/params-trailing-comma-multiple.js new file mode 100644 index 0000000000..58ab67fc29 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/gen-method-static/params-trailing-comma-multiple.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/params-trailing-comma-multiple.case +// - src/function-forms/default/cls-decl-gen-meth-static.template +/*--- +description: A trailing comma should not increase the respective length, using multiple parameters (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + + Trailing comma in the parameters list + + 14.1 Function Definitions + + FormalParameters[Yield, Await] : FormalParameterList[?Yield, ?Await] , +---*/ + +var callCount = 0; +class C { + static *method(a, b,) { + assert.sameValue(a, 42); + assert.sameValue(b, 39); + callCount = callCount + 1; + } +} + +C.method(42, 39, 1).next(); + +// Stores a reference `ref` for case evaluation +var ref = C.method; + +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +assert.sameValue(ref.length, 2, 'length is properly set'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/gen-method-static/params-trailing-comma-single.js b/js/src/tests/test262/language/statements/class/gen-method-static/params-trailing-comma-single.js new file mode 100644 index 0000000000..f638c61197 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/gen-method-static/params-trailing-comma-single.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/params-trailing-comma-single.case +// - src/function-forms/default/cls-decl-gen-meth-static.template +/*--- +description: A trailing comma should not increase the respective length, using a single parameter (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + + Trailing comma in the parameters list + + 14.1 Function Definitions + + FormalParameters[Yield, Await] : FormalParameterList[?Yield, ?Await] , +---*/ + +var callCount = 0; +class C { + static *method(a,) { + assert.sameValue(a, 42); + callCount = callCount + 1; + } +} + +C.method(42, 39).next(); + +// Stores a reference `ref` for case evaluation +var ref = C.method; + +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +assert.sameValue(ref.length, 1, 'length is properly set'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/gen-method-static/rest-param-strict-body.js b/js/src/tests/test262/language/statements/class/gen-method-static/rest-param-strict-body.js new file mode 100644 index 0000000000..4ab6f6d7f9 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/gen-method-static/rest-param-strict-body.js @@ -0,0 +1,157 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/function-forms/rest-param-strict-body.case +// - src/function-forms/syntax/cls-decl-gen-meth-static.template +/*--- +description: RestParameter and Use Strict Directive are not allowed to coexist for the same function. (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [rest-parameters, generators] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + + 14.1.13 Static Semantics: IsSimpleParameterList + + FormalParameters : FormalParameterList , FunctionRestParameter + + 1. Return false. + + 14.1.2 Static Semantics: Early Errors + + FunctionDeclaration : function BindingIdentifier ( FormalParameters ) { FunctionBody } + FunctionDeclaration : function ( FormalParameters ) { FunctionBody } + FunctionExpression : function BindingIdentifier ( FormalParameters ) { FunctionBody } + + - It is a Syntax Error if ContainsUseStrict of FunctionBody is true and + IsSimpleParameterList of FormalParameters is false. + + 14.2.1 Static Semantics: Early Errors + + ArrowFunction : ArrowParameters => ConciseBody + + - It is a Syntax Error if ContainsUseStrict of ConciseBody is true and + IsSimpleParameterList of ArrowParameters is false. + + 14.3.1 Static Semantics: Early Errors + + MethodDefinition : PropertyName ( UniqueFormalParameters ) { FunctionBody } + + - It is a Syntax Error if ContainsUseStrict of FunctionBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + MethodDefinition : set PropertyName ( PropertySetParameterList ) { FunctionBody } + + - It is a Syntax Error if ContainsUseStrict of FunctionBody is true and + IsSimpleParameterList of PropertySetParameterList is false. + + 14.4.1 Static Semantics: Early Errors + + GeneratorMethod : * PropertyName ( UniqueFormalParameters ) { GeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of GeneratorBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + GeneratorDeclaration : function * BindingIdentifier ( FormalParameters ) { GeneratorBody } + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + GeneratorExpression : function * BindingIdentifier ( FormalParameters ) { GeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of GeneratorBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + 14.5.1 Static Semantics: Early Errors + + AsyncGeneratorMethod : async * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncGeneratorBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + AsyncGeneratorDeclaration : async function * BindingIdentifier ( FormalParameters ) { AsyncGeneratorBody } + AsyncGeneratorDeclaration : async function * ( FormalParameters ) { AsyncGeneratorBody } + AsyncGeneratorExpression : async function * BindingIdentifier ( FormalParameters ) { AsyncGeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncGeneratorBody is true and + IsSimpleParameterList of FormalParameters is false. + + 14.7.1 Static Semantics: Early Errors + + AsyncMethod : async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncFunctionBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + AsyncFunctionDeclaration : async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody } + AsyncFunctionDeclaration : async function ( FormalParameters ) { AsyncFunctionBody } + AsyncFunctionExpression : async function ( FormalParameters ) { AsyncFunctionBody } + AsyncFunctionExpression : async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncFunctionBody is true and + IsSimpleParameterList of FormalParameters is false. + + 14.8.1 Static Semantics: Early Errors + + AsyncArrowFunction : CoverCallExpressionAndAsyncArrowHead => AsyncConciseBody + + - It is a Syntax Error if ContainsUseStrict of AsyncConciseBody is true and + IsSimpleParameterList of CoverCallExpressionAndAsyncArrowHead is false. + +---*/ +$DONOTEVALUATE(); + +class C { + static *method(a,...rest) { + "use strict"; + } +} diff --git a/js/src/tests/test262/language/statements/class/gen-method-static/rest-params-trailing-comma-early-error.js b/js/src/tests/test262/language/statements/class/gen-method-static/rest-params-trailing-comma-early-error.js new file mode 100644 index 0000000000..f3ee1689c8 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/gen-method-static/rest-params-trailing-comma-early-error.js @@ -0,0 +1,83 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/function-forms/rest-params-trailing-comma-early-error.case +// - src/function-forms/syntax/cls-decl-gen-meth-static.template +/*--- +description: It's a syntax error if a FunctionRestParameter is followed by a trailing comma (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [generators] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + + Trailing comma in the parameters list + + 14.1 Function Definitions + + FormalParameters[Yield, Await] : + [empty] + FunctionRestParameter[?Yield, ?Await] + FormalParameterList[?Yield, ?Await] + FormalParameterList[?Yield, ?Await] , + FormalParameterList[?Yield, ?Await] , FunctionRestParameter[?Yield, ?Await] +---*/ +$DONOTEVALUATE(); + +class C { + static *method(...a,) { + + } +} diff --git a/js/src/tests/test262/language/statements/class/gen-method-static/shell.js b/js/src/tests/test262/language/statements/class/gen-method-static/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/gen-method-static/yield-as-binding-identifier-escaped.js b/js/src/tests/test262/language/statements/class/gen-method-static/yield-as-binding-identifier-escaped.js new file mode 100644 index 0000000000..674410fd55 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/gen-method-static/yield-as-binding-identifier-escaped.js @@ -0,0 +1,36 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/generators/yield-as-binding-identifier-escaped.case +// - src/generators/syntax/class-decl-static-method.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as a binding identifier. (Static generator method as a ClassDeclaration element) +esid: prod-GeneratorMethod +features: [generators] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + GeneratorMethod + + 14.4 Generator Function Definitions + + GeneratorMethod : + * PropertyName ( UniqueFormalParameters ) { GeneratorBody } + + + BindingIdentifier : Identifier + + It is a Syntax Error if this production has a [Yield] parameter and + StringValue of Identifier is "yield". + +---*/ +$DONOTEVALUATE(); + +class C {static *gen() { + var yi\u0065ld; +}} diff --git a/js/src/tests/test262/language/statements/class/gen-method-static/yield-as-binding-identifier.js b/js/src/tests/test262/language/statements/class/gen-method-static/yield-as-binding-identifier.js new file mode 100644 index 0000000000..14060c146c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/gen-method-static/yield-as-binding-identifier.js @@ -0,0 +1,36 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/generators/yield-as-binding-identifier.case +// - src/generators/syntax/class-decl-static-method.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as a binding identifier. (Static generator method as a ClassDeclaration element) +esid: prod-GeneratorMethod +features: [generators] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + GeneratorMethod + + 14.4 Generator Function Definitions + + GeneratorMethod : + * PropertyName ( UniqueFormalParameters ) { GeneratorBody } + + + BindingIdentifier : Identifier + + It is a Syntax Error if this production has a [Yield] parameter and + StringValue of Identifier is "yield". + +---*/ +$DONOTEVALUATE(); + +class C {static *gen() { + var yield; +}} diff --git a/js/src/tests/test262/language/statements/class/gen-method-static/yield-as-identifier-reference-escaped.js b/js/src/tests/test262/language/statements/class/gen-method-static/yield-as-identifier-reference-escaped.js new file mode 100644 index 0000000000..0033f06424 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/gen-method-static/yield-as-identifier-reference-escaped.js @@ -0,0 +1,36 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/generators/yield-as-identifier-reference-escaped.case +// - src/generators/syntax/class-decl-static-method.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as an identifier reference. (Static generator method as a ClassDeclaration element) +esid: prod-GeneratorMethod +features: [generators] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + GeneratorMethod + + 14.4 Generator Function Definitions + + GeneratorMethod : + * PropertyName ( UniqueFormalParameters ) { GeneratorBody } + + + IdentifierReference : Identifier + + It is a Syntax Error if this production has a [Yield] parameter and + StringValue of Identifier is "yield". + +---*/ +$DONOTEVALUATE(); + +class C {static *gen() { + void yi\u0065ld; +}} diff --git a/js/src/tests/test262/language/statements/class/gen-method-static/yield-as-identifier-reference.js b/js/src/tests/test262/language/statements/class/gen-method-static/yield-as-identifier-reference.js new file mode 100644 index 0000000000..dbc38e6a7f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/gen-method-static/yield-as-identifier-reference.js @@ -0,0 +1,36 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/generators/yield-as-identifier-reference.case +// - src/generators/syntax/class-decl-static-method.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as an identifier reference. (Static generator method as a ClassDeclaration element) +esid: prod-GeneratorMethod +features: [generators] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + GeneratorMethod + + 14.4 Generator Function Definitions + + GeneratorMethod : + * PropertyName ( UniqueFormalParameters ) { GeneratorBody } + + + IdentifierReference : Identifier + + It is a Syntax Error if this production has a [Yield] parameter and + StringValue of Identifier is "yield". + +---*/ +$DONOTEVALUATE(); + +class C {static *gen() { + void yield; +}} diff --git a/js/src/tests/test262/language/statements/class/gen-method-static/yield-as-label-identifier-escaped.js b/js/src/tests/test262/language/statements/class/gen-method-static/yield-as-label-identifier-escaped.js new file mode 100644 index 0000000000..9ee1269a64 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/gen-method-static/yield-as-label-identifier-escaped.js @@ -0,0 +1,36 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/generators/yield-as-label-identifier-escaped.case +// - src/generators/syntax/class-decl-static-method.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as a label identifier. (Static generator method as a ClassDeclaration element) +esid: prod-GeneratorMethod +features: [generators] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + GeneratorMethod + + 14.4 Generator Function Definitions + + GeneratorMethod : + * PropertyName ( UniqueFormalParameters ) { GeneratorBody } + + + LabelIdentifier : Identifier + + It is a Syntax Error if this production has a [Yield] parameter and + StringValue of Identifier is "yield". + +---*/ +$DONOTEVALUATE(); + +class C {static *gen() { + yi\u0065ld: ; +}} diff --git a/js/src/tests/test262/language/statements/class/gen-method-static/yield-as-label-identifier.js b/js/src/tests/test262/language/statements/class/gen-method-static/yield-as-label-identifier.js new file mode 100644 index 0000000000..3e58703d96 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/gen-method-static/yield-as-label-identifier.js @@ -0,0 +1,36 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/generators/yield-as-label-identifier.case +// - src/generators/syntax/class-decl-static-method.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as a label identifier. (Static generator method as a ClassDeclaration element) +esid: prod-GeneratorMethod +features: [generators] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + GeneratorMethod + + 14.4 Generator Function Definitions + + GeneratorMethod : + * PropertyName ( UniqueFormalParameters ) { GeneratorBody } + + + LabelIdentifier : Identifier + + It is a Syntax Error if this production has a [Yield] parameter and + StringValue of Identifier is "yield". + +---*/ +$DONOTEVALUATE(); + +class C {static *gen() { + yield: ; +}} diff --git a/js/src/tests/test262/language/statements/class/gen-method-static/yield-identifier-spread-strict-strict.js b/js/src/tests/test262/language/statements/class/gen-method-static/yield-identifier-spread-strict-strict.js new file mode 100644 index 0000000000..844d21c890 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/gen-method-static/yield-identifier-spread-strict-strict.js @@ -0,0 +1,54 @@ +// |reftest| error:SyntaxError +'use strict'; +// This file was procedurally generated from the following sources: +// - src/generators/yield-identifier-spread-strict.case +// - src/generators/default/class-decl-static-method.template +/*--- +description: It's an early error if the AssignmentExpression is a function body with yield as an identifier in strict mode. (Static generator method as a ClassDeclaration element) +esid: prod-GeneratorMethod +features: [object-spread, generators] +flags: [generated, onlyStrict] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + GeneratorMethod + + 14.4 Generator Function Definitions + + GeneratorMethod : + * PropertyName ( UniqueFormalParameters ) { GeneratorBody } + + + Spread Properties + + PropertyDefinition[Yield]: + (...) + ...AssignmentExpression[In, ?Yield] + +---*/ +$DONOTEVALUATE(); + +var callCount = 0; + +class C {static *gen() { + callCount += 1; + return { + ...(function() { + var yield; + throw new Test262Error(); + }()), + } +}} + +var gen = C.gen; + +var iter = gen(); + + + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/gen-method-static/yield-identifier-strict-strict.js b/js/src/tests/test262/language/statements/class/gen-method-static/yield-identifier-strict-strict.js new file mode 100644 index 0000000000..280fc5bb56 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/gen-method-static/yield-identifier-strict-strict.js @@ -0,0 +1,45 @@ +// |reftest| error:SyntaxError +'use strict'; +// This file was procedurally generated from the following sources: +// - src/generators/yield-identifier-strict.case +// - src/generators/default/class-decl-static-method.template +/*--- +description: It's an early error if the generator body has another function body with yield as an identifier in strict mode. (Static generator method as a ClassDeclaration element) +esid: prod-GeneratorMethod +features: [generators] +flags: [generated, onlyStrict] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + GeneratorMethod + + 14.4 Generator Function Definitions + + GeneratorMethod : + * PropertyName ( UniqueFormalParameters ) { GeneratorBody } + +---*/ +$DONOTEVALUATE(); + +var callCount = 0; + +class C {static *gen() { + callCount += 1; + (function() { + var yield; + throw new Test262Error(); + }()) +}} + +var gen = C.gen; + +var iter = gen(); + + + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/gen-method-static/yield-spread-arr-multiple.js b/js/src/tests/test262/language/statements/class/gen-method-static/yield-spread-arr-multiple.js new file mode 100644 index 0000000000..c5e27efa20 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/gen-method-static/yield-spread-arr-multiple.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/generators/yield-spread-arr-multiple.case +// - src/generators/default/class-decl-static-method.template +/*--- +description: Use yield value in a array spread position (Static generator method as a ClassDeclaration element) +esid: prod-GeneratorMethod +features: [generators] +flags: [generated] +includes: [compareArray.js] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + GeneratorMethod + + 14.4 Generator Function Definitions + + GeneratorMethod : + * PropertyName ( UniqueFormalParameters ) { GeneratorBody } + + + Array Initializer + + SpreadElement[Yield, Await]: + ...AssignmentExpression[+In, ?Yield, ?Await] + +---*/ +var arr = ['a', 'b', 'c']; +var item; + +var callCount = 0; + +class C {static *gen() { + callCount += 1; + yield [...yield yield]; +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next(false); +item = iter.next(['a', 'b', 'c']); +item = iter.next(item.value); + +assert.compareArray(item.value, arr); +assert.sameValue(item.done, false); + +assert.sameValue(callCount, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/gen-method-static/yield-spread-arr-single.js b/js/src/tests/test262/language/statements/class/gen-method-static/yield-spread-arr-single.js new file mode 100644 index 0000000000..08baa75ed6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/gen-method-static/yield-spread-arr-single.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/generators/yield-spread-arr-single.case +// - src/generators/default/class-decl-static-method.template +/*--- +description: Use yield value in a array spread position (Static generator method as a ClassDeclaration element) +esid: prod-GeneratorMethod +features: [generators] +flags: [generated] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + GeneratorMethod + + 14.4 Generator Function Definitions + + GeneratorMethod : + * PropertyName ( UniqueFormalParameters ) { GeneratorBody } + + + Array Initializer + + SpreadElement[Yield, Await]: + ...AssignmentExpression[+In, ?Yield, ?Await] +---*/ +var arr = ['a', 'b', 'c']; + +var callCount = 0; + +class C {static *gen() { + callCount += 1; + yield [...yield]; +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next(false); +var item = iter.next(arr); +var value = item.value; + +assert.notSameValue(value, arr, 'value is a new array'); +assert(Array.isArray(value), 'value is an Array exotic object'); +assert.sameValue(value.length, 3) +assert.sameValue(value[0], 'a'); +assert.sameValue(value[1], 'b'); +assert.sameValue(value[2], 'c'); +assert.sameValue(item.done, false); + +assert.sameValue(callCount, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/gen-method-static/yield-spread-obj.js b/js/src/tests/test262/language/statements/class/gen-method-static/yield-spread-obj.js new file mode 100644 index 0000000000..429f35eb9c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/gen-method-static/yield-spread-obj.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/generators/yield-spread-obj.case +// - src/generators/default/class-decl-static-method.template +/*--- +description: Use yield value in a object spread position (Static generator method as a ClassDeclaration element) +esid: prod-GeneratorMethod +features: [object-spread, generators] +flags: [generated] +info: | + ClassElement : + static MethodDefinition + + MethodDefinition : + GeneratorMethod + + 14.4 Generator Function Definitions + + GeneratorMethod : + * PropertyName ( UniqueFormalParameters ) { GeneratorBody } + + + Spread Properties + + PropertyDefinition[Yield]: + (...) + ...AssignmentExpression[In, ?Yield] + +---*/ + +var callCount = 0; + +class C {static *gen() { + callCount += 1; + yield { + ...yield, + y: 1, + ...yield yield, + }; +}} + +var gen = C.gen; + +var iter = gen(); + +iter.next(); +iter.next({ x: 42 }); +iter.next({ x: 'lol' }); +var item = iter.next({ y: 39 }); + +assert.sameValue(item.value.x, 42); +assert.sameValue(item.value.y, 39); +assert.sameValue(Object.keys(item.value).length, 2); +assert.sameValue(item.done, false); + +assert.sameValue(callCount, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/gen-method/array-destructuring-param-strict-body.js b/js/src/tests/test262/language/statements/class/gen-method/array-destructuring-param-strict-body.js new file mode 100644 index 0000000000..e6d0cf99a6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/gen-method/array-destructuring-param-strict-body.js @@ -0,0 +1,157 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/function-forms/array-destructuring-param-strict-body.case +// - src/function-forms/syntax/cls-decl-gen-meth.template +/*--- +description: ArrayBindingPattern and Use Strict Directive are not allowed to coexist for the same function. (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [rest-parameters, generators] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + + 13.3.3.4 Static Semantics: IsSimpleParameterList + + BindingElement : BindingPattern + + 1. Return false. + + 14.1.2 Static Semantics: Early Errors + + FunctionDeclaration : function BindingIdentifier ( FormalParameters ) { FunctionBody } + FunctionDeclaration : function ( FormalParameters ) { FunctionBody } + FunctionExpression : function BindingIdentifier ( FormalParameters ) { FunctionBody } + + - It is a Syntax Error if ContainsUseStrict of FunctionBody is true and + IsSimpleParameterList of FormalParameters is false. + + 14.2.1 Static Semantics: Early Errors + + ArrowFunction : ArrowParameters => ConciseBody + + - It is a Syntax Error if ContainsUseStrict of ConciseBody is true and + IsSimpleParameterList of ArrowParameters is false. + + 14.3.1 Static Semantics: Early Errors + + MethodDefinition : PropertyName ( UniqueFormalParameters ) { FunctionBody } + + - It is a Syntax Error if ContainsUseStrict of FunctionBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + MethodDefinition : set PropertyName ( PropertySetParameterList ) { FunctionBody } + + - It is a Syntax Error if ContainsUseStrict of FunctionBody is true and + IsSimpleParameterList of PropertySetParameterList is false. + + 14.4.1 Static Semantics: Early Errors + + GeneratorMethod : * PropertyName ( UniqueFormalParameters ) { GeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of GeneratorBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + GeneratorDeclaration : function * BindingIdentifier ( FormalParameters ) { GeneratorBody } + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + GeneratorExpression : function * BindingIdentifier ( FormalParameters ) { GeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of GeneratorBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + 14.5.1 Static Semantics: Early Errors + + AsyncGeneratorMethod : async * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncGeneratorBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + AsyncGeneratorDeclaration : async function * BindingIdentifier ( FormalParameters ) { AsyncGeneratorBody } + AsyncGeneratorDeclaration : async function * ( FormalParameters ) { AsyncGeneratorBody } + AsyncGeneratorExpression : async function * BindingIdentifier ( FormalParameters ) { AsyncGeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncGeneratorBody is true and + IsSimpleParameterList of FormalParameters is false. + + 14.7.1 Static Semantics: Early Errors + + AsyncMethod : async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncFunctionBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + AsyncFunctionDeclaration : async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody } + AsyncFunctionDeclaration : async function ( FormalParameters ) { AsyncFunctionBody } + AsyncFunctionExpression : async function ( FormalParameters ) { AsyncFunctionBody } + AsyncFunctionExpression : async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncFunctionBody is true and + IsSimpleParameterList of FormalParameters is false. + + 14.8.1 Static Semantics: Early Errors + + AsyncArrowFunction : CoverCallExpressionAndAsyncArrowHead => AsyncConciseBody + + - It is a Syntax Error if ContainsUseStrict of AsyncConciseBody is true and + IsSimpleParameterList of CoverCallExpressionAndAsyncArrowHead is false. + +---*/ +$DONOTEVALUATE(); + +class C { + *method([element]) { + "use strict"; + } +} diff --git a/js/src/tests/test262/language/statements/class/gen-method/browser.js b/js/src/tests/test262/language/statements/class/gen-method/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/gen-method/dflt-params-abrupt.js b/js/src/tests/test262/language/statements/class/gen-method/dflt-params-abrupt.js new file mode 100644 index 0000000000..1b084ac1b8 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/gen-method/dflt-params-abrupt.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-abrupt.case +// - src/function-forms/error/cls-decl-gen-meth.template +/*--- +description: Abrupt completion returned by evaluation of initializer (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [default-parameters, generators] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. + +---*/ + +var callCount = 0; +class C { + *method(_ = (function() { throw new Test262Error(); }())) { + + callCount = callCount + 1; + } +} + +assert.throws(Test262Error, function() { + C.prototype.method(); +}); +assert.sameValue(callCount, 0, 'method body not evaluated'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/gen-method/dflt-params-arg-val-not-undefined.js b/js/src/tests/test262/language/statements/class/gen-method/dflt-params-arg-val-not-undefined.js new file mode 100644 index 0000000000..c7e02f7c79 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/gen-method/dflt-params-arg-val-not-undefined.js @@ -0,0 +1,112 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-arg-val-not-undefined.case +// - src/function-forms/default/cls-decl-gen-meth.template +/*--- +description: Use of initializer when argument value is not `undefined` (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [default-parameters, generators] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + [...] + 23. Let iteratorRecord be Record {[[Iterator]]: + CreateListIterator(argumentsList), [[Done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + a. Perform ? IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + +---*/ +var obj = {}; +var falseCount = 0; +var stringCount = 0; +var nanCount = 0; +var zeroCount = 0; +var nullCount = 0; +var objCount = 0; + +var callCount = 0; +class C { + *method(aFalse = falseCount +=1, aString = stringCount += 1, aNaN = nanCount += 1, a0 = zeroCount += 1, aNull = nullCount += 1, aObj = objCount +=1) { + assert.sameValue(aFalse, false); + assert.sameValue(aString, ''); + assert.sameValue(aNaN, NaN); + assert.sameValue(a0, 0); + assert.sameValue(aNull, null); + assert.sameValue(aObj, obj); + callCount = callCount + 1; + } +} + +C.prototype.method(false, '', NaN, 0, null, obj).next(); + +// Stores a reference `ref` for case evaluation +var ref = C.prototype.method; + +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +assert.sameValue(falseCount, 0, 'initializer not evaluated: false'); +assert.sameValue(stringCount, 0, 'initializer not evaluated: string'); +assert.sameValue(nanCount, 0, 'initializer not evaluated: NaN'); +assert.sameValue(zeroCount, 0, 'initializer not evaluated: 0'); +assert.sameValue(nullCount, 0, 'initializer not evaluated: null'); +assert.sameValue(objCount, 0, 'initializer not evaluated: object'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/gen-method/dflt-params-arg-val-undefined.js b/js/src/tests/test262/language/statements/class/gen-method/dflt-params-arg-val-undefined.js new file mode 100644 index 0000000000..1b3131ac20 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/gen-method/dflt-params-arg-val-undefined.js @@ -0,0 +1,95 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-arg-val-undefined.case +// - src/function-forms/default/cls-decl-gen-meth.template +/*--- +description: Use of initializer when argument value is `undefined` (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [default-parameters, generators] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + [...] + 23. Let iteratorRecord be Record {[[Iterator]]: + CreateListIterator(argumentsList), [[Done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + a. Perform ? IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + +---*/ + +var callCount = 0; +class C { + *method(fromLiteral = 23, fromExpr = 45, fromHole = 99) { + assert.sameValue(fromLiteral, 23); + assert.sameValue(fromExpr, 45); + assert.sameValue(fromHole, 99); + callCount = callCount + 1; + } +} + +C.prototype.method(undefined, void 0).next(); + +// Stores a reference `ref` for case evaluation +var ref = C.prototype.method; + +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/gen-method/dflt-params-duplicates.js b/js/src/tests/test262/language/statements/class/gen-method/dflt-params-duplicates.js new file mode 100644 index 0000000000..55875096b5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/gen-method/dflt-params-duplicates.js @@ -0,0 +1,86 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-duplicates.case +// - src/function-forms/syntax/cls-decl-gen-meth.template +/*--- +description: It is a Syntax Error if BoundNames of FormalParameters contains any duplicate elements. (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [default-parameters, generators] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + + 14.1.2 Static Semantics: Early Errors + + StrictFormalParameters : FormalParameters + + - It is a Syntax Error if BoundNames of FormalParameters contains any + duplicate elements. + + FormalParameters : FormalParameterList + + - It is a Syntax Error if IsSimpleParameterList of FormalParameterList is + false and BoundNames of FormalParameterList contains any duplicate + elements. + +---*/ +$DONOTEVALUATE(); + +class C { + *method(x = 0, x) { + + } +} diff --git a/js/src/tests/test262/language/statements/class/gen-method/dflt-params-ref-later.js b/js/src/tests/test262/language/statements/class/gen-method/dflt-params-ref-later.js new file mode 100644 index 0000000000..0551964520 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/gen-method/dflt-params-ref-later.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-ref-later.case +// - src/function-forms/error/cls-decl-gen-meth.template +/*--- +description: Referencing a parameter that occurs later in the ParameterList (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [default-parameters, generators] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. + +---*/ +var x = 0; + +var callCount = 0; +class C { + *method(x = y, y) { + + callCount = callCount + 1; + } +} + +assert.throws(ReferenceError, function() { + C.prototype.method(); +}); +assert.sameValue(callCount, 0, 'method body not evaluated'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/gen-method/dflt-params-ref-prior.js b/js/src/tests/test262/language/statements/class/gen-method/dflt-params-ref-prior.js new file mode 100644 index 0000000000..f7dd334fd4 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/gen-method/dflt-params-ref-prior.js @@ -0,0 +1,92 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-ref-prior.case +// - src/function-forms/default/cls-decl-gen-meth.template +/*--- +description: Referencing a parameter that occurs earlier in the ParameterList (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [default-parameters, generators] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. + +---*/ +var x = 0; + +var callCount = 0; +class C { + *method(x, y = x, z = y) { + assert.sameValue(x, 3, 'first argument value'); + assert.sameValue(y, 3, 'second argument value'); + assert.sameValue(z, 3, 'third argument value'); + callCount = callCount + 1; + } +} + +C.prototype.method(3).next(); + +// Stores a reference `ref` for case evaluation +var ref = C.prototype.method; + +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/gen-method/dflt-params-ref-self.js b/js/src/tests/test262/language/statements/class/gen-method/dflt-params-ref-self.js new file mode 100644 index 0000000000..aac84e6fa1 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/gen-method/dflt-params-ref-self.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-ref-self.case +// - src/function-forms/error/cls-decl-gen-meth.template +/*--- +description: Referencing a parameter from within its own initializer (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [default-parameters, generators] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. + +---*/ +var x = 0; + +var callCount = 0; +class C { + *method(x = x) { + + callCount = callCount + 1; + } +} + +assert.throws(ReferenceError, function() { + C.prototype.method(); +}); +assert.sameValue(callCount, 0, 'method body not evaluated'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/gen-method/dflt-params-rest.js b/js/src/tests/test262/language/statements/class/gen-method/dflt-params-rest.js new file mode 100644 index 0000000000..1268cbb8d1 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/gen-method/dflt-params-rest.js @@ -0,0 +1,90 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-rest.case +// - src/function-forms/syntax/cls-decl-gen-meth.template +/*--- +description: RestParameter does not support an initializer (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [default-parameters, generators] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + + 14.1 Function Definitions + + Syntax + + FunctionRestParameter[Yield] : + + BindingRestElement[?Yield] + + 13.3.3 Destructuring Binding Patterns + + Syntax + + BindingRestElement[Yield] : + + ...BindingIdentifier[?Yield] + ...BindingPattern[?Yield] + +---*/ +$DONOTEVALUATE(); + +class C { + *method(...x = []) { + + } +} diff --git a/js/src/tests/test262/language/statements/class/gen-method/dflt-params-trailing-comma.js b/js/src/tests/test262/language/statements/class/gen-method/dflt-params-trailing-comma.js new file mode 100644 index 0000000000..23ce717020 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/gen-method/dflt-params-trailing-comma.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-trailing-comma.case +// - src/function-forms/default/cls-decl-gen-meth.template +/*--- +description: A trailing comma should not increase the respective length, using default parameters (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + + Trailing comma in the parameters list + + 14.1 Function Definitions + + FormalParameters[Yield, Await] : FormalParameterList[?Yield, ?Await] , +---*/ + +var callCount = 0; +class C { + *method(a, b = 39,) { + assert.sameValue(a, 42); + assert.sameValue(b, 39); + callCount = callCount + 1; + } +} + +C.prototype.method(42, undefined, 1).next(); + +// Stores a reference `ref` for case evaluation +var ref = C.prototype.method; + +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +assert.sameValue(ref.length, 1, 'length is properly set'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/gen-method/forbidden-ext/b1/browser.js b/js/src/tests/test262/language/statements/class/gen-method/forbidden-ext/b1/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/gen-method/forbidden-ext/b1/cls-decl-gen-meth-forbidden-ext-direct-access-prop-arguments.js b/js/src/tests/test262/language/statements/class/gen-method/forbidden-ext/b1/cls-decl-gen-meth-forbidden-ext-direct-access-prop-arguments.js new file mode 100644 index 0000000000..d3eb48a9ba --- /dev/null +++ b/js/src/tests/test262/language/statements/class/gen-method/forbidden-ext/b1/cls-decl-gen-meth-forbidden-ext-direct-access-prop-arguments.js @@ -0,0 +1,37 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/forbidden-ext-direct-access-prop-arguments.case +// - src/function-forms/forbidden-extensions/bullet-one/cls-decl-gen-meth.template +/*--- +description: Forbidden extension, f.arguments (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, generators] +flags: [generated, noStrict] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + + ECMAScript function objects defined using syntactic constructors in strict mode code must + not be created with own properties named "caller" or "arguments". Such own properties also + must not be created for function objects defined using an ArrowFunction, MethodDefinition, + GeneratorDeclaration, GeneratorExpression, AsyncGeneratorDeclaration, AsyncGeneratorExpression, + ClassDeclaration, ClassExpression, AsyncFunctionDeclaration, AsyncFunctionExpression, or + AsyncArrowFunction regardless of whether the definition is contained in strict mode code. + Built-in functions, strict functions created using the Function constructor, generator functions + created using the Generator constructor, async functions created using the AsyncFunction + constructor, and functions created using the bind method also must not be created with such own + properties. + +---*/ + +var callCount = 0; +class C { + *method() { + assert.sameValue(this.method.hasOwnProperty("arguments"), false); + callCount++; + } +} + +C.prototype.method().next(); +assert.sameValue(callCount, 1, 'method body evaluated'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/gen-method/forbidden-ext/b1/cls-decl-gen-meth-forbidden-ext-direct-access-prop-caller.js b/js/src/tests/test262/language/statements/class/gen-method/forbidden-ext/b1/cls-decl-gen-meth-forbidden-ext-direct-access-prop-caller.js new file mode 100644 index 0000000000..a9a9fa54f7 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/gen-method/forbidden-ext/b1/cls-decl-gen-meth-forbidden-ext-direct-access-prop-caller.js @@ -0,0 +1,37 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/forbidden-ext-direct-access-prop-caller.case +// - src/function-forms/forbidden-extensions/bullet-one/cls-decl-gen-meth.template +/*--- +description: Forbidden extension, o.caller (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, generators] +flags: [generated, noStrict] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + + ECMAScript function objects defined using syntactic constructors in strict mode code must + not be created with own properties named "caller" or "arguments". Such own properties also + must not be created for function objects defined using an ArrowFunction, MethodDefinition, + GeneratorDeclaration, GeneratorExpression, AsyncGeneratorDeclaration, AsyncGeneratorExpression, + ClassDeclaration, ClassExpression, AsyncFunctionDeclaration, AsyncFunctionExpression, or + AsyncArrowFunction regardless of whether the definition is contained in strict mode code. + Built-in functions, strict functions created using the Function constructor, generator functions + created using the Generator constructor, async functions created using the AsyncFunction + constructor, and functions created using the bind method also must not be created with such own + properties. + +---*/ + +var callCount = 0; +class C { + *method() { + assert.sameValue(this.method.hasOwnProperty("caller"), false); + callCount++; + } +} + +C.prototype.method().next(); +assert.sameValue(callCount, 1, 'method body evaluated'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/gen-method/forbidden-ext/b1/shell.js b/js/src/tests/test262/language/statements/class/gen-method/forbidden-ext/b1/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/gen-method/forbidden-ext/b2/browser.js b/js/src/tests/test262/language/statements/class/gen-method/forbidden-ext/b2/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/gen-method/forbidden-ext/b2/cls-decl-gen-meth-forbidden-ext-indirect-access-own-prop-caller-get.js b/js/src/tests/test262/language/statements/class/gen-method/forbidden-ext/b2/cls-decl-gen-meth-forbidden-ext-indirect-access-own-prop-caller-get.js new file mode 100644 index 0000000000..c63b93776a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/gen-method/forbidden-ext/b2/cls-decl-gen-meth-forbidden-ext-indirect-access-own-prop-caller-get.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/forbidden-ext-indirect-access-own-prop-caller-get.case +// - src/function-forms/forbidden-extensions/bullet-two/cls-decl-gen-meth.template +/*--- +description: Forbidden extension, o.caller (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, generators] +flags: [generated, noStrict] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + + If an implementation extends any function object with an own property named "caller" the value of + that property, as observed using [[Get]] or [[GetOwnProperty]], must not be a strict function + object. If it is an accessor property, the function that is the value of the property's [[Get]] + attribute must never return a strict function when called. + +---*/ +var CALLER_OWN_PROPERTY_DOES_NOT_EXIST = Symbol(); +function inner() { + // This property may exist, but is forbidden from having a value that is a strict function object + return inner.hasOwnProperty("caller") + ? inner.caller + : CALLER_OWN_PROPERTY_DOES_NOT_EXIST; +} + +var callCount = 0; +class C { + *method() { + /* implicit strict */ + // This and the following conditional value is set in the test's .case file. + // For every test that has a "true" value here, there is a + // corresponding test that has a "false" value here. + // They are generated from two different case files, which use + let descriptor = Object.getOwnPropertyDescriptor(inner, "caller"); + if (descriptor && descriptor.configurable && true) { + Object.defineProperty(inner, "caller", {get(){return 1}}); + } + var result = inner(); + if (descriptor && descriptor.configurable && true) { + assert.sameValue(result, 1, 'If this test defined an own "caller" property on the inner function, then it should be accessible and should return the value it was set to.'); + } + + // "CALLER_OWN_PROPERTY_DOES_NOT_EXIST" is from + // forbidden-ext-indirect-access-prop-caller.case + // + // If the function object "inner" has an own property + // named "caller", then its value will be returned. + // + // If the function object "inner" DOES NOT have an + // own property named "caller", then the symbol + // CALLER_OWN_PROPERTY_DOES_NOT_EXIST will be returned. + if (result !== CALLER_OWN_PROPERTY_DOES_NOT_EXIST) { + assert.notSameValue(result, this.method); + } + callCount++; + } +} + +C.prototype.method().next(); +assert.sameValue(callCount, 1, 'method body evaluated'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/gen-method/forbidden-ext/b2/cls-decl-gen-meth-forbidden-ext-indirect-access-own-prop-caller-value.js b/js/src/tests/test262/language/statements/class/gen-method/forbidden-ext/b2/cls-decl-gen-meth-forbidden-ext-indirect-access-own-prop-caller-value.js new file mode 100644 index 0000000000..6998ef9360 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/gen-method/forbidden-ext/b2/cls-decl-gen-meth-forbidden-ext-indirect-access-own-prop-caller-value.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/forbidden-ext-indirect-access-own-prop-caller-value.case +// - src/function-forms/forbidden-extensions/bullet-two/cls-decl-gen-meth.template +/*--- +description: Forbidden extension, o.caller (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, generators] +flags: [generated, noStrict] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + + If an implementation extends any function object with an own property named "caller" the value of + that property, as observed using [[Get]] or [[GetOwnProperty]], must not be a strict function + object. If it is an accessor property, the function that is the value of the property's [[Get]] + attribute must never return a strict function when called. + +---*/ +var CALLER_OWN_PROPERTY_DOES_NOT_EXIST = Symbol(); +function inner() { + // This property may exist, but is forbidden from having a value that is a strict function object + return inner.hasOwnProperty("caller") + ? inner.caller + : CALLER_OWN_PROPERTY_DOES_NOT_EXIST; +} + +var callCount = 0; +class C { + *method() { + /* implicit strict */ + // This and the following conditional value is set in the test's .case file. + // For every test that has a "true" value here, there is a + // corresponding test that has a "false" value here. + // They are generated from two different case files, which use + let descriptor = Object.getOwnPropertyDescriptor(inner, "caller"); + if (descriptor && descriptor.configurable && true) { + Object.defineProperty(inner, "caller", {value: 1}); + } + var result = inner(); + if (descriptor && descriptor.configurable && true) { + assert.sameValue(result, 1, 'If this test defined an own "caller" property on the inner function, then it should be accessible and should return the value it was set to.'); + } + + // "CALLER_OWN_PROPERTY_DOES_NOT_EXIST" is from + // forbidden-ext-indirect-access-prop-caller.case + // + // If the function object "inner" has an own property + // named "caller", then its value will be returned. + // + // If the function object "inner" DOES NOT have an + // own property named "caller", then the symbol + // CALLER_OWN_PROPERTY_DOES_NOT_EXIST will be returned. + if (result !== CALLER_OWN_PROPERTY_DOES_NOT_EXIST) { + assert.notSameValue(result, this.method); + } + callCount++; + } +} + +C.prototype.method().next(); +assert.sameValue(callCount, 1, 'method body evaluated'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/gen-method/forbidden-ext/b2/cls-decl-gen-meth-forbidden-ext-indirect-access-prop-caller.js b/js/src/tests/test262/language/statements/class/gen-method/forbidden-ext/b2/cls-decl-gen-meth-forbidden-ext-indirect-access-prop-caller.js new file mode 100644 index 0000000000..e6305a593c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/gen-method/forbidden-ext/b2/cls-decl-gen-meth-forbidden-ext-indirect-access-prop-caller.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/forbidden-ext-indirect-access-prop-caller.case +// - src/function-forms/forbidden-extensions/bullet-two/cls-decl-gen-meth.template +/*--- +description: Forbidden extension, o.caller (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [class, generators] +flags: [generated, noStrict] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + + If an implementation extends any function object with an own property named "caller" the value of + that property, as observed using [[Get]] or [[GetOwnProperty]], must not be a strict function + object. If it is an accessor property, the function that is the value of the property's [[Get]] + attribute must never return a strict function when called. + +---*/ +var CALLER_OWN_PROPERTY_DOES_NOT_EXIST = Symbol(); +function inner() { + // This property may exist, but is forbidden from having a value that is a strict function object + return inner.hasOwnProperty("caller") + ? inner.caller + : CALLER_OWN_PROPERTY_DOES_NOT_EXIST; +} + +var callCount = 0; +class C { + *method() { + /* implicit strict */ + // This and the following conditional value is set in the test's .case file. + // For every test that has a "true" value here, there is a + // corresponding test that has a "false" value here. + // They are generated from two different case files, which use + let descriptor = Object.getOwnPropertyDescriptor(inner, "caller"); + if (descriptor && descriptor.configurable && false) { + Object.defineProperty(inner, "caller", {}); + } + var result = inner(); + if (descriptor && descriptor.configurable && false) { + assert.sameValue(result, 1, 'If this test defined an own "caller" property on the inner function, then it should be accessible and should return the value it was set to.'); + } + + // "CALLER_OWN_PROPERTY_DOES_NOT_EXIST" is from + // forbidden-ext-indirect-access-prop-caller.case + // + // If the function object "inner" has an own property + // named "caller", then its value will be returned. + // + // If the function object "inner" DOES NOT have an + // own property named "caller", then the symbol + // CALLER_OWN_PROPERTY_DOES_NOT_EXIST will be returned. + if (result !== CALLER_OWN_PROPERTY_DOES_NOT_EXIST) { + assert.notSameValue(result, this.method); + } + callCount++; + } +} + +C.prototype.method().next(); +assert.sameValue(callCount, 1, 'method body evaluated'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/gen-method/forbidden-ext/b2/shell.js b/js/src/tests/test262/language/statements/class/gen-method/forbidden-ext/b2/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/gen-method/forbidden-ext/browser.js b/js/src/tests/test262/language/statements/class/gen-method/forbidden-ext/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/gen-method/forbidden-ext/shell.js b/js/src/tests/test262/language/statements/class/gen-method/forbidden-ext/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/gen-method/object-destructuring-param-strict-body.js b/js/src/tests/test262/language/statements/class/gen-method/object-destructuring-param-strict-body.js new file mode 100644 index 0000000000..416e2791eb --- /dev/null +++ b/js/src/tests/test262/language/statements/class/gen-method/object-destructuring-param-strict-body.js @@ -0,0 +1,157 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/function-forms/object-destructuring-param-strict-body.case +// - src/function-forms/syntax/cls-decl-gen-meth.template +/*--- +description: ObjectBindingPattern and Use Strict Directive are not allowed to coexist for the same function. (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [rest-parameters, generators] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + + 13.3.3.4 Static Semantics: IsSimpleParameterList + + BindingElement : BindingPattern + + 1. Return false. + + 14.1.2 Static Semantics: Early Errors + + FunctionDeclaration : function BindingIdentifier ( FormalParameters ) { FunctionBody } + FunctionDeclaration : function ( FormalParameters ) { FunctionBody } + FunctionExpression : function BindingIdentifier ( FormalParameters ) { FunctionBody } + + - It is a Syntax Error if ContainsUseStrict of FunctionBody is true and + IsSimpleParameterList of FormalParameters is false. + + 14.2.1 Static Semantics: Early Errors + + ArrowFunction : ArrowParameters => ConciseBody + + - It is a Syntax Error if ContainsUseStrict of ConciseBody is true and + IsSimpleParameterList of ArrowParameters is false. + + 14.3.1 Static Semantics: Early Errors + + MethodDefinition : PropertyName ( UniqueFormalParameters ) { FunctionBody } + + - It is a Syntax Error if ContainsUseStrict of FunctionBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + MethodDefinition : set PropertyName ( PropertySetParameterList ) { FunctionBody } + + - It is a Syntax Error if ContainsUseStrict of FunctionBody is true and + IsSimpleParameterList of PropertySetParameterList is false. + + 14.4.1 Static Semantics: Early Errors + + GeneratorMethod : * PropertyName ( UniqueFormalParameters ) { GeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of GeneratorBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + GeneratorDeclaration : function * BindingIdentifier ( FormalParameters ) { GeneratorBody } + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + GeneratorExpression : function * BindingIdentifier ( FormalParameters ) { GeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of GeneratorBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + 14.5.1 Static Semantics: Early Errors + + AsyncGeneratorMethod : async * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncGeneratorBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + AsyncGeneratorDeclaration : async function * BindingIdentifier ( FormalParameters ) { AsyncGeneratorBody } + AsyncGeneratorDeclaration : async function * ( FormalParameters ) { AsyncGeneratorBody } + AsyncGeneratorExpression : async function * BindingIdentifier ( FormalParameters ) { AsyncGeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncGeneratorBody is true and + IsSimpleParameterList of FormalParameters is false. + + 14.7.1 Static Semantics: Early Errors + + AsyncMethod : async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncFunctionBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + AsyncFunctionDeclaration : async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody } + AsyncFunctionDeclaration : async function ( FormalParameters ) { AsyncFunctionBody } + AsyncFunctionExpression : async function ( FormalParameters ) { AsyncFunctionBody } + AsyncFunctionExpression : async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncFunctionBody is true and + IsSimpleParameterList of FormalParameters is false. + + 14.8.1 Static Semantics: Early Errors + + AsyncArrowFunction : CoverCallExpressionAndAsyncArrowHead => AsyncConciseBody + + - It is a Syntax Error if ContainsUseStrict of AsyncConciseBody is true and + IsSimpleParameterList of CoverCallExpressionAndAsyncArrowHead is false. + +---*/ +$DONOTEVALUATE(); + +class C { + *method({property}) { + "use strict"; + } +} diff --git a/js/src/tests/test262/language/statements/class/gen-method/params-trailing-comma-multiple.js b/js/src/tests/test262/language/statements/class/gen-method/params-trailing-comma-multiple.js new file mode 100644 index 0000000000..e59b4461f9 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/gen-method/params-trailing-comma-multiple.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/params-trailing-comma-multiple.case +// - src/function-forms/default/cls-decl-gen-meth.template +/*--- +description: A trailing comma should not increase the respective length, using multiple parameters (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + + Trailing comma in the parameters list + + 14.1 Function Definitions + + FormalParameters[Yield, Await] : FormalParameterList[?Yield, ?Await] , +---*/ + +var callCount = 0; +class C { + *method(a, b,) { + assert.sameValue(a, 42); + assert.sameValue(b, 39); + callCount = callCount + 1; + } +} + +C.prototype.method(42, 39, 1).next(); + +// Stores a reference `ref` for case evaluation +var ref = C.prototype.method; + +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +assert.sameValue(ref.length, 2, 'length is properly set'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/gen-method/params-trailing-comma-single.js b/js/src/tests/test262/language/statements/class/gen-method/params-trailing-comma-single.js new file mode 100644 index 0000000000..0b7c6fddb6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/gen-method/params-trailing-comma-single.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/params-trailing-comma-single.case +// - src/function-forms/default/cls-decl-gen-meth.template +/*--- +description: A trailing comma should not increase the respective length, using a single parameter (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + + Trailing comma in the parameters list + + 14.1 Function Definitions + + FormalParameters[Yield, Await] : FormalParameterList[?Yield, ?Await] , +---*/ + +var callCount = 0; +class C { + *method(a,) { + assert.sameValue(a, 42); + callCount = callCount + 1; + } +} + +C.prototype.method(42, 39).next(); + +// Stores a reference `ref` for case evaluation +var ref = C.prototype.method; + +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +assert.sameValue(ref.length, 1, 'length is properly set'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/gen-method/rest-param-strict-body.js b/js/src/tests/test262/language/statements/class/gen-method/rest-param-strict-body.js new file mode 100644 index 0000000000..ad3b876fec --- /dev/null +++ b/js/src/tests/test262/language/statements/class/gen-method/rest-param-strict-body.js @@ -0,0 +1,157 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/function-forms/rest-param-strict-body.case +// - src/function-forms/syntax/cls-decl-gen-meth.template +/*--- +description: RestParameter and Use Strict Directive are not allowed to coexist for the same function. (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [rest-parameters, generators] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + + 14.1.13 Static Semantics: IsSimpleParameterList + + FormalParameters : FormalParameterList , FunctionRestParameter + + 1. Return false. + + 14.1.2 Static Semantics: Early Errors + + FunctionDeclaration : function BindingIdentifier ( FormalParameters ) { FunctionBody } + FunctionDeclaration : function ( FormalParameters ) { FunctionBody } + FunctionExpression : function BindingIdentifier ( FormalParameters ) { FunctionBody } + + - It is a Syntax Error if ContainsUseStrict of FunctionBody is true and + IsSimpleParameterList of FormalParameters is false. + + 14.2.1 Static Semantics: Early Errors + + ArrowFunction : ArrowParameters => ConciseBody + + - It is a Syntax Error if ContainsUseStrict of ConciseBody is true and + IsSimpleParameterList of ArrowParameters is false. + + 14.3.1 Static Semantics: Early Errors + + MethodDefinition : PropertyName ( UniqueFormalParameters ) { FunctionBody } + + - It is a Syntax Error if ContainsUseStrict of FunctionBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + MethodDefinition : set PropertyName ( PropertySetParameterList ) { FunctionBody } + + - It is a Syntax Error if ContainsUseStrict of FunctionBody is true and + IsSimpleParameterList of PropertySetParameterList is false. + + 14.4.1 Static Semantics: Early Errors + + GeneratorMethod : * PropertyName ( UniqueFormalParameters ) { GeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of GeneratorBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + GeneratorDeclaration : function * BindingIdentifier ( FormalParameters ) { GeneratorBody } + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + GeneratorExpression : function * BindingIdentifier ( FormalParameters ) { GeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of GeneratorBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + 14.5.1 Static Semantics: Early Errors + + AsyncGeneratorMethod : async * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncGeneratorBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + AsyncGeneratorDeclaration : async function * BindingIdentifier ( FormalParameters ) { AsyncGeneratorBody } + AsyncGeneratorDeclaration : async function * ( FormalParameters ) { AsyncGeneratorBody } + AsyncGeneratorExpression : async function * BindingIdentifier ( FormalParameters ) { AsyncGeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncGeneratorBody is true and + IsSimpleParameterList of FormalParameters is false. + + 14.7.1 Static Semantics: Early Errors + + AsyncMethod : async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncFunctionBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + AsyncFunctionDeclaration : async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody } + AsyncFunctionDeclaration : async function ( FormalParameters ) { AsyncFunctionBody } + AsyncFunctionExpression : async function ( FormalParameters ) { AsyncFunctionBody } + AsyncFunctionExpression : async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncFunctionBody is true and + IsSimpleParameterList of FormalParameters is false. + + 14.8.1 Static Semantics: Early Errors + + AsyncArrowFunction : CoverCallExpressionAndAsyncArrowHead => AsyncConciseBody + + - It is a Syntax Error if ContainsUseStrict of AsyncConciseBody is true and + IsSimpleParameterList of CoverCallExpressionAndAsyncArrowHead is false. + +---*/ +$DONOTEVALUATE(); + +class C { + *method(a,...rest) { + "use strict"; + } +} diff --git a/js/src/tests/test262/language/statements/class/gen-method/rest-params-trailing-comma-early-error.js b/js/src/tests/test262/language/statements/class/gen-method/rest-params-trailing-comma-early-error.js new file mode 100644 index 0000000000..35fbeeb2f4 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/gen-method/rest-params-trailing-comma-early-error.js @@ -0,0 +1,83 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/function-forms/rest-params-trailing-comma-early-error.case +// - src/function-forms/syntax/cls-decl-gen-meth.template +/*--- +description: It's a syntax error if a FunctionRestParameter is followed by a trailing comma (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +features: [generators] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + + Trailing comma in the parameters list + + 14.1 Function Definitions + + FormalParameters[Yield, Await] : + [empty] + FunctionRestParameter[?Yield, ?Await] + FormalParameterList[?Yield, ?Await] + FormalParameterList[?Yield, ?Await] , + FormalParameterList[?Yield, ?Await] , FunctionRestParameter[?Yield, ?Await] +---*/ +$DONOTEVALUATE(); + +class C { + *method(...a,) { + + } +} diff --git a/js/src/tests/test262/language/statements/class/gen-method/shell.js b/js/src/tests/test262/language/statements/class/gen-method/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/gen-method/yield-as-binding-identifier-escaped.js b/js/src/tests/test262/language/statements/class/gen-method/yield-as-binding-identifier-escaped.js new file mode 100644 index 0000000000..17ecc0c5d4 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/gen-method/yield-as-binding-identifier-escaped.js @@ -0,0 +1,36 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/generators/yield-as-binding-identifier-escaped.case +// - src/generators/syntax/class-decl-method.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as a binding identifier. (Generator method as a ClassDeclaration element) +esid: prod-GeneratorMethod +features: [generators] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + GeneratorMethod + + 14.4 Generator Function Definitions + + GeneratorMethod : + * PropertyName ( UniqueFormalParameters ) { GeneratorBody } + + + BindingIdentifier : Identifier + + It is a Syntax Error if this production has a [Yield] parameter and + StringValue of Identifier is "yield". + +---*/ +$DONOTEVALUATE(); + +class C { *gen() { + var yi\u0065ld; +}} diff --git a/js/src/tests/test262/language/statements/class/gen-method/yield-as-binding-identifier.js b/js/src/tests/test262/language/statements/class/gen-method/yield-as-binding-identifier.js new file mode 100644 index 0000000000..76e2b87f32 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/gen-method/yield-as-binding-identifier.js @@ -0,0 +1,36 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/generators/yield-as-binding-identifier.case +// - src/generators/syntax/class-decl-method.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as a binding identifier. (Generator method as a ClassDeclaration element) +esid: prod-GeneratorMethod +features: [generators] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + GeneratorMethod + + 14.4 Generator Function Definitions + + GeneratorMethod : + * PropertyName ( UniqueFormalParameters ) { GeneratorBody } + + + BindingIdentifier : Identifier + + It is a Syntax Error if this production has a [Yield] parameter and + StringValue of Identifier is "yield". + +---*/ +$DONOTEVALUATE(); + +class C { *gen() { + var yield; +}} diff --git a/js/src/tests/test262/language/statements/class/gen-method/yield-as-identifier-reference-escaped.js b/js/src/tests/test262/language/statements/class/gen-method/yield-as-identifier-reference-escaped.js new file mode 100644 index 0000000000..670dc2e705 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/gen-method/yield-as-identifier-reference-escaped.js @@ -0,0 +1,36 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/generators/yield-as-identifier-reference-escaped.case +// - src/generators/syntax/class-decl-method.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as an identifier reference. (Generator method as a ClassDeclaration element) +esid: prod-GeneratorMethod +features: [generators] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + GeneratorMethod + + 14.4 Generator Function Definitions + + GeneratorMethod : + * PropertyName ( UniqueFormalParameters ) { GeneratorBody } + + + IdentifierReference : Identifier + + It is a Syntax Error if this production has a [Yield] parameter and + StringValue of Identifier is "yield". + +---*/ +$DONOTEVALUATE(); + +class C { *gen() { + void yi\u0065ld; +}} diff --git a/js/src/tests/test262/language/statements/class/gen-method/yield-as-identifier-reference.js b/js/src/tests/test262/language/statements/class/gen-method/yield-as-identifier-reference.js new file mode 100644 index 0000000000..b3701c7e7d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/gen-method/yield-as-identifier-reference.js @@ -0,0 +1,36 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/generators/yield-as-identifier-reference.case +// - src/generators/syntax/class-decl-method.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as an identifier reference. (Generator method as a ClassDeclaration element) +esid: prod-GeneratorMethod +features: [generators] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + GeneratorMethod + + 14.4 Generator Function Definitions + + GeneratorMethod : + * PropertyName ( UniqueFormalParameters ) { GeneratorBody } + + + IdentifierReference : Identifier + + It is a Syntax Error if this production has a [Yield] parameter and + StringValue of Identifier is "yield". + +---*/ +$DONOTEVALUATE(); + +class C { *gen() { + void yield; +}} diff --git a/js/src/tests/test262/language/statements/class/gen-method/yield-as-label-identifier-escaped.js b/js/src/tests/test262/language/statements/class/gen-method/yield-as-label-identifier-escaped.js new file mode 100644 index 0000000000..f8173bc45f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/gen-method/yield-as-label-identifier-escaped.js @@ -0,0 +1,36 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/generators/yield-as-label-identifier-escaped.case +// - src/generators/syntax/class-decl-method.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as a label identifier. (Generator method as a ClassDeclaration element) +esid: prod-GeneratorMethod +features: [generators] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + GeneratorMethod + + 14.4 Generator Function Definitions + + GeneratorMethod : + * PropertyName ( UniqueFormalParameters ) { GeneratorBody } + + + LabelIdentifier : Identifier + + It is a Syntax Error if this production has a [Yield] parameter and + StringValue of Identifier is "yield". + +---*/ +$DONOTEVALUATE(); + +class C { *gen() { + yi\u0065ld: ; +}} diff --git a/js/src/tests/test262/language/statements/class/gen-method/yield-as-label-identifier.js b/js/src/tests/test262/language/statements/class/gen-method/yield-as-label-identifier.js new file mode 100644 index 0000000000..ef0b7e2ca6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/gen-method/yield-as-label-identifier.js @@ -0,0 +1,36 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/generators/yield-as-label-identifier.case +// - src/generators/syntax/class-decl-method.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as a label identifier. (Generator method as a ClassDeclaration element) +esid: prod-GeneratorMethod +features: [generators] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + GeneratorMethod + + 14.4 Generator Function Definitions + + GeneratorMethod : + * PropertyName ( UniqueFormalParameters ) { GeneratorBody } + + + LabelIdentifier : Identifier + + It is a Syntax Error if this production has a [Yield] parameter and + StringValue of Identifier is "yield". + +---*/ +$DONOTEVALUATE(); + +class C { *gen() { + yield: ; +}} diff --git a/js/src/tests/test262/language/statements/class/gen-method/yield-identifier-spread-strict-strict.js b/js/src/tests/test262/language/statements/class/gen-method/yield-identifier-spread-strict-strict.js new file mode 100644 index 0000000000..66078a5fb6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/gen-method/yield-identifier-spread-strict-strict.js @@ -0,0 +1,54 @@ +// |reftest| error:SyntaxError +'use strict'; +// This file was procedurally generated from the following sources: +// - src/generators/yield-identifier-spread-strict.case +// - src/generators/default/class-decl-method.template +/*--- +description: It's an early error if the AssignmentExpression is a function body with yield as an identifier in strict mode. (Generator method as a ClassDeclaration element) +esid: prod-GeneratorMethod +features: [object-spread, generators] +flags: [generated, onlyStrict] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + GeneratorMethod + + 14.4 Generator Function Definitions + + GeneratorMethod : + * PropertyName ( UniqueFormalParameters ) { GeneratorBody } + + + Spread Properties + + PropertyDefinition[Yield]: + (...) + ...AssignmentExpression[In, ?Yield] + +---*/ +$DONOTEVALUATE(); + +var callCount = 0; + +class C { *gen() { + callCount += 1; + return { + ...(function() { + var yield; + throw new Test262Error(); + }()), + } +}} + +var gen = C.prototype.gen; + +var iter = gen(); + + + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/gen-method/yield-identifier-strict-strict.js b/js/src/tests/test262/language/statements/class/gen-method/yield-identifier-strict-strict.js new file mode 100644 index 0000000000..ba5630356b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/gen-method/yield-identifier-strict-strict.js @@ -0,0 +1,45 @@ +// |reftest| error:SyntaxError +'use strict'; +// This file was procedurally generated from the following sources: +// - src/generators/yield-identifier-strict.case +// - src/generators/default/class-decl-method.template +/*--- +description: It's an early error if the generator body has another function body with yield as an identifier in strict mode. (Generator method as a ClassDeclaration element) +esid: prod-GeneratorMethod +features: [generators] +flags: [generated, onlyStrict] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + GeneratorMethod + + 14.4 Generator Function Definitions + + GeneratorMethod : + * PropertyName ( UniqueFormalParameters ) { GeneratorBody } + +---*/ +$DONOTEVALUATE(); + +var callCount = 0; + +class C { *gen() { + callCount += 1; + (function() { + var yield; + throw new Test262Error(); + }()) +}} + +var gen = C.prototype.gen; + +var iter = gen(); + + + +assert.sameValue(callCount, 1); diff --git a/js/src/tests/test262/language/statements/class/gen-method/yield-spread-arr-multiple.js b/js/src/tests/test262/language/statements/class/gen-method/yield-spread-arr-multiple.js new file mode 100644 index 0000000000..5fc963769b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/gen-method/yield-spread-arr-multiple.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/generators/yield-spread-arr-multiple.case +// - src/generators/default/class-decl-method.template +/*--- +description: Use yield value in a array spread position (Generator method as a ClassDeclaration element) +esid: prod-GeneratorMethod +features: [generators] +flags: [generated] +includes: [compareArray.js] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + GeneratorMethod + + 14.4 Generator Function Definitions + + GeneratorMethod : + * PropertyName ( UniqueFormalParameters ) { GeneratorBody } + + + Array Initializer + + SpreadElement[Yield, Await]: + ...AssignmentExpression[+In, ?Yield, ?Await] + +---*/ +var arr = ['a', 'b', 'c']; +var item; + +var callCount = 0; + +class C { *gen() { + callCount += 1; + yield [...yield yield]; +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next(false); +item = iter.next(['a', 'b', 'c']); +item = iter.next(item.value); + +assert.compareArray(item.value, arr); +assert.sameValue(item.done, false); + +assert.sameValue(callCount, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/gen-method/yield-spread-arr-single.js b/js/src/tests/test262/language/statements/class/gen-method/yield-spread-arr-single.js new file mode 100644 index 0000000000..d93a8847dc --- /dev/null +++ b/js/src/tests/test262/language/statements/class/gen-method/yield-spread-arr-single.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/generators/yield-spread-arr-single.case +// - src/generators/default/class-decl-method.template +/*--- +description: Use yield value in a array spread position (Generator method as a ClassDeclaration element) +esid: prod-GeneratorMethod +features: [generators] +flags: [generated] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + GeneratorMethod + + 14.4 Generator Function Definitions + + GeneratorMethod : + * PropertyName ( UniqueFormalParameters ) { GeneratorBody } + + + Array Initializer + + SpreadElement[Yield, Await]: + ...AssignmentExpression[+In, ?Yield, ?Await] +---*/ +var arr = ['a', 'b', 'c']; + +var callCount = 0; + +class C { *gen() { + callCount += 1; + yield [...yield]; +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next(false); +var item = iter.next(arr); +var value = item.value; + +assert.notSameValue(value, arr, 'value is a new array'); +assert(Array.isArray(value), 'value is an Array exotic object'); +assert.sameValue(value.length, 3) +assert.sameValue(value[0], 'a'); +assert.sameValue(value[1], 'b'); +assert.sameValue(value[2], 'c'); +assert.sameValue(item.done, false); + +assert.sameValue(callCount, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/gen-method/yield-spread-obj.js b/js/src/tests/test262/language/statements/class/gen-method/yield-spread-obj.js new file mode 100644 index 0000000000..54171419bd --- /dev/null +++ b/js/src/tests/test262/language/statements/class/gen-method/yield-spread-obj.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/generators/yield-spread-obj.case +// - src/generators/default/class-decl-method.template +/*--- +description: Use yield value in a object spread position (Generator method as a ClassDeclaration element) +esid: prod-GeneratorMethod +features: [object-spread, generators] +flags: [generated] +info: | + ClassElement : + MethodDefinition + + MethodDefinition : + GeneratorMethod + + 14.4 Generator Function Definitions + + GeneratorMethod : + * PropertyName ( UniqueFormalParameters ) { GeneratorBody } + + + Spread Properties + + PropertyDefinition[Yield]: + (...) + ...AssignmentExpression[In, ?Yield] + +---*/ + +var callCount = 0; + +class C { *gen() { + callCount += 1; + yield { + ...yield, + y: 1, + ...yield yield, + }; +}} + +var gen = C.prototype.gen; + +var iter = gen(); + +iter.next(); +iter.next({ x: 42 }); +iter.next({ x: 'lol' }); +var item = iter.next({ y: 39 }); + +assert.sameValue(item.value.x, 42); +assert.sameValue(item.value.y, 39); +assert.sameValue(Object.keys(item.value).length, 2); +assert.sameValue(item.done, false); + +assert.sameValue(callCount, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/getter-param-dflt.js b/js/src/tests/test262/language/statements/class/getter-param-dflt.js new file mode 100644 index 0000000000..f5d813fff0 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/getter-param-dflt.js @@ -0,0 +1,24 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-method-definitions +es6id: 14.3 +description: > + Get accessor method may not have a formal parameter (regardless of the + presence of an initializer) +info: | + Syntax + + MethodDefinition[Yield] : + + get PropertyName[?Yield] ( ) { FunctionBody } +features: [default-parameters] +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +class C { get a(param = null) {} } diff --git a/js/src/tests/test262/language/statements/class/ident-name-method-def-break-escaped.js b/js/src/tests/test262/language/statements/class/ident-name-method-def-break-escaped.js new file mode 100644 index 0000000000..bfcedac619 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/ident-name-method-def-break-escaped.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/break-escaped.case +// - src/identifier-names/default/class-statement-method-def.template +/*--- +description: break is a valid identifier name, using escape (MethodDefinition) +esid: prod-PropertyDefinition +features: [class] +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + MethodDefinition + ... + + MethodDefinition: + PropertyName ( UniqueFormalParameters ){ FunctionBody } + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. + +---*/ + + +class C { + bre\u0061k() { return 42; } +} + +var obj = new C(); + +assert.sameValue(obj['break'](), 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/ident-name-method-def-case-escaped.js b/js/src/tests/test262/language/statements/class/ident-name-method-def-case-escaped.js new file mode 100644 index 0000000000..6830cb6187 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/ident-name-method-def-case-escaped.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/case-escaped.case +// - src/identifier-names/default/class-statement-method-def.template +/*--- +description: case is a valid identifier name, using escape (MethodDefinition) +esid: prod-PropertyDefinition +features: [class] +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + MethodDefinition + ... + + MethodDefinition: + PropertyName ( UniqueFormalParameters ){ FunctionBody } + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. + +---*/ + + +class C { + c\u0061se() { return 42; } +} + +var obj = new C(); + +assert.sameValue(obj['case'](), 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/ident-name-method-def-catch-escaped.js b/js/src/tests/test262/language/statements/class/ident-name-method-def-catch-escaped.js new file mode 100644 index 0000000000..4f4cf9068f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/ident-name-method-def-catch-escaped.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/catch-escaped.case +// - src/identifier-names/default/class-statement-method-def.template +/*--- +description: catch is a valid identifier name, using escape (MethodDefinition) +esid: prod-PropertyDefinition +features: [class] +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + MethodDefinition + ... + + MethodDefinition: + PropertyName ( UniqueFormalParameters ){ FunctionBody } + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. + +---*/ + + +class C { + c\u0061tch() { return 42; } +} + +var obj = new C(); + +assert.sameValue(obj['catch'](), 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/ident-name-method-def-class-escaped.js b/js/src/tests/test262/language/statements/class/ident-name-method-def-class-escaped.js new file mode 100644 index 0000000000..2b16ead2e8 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/ident-name-method-def-class-escaped.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/class-escaped.case +// - src/identifier-names/default/class-statement-method-def.template +/*--- +description: class is a valid identifier name, using escape (MethodDefinition) +esid: prod-PropertyDefinition +features: [class] +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + MethodDefinition + ... + + MethodDefinition: + PropertyName ( UniqueFormalParameters ){ FunctionBody } + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. + +---*/ + + +class C { + cl\u0061ss() { return 42; } +} + +var obj = new C(); + +assert.sameValue(obj['class'](), 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/ident-name-method-def-const-escaped.js b/js/src/tests/test262/language/statements/class/ident-name-method-def-const-escaped.js new file mode 100644 index 0000000000..5083eeb0f7 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/ident-name-method-def-const-escaped.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/const-escaped.case +// - src/identifier-names/default/class-statement-method-def.template +/*--- +description: const is a valid identifier name, using escape (MethodDefinition) +esid: prod-PropertyDefinition +features: [class] +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + MethodDefinition + ... + + MethodDefinition: + PropertyName ( UniqueFormalParameters ){ FunctionBody } + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. + +---*/ + + +class C { + \u0063onst() { return 42; } +} + +var obj = new C(); + +assert.sameValue(obj['const'](), 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/ident-name-method-def-continue-escaped.js b/js/src/tests/test262/language/statements/class/ident-name-method-def-continue-escaped.js new file mode 100644 index 0000000000..e99588679b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/ident-name-method-def-continue-escaped.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/continue-escaped.case +// - src/identifier-names/default/class-statement-method-def.template +/*--- +description: continue is a valid identifier name, using escape (MethodDefinition) +esid: prod-PropertyDefinition +features: [class] +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + MethodDefinition + ... + + MethodDefinition: + PropertyName ( UniqueFormalParameters ){ FunctionBody } + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. + +---*/ + + +class C { + \u0063ontinue() { return 42; } +} + +var obj = new C(); + +assert.sameValue(obj['continue'](), 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/ident-name-method-def-debugger-escaped.js b/js/src/tests/test262/language/statements/class/ident-name-method-def-debugger-escaped.js new file mode 100644 index 0000000000..b0657b5cf6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/ident-name-method-def-debugger-escaped.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/debugger-escaped.case +// - src/identifier-names/default/class-statement-method-def.template +/*--- +description: debugger is a valid identifier name, using escape (MethodDefinition) +esid: prod-PropertyDefinition +features: [class] +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + MethodDefinition + ... + + MethodDefinition: + PropertyName ( UniqueFormalParameters ){ FunctionBody } + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. + +---*/ + + +class C { + \u0064ebugger() { return 42; } +} + +var obj = new C(); + +assert.sameValue(obj['debugger'](), 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/ident-name-method-def-default-escaped-ext.js b/js/src/tests/test262/language/statements/class/ident-name-method-def-default-escaped-ext.js new file mode 100644 index 0000000000..a7b6bdf12a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/ident-name-method-def-default-escaped-ext.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/default-escaped-ext.case +// - src/identifier-names/default/class-statement-method-def.template +/*--- +description: default is a valid identifier name, using extended escape (MethodDefinition) +esid: prod-PropertyDefinition +features: [class] +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + MethodDefinition + ... + + MethodDefinition: + PropertyName ( UniqueFormalParameters ){ FunctionBody } + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. + +---*/ + + +class C { + def\u{61}ult() { return 42; } +} + +var obj = new C(); + +assert.sameValue(obj['default'](), 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/ident-name-method-def-default-escaped.js b/js/src/tests/test262/language/statements/class/ident-name-method-def-default-escaped.js new file mode 100644 index 0000000000..e3fd1ee427 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/ident-name-method-def-default-escaped.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/default-escaped.case +// - src/identifier-names/default/class-statement-method-def.template +/*--- +description: default is a valid identifier name, using escape (MethodDefinition) +esid: prod-PropertyDefinition +features: [class] +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + MethodDefinition + ... + + MethodDefinition: + PropertyName ( UniqueFormalParameters ){ FunctionBody } + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. + +---*/ + + +class C { + def\u0061ult() { return 42; } +} + +var obj = new C(); + +assert.sameValue(obj['default'](), 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/ident-name-method-def-default.js b/js/src/tests/test262/language/statements/class/ident-name-method-def-default.js new file mode 100644 index 0000000000..47a92739ca --- /dev/null +++ b/js/src/tests/test262/language/statements/class/ident-name-method-def-default.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/default.case +// - src/identifier-names/default/class-statement-method-def.template +/*--- +description: default is a valid identifier name (MethodDefinition) +esid: prod-PropertyDefinition +features: [class] +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + MethodDefinition + ... + + MethodDefinition: + PropertyName ( UniqueFormalParameters ){ FunctionBody } + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. + +---*/ + + +class C { + default() { return 42; } +} + +var obj = new C(); + +assert.sameValue(obj['default'](), 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/ident-name-method-def-delete-escaped.js b/js/src/tests/test262/language/statements/class/ident-name-method-def-delete-escaped.js new file mode 100644 index 0000000000..fa1ed7ed4c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/ident-name-method-def-delete-escaped.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/delete-escaped.case +// - src/identifier-names/default/class-statement-method-def.template +/*--- +description: delete is a valid identifier name, using escape (MethodDefinition) +esid: prod-PropertyDefinition +features: [class] +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + MethodDefinition + ... + + MethodDefinition: + PropertyName ( UniqueFormalParameters ){ FunctionBody } + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. + +---*/ + + +class C { + \u0064elete() { return 42; } +} + +var obj = new C(); + +assert.sameValue(obj['delete'](), 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/ident-name-method-def-do-escaped.js b/js/src/tests/test262/language/statements/class/ident-name-method-def-do-escaped.js new file mode 100644 index 0000000000..bcfa66ae50 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/ident-name-method-def-do-escaped.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/do-escaped.case +// - src/identifier-names/default/class-statement-method-def.template +/*--- +description: do is a valid identifier name, using escape (MethodDefinition) +esid: prod-PropertyDefinition +features: [class] +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + MethodDefinition + ... + + MethodDefinition: + PropertyName ( UniqueFormalParameters ){ FunctionBody } + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. + +---*/ + + +class C { + \u0064o() { return 42; } +} + +var obj = new C(); + +assert.sameValue(obj['do'](), 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/ident-name-method-def-else-escaped.js b/js/src/tests/test262/language/statements/class/ident-name-method-def-else-escaped.js new file mode 100644 index 0000000000..384dddc501 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/ident-name-method-def-else-escaped.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/else-escaped.case +// - src/identifier-names/default/class-statement-method-def.template +/*--- +description: else is a valid identifier name, using escape (MethodDefinition) +esid: prod-PropertyDefinition +features: [class] +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + MethodDefinition + ... + + MethodDefinition: + PropertyName ( UniqueFormalParameters ){ FunctionBody } + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. + +---*/ + + +class C { + \u0065lse() { return 42; } +} + +var obj = new C(); + +assert.sameValue(obj['else'](), 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/ident-name-method-def-enum-escaped.js b/js/src/tests/test262/language/statements/class/ident-name-method-def-enum-escaped.js new file mode 100644 index 0000000000..6a9c5a580c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/ident-name-method-def-enum-escaped.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/enum-escaped.case +// - src/identifier-names/default/class-statement-method-def.template +/*--- +description: enum is a valid identifier name, using escape (MethodDefinition) +esid: prod-PropertyDefinition +features: [class] +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + MethodDefinition + ... + + MethodDefinition: + PropertyName ( UniqueFormalParameters ){ FunctionBody } + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. + +---*/ + + +class C { + \u0065num() { return 42; } +} + +var obj = new C(); + +assert.sameValue(obj['enum'](), 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/ident-name-method-def-export-escaped.js b/js/src/tests/test262/language/statements/class/ident-name-method-def-export-escaped.js new file mode 100644 index 0000000000..9d057327a5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/ident-name-method-def-export-escaped.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/export-escaped.case +// - src/identifier-names/default/class-statement-method-def.template +/*--- +description: export is a valid identifier name, using escape (MethodDefinition) +esid: prod-PropertyDefinition +features: [class] +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + MethodDefinition + ... + + MethodDefinition: + PropertyName ( UniqueFormalParameters ){ FunctionBody } + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. + +---*/ + + +class C { + \u0065xport() { return 42; } +} + +var obj = new C(); + +assert.sameValue(obj['export'](), 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/ident-name-method-def-extends-escaped-ext.js b/js/src/tests/test262/language/statements/class/ident-name-method-def-extends-escaped-ext.js new file mode 100644 index 0000000000..d880700cf1 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/ident-name-method-def-extends-escaped-ext.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/extends-escaped-ext.case +// - src/identifier-names/default/class-statement-method-def.template +/*--- +description: extends is a valid identifier name, using extended escape (MethodDefinition) +esid: prod-PropertyDefinition +features: [class] +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + MethodDefinition + ... + + MethodDefinition: + PropertyName ( UniqueFormalParameters ){ FunctionBody } + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. + +---*/ + + +class C { + \u{65}xtends() { return 42; } +} + +var obj = new C(); + +assert.sameValue(obj['extends'](), 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/ident-name-method-def-extends-escaped.js b/js/src/tests/test262/language/statements/class/ident-name-method-def-extends-escaped.js new file mode 100644 index 0000000000..df0ecebdcc --- /dev/null +++ b/js/src/tests/test262/language/statements/class/ident-name-method-def-extends-escaped.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/extends-escaped.case +// - src/identifier-names/default/class-statement-method-def.template +/*--- +description: extends is a valid identifier name, using escape (MethodDefinition) +esid: prod-PropertyDefinition +features: [class] +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + MethodDefinition + ... + + MethodDefinition: + PropertyName ( UniqueFormalParameters ){ FunctionBody } + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. + +---*/ + + +class C { + \u0065xtends() { return 42; } +} + +var obj = new C(); + +assert.sameValue(obj['extends'](), 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/ident-name-method-def-extends.js b/js/src/tests/test262/language/statements/class/ident-name-method-def-extends.js new file mode 100644 index 0000000000..c8b6b46db7 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/ident-name-method-def-extends.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/extends.case +// - src/identifier-names/default/class-statement-method-def.template +/*--- +description: extends is a valid identifier name (MethodDefinition) +esid: prod-PropertyDefinition +features: [class] +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + MethodDefinition + ... + + MethodDefinition: + PropertyName ( UniqueFormalParameters ){ FunctionBody } + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. + +---*/ + + +class C { + extends() { return 42; } +} + +var obj = new C(); + +assert.sameValue(obj['extends'](), 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/ident-name-method-def-finally-escaped.js b/js/src/tests/test262/language/statements/class/ident-name-method-def-finally-escaped.js new file mode 100644 index 0000000000..01ae276115 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/ident-name-method-def-finally-escaped.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/finally-escaped.case +// - src/identifier-names/default/class-statement-method-def.template +/*--- +description: finally is a valid identifier name, using escape (MethodDefinition) +esid: prod-PropertyDefinition +features: [class] +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + MethodDefinition + ... + + MethodDefinition: + PropertyName ( UniqueFormalParameters ){ FunctionBody } + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. + +---*/ + + +class C { + \u0066inally() { return 42; } +} + +var obj = new C(); + +assert.sameValue(obj['finally'](), 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/ident-name-method-def-for-escaped.js b/js/src/tests/test262/language/statements/class/ident-name-method-def-for-escaped.js new file mode 100644 index 0000000000..34737f7bb4 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/ident-name-method-def-for-escaped.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/for-escaped.case +// - src/identifier-names/default/class-statement-method-def.template +/*--- +description: for is a valid identifier name, using escape (MethodDefinition) +esid: prod-PropertyDefinition +features: [class] +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + MethodDefinition + ... + + MethodDefinition: + PropertyName ( UniqueFormalParameters ){ FunctionBody } + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. + +---*/ + + +class C { + \u0066or() { return 42; } +} + +var obj = new C(); + +assert.sameValue(obj['for'](), 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/ident-name-method-def-function-escaped.js b/js/src/tests/test262/language/statements/class/ident-name-method-def-function-escaped.js new file mode 100644 index 0000000000..6230712a8e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/ident-name-method-def-function-escaped.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/function-escaped.case +// - src/identifier-names/default/class-statement-method-def.template +/*--- +description: function is a valid identifier name, using escape (MethodDefinition) +esid: prod-PropertyDefinition +features: [class] +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + MethodDefinition + ... + + MethodDefinition: + PropertyName ( UniqueFormalParameters ){ FunctionBody } + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. + +---*/ + + +class C { + \u0066unction() { return 42; } +} + +var obj = new C(); + +assert.sameValue(obj['function'](), 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/ident-name-method-def-if-escaped.js b/js/src/tests/test262/language/statements/class/ident-name-method-def-if-escaped.js new file mode 100644 index 0000000000..5f68c226a6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/ident-name-method-def-if-escaped.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/if-escaped.case +// - src/identifier-names/default/class-statement-method-def.template +/*--- +description: if is a valid identifier name, using escape (MethodDefinition) +esid: prod-PropertyDefinition +features: [class] +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + MethodDefinition + ... + + MethodDefinition: + PropertyName ( UniqueFormalParameters ){ FunctionBody } + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. + +---*/ + + +class C { + i\u0066() { return 42; } +} + +var obj = new C(); + +assert.sameValue(obj['if'](), 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/ident-name-method-def-implements-escaped.js b/js/src/tests/test262/language/statements/class/ident-name-method-def-implements-escaped.js new file mode 100644 index 0000000000..ecc8d182ac --- /dev/null +++ b/js/src/tests/test262/language/statements/class/ident-name-method-def-implements-escaped.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/implements-escaped.case +// - src/identifier-names/future-reserved-words/class-statement-method-def.template +/*--- +description: implements is a valid identifier name, using escape (MethodDefinition) +esid: prod-PropertyDefinition +features: [class] +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + MethodDefinition + ... + + MethodDefinition: + PropertyName ( UniqueFormalParameters ){ FunctionBody } + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. + +---*/ + + +class C { + \u0069mplements() { return 42; } +} + +var obj = new C(); + +assert.sameValue(obj['implements'](), 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/ident-name-method-def-import-escaped.js b/js/src/tests/test262/language/statements/class/ident-name-method-def-import-escaped.js new file mode 100644 index 0000000000..fef86812b0 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/ident-name-method-def-import-escaped.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/import-escaped.case +// - src/identifier-names/default/class-statement-method-def.template +/*--- +description: import is a valid identifier name, using escape (MethodDefinition) +esid: prod-PropertyDefinition +features: [class] +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + MethodDefinition + ... + + MethodDefinition: + PropertyName ( UniqueFormalParameters ){ FunctionBody } + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. + +---*/ + + +class C { + \u0069mport() { return 42; } +} + +var obj = new C(); + +assert.sameValue(obj['import'](), 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/ident-name-method-def-in-escaped.js b/js/src/tests/test262/language/statements/class/ident-name-method-def-in-escaped.js new file mode 100644 index 0000000000..4b228a3110 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/ident-name-method-def-in-escaped.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/in-escaped.case +// - src/identifier-names/default/class-statement-method-def.template +/*--- +description: in is a valid identifier name, using escape (MethodDefinition) +esid: prod-PropertyDefinition +features: [class] +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + MethodDefinition + ... + + MethodDefinition: + PropertyName ( UniqueFormalParameters ){ FunctionBody } + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. + +---*/ + + +class C { + \u0069n() { return 42; } +} + +var obj = new C(); + +assert.sameValue(obj['in'](), 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/ident-name-method-def-instanceof-escaped.js b/js/src/tests/test262/language/statements/class/ident-name-method-def-instanceof-escaped.js new file mode 100644 index 0000000000..3169ec3265 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/ident-name-method-def-instanceof-escaped.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/instanceof-escaped.case +// - src/identifier-names/default/class-statement-method-def.template +/*--- +description: instanceof is a valid identifier name, using escape (MethodDefinition) +esid: prod-PropertyDefinition +features: [class] +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + MethodDefinition + ... + + MethodDefinition: + PropertyName ( UniqueFormalParameters ){ FunctionBody } + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. + +---*/ + + +class C { + \u0069nstanceof() { return 42; } +} + +var obj = new C(); + +assert.sameValue(obj['instanceof'](), 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/ident-name-method-def-interface-escaped.js b/js/src/tests/test262/language/statements/class/ident-name-method-def-interface-escaped.js new file mode 100644 index 0000000000..0f13a0c9f8 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/ident-name-method-def-interface-escaped.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/interface-escaped.case +// - src/identifier-names/future-reserved-words/class-statement-method-def.template +/*--- +description: interface is a valid identifier name, using escape (MethodDefinition) +esid: prod-PropertyDefinition +features: [class] +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + MethodDefinition + ... + + MethodDefinition: + PropertyName ( UniqueFormalParameters ){ FunctionBody } + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. + +---*/ + + +class C { + interf\u0061ce() { return 42; } +} + +var obj = new C(); + +assert.sameValue(obj['interface'](), 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/ident-name-method-def-let-escaped.js b/js/src/tests/test262/language/statements/class/ident-name-method-def-let-escaped.js new file mode 100644 index 0000000000..c240a393cb --- /dev/null +++ b/js/src/tests/test262/language/statements/class/ident-name-method-def-let-escaped.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/let-escaped.case +// - src/identifier-names/future-reserved-words/class-statement-method-def.template +/*--- +description: let is a valid identifier name, using escape (MethodDefinition) +esid: prod-PropertyDefinition +features: [class] +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + MethodDefinition + ... + + MethodDefinition: + PropertyName ( UniqueFormalParameters ){ FunctionBody } + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. + +---*/ + + +class C { + l\u0065t() { return 42; } +} + +var obj = new C(); + +assert.sameValue(obj['let'](), 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/ident-name-method-def-new-escaped.js b/js/src/tests/test262/language/statements/class/ident-name-method-def-new-escaped.js new file mode 100644 index 0000000000..4e3b9988f9 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/ident-name-method-def-new-escaped.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/new-escaped.case +// - src/identifier-names/default/class-statement-method-def.template +/*--- +description: new is a valid identifier name, using escape (MethodDefinition) +esid: prod-PropertyDefinition +features: [class] +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + MethodDefinition + ... + + MethodDefinition: + PropertyName ( UniqueFormalParameters ){ FunctionBody } + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. + +---*/ + + +class C { + n\u0065w() { return 42; } +} + +var obj = new C(); + +assert.sameValue(obj['new'](), 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/ident-name-method-def-package-escaped.js b/js/src/tests/test262/language/statements/class/ident-name-method-def-package-escaped.js new file mode 100644 index 0000000000..815418c6ee --- /dev/null +++ b/js/src/tests/test262/language/statements/class/ident-name-method-def-package-escaped.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/package-escaped.case +// - src/identifier-names/future-reserved-words/class-statement-method-def.template +/*--- +description: package is a valid identifier name, using escape (MethodDefinition) +esid: prod-PropertyDefinition +features: [class] +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + MethodDefinition + ... + + MethodDefinition: + PropertyName ( UniqueFormalParameters ){ FunctionBody } + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. + +---*/ + + +class C { + p\u0061ckage() { return 42; } +} + +var obj = new C(); + +assert.sameValue(obj['package'](), 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/ident-name-method-def-private-escaped.js b/js/src/tests/test262/language/statements/class/ident-name-method-def-private-escaped.js new file mode 100644 index 0000000000..bb38984d92 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/ident-name-method-def-private-escaped.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/private-escaped.case +// - src/identifier-names/future-reserved-words/class-statement-method-def.template +/*--- +description: private is a valid identifier name, using escape (MethodDefinition) +esid: prod-PropertyDefinition +features: [class] +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + MethodDefinition + ... + + MethodDefinition: + PropertyName ( UniqueFormalParameters ){ FunctionBody } + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. + +---*/ + + +class C { + privat\u0065() { return 42; } +} + +var obj = new C(); + +assert.sameValue(obj['private'](), 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/ident-name-method-def-protected-escaped.js b/js/src/tests/test262/language/statements/class/ident-name-method-def-protected-escaped.js new file mode 100644 index 0000000000..11aacc7112 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/ident-name-method-def-protected-escaped.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/protected-escaped.case +// - src/identifier-names/future-reserved-words/class-statement-method-def.template +/*--- +description: protected is a valid identifier name, using escape (MethodDefinition) +esid: prod-PropertyDefinition +features: [class] +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + MethodDefinition + ... + + MethodDefinition: + PropertyName ( UniqueFormalParameters ){ FunctionBody } + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. + +---*/ + + +class C { + prot\u0065cted() { return 42; } +} + +var obj = new C(); + +assert.sameValue(obj['protected'](), 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/ident-name-method-def-public-escaped.js b/js/src/tests/test262/language/statements/class/ident-name-method-def-public-escaped.js new file mode 100644 index 0000000000..7d64d6ed91 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/ident-name-method-def-public-escaped.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/public-escaped.case +// - src/identifier-names/future-reserved-words/class-statement-method-def.template +/*--- +description: public is a valid identifier name, using escape (MethodDefinition) +esid: prod-PropertyDefinition +features: [class] +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + MethodDefinition + ... + + MethodDefinition: + PropertyName ( UniqueFormalParameters ){ FunctionBody } + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. + +---*/ + + +class C { + pu\u0062lic() { return 42; } +} + +var obj = new C(); + +assert.sameValue(obj['public'](), 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/ident-name-method-def-return-escaped.js b/js/src/tests/test262/language/statements/class/ident-name-method-def-return-escaped.js new file mode 100644 index 0000000000..250774c536 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/ident-name-method-def-return-escaped.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/return-escaped.case +// - src/identifier-names/default/class-statement-method-def.template +/*--- +description: return is a valid identifier name, using escape (MethodDefinition) +esid: prod-PropertyDefinition +features: [class] +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + MethodDefinition + ... + + MethodDefinition: + PropertyName ( UniqueFormalParameters ){ FunctionBody } + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. + +---*/ + + +class C { + r\u0065turn() { return 42; } +} + +var obj = new C(); + +assert.sameValue(obj['return'](), 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/ident-name-method-def-static-escaped.js b/js/src/tests/test262/language/statements/class/ident-name-method-def-static-escaped.js new file mode 100644 index 0000000000..2976f6dcb6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/ident-name-method-def-static-escaped.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/static-escaped.case +// - src/identifier-names/future-reserved-words/class-statement-method-def.template +/*--- +description: static is a valid identifier name, using escape (MethodDefinition) +esid: prod-PropertyDefinition +features: [class] +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + MethodDefinition + ... + + MethodDefinition: + PropertyName ( UniqueFormalParameters ){ FunctionBody } + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. + +---*/ + + +class C { + st\u0061tic() { return 42; } +} + +var obj = new C(); + +assert.sameValue(obj['static'](), 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/ident-name-method-def-super-escaped.js b/js/src/tests/test262/language/statements/class/ident-name-method-def-super-escaped.js new file mode 100644 index 0000000000..e0392ac5ac --- /dev/null +++ b/js/src/tests/test262/language/statements/class/ident-name-method-def-super-escaped.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/super-escaped.case +// - src/identifier-names/default/class-statement-method-def.template +/*--- +description: super is a valid identifier name, using escape (MethodDefinition) +esid: prod-PropertyDefinition +features: [class] +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + MethodDefinition + ... + + MethodDefinition: + PropertyName ( UniqueFormalParameters ){ FunctionBody } + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. + +---*/ + + +class C { + sup\u0065r() { return 42; } +} + +var obj = new C(); + +assert.sameValue(obj['super'](), 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/ident-name-method-def-switch-escaped.js b/js/src/tests/test262/language/statements/class/ident-name-method-def-switch-escaped.js new file mode 100644 index 0000000000..5d3388b8e7 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/ident-name-method-def-switch-escaped.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/switch-escaped.case +// - src/identifier-names/default/class-statement-method-def.template +/*--- +description: switch is a valid identifier name, using escape (MethodDefinition) +esid: prod-PropertyDefinition +features: [class] +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + MethodDefinition + ... + + MethodDefinition: + PropertyName ( UniqueFormalParameters ){ FunctionBody } + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. + +---*/ + + +class C { + sw\u0069tch() { return 42; } +} + +var obj = new C(); + +assert.sameValue(obj['switch'](), 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/ident-name-method-def-this-escaped.js b/js/src/tests/test262/language/statements/class/ident-name-method-def-this-escaped.js new file mode 100644 index 0000000000..073901ff5d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/ident-name-method-def-this-escaped.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/this-escaped.case +// - src/identifier-names/default/class-statement-method-def.template +/*--- +description: this is a valid identifier name, using escape (MethodDefinition) +esid: prod-PropertyDefinition +features: [class] +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + MethodDefinition + ... + + MethodDefinition: + PropertyName ( UniqueFormalParameters ){ FunctionBody } + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. + +---*/ + + +class C { + th\u0069s() { return 42; } +} + +var obj = new C(); + +assert.sameValue(obj['this'](), 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/ident-name-method-def-throw-escaped.js b/js/src/tests/test262/language/statements/class/ident-name-method-def-throw-escaped.js new file mode 100644 index 0000000000..bbf8d8acd8 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/ident-name-method-def-throw-escaped.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/throw-escaped.case +// - src/identifier-names/default/class-statement-method-def.template +/*--- +description: throw is a valid identifier name, using escape (MethodDefinition) +esid: prod-PropertyDefinition +features: [class] +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + MethodDefinition + ... + + MethodDefinition: + PropertyName ( UniqueFormalParameters ){ FunctionBody } + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. + +---*/ + + +class C { + t\u0068row() { return 42; } +} + +var obj = new C(); + +assert.sameValue(obj['throw'](), 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/ident-name-method-def-try-escaped.js b/js/src/tests/test262/language/statements/class/ident-name-method-def-try-escaped.js new file mode 100644 index 0000000000..0187eb665d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/ident-name-method-def-try-escaped.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/try-escaped.case +// - src/identifier-names/default/class-statement-method-def.template +/*--- +description: try is a valid identifier name, using escape (MethodDefinition) +esid: prod-PropertyDefinition +features: [class] +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + MethodDefinition + ... + + MethodDefinition: + PropertyName ( UniqueFormalParameters ){ FunctionBody } + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. + +---*/ + + +class C { + tr\u0079() { return 42; } +} + +var obj = new C(); + +assert.sameValue(obj['try'](), 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/ident-name-method-def-typeof-escaped.js b/js/src/tests/test262/language/statements/class/ident-name-method-def-typeof-escaped.js new file mode 100644 index 0000000000..10bf1065f8 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/ident-name-method-def-typeof-escaped.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/typeof-escaped.case +// - src/identifier-names/default/class-statement-method-def.template +/*--- +description: typeof is a valid identifier name, using escape (MethodDefinition) +esid: prod-PropertyDefinition +features: [class] +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + MethodDefinition + ... + + MethodDefinition: + PropertyName ( UniqueFormalParameters ){ FunctionBody } + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. + +---*/ + + +class C { + typ\u0065of() { return 42; } +} + +var obj = new C(); + +assert.sameValue(obj['typeof'](), 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/ident-name-method-def-var-escaped.js b/js/src/tests/test262/language/statements/class/ident-name-method-def-var-escaped.js new file mode 100644 index 0000000000..5cb915a3e1 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/ident-name-method-def-var-escaped.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/var-escaped.case +// - src/identifier-names/default/class-statement-method-def.template +/*--- +description: var is a valid identifier name, using escape (MethodDefinition) +esid: prod-PropertyDefinition +features: [class] +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + MethodDefinition + ... + + MethodDefinition: + PropertyName ( UniqueFormalParameters ){ FunctionBody } + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. + +---*/ + + +class C { + v\u0061r() { return 42; } +} + +var obj = new C(); + +assert.sameValue(obj['var'](), 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/ident-name-method-def-void-escaped.js b/js/src/tests/test262/language/statements/class/ident-name-method-def-void-escaped.js new file mode 100644 index 0000000000..a290a9dd88 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/ident-name-method-def-void-escaped.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/void-escaped.case +// - src/identifier-names/default/class-statement-method-def.template +/*--- +description: void is a valid identifier name, using escape (MethodDefinition) +esid: prod-PropertyDefinition +features: [class] +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + MethodDefinition + ... + + MethodDefinition: + PropertyName ( UniqueFormalParameters ){ FunctionBody } + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. + +---*/ + + +class C { + voi\u0064() { return 42; } +} + +var obj = new C(); + +assert.sameValue(obj['void'](), 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/ident-name-method-def-while-escaped.js b/js/src/tests/test262/language/statements/class/ident-name-method-def-while-escaped.js new file mode 100644 index 0000000000..cfde8f919a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/ident-name-method-def-while-escaped.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/while-escaped.case +// - src/identifier-names/default/class-statement-method-def.template +/*--- +description: while is a valid identifier name, using escape (MethodDefinition) +esid: prod-PropertyDefinition +features: [class] +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + MethodDefinition + ... + + MethodDefinition: + PropertyName ( UniqueFormalParameters ){ FunctionBody } + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. + +---*/ + + +class C { + whil\u0065() { return 42; } +} + +var obj = new C(); + +assert.sameValue(obj['while'](), 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/ident-name-method-def-with-escaped.js b/js/src/tests/test262/language/statements/class/ident-name-method-def-with-escaped.js new file mode 100644 index 0000000000..07309d0177 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/ident-name-method-def-with-escaped.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/identifier-names/with-escaped.case +// - src/identifier-names/default/class-statement-method-def.template +/*--- +description: with is a valid identifier name, using escape (MethodDefinition) +esid: prod-PropertyDefinition +features: [class] +flags: [generated] +info: | + ObjectLiteral : + { PropertyDefinitionList } + { PropertyDefinitionList , } + + PropertyDefinitionList: + PropertyDefinition + PropertyDefinitionList , PropertyDefinition + + PropertyDefinition: + MethodDefinition + ... + + MethodDefinition: + PropertyName ( UniqueFormalParameters ){ FunctionBody } + + PropertyName: + LiteralPropertyName + ... + + LiteralPropertyName: + IdentifierName + ... + + Reserved Words + + A reserved word is an IdentifierName that cannot be used as an Identifier. + +---*/ + + +class C { + w\u0069th() { return 42; } +} + +var obj = new C(); + +assert.sameValue(obj['with'](), 42, 'property exists'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/method-length-dflt.js b/js/src/tests/test262/language/statements/class/method-length-dflt.js new file mode 100644 index 0000000000..c57f8a2236 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/method-length-dflt.js @@ -0,0 +1,69 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.1.6 +description: > + Default parameters' effect on function length +info: | + Function length is counted by the non initialized parameters in the left. + + 9.2.4 FunctionInitialize (F, kind, ParameterList, Body, Scope) + + [...] + 2. Let len be the ExpectedArgumentCount of ParameterList. + 3. Perform ! DefinePropertyOrThrow(F, "length", PropertyDescriptor{[[Value]]: + len, [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true}). + [...] + + FormalsList : FormalParameter + + 1. If HasInitializer of FormalParameter is true return 0 + 2. Return 1. + + FormalsList : FormalsList , FormalParameter + + 1. Let count be the ExpectedArgumentCount of FormalsList. + 2. If HasInitializer of FormalsList is true or HasInitializer of + FormalParameter is true, return count. + 3. Return count+1. +features: [default-parameters] +includes: [propertyHelper.js] +---*/ + +class C1 { m(x = 42) {} } + +var m1 = C1.prototype.m; + +assert.sameValue(m1.length, 0, 'formalslist: x = 42'); +verifyNotEnumerable(m1, 'length'); +verifyNotWritable(m1, 'length'); +verifyConfigurable(m1, 'length'); + +class C2 { m(x = 42, y) {} } + +var m2 = C2.prototype.m; + +assert.sameValue(m2.length, 0, 'formalslist: x = 42, y'); +verifyNotEnumerable(m2, 'length'); +verifyNotWritable(m2, 'length'); +verifyConfigurable(m2, 'length'); + +class C3 { m(x, y = 42) {} } + +var m3 = C3.prototype.m; + +assert.sameValue(m3.length, 1, 'formalslist: x, y = 42'); +verifyNotEnumerable(m3, 'length'); +verifyNotWritable(m3, 'length'); +verifyConfigurable(m3, 'length'); + +class C4 { m(x, y = 42, z) {} } + +var m4 = C4.prototype.m; + +assert.sameValue(m4.length, 1, 'formalslist: x, y = 42, z'); +verifyNotEnumerable(m4, 'length'); +verifyNotWritable(m4, 'length'); +verifyConfigurable(m4, 'length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/method-param-yield.js b/js/src/tests/test262/language/statements/class/method-param-yield.js new file mode 100644 index 0000000000..a6caac76cb --- /dev/null +++ b/js/src/tests/test262/language/statements/class/method-param-yield.js @@ -0,0 +1,23 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-method-definitions +es6id: 14.3 +description: > + YieldExpression cannot be used within the FormalParameters of a class method +info: | + MethodDefinition[Yield] : + + PropertyName[?Yield] ( StrictFormalParameters ) { FunctionBody } +features: [generators, default-parameters] +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +class C { + m(x = yield) {} +} diff --git a/js/src/tests/test262/language/statements/class/method-static/array-destructuring-param-strict-body.js b/js/src/tests/test262/language/statements/class/method-static/array-destructuring-param-strict-body.js new file mode 100644 index 0000000000..9f515ac743 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/method-static/array-destructuring-param-strict-body.js @@ -0,0 +1,154 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/function-forms/array-destructuring-param-strict-body.case +// - src/function-forms/syntax/cls-decl-meth-static.template +/*--- +description: ArrayBindingPattern and Use Strict Directive are not allowed to coexist for the same function. (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [rest-parameters] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.4 Static Semantics: IsSimpleParameterList + + BindingElement : BindingPattern + + 1. Return false. + + 14.1.2 Static Semantics: Early Errors + + FunctionDeclaration : function BindingIdentifier ( FormalParameters ) { FunctionBody } + FunctionDeclaration : function ( FormalParameters ) { FunctionBody } + FunctionExpression : function BindingIdentifier ( FormalParameters ) { FunctionBody } + + - It is a Syntax Error if ContainsUseStrict of FunctionBody is true and + IsSimpleParameterList of FormalParameters is false. + + 14.2.1 Static Semantics: Early Errors + + ArrowFunction : ArrowParameters => ConciseBody + + - It is a Syntax Error if ContainsUseStrict of ConciseBody is true and + IsSimpleParameterList of ArrowParameters is false. + + 14.3.1 Static Semantics: Early Errors + + MethodDefinition : PropertyName ( UniqueFormalParameters ) { FunctionBody } + + - It is a Syntax Error if ContainsUseStrict of FunctionBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + MethodDefinition : set PropertyName ( PropertySetParameterList ) { FunctionBody } + + - It is a Syntax Error if ContainsUseStrict of FunctionBody is true and + IsSimpleParameterList of PropertySetParameterList is false. + + 14.4.1 Static Semantics: Early Errors + + GeneratorMethod : * PropertyName ( UniqueFormalParameters ) { GeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of GeneratorBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + GeneratorDeclaration : function * BindingIdentifier ( FormalParameters ) { GeneratorBody } + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + GeneratorExpression : function * BindingIdentifier ( FormalParameters ) { GeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of GeneratorBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + 14.5.1 Static Semantics: Early Errors + + AsyncGeneratorMethod : async * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncGeneratorBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + AsyncGeneratorDeclaration : async function * BindingIdentifier ( FormalParameters ) { AsyncGeneratorBody } + AsyncGeneratorDeclaration : async function * ( FormalParameters ) { AsyncGeneratorBody } + AsyncGeneratorExpression : async function * BindingIdentifier ( FormalParameters ) { AsyncGeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncGeneratorBody is true and + IsSimpleParameterList of FormalParameters is false. + + 14.7.1 Static Semantics: Early Errors + + AsyncMethod : async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncFunctionBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + AsyncFunctionDeclaration : async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody } + AsyncFunctionDeclaration : async function ( FormalParameters ) { AsyncFunctionBody } + AsyncFunctionExpression : async function ( FormalParameters ) { AsyncFunctionBody } + AsyncFunctionExpression : async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncFunctionBody is true and + IsSimpleParameterList of FormalParameters is false. + + 14.8.1 Static Semantics: Early Errors + + AsyncArrowFunction : CoverCallExpressionAndAsyncArrowHead => AsyncConciseBody + + - It is a Syntax Error if ContainsUseStrict of AsyncConciseBody is true and + IsSimpleParameterList of CoverCallExpressionAndAsyncArrowHead is false. + +---*/ +$DONOTEVALUATE(); + +class C { + static method([element]) { + "use strict"; + } +} diff --git a/js/src/tests/test262/language/statements/class/method-static/browser.js b/js/src/tests/test262/language/statements/class/method-static/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/method-static/dflt-params-abrupt.js b/js/src/tests/test262/language/statements/class/method-static/dflt-params-abrupt.js new file mode 100644 index 0000000000..92e9bba807 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/method-static/dflt-params-abrupt.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-abrupt.case +// - src/function-forms/error/cls-decl-meth-static.template +/*--- +description: Abrupt completion returned by evaluation of initializer (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. + +---*/ + +var callCount = 0; +class C { + static method(_ = (function() { throw new Test262Error(); }())) { + + callCount = callCount + 1; + } +} + +assert.throws(Test262Error, function() { + C.method(); +}); +assert.sameValue(callCount, 0, 'method body not evaluated'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/method-static/dflt-params-arg-val-not-undefined.js b/js/src/tests/test262/language/statements/class/method-static/dflt-params-arg-val-not-undefined.js new file mode 100644 index 0000000000..6847bb534e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/method-static/dflt-params-arg-val-not-undefined.js @@ -0,0 +1,109 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-arg-val-not-undefined.case +// - src/function-forms/default/cls-decl-meth-static.template +/*--- +description: Use of initializer when argument value is not `undefined` (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + [...] + 23. Let iteratorRecord be Record {[[Iterator]]: + CreateListIterator(argumentsList), [[Done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + a. Perform ? IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + +---*/ +var obj = {}; +var falseCount = 0; +var stringCount = 0; +var nanCount = 0; +var zeroCount = 0; +var nullCount = 0; +var objCount = 0; + +var callCount = 0; +class C { + static method(aFalse = falseCount +=1, aString = stringCount += 1, aNaN = nanCount += 1, a0 = zeroCount += 1, aNull = nullCount += 1, aObj = objCount +=1) { + assert.sameValue(aFalse, false); + assert.sameValue(aString, ''); + assert.sameValue(aNaN, NaN); + assert.sameValue(a0, 0); + assert.sameValue(aNull, null); + assert.sameValue(aObj, obj); + callCount = callCount + 1; + } +} + +C.method(false, '', NaN, 0, null, obj); + +// Stores a reference `ref` for case evaluation +var ref = C.method; + +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +assert.sameValue(falseCount, 0, 'initializer not evaluated: false'); +assert.sameValue(stringCount, 0, 'initializer not evaluated: string'); +assert.sameValue(nanCount, 0, 'initializer not evaluated: NaN'); +assert.sameValue(zeroCount, 0, 'initializer not evaluated: 0'); +assert.sameValue(nullCount, 0, 'initializer not evaluated: null'); +assert.sameValue(objCount, 0, 'initializer not evaluated: object'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/method-static/dflt-params-arg-val-undefined.js b/js/src/tests/test262/language/statements/class/method-static/dflt-params-arg-val-undefined.js new file mode 100644 index 0000000000..802862c01f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/method-static/dflt-params-arg-val-undefined.js @@ -0,0 +1,92 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-arg-val-undefined.case +// - src/function-forms/default/cls-decl-meth-static.template +/*--- +description: Use of initializer when argument value is `undefined` (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + [...] + 23. Let iteratorRecord be Record {[[Iterator]]: + CreateListIterator(argumentsList), [[Done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + a. Perform ? IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + +---*/ + +var callCount = 0; +class C { + static method(fromLiteral = 23, fromExpr = 45, fromHole = 99) { + assert.sameValue(fromLiteral, 23); + assert.sameValue(fromExpr, 45); + assert.sameValue(fromHole, 99); + callCount = callCount + 1; + } +} + +C.method(undefined, void 0); + +// Stores a reference `ref` for case evaluation +var ref = C.method; + +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/method-static/dflt-params-duplicates.js b/js/src/tests/test262/language/statements/class/method-static/dflt-params-duplicates.js new file mode 100644 index 0000000000..8c4b05c71a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/method-static/dflt-params-duplicates.js @@ -0,0 +1,83 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-duplicates.case +// - src/function-forms/syntax/cls-decl-meth-static.template +/*--- +description: It is a Syntax Error if BoundNames of FormalParameters contains any duplicate elements. (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [default-parameters] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.2 Static Semantics: Early Errors + + StrictFormalParameters : FormalParameters + + - It is a Syntax Error if BoundNames of FormalParameters contains any + duplicate elements. + + FormalParameters : FormalParameterList + + - It is a Syntax Error if IsSimpleParameterList of FormalParameterList is + false and BoundNames of FormalParameterList contains any duplicate + elements. + +---*/ +$DONOTEVALUATE(); + +class C { + static method(x = 0, x) { + + } +} diff --git a/js/src/tests/test262/language/statements/class/method-static/dflt-params-ref-later.js b/js/src/tests/test262/language/statements/class/method-static/dflt-params-ref-later.js new file mode 100644 index 0000000000..b4fa9f3992 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/method-static/dflt-params-ref-later.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-ref-later.case +// - src/function-forms/error/cls-decl-meth-static.template +/*--- +description: Referencing a parameter that occurs later in the ParameterList (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. + +---*/ +var x = 0; + +var callCount = 0; +class C { + static method(x = y, y) { + + callCount = callCount + 1; + } +} + +assert.throws(ReferenceError, function() { + C.method(); +}); +assert.sameValue(callCount, 0, 'method body not evaluated'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/method-static/dflt-params-ref-prior.js b/js/src/tests/test262/language/statements/class/method-static/dflt-params-ref-prior.js new file mode 100644 index 0000000000..7ba959125a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/method-static/dflt-params-ref-prior.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-ref-prior.case +// - src/function-forms/default/cls-decl-meth-static.template +/*--- +description: Referencing a parameter that occurs earlier in the ParameterList (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. + +---*/ +var x = 0; + +var callCount = 0; +class C { + static method(x, y = x, z = y) { + assert.sameValue(x, 3, 'first argument value'); + assert.sameValue(y, 3, 'second argument value'); + assert.sameValue(z, 3, 'third argument value'); + callCount = callCount + 1; + } +} + +C.method(3); + +// Stores a reference `ref` for case evaluation +var ref = C.method; + +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/method-static/dflt-params-ref-self.js b/js/src/tests/test262/language/statements/class/method-static/dflt-params-ref-self.js new file mode 100644 index 0000000000..42013042ff --- /dev/null +++ b/js/src/tests/test262/language/statements/class/method-static/dflt-params-ref-self.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-ref-self.case +// - src/function-forms/error/cls-decl-meth-static.template +/*--- +description: Referencing a parameter from within its own initializer (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. + +---*/ +var x = 0; + +var callCount = 0; +class C { + static method(x = x) { + + callCount = callCount + 1; + } +} + +assert.throws(ReferenceError, function() { + C.method(); +}); +assert.sameValue(callCount, 0, 'method body not evaluated'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/method-static/dflt-params-rest.js b/js/src/tests/test262/language/statements/class/method-static/dflt-params-rest.js new file mode 100644 index 0000000000..a7841ccd90 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/method-static/dflt-params-rest.js @@ -0,0 +1,87 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-rest.case +// - src/function-forms/syntax/cls-decl-meth-static.template +/*--- +description: RestParameter does not support an initializer (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [default-parameters] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1 Function Definitions + + Syntax + + FunctionRestParameter[Yield] : + + BindingRestElement[?Yield] + + 13.3.3 Destructuring Binding Patterns + + Syntax + + BindingRestElement[Yield] : + + ...BindingIdentifier[?Yield] + ...BindingPattern[?Yield] + +---*/ +$DONOTEVALUATE(); + +class C { + static method(...x = []) { + + } +} diff --git a/js/src/tests/test262/language/statements/class/method-static/dflt-params-trailing-comma.js b/js/src/tests/test262/language/statements/class/method-static/dflt-params-trailing-comma.js new file mode 100644 index 0000000000..c8c78c68c7 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/method-static/dflt-params-trailing-comma.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-trailing-comma.case +// - src/function-forms/default/cls-decl-meth-static.template +/*--- +description: A trailing comma should not increase the respective length, using default parameters (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Trailing comma in the parameters list + + 14.1 Function Definitions + + FormalParameters[Yield, Await] : FormalParameterList[?Yield, ?Await] , +---*/ + +var callCount = 0; +class C { + static method(a, b = 39,) { + assert.sameValue(a, 42); + assert.sameValue(b, 39); + callCount = callCount + 1; + } +} + +C.method(42, undefined, 1); + +// Stores a reference `ref` for case evaluation +var ref = C.method; + +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +assert.sameValue(ref.length, 1, 'length is properly set'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/method-static/forbidden-ext/b1/browser.js b/js/src/tests/test262/language/statements/class/method-static/forbidden-ext/b1/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/method-static/forbidden-ext/b1/cls-decl-meth-static-forbidden-ext-direct-access-prop-arguments.js b/js/src/tests/test262/language/statements/class/method-static/forbidden-ext/b1/cls-decl-meth-static-forbidden-ext-direct-access-prop-arguments.js new file mode 100644 index 0000000000..4b4d3b0078 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/method-static/forbidden-ext/b1/cls-decl-meth-static-forbidden-ext-direct-access-prop-arguments.js @@ -0,0 +1,37 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/forbidden-ext-direct-access-prop-arguments.case +// - src/function-forms/forbidden-extensions/bullet-one/cls-decl-meth-static.template +/*--- +description: Forbidden extension, f.arguments (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class] +flags: [generated, noStrict] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + + ECMAScript function objects defined using syntactic constructors in strict mode code must + not be created with own properties named "caller" or "arguments". Such own properties also + must not be created for function objects defined using an ArrowFunction, MethodDefinition, + GeneratorDeclaration, GeneratorExpression, AsyncGeneratorDeclaration, AsyncGeneratorExpression, + ClassDeclaration, ClassExpression, AsyncFunctionDeclaration, AsyncFunctionExpression, or + AsyncArrowFunction regardless of whether the definition is contained in strict mode code. + Built-in functions, strict functions created using the Function constructor, generator functions + created using the Generator constructor, async functions created using the AsyncFunction + constructor, and functions created using the bind method also must not be created with such own + properties. + +---*/ + +var callCount = 0; +class C { + static method() { + assert.sameValue(this.method.hasOwnProperty("arguments"), false); + callCount++; + } +} + +C.method(); +assert.sameValue(callCount, 1, 'method body evaluated'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/method-static/forbidden-ext/b1/cls-decl-meth-static-forbidden-ext-direct-access-prop-caller.js b/js/src/tests/test262/language/statements/class/method-static/forbidden-ext/b1/cls-decl-meth-static-forbidden-ext-direct-access-prop-caller.js new file mode 100644 index 0000000000..f98dede24d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/method-static/forbidden-ext/b1/cls-decl-meth-static-forbidden-ext-direct-access-prop-caller.js @@ -0,0 +1,37 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/forbidden-ext-direct-access-prop-caller.case +// - src/function-forms/forbidden-extensions/bullet-one/cls-decl-meth-static.template +/*--- +description: Forbidden extension, o.caller (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class] +flags: [generated, noStrict] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + + ECMAScript function objects defined using syntactic constructors in strict mode code must + not be created with own properties named "caller" or "arguments". Such own properties also + must not be created for function objects defined using an ArrowFunction, MethodDefinition, + GeneratorDeclaration, GeneratorExpression, AsyncGeneratorDeclaration, AsyncGeneratorExpression, + ClassDeclaration, ClassExpression, AsyncFunctionDeclaration, AsyncFunctionExpression, or + AsyncArrowFunction regardless of whether the definition is contained in strict mode code. + Built-in functions, strict functions created using the Function constructor, generator functions + created using the Generator constructor, async functions created using the AsyncFunction + constructor, and functions created using the bind method also must not be created with such own + properties. + +---*/ + +var callCount = 0; +class C { + static method() { + assert.sameValue(this.method.hasOwnProperty("caller"), false); + callCount++; + } +} + +C.method(); +assert.sameValue(callCount, 1, 'method body evaluated'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/method-static/forbidden-ext/b1/shell.js b/js/src/tests/test262/language/statements/class/method-static/forbidden-ext/b1/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/method-static/forbidden-ext/b2/browser.js b/js/src/tests/test262/language/statements/class/method-static/forbidden-ext/b2/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/method-static/forbidden-ext/b2/cls-decl-meth-static-forbidden-ext-indirect-access-own-prop-caller-get.js b/js/src/tests/test262/language/statements/class/method-static/forbidden-ext/b2/cls-decl-meth-static-forbidden-ext-indirect-access-own-prop-caller-get.js new file mode 100644 index 0000000000..9403f1f66b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/method-static/forbidden-ext/b2/cls-decl-meth-static-forbidden-ext-indirect-access-own-prop-caller-get.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/forbidden-ext-indirect-access-own-prop-caller-get.case +// - src/function-forms/forbidden-extensions/bullet-two/cls-decl-meth-static.template +/*--- +description: Forbidden extension, o.caller (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class] +flags: [generated, noStrict] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + + If an implementation extends any function object with an own property named "caller" the value of + that property, as observed using [[Get]] or [[GetOwnProperty]], must not be a strict function + object. If it is an accessor property, the function that is the value of the property's [[Get]] + attribute must never return a strict function when called. + +---*/ +var CALLER_OWN_PROPERTY_DOES_NOT_EXIST = Symbol(); +function inner() { + // This property may exist, but is forbidden from having a value that is a strict function object + return inner.hasOwnProperty("caller") + ? inner.caller + : CALLER_OWN_PROPERTY_DOES_NOT_EXIST; +} + +var callCount = 0; +class C { + static method() { + /* implicit strict */ + // This and the following conditional value is set in the test's .case file. + // For every test that has a "true" value here, there is a + // corresponding test that has a "false" value here. + // They are generated from two different case files, which use + let descriptor = Object.getOwnPropertyDescriptor(inner, "caller"); + if (descriptor && descriptor.configurable && true) { + Object.defineProperty(inner, "caller", {get(){return 1}}); + } + var result = inner(); + if (descriptor && descriptor.configurable && true) { + assert.sameValue(result, 1, 'If this test defined an own "caller" property on the inner function, then it should be accessible and should return the value it was set to.'); + } + + // "CALLER_OWN_PROPERTY_DOES_NOT_EXIST" is from + // forbidden-ext-indirect-access-prop-caller.case + // + // If the function object "inner" has an own property + // named "caller", then its value will be returned. + // + // If the function object "inner" DOES NOT have an + // own property named "caller", then the symbol + // CALLER_OWN_PROPERTY_DOES_NOT_EXIST will be returned. + if (result !== CALLER_OWN_PROPERTY_DOES_NOT_EXIST) { + assert.notSameValue(result, this.method); + } + callCount++; + } +} + +C.method(); +assert.sameValue(callCount, 1, 'method body evaluated'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/method-static/forbidden-ext/b2/cls-decl-meth-static-forbidden-ext-indirect-access-own-prop-caller-value.js b/js/src/tests/test262/language/statements/class/method-static/forbidden-ext/b2/cls-decl-meth-static-forbidden-ext-indirect-access-own-prop-caller-value.js new file mode 100644 index 0000000000..177e2303d1 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/method-static/forbidden-ext/b2/cls-decl-meth-static-forbidden-ext-indirect-access-own-prop-caller-value.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/forbidden-ext-indirect-access-own-prop-caller-value.case +// - src/function-forms/forbidden-extensions/bullet-two/cls-decl-meth-static.template +/*--- +description: Forbidden extension, o.caller (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class] +flags: [generated, noStrict] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + + If an implementation extends any function object with an own property named "caller" the value of + that property, as observed using [[Get]] or [[GetOwnProperty]], must not be a strict function + object. If it is an accessor property, the function that is the value of the property's [[Get]] + attribute must never return a strict function when called. + +---*/ +var CALLER_OWN_PROPERTY_DOES_NOT_EXIST = Symbol(); +function inner() { + // This property may exist, but is forbidden from having a value that is a strict function object + return inner.hasOwnProperty("caller") + ? inner.caller + : CALLER_OWN_PROPERTY_DOES_NOT_EXIST; +} + +var callCount = 0; +class C { + static method() { + /* implicit strict */ + // This and the following conditional value is set in the test's .case file. + // For every test that has a "true" value here, there is a + // corresponding test that has a "false" value here. + // They are generated from two different case files, which use + let descriptor = Object.getOwnPropertyDescriptor(inner, "caller"); + if (descriptor && descriptor.configurable && true) { + Object.defineProperty(inner, "caller", {value: 1}); + } + var result = inner(); + if (descriptor && descriptor.configurable && true) { + assert.sameValue(result, 1, 'If this test defined an own "caller" property on the inner function, then it should be accessible and should return the value it was set to.'); + } + + // "CALLER_OWN_PROPERTY_DOES_NOT_EXIST" is from + // forbidden-ext-indirect-access-prop-caller.case + // + // If the function object "inner" has an own property + // named "caller", then its value will be returned. + // + // If the function object "inner" DOES NOT have an + // own property named "caller", then the symbol + // CALLER_OWN_PROPERTY_DOES_NOT_EXIST will be returned. + if (result !== CALLER_OWN_PROPERTY_DOES_NOT_EXIST) { + assert.notSameValue(result, this.method); + } + callCount++; + } +} + +C.method(); +assert.sameValue(callCount, 1, 'method body evaluated'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/method-static/forbidden-ext/b2/cls-decl-meth-static-forbidden-ext-indirect-access-prop-caller.js b/js/src/tests/test262/language/statements/class/method-static/forbidden-ext/b2/cls-decl-meth-static-forbidden-ext-indirect-access-prop-caller.js new file mode 100644 index 0000000000..8331dceed3 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/method-static/forbidden-ext/b2/cls-decl-meth-static-forbidden-ext-indirect-access-prop-caller.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/forbidden-ext-indirect-access-prop-caller.case +// - src/function-forms/forbidden-extensions/bullet-two/cls-decl-meth-static.template +/*--- +description: Forbidden extension, o.caller (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class] +flags: [generated, noStrict] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + + If an implementation extends any function object with an own property named "caller" the value of + that property, as observed using [[Get]] or [[GetOwnProperty]], must not be a strict function + object. If it is an accessor property, the function that is the value of the property's [[Get]] + attribute must never return a strict function when called. + +---*/ +var CALLER_OWN_PROPERTY_DOES_NOT_EXIST = Symbol(); +function inner() { + // This property may exist, but is forbidden from having a value that is a strict function object + return inner.hasOwnProperty("caller") + ? inner.caller + : CALLER_OWN_PROPERTY_DOES_NOT_EXIST; +} + +var callCount = 0; +class C { + static method() { + /* implicit strict */ + // This and the following conditional value is set in the test's .case file. + // For every test that has a "true" value here, there is a + // corresponding test that has a "false" value here. + // They are generated from two different case files, which use + let descriptor = Object.getOwnPropertyDescriptor(inner, "caller"); + if (descriptor && descriptor.configurable && false) { + Object.defineProperty(inner, "caller", {}); + } + var result = inner(); + if (descriptor && descriptor.configurable && false) { + assert.sameValue(result, 1, 'If this test defined an own "caller" property on the inner function, then it should be accessible and should return the value it was set to.'); + } + + // "CALLER_OWN_PROPERTY_DOES_NOT_EXIST" is from + // forbidden-ext-indirect-access-prop-caller.case + // + // If the function object "inner" has an own property + // named "caller", then its value will be returned. + // + // If the function object "inner" DOES NOT have an + // own property named "caller", then the symbol + // CALLER_OWN_PROPERTY_DOES_NOT_EXIST will be returned. + if (result !== CALLER_OWN_PROPERTY_DOES_NOT_EXIST) { + assert.notSameValue(result, this.method); + } + callCount++; + } +} + +C.method(); +assert.sameValue(callCount, 1, 'method body evaluated'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/method-static/forbidden-ext/b2/shell.js b/js/src/tests/test262/language/statements/class/method-static/forbidden-ext/b2/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/method-static/forbidden-ext/browser.js b/js/src/tests/test262/language/statements/class/method-static/forbidden-ext/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/method-static/forbidden-ext/shell.js b/js/src/tests/test262/language/statements/class/method-static/forbidden-ext/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/method-static/object-destructuring-param-strict-body.js b/js/src/tests/test262/language/statements/class/method-static/object-destructuring-param-strict-body.js new file mode 100644 index 0000000000..0719ae9c12 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/method-static/object-destructuring-param-strict-body.js @@ -0,0 +1,154 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/function-forms/object-destructuring-param-strict-body.case +// - src/function-forms/syntax/cls-decl-meth-static.template +/*--- +description: ObjectBindingPattern and Use Strict Directive are not allowed to coexist for the same function. (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [rest-parameters] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.4 Static Semantics: IsSimpleParameterList + + BindingElement : BindingPattern + + 1. Return false. + + 14.1.2 Static Semantics: Early Errors + + FunctionDeclaration : function BindingIdentifier ( FormalParameters ) { FunctionBody } + FunctionDeclaration : function ( FormalParameters ) { FunctionBody } + FunctionExpression : function BindingIdentifier ( FormalParameters ) { FunctionBody } + + - It is a Syntax Error if ContainsUseStrict of FunctionBody is true and + IsSimpleParameterList of FormalParameters is false. + + 14.2.1 Static Semantics: Early Errors + + ArrowFunction : ArrowParameters => ConciseBody + + - It is a Syntax Error if ContainsUseStrict of ConciseBody is true and + IsSimpleParameterList of ArrowParameters is false. + + 14.3.1 Static Semantics: Early Errors + + MethodDefinition : PropertyName ( UniqueFormalParameters ) { FunctionBody } + + - It is a Syntax Error if ContainsUseStrict of FunctionBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + MethodDefinition : set PropertyName ( PropertySetParameterList ) { FunctionBody } + + - It is a Syntax Error if ContainsUseStrict of FunctionBody is true and + IsSimpleParameterList of PropertySetParameterList is false. + + 14.4.1 Static Semantics: Early Errors + + GeneratorMethod : * PropertyName ( UniqueFormalParameters ) { GeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of GeneratorBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + GeneratorDeclaration : function * BindingIdentifier ( FormalParameters ) { GeneratorBody } + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + GeneratorExpression : function * BindingIdentifier ( FormalParameters ) { GeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of GeneratorBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + 14.5.1 Static Semantics: Early Errors + + AsyncGeneratorMethod : async * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncGeneratorBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + AsyncGeneratorDeclaration : async function * BindingIdentifier ( FormalParameters ) { AsyncGeneratorBody } + AsyncGeneratorDeclaration : async function * ( FormalParameters ) { AsyncGeneratorBody } + AsyncGeneratorExpression : async function * BindingIdentifier ( FormalParameters ) { AsyncGeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncGeneratorBody is true and + IsSimpleParameterList of FormalParameters is false. + + 14.7.1 Static Semantics: Early Errors + + AsyncMethod : async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncFunctionBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + AsyncFunctionDeclaration : async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody } + AsyncFunctionDeclaration : async function ( FormalParameters ) { AsyncFunctionBody } + AsyncFunctionExpression : async function ( FormalParameters ) { AsyncFunctionBody } + AsyncFunctionExpression : async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncFunctionBody is true and + IsSimpleParameterList of FormalParameters is false. + + 14.8.1 Static Semantics: Early Errors + + AsyncArrowFunction : CoverCallExpressionAndAsyncArrowHead => AsyncConciseBody + + - It is a Syntax Error if ContainsUseStrict of AsyncConciseBody is true and + IsSimpleParameterList of CoverCallExpressionAndAsyncArrowHead is false. + +---*/ +$DONOTEVALUATE(); + +class C { + static method({property}) { + "use strict"; + } +} diff --git a/js/src/tests/test262/language/statements/class/method-static/params-trailing-comma-multiple.js b/js/src/tests/test262/language/statements/class/method-static/params-trailing-comma-multiple.js new file mode 100644 index 0000000000..07792de2ef --- /dev/null +++ b/js/src/tests/test262/language/statements/class/method-static/params-trailing-comma-multiple.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/params-trailing-comma-multiple.case +// - src/function-forms/default/cls-decl-meth-static.template +/*--- +description: A trailing comma should not increase the respective length, using multiple parameters (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Trailing comma in the parameters list + + 14.1 Function Definitions + + FormalParameters[Yield, Await] : FormalParameterList[?Yield, ?Await] , +---*/ + +var callCount = 0; +class C { + static method(a, b,) { + assert.sameValue(a, 42); + assert.sameValue(b, 39); + callCount = callCount + 1; + } +} + +C.method(42, 39, 1); + +// Stores a reference `ref` for case evaluation +var ref = C.method; + +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +assert.sameValue(ref.length, 2, 'length is properly set'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/method-static/params-trailing-comma-single.js b/js/src/tests/test262/language/statements/class/method-static/params-trailing-comma-single.js new file mode 100644 index 0000000000..0e9e5914d6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/method-static/params-trailing-comma-single.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/params-trailing-comma-single.case +// - src/function-forms/default/cls-decl-meth-static.template +/*--- +description: A trailing comma should not increase the respective length, using a single parameter (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Trailing comma in the parameters list + + 14.1 Function Definitions + + FormalParameters[Yield, Await] : FormalParameterList[?Yield, ?Await] , +---*/ + +var callCount = 0; +class C { + static method(a,) { + assert.sameValue(a, 42); + callCount = callCount + 1; + } +} + +C.method(42, 39); + +// Stores a reference `ref` for case evaluation +var ref = C.method; + +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +assert.sameValue(ref.length, 1, 'length is properly set'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/method-static/rest-param-strict-body.js b/js/src/tests/test262/language/statements/class/method-static/rest-param-strict-body.js new file mode 100644 index 0000000000..f3557563c6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/method-static/rest-param-strict-body.js @@ -0,0 +1,154 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/function-forms/rest-param-strict-body.case +// - src/function-forms/syntax/cls-decl-meth-static.template +/*--- +description: RestParameter and Use Strict Directive are not allowed to coexist for the same function. (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [rest-parameters] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.13 Static Semantics: IsSimpleParameterList + + FormalParameters : FormalParameterList , FunctionRestParameter + + 1. Return false. + + 14.1.2 Static Semantics: Early Errors + + FunctionDeclaration : function BindingIdentifier ( FormalParameters ) { FunctionBody } + FunctionDeclaration : function ( FormalParameters ) { FunctionBody } + FunctionExpression : function BindingIdentifier ( FormalParameters ) { FunctionBody } + + - It is a Syntax Error if ContainsUseStrict of FunctionBody is true and + IsSimpleParameterList of FormalParameters is false. + + 14.2.1 Static Semantics: Early Errors + + ArrowFunction : ArrowParameters => ConciseBody + + - It is a Syntax Error if ContainsUseStrict of ConciseBody is true and + IsSimpleParameterList of ArrowParameters is false. + + 14.3.1 Static Semantics: Early Errors + + MethodDefinition : PropertyName ( UniqueFormalParameters ) { FunctionBody } + + - It is a Syntax Error if ContainsUseStrict of FunctionBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + MethodDefinition : set PropertyName ( PropertySetParameterList ) { FunctionBody } + + - It is a Syntax Error if ContainsUseStrict of FunctionBody is true and + IsSimpleParameterList of PropertySetParameterList is false. + + 14.4.1 Static Semantics: Early Errors + + GeneratorMethod : * PropertyName ( UniqueFormalParameters ) { GeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of GeneratorBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + GeneratorDeclaration : function * BindingIdentifier ( FormalParameters ) { GeneratorBody } + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + GeneratorExpression : function * BindingIdentifier ( FormalParameters ) { GeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of GeneratorBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + 14.5.1 Static Semantics: Early Errors + + AsyncGeneratorMethod : async * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncGeneratorBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + AsyncGeneratorDeclaration : async function * BindingIdentifier ( FormalParameters ) { AsyncGeneratorBody } + AsyncGeneratorDeclaration : async function * ( FormalParameters ) { AsyncGeneratorBody } + AsyncGeneratorExpression : async function * BindingIdentifier ( FormalParameters ) { AsyncGeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncGeneratorBody is true and + IsSimpleParameterList of FormalParameters is false. + + 14.7.1 Static Semantics: Early Errors + + AsyncMethod : async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncFunctionBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + AsyncFunctionDeclaration : async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody } + AsyncFunctionDeclaration : async function ( FormalParameters ) { AsyncFunctionBody } + AsyncFunctionExpression : async function ( FormalParameters ) { AsyncFunctionBody } + AsyncFunctionExpression : async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncFunctionBody is true and + IsSimpleParameterList of FormalParameters is false. + + 14.8.1 Static Semantics: Early Errors + + AsyncArrowFunction : CoverCallExpressionAndAsyncArrowHead => AsyncConciseBody + + - It is a Syntax Error if ContainsUseStrict of AsyncConciseBody is true and + IsSimpleParameterList of CoverCallExpressionAndAsyncArrowHead is false. + +---*/ +$DONOTEVALUATE(); + +class C { + static method(a,...rest) { + "use strict"; + } +} diff --git a/js/src/tests/test262/language/statements/class/method-static/rest-params-trailing-comma-early-error.js b/js/src/tests/test262/language/statements/class/method-static/rest-params-trailing-comma-early-error.js new file mode 100644 index 0000000000..4dafdc9681 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/method-static/rest-params-trailing-comma-early-error.js @@ -0,0 +1,79 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/function-forms/rest-params-trailing-comma-early-error.case +// - src/function-forms/syntax/cls-decl-meth-static.template +/*--- +description: It's a syntax error if a FunctionRestParameter is followed by a trailing comma (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Trailing comma in the parameters list + + 14.1 Function Definitions + + FormalParameters[Yield, Await] : + [empty] + FunctionRestParameter[?Yield, ?Await] + FormalParameterList[?Yield, ?Await] + FormalParameterList[?Yield, ?Await] , + FormalParameterList[?Yield, ?Await] , FunctionRestParameter[?Yield, ?Await] +---*/ +$DONOTEVALUATE(); + +class C { + static method(...a,) { + + } +} diff --git a/js/src/tests/test262/language/statements/class/method-static/shell.js b/js/src/tests/test262/language/statements/class/method-static/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/method/array-destructuring-param-strict-body.js b/js/src/tests/test262/language/statements/class/method/array-destructuring-param-strict-body.js new file mode 100644 index 0000000000..ec50f6f725 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/method/array-destructuring-param-strict-body.js @@ -0,0 +1,154 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/function-forms/array-destructuring-param-strict-body.case +// - src/function-forms/syntax/cls-decl-meth.template +/*--- +description: ArrayBindingPattern and Use Strict Directive are not allowed to coexist for the same function. (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [rest-parameters] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.4 Static Semantics: IsSimpleParameterList + + BindingElement : BindingPattern + + 1. Return false. + + 14.1.2 Static Semantics: Early Errors + + FunctionDeclaration : function BindingIdentifier ( FormalParameters ) { FunctionBody } + FunctionDeclaration : function ( FormalParameters ) { FunctionBody } + FunctionExpression : function BindingIdentifier ( FormalParameters ) { FunctionBody } + + - It is a Syntax Error if ContainsUseStrict of FunctionBody is true and + IsSimpleParameterList of FormalParameters is false. + + 14.2.1 Static Semantics: Early Errors + + ArrowFunction : ArrowParameters => ConciseBody + + - It is a Syntax Error if ContainsUseStrict of ConciseBody is true and + IsSimpleParameterList of ArrowParameters is false. + + 14.3.1 Static Semantics: Early Errors + + MethodDefinition : PropertyName ( UniqueFormalParameters ) { FunctionBody } + + - It is a Syntax Error if ContainsUseStrict of FunctionBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + MethodDefinition : set PropertyName ( PropertySetParameterList ) { FunctionBody } + + - It is a Syntax Error if ContainsUseStrict of FunctionBody is true and + IsSimpleParameterList of PropertySetParameterList is false. + + 14.4.1 Static Semantics: Early Errors + + GeneratorMethod : * PropertyName ( UniqueFormalParameters ) { GeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of GeneratorBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + GeneratorDeclaration : function * BindingIdentifier ( FormalParameters ) { GeneratorBody } + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + GeneratorExpression : function * BindingIdentifier ( FormalParameters ) { GeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of GeneratorBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + 14.5.1 Static Semantics: Early Errors + + AsyncGeneratorMethod : async * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncGeneratorBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + AsyncGeneratorDeclaration : async function * BindingIdentifier ( FormalParameters ) { AsyncGeneratorBody } + AsyncGeneratorDeclaration : async function * ( FormalParameters ) { AsyncGeneratorBody } + AsyncGeneratorExpression : async function * BindingIdentifier ( FormalParameters ) { AsyncGeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncGeneratorBody is true and + IsSimpleParameterList of FormalParameters is false. + + 14.7.1 Static Semantics: Early Errors + + AsyncMethod : async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncFunctionBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + AsyncFunctionDeclaration : async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody } + AsyncFunctionDeclaration : async function ( FormalParameters ) { AsyncFunctionBody } + AsyncFunctionExpression : async function ( FormalParameters ) { AsyncFunctionBody } + AsyncFunctionExpression : async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncFunctionBody is true and + IsSimpleParameterList of FormalParameters is false. + + 14.8.1 Static Semantics: Early Errors + + AsyncArrowFunction : CoverCallExpressionAndAsyncArrowHead => AsyncConciseBody + + - It is a Syntax Error if ContainsUseStrict of AsyncConciseBody is true and + IsSimpleParameterList of CoverCallExpressionAndAsyncArrowHead is false. + +---*/ +$DONOTEVALUATE(); + +class C { + method([element]) { + "use strict"; + } +} diff --git a/js/src/tests/test262/language/statements/class/method/browser.js b/js/src/tests/test262/language/statements/class/method/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/method/dflt-params-abrupt.js b/js/src/tests/test262/language/statements/class/method/dflt-params-abrupt.js new file mode 100644 index 0000000000..cd6c3a13fc --- /dev/null +++ b/js/src/tests/test262/language/statements/class/method/dflt-params-abrupt.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-abrupt.case +// - src/function-forms/error/cls-decl-meth.template +/*--- +description: Abrupt completion returned by evaluation of initializer (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. + +---*/ + +var callCount = 0; +class C { + method(_ = (function() { throw new Test262Error(); }())) { + + callCount = callCount + 1; + } +} + +assert.throws(Test262Error, function() { + C.prototype.method(); +}); +assert.sameValue(callCount, 0, 'method body not evaluated'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/method/dflt-params-arg-val-not-undefined.js b/js/src/tests/test262/language/statements/class/method/dflt-params-arg-val-not-undefined.js new file mode 100644 index 0000000000..18651a613b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/method/dflt-params-arg-val-not-undefined.js @@ -0,0 +1,109 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-arg-val-not-undefined.case +// - src/function-forms/default/cls-decl-meth.template +/*--- +description: Use of initializer when argument value is not `undefined` (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + [...] + 23. Let iteratorRecord be Record {[[Iterator]]: + CreateListIterator(argumentsList), [[Done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + a. Perform ? IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + +---*/ +var obj = {}; +var falseCount = 0; +var stringCount = 0; +var nanCount = 0; +var zeroCount = 0; +var nullCount = 0; +var objCount = 0; + +var callCount = 0; +class C { + method(aFalse = falseCount +=1, aString = stringCount += 1, aNaN = nanCount += 1, a0 = zeroCount += 1, aNull = nullCount += 1, aObj = objCount +=1) { + assert.sameValue(aFalse, false); + assert.sameValue(aString, ''); + assert.sameValue(aNaN, NaN); + assert.sameValue(a0, 0); + assert.sameValue(aNull, null); + assert.sameValue(aObj, obj); + callCount = callCount + 1; + } +} + +C.prototype.method(false, '', NaN, 0, null, obj); + +// Stores a reference `ref` for case evaluation +var ref = C.prototype.method; + +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +assert.sameValue(falseCount, 0, 'initializer not evaluated: false'); +assert.sameValue(stringCount, 0, 'initializer not evaluated: string'); +assert.sameValue(nanCount, 0, 'initializer not evaluated: NaN'); +assert.sameValue(zeroCount, 0, 'initializer not evaluated: 0'); +assert.sameValue(nullCount, 0, 'initializer not evaluated: null'); +assert.sameValue(objCount, 0, 'initializer not evaluated: object'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/method/dflt-params-arg-val-undefined.js b/js/src/tests/test262/language/statements/class/method/dflt-params-arg-val-undefined.js new file mode 100644 index 0000000000..427e0a2957 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/method/dflt-params-arg-val-undefined.js @@ -0,0 +1,92 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-arg-val-undefined.case +// - src/function-forms/default/cls-decl-meth.template +/*--- +description: Use of initializer when argument value is `undefined` (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + [...] + 23. Let iteratorRecord be Record {[[Iterator]]: + CreateListIterator(argumentsList), [[Done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + a. Perform ? IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + +---*/ + +var callCount = 0; +class C { + method(fromLiteral = 23, fromExpr = 45, fromHole = 99) { + assert.sameValue(fromLiteral, 23); + assert.sameValue(fromExpr, 45); + assert.sameValue(fromHole, 99); + callCount = callCount + 1; + } +} + +C.prototype.method(undefined, void 0); + +// Stores a reference `ref` for case evaluation +var ref = C.prototype.method; + +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/method/dflt-params-duplicates.js b/js/src/tests/test262/language/statements/class/method/dflt-params-duplicates.js new file mode 100644 index 0000000000..7f538556d8 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/method/dflt-params-duplicates.js @@ -0,0 +1,83 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-duplicates.case +// - src/function-forms/syntax/cls-decl-meth.template +/*--- +description: It is a Syntax Error if BoundNames of FormalParameters contains any duplicate elements. (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [default-parameters] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.2 Static Semantics: Early Errors + + StrictFormalParameters : FormalParameters + + - It is a Syntax Error if BoundNames of FormalParameters contains any + duplicate elements. + + FormalParameters : FormalParameterList + + - It is a Syntax Error if IsSimpleParameterList of FormalParameterList is + false and BoundNames of FormalParameterList contains any duplicate + elements. + +---*/ +$DONOTEVALUATE(); + +class C { + method(x = 0, x) { + + } +} diff --git a/js/src/tests/test262/language/statements/class/method/dflt-params-ref-later.js b/js/src/tests/test262/language/statements/class/method/dflt-params-ref-later.js new file mode 100644 index 0000000000..7182c96538 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/method/dflt-params-ref-later.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-ref-later.case +// - src/function-forms/error/cls-decl-meth.template +/*--- +description: Referencing a parameter that occurs later in the ParameterList (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. + +---*/ +var x = 0; + +var callCount = 0; +class C { + method(x = y, y) { + + callCount = callCount + 1; + } +} + +assert.throws(ReferenceError, function() { + C.prototype.method(); +}); +assert.sameValue(callCount, 0, 'method body not evaluated'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/method/dflt-params-ref-prior.js b/js/src/tests/test262/language/statements/class/method/dflt-params-ref-prior.js new file mode 100644 index 0000000000..2318e55d8e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/method/dflt-params-ref-prior.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-ref-prior.case +// - src/function-forms/default/cls-decl-meth.template +/*--- +description: Referencing a parameter that occurs earlier in the ParameterList (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. + +---*/ +var x = 0; + +var callCount = 0; +class C { + method(x, y = x, z = y) { + assert.sameValue(x, 3, 'first argument value'); + assert.sameValue(y, 3, 'second argument value'); + assert.sameValue(z, 3, 'third argument value'); + callCount = callCount + 1; + } +} + +C.prototype.method(3); + +// Stores a reference `ref` for case evaluation +var ref = C.prototype.method; + +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/method/dflt-params-ref-self.js b/js/src/tests/test262/language/statements/class/method/dflt-params-ref-self.js new file mode 100644 index 0000000000..720abe5a79 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/method/dflt-params-ref-self.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-ref-self.case +// - src/function-forms/error/cls-decl-meth.template +/*--- +description: Referencing a parameter from within its own initializer (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [default-parameters] +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. + +---*/ +var x = 0; + +var callCount = 0; +class C { + method(x = x) { + + callCount = callCount + 1; + } +} + +assert.throws(ReferenceError, function() { + C.prototype.method(); +}); +assert.sameValue(callCount, 0, 'method body not evaluated'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/method/dflt-params-rest.js b/js/src/tests/test262/language/statements/class/method/dflt-params-rest.js new file mode 100644 index 0000000000..ad7fad6e70 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/method/dflt-params-rest.js @@ -0,0 +1,87 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-rest.case +// - src/function-forms/syntax/cls-decl-meth.template +/*--- +description: RestParameter does not support an initializer (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [default-parameters] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1 Function Definitions + + Syntax + + FunctionRestParameter[Yield] : + + BindingRestElement[?Yield] + + 13.3.3 Destructuring Binding Patterns + + Syntax + + BindingRestElement[Yield] : + + ...BindingIdentifier[?Yield] + ...BindingPattern[?Yield] + +---*/ +$DONOTEVALUATE(); + +class C { + method(...x = []) { + + } +} diff --git a/js/src/tests/test262/language/statements/class/method/dflt-params-trailing-comma.js b/js/src/tests/test262/language/statements/class/method/dflt-params-trailing-comma.js new file mode 100644 index 0000000000..0a95459ff6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/method/dflt-params-trailing-comma.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/dflt-params-trailing-comma.case +// - src/function-forms/default/cls-decl-meth.template +/*--- +description: A trailing comma should not increase the respective length, using default parameters (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Trailing comma in the parameters list + + 14.1 Function Definitions + + FormalParameters[Yield, Await] : FormalParameterList[?Yield, ?Await] , +---*/ + +var callCount = 0; +class C { + method(a, b = 39,) { + assert.sameValue(a, 42); + assert.sameValue(b, 39); + callCount = callCount + 1; + } +} + +C.prototype.method(42, undefined, 1); + +// Stores a reference `ref` for case evaluation +var ref = C.prototype.method; + +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +assert.sameValue(ref.length, 1, 'length is properly set'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/method/forbidden-ext/b1/browser.js b/js/src/tests/test262/language/statements/class/method/forbidden-ext/b1/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/method/forbidden-ext/b1/cls-decl-meth-forbidden-ext-direct-access-prop-arguments.js b/js/src/tests/test262/language/statements/class/method/forbidden-ext/b1/cls-decl-meth-forbidden-ext-direct-access-prop-arguments.js new file mode 100644 index 0000000000..f5892c457f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/method/forbidden-ext/b1/cls-decl-meth-forbidden-ext-direct-access-prop-arguments.js @@ -0,0 +1,37 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/forbidden-ext-direct-access-prop-arguments.case +// - src/function-forms/forbidden-extensions/bullet-one/cls-decl-meth.template +/*--- +description: Forbidden extension, f.arguments (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class] +flags: [generated, noStrict] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + + ECMAScript function objects defined using syntactic constructors in strict mode code must + not be created with own properties named "caller" or "arguments". Such own properties also + must not be created for function objects defined using an ArrowFunction, MethodDefinition, + GeneratorDeclaration, GeneratorExpression, AsyncGeneratorDeclaration, AsyncGeneratorExpression, + ClassDeclaration, ClassExpression, AsyncFunctionDeclaration, AsyncFunctionExpression, or + AsyncArrowFunction regardless of whether the definition is contained in strict mode code. + Built-in functions, strict functions created using the Function constructor, generator functions + created using the Generator constructor, async functions created using the AsyncFunction + constructor, and functions created using the bind method also must not be created with such own + properties. + +---*/ + +var callCount = 0; +class C { + method() { + assert.sameValue(this.method.hasOwnProperty("arguments"), false); + callCount++; + } +} + +C.prototype.method(); +assert.sameValue(callCount, 1, 'method body evaluated'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/method/forbidden-ext/b1/cls-decl-meth-forbidden-ext-direct-access-prop-caller.js b/js/src/tests/test262/language/statements/class/method/forbidden-ext/b1/cls-decl-meth-forbidden-ext-direct-access-prop-caller.js new file mode 100644 index 0000000000..62f6e9e322 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/method/forbidden-ext/b1/cls-decl-meth-forbidden-ext-direct-access-prop-caller.js @@ -0,0 +1,37 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/forbidden-ext-direct-access-prop-caller.case +// - src/function-forms/forbidden-extensions/bullet-one/cls-decl-meth.template +/*--- +description: Forbidden extension, o.caller (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class] +flags: [generated, noStrict] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + + ECMAScript function objects defined using syntactic constructors in strict mode code must + not be created with own properties named "caller" or "arguments". Such own properties also + must not be created for function objects defined using an ArrowFunction, MethodDefinition, + GeneratorDeclaration, GeneratorExpression, AsyncGeneratorDeclaration, AsyncGeneratorExpression, + ClassDeclaration, ClassExpression, AsyncFunctionDeclaration, AsyncFunctionExpression, or + AsyncArrowFunction regardless of whether the definition is contained in strict mode code. + Built-in functions, strict functions created using the Function constructor, generator functions + created using the Generator constructor, async functions created using the AsyncFunction + constructor, and functions created using the bind method also must not be created with such own + properties. + +---*/ + +var callCount = 0; +class C { + method() { + assert.sameValue(this.method.hasOwnProperty("caller"), false); + callCount++; + } +} + +C.prototype.method(); +assert.sameValue(callCount, 1, 'method body evaluated'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/method/forbidden-ext/b1/shell.js b/js/src/tests/test262/language/statements/class/method/forbidden-ext/b1/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/method/forbidden-ext/b2/browser.js b/js/src/tests/test262/language/statements/class/method/forbidden-ext/b2/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/method/forbidden-ext/b2/cls-decl-meth-forbidden-ext-indirect-access-own-prop-caller-get.js b/js/src/tests/test262/language/statements/class/method/forbidden-ext/b2/cls-decl-meth-forbidden-ext-indirect-access-own-prop-caller-get.js new file mode 100644 index 0000000000..4252206488 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/method/forbidden-ext/b2/cls-decl-meth-forbidden-ext-indirect-access-own-prop-caller-get.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/forbidden-ext-indirect-access-own-prop-caller-get.case +// - src/function-forms/forbidden-extensions/bullet-two/cls-decl-meth.template +/*--- +description: Forbidden extension, o.caller (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class] +flags: [generated, noStrict] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + + If an implementation extends any function object with an own property named "caller" the value of + that property, as observed using [[Get]] or [[GetOwnProperty]], must not be a strict function + object. If it is an accessor property, the function that is the value of the property's [[Get]] + attribute must never return a strict function when called. + +---*/ +var CALLER_OWN_PROPERTY_DOES_NOT_EXIST = Symbol(); +function inner() { + // This property may exist, but is forbidden from having a value that is a strict function object + return inner.hasOwnProperty("caller") + ? inner.caller + : CALLER_OWN_PROPERTY_DOES_NOT_EXIST; +} + +var callCount = 0; +class C { + method() { + /* implicit strict */ + // This and the following conditional value is set in the test's .case file. + // For every test that has a "true" value here, there is a + // corresponding test that has a "false" value here. + // They are generated from two different case files, which use + let descriptor = Object.getOwnPropertyDescriptor(inner, "caller"); + if (descriptor && descriptor.configurable && true) { + Object.defineProperty(inner, "caller", {get(){return 1}}); + } + var result = inner(); + if (descriptor && descriptor.configurable && true) { + assert.sameValue(result, 1, 'If this test defined an own "caller" property on the inner function, then it should be accessible and should return the value it was set to.'); + } + + // "CALLER_OWN_PROPERTY_DOES_NOT_EXIST" is from + // forbidden-ext-indirect-access-prop-caller.case + // + // If the function object "inner" has an own property + // named "caller", then its value will be returned. + // + // If the function object "inner" DOES NOT have an + // own property named "caller", then the symbol + // CALLER_OWN_PROPERTY_DOES_NOT_EXIST will be returned. + if (result !== CALLER_OWN_PROPERTY_DOES_NOT_EXIST) { + assert.notSameValue(result, this.method); + } + callCount++; + } +} + +C.prototype.method(); +assert.sameValue(callCount, 1, 'method body evaluated'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/method/forbidden-ext/b2/cls-decl-meth-forbidden-ext-indirect-access-own-prop-caller-value.js b/js/src/tests/test262/language/statements/class/method/forbidden-ext/b2/cls-decl-meth-forbidden-ext-indirect-access-own-prop-caller-value.js new file mode 100644 index 0000000000..292a409f22 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/method/forbidden-ext/b2/cls-decl-meth-forbidden-ext-indirect-access-own-prop-caller-value.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/forbidden-ext-indirect-access-own-prop-caller-value.case +// - src/function-forms/forbidden-extensions/bullet-two/cls-decl-meth.template +/*--- +description: Forbidden extension, o.caller (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class] +flags: [generated, noStrict] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + + If an implementation extends any function object with an own property named "caller" the value of + that property, as observed using [[Get]] or [[GetOwnProperty]], must not be a strict function + object. If it is an accessor property, the function that is the value of the property's [[Get]] + attribute must never return a strict function when called. + +---*/ +var CALLER_OWN_PROPERTY_DOES_NOT_EXIST = Symbol(); +function inner() { + // This property may exist, but is forbidden from having a value that is a strict function object + return inner.hasOwnProperty("caller") + ? inner.caller + : CALLER_OWN_PROPERTY_DOES_NOT_EXIST; +} + +var callCount = 0; +class C { + method() { + /* implicit strict */ + // This and the following conditional value is set in the test's .case file. + // For every test that has a "true" value here, there is a + // corresponding test that has a "false" value here. + // They are generated from two different case files, which use + let descriptor = Object.getOwnPropertyDescriptor(inner, "caller"); + if (descriptor && descriptor.configurable && true) { + Object.defineProperty(inner, "caller", {value: 1}); + } + var result = inner(); + if (descriptor && descriptor.configurable && true) { + assert.sameValue(result, 1, 'If this test defined an own "caller" property on the inner function, then it should be accessible and should return the value it was set to.'); + } + + // "CALLER_OWN_PROPERTY_DOES_NOT_EXIST" is from + // forbidden-ext-indirect-access-prop-caller.case + // + // If the function object "inner" has an own property + // named "caller", then its value will be returned. + // + // If the function object "inner" DOES NOT have an + // own property named "caller", then the symbol + // CALLER_OWN_PROPERTY_DOES_NOT_EXIST will be returned. + if (result !== CALLER_OWN_PROPERTY_DOES_NOT_EXIST) { + assert.notSameValue(result, this.method); + } + callCount++; + } +} + +C.prototype.method(); +assert.sameValue(callCount, 1, 'method body evaluated'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/method/forbidden-ext/b2/cls-decl-meth-forbidden-ext-indirect-access-prop-caller.js b/js/src/tests/test262/language/statements/class/method/forbidden-ext/b2/cls-decl-meth-forbidden-ext-indirect-access-prop-caller.js new file mode 100644 index 0000000000..23577b3c1c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/method/forbidden-ext/b2/cls-decl-meth-forbidden-ext-indirect-access-prop-caller.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/forbidden-ext-indirect-access-prop-caller.case +// - src/function-forms/forbidden-extensions/bullet-two/cls-decl-meth.template +/*--- +description: Forbidden extension, o.caller (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [class] +flags: [generated, noStrict] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + + If an implementation extends any function object with an own property named "caller" the value of + that property, as observed using [[Get]] or [[GetOwnProperty]], must not be a strict function + object. If it is an accessor property, the function that is the value of the property's [[Get]] + attribute must never return a strict function when called. + +---*/ +var CALLER_OWN_PROPERTY_DOES_NOT_EXIST = Symbol(); +function inner() { + // This property may exist, but is forbidden from having a value that is a strict function object + return inner.hasOwnProperty("caller") + ? inner.caller + : CALLER_OWN_PROPERTY_DOES_NOT_EXIST; +} + +var callCount = 0; +class C { + method() { + /* implicit strict */ + // This and the following conditional value is set in the test's .case file. + // For every test that has a "true" value here, there is a + // corresponding test that has a "false" value here. + // They are generated from two different case files, which use + let descriptor = Object.getOwnPropertyDescriptor(inner, "caller"); + if (descriptor && descriptor.configurable && false) { + Object.defineProperty(inner, "caller", {}); + } + var result = inner(); + if (descriptor && descriptor.configurable && false) { + assert.sameValue(result, 1, 'If this test defined an own "caller" property on the inner function, then it should be accessible and should return the value it was set to.'); + } + + // "CALLER_OWN_PROPERTY_DOES_NOT_EXIST" is from + // forbidden-ext-indirect-access-prop-caller.case + // + // If the function object "inner" has an own property + // named "caller", then its value will be returned. + // + // If the function object "inner" DOES NOT have an + // own property named "caller", then the symbol + // CALLER_OWN_PROPERTY_DOES_NOT_EXIST will be returned. + if (result !== CALLER_OWN_PROPERTY_DOES_NOT_EXIST) { + assert.notSameValue(result, this.method); + } + callCount++; + } +} + +C.prototype.method(); +assert.sameValue(callCount, 1, 'method body evaluated'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/method/forbidden-ext/b2/shell.js b/js/src/tests/test262/language/statements/class/method/forbidden-ext/b2/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/method/forbidden-ext/browser.js b/js/src/tests/test262/language/statements/class/method/forbidden-ext/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/method/forbidden-ext/shell.js b/js/src/tests/test262/language/statements/class/method/forbidden-ext/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/method/object-destructuring-param-strict-body.js b/js/src/tests/test262/language/statements/class/method/object-destructuring-param-strict-body.js new file mode 100644 index 0000000000..950347f1b7 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/method/object-destructuring-param-strict-body.js @@ -0,0 +1,154 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/function-forms/object-destructuring-param-strict-body.case +// - src/function-forms/syntax/cls-decl-meth.template +/*--- +description: ObjectBindingPattern and Use Strict Directive are not allowed to coexist for the same function. (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [rest-parameters] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.4 Static Semantics: IsSimpleParameterList + + BindingElement : BindingPattern + + 1. Return false. + + 14.1.2 Static Semantics: Early Errors + + FunctionDeclaration : function BindingIdentifier ( FormalParameters ) { FunctionBody } + FunctionDeclaration : function ( FormalParameters ) { FunctionBody } + FunctionExpression : function BindingIdentifier ( FormalParameters ) { FunctionBody } + + - It is a Syntax Error if ContainsUseStrict of FunctionBody is true and + IsSimpleParameterList of FormalParameters is false. + + 14.2.1 Static Semantics: Early Errors + + ArrowFunction : ArrowParameters => ConciseBody + + - It is a Syntax Error if ContainsUseStrict of ConciseBody is true and + IsSimpleParameterList of ArrowParameters is false. + + 14.3.1 Static Semantics: Early Errors + + MethodDefinition : PropertyName ( UniqueFormalParameters ) { FunctionBody } + + - It is a Syntax Error if ContainsUseStrict of FunctionBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + MethodDefinition : set PropertyName ( PropertySetParameterList ) { FunctionBody } + + - It is a Syntax Error if ContainsUseStrict of FunctionBody is true and + IsSimpleParameterList of PropertySetParameterList is false. + + 14.4.1 Static Semantics: Early Errors + + GeneratorMethod : * PropertyName ( UniqueFormalParameters ) { GeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of GeneratorBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + GeneratorDeclaration : function * BindingIdentifier ( FormalParameters ) { GeneratorBody } + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + GeneratorExpression : function * BindingIdentifier ( FormalParameters ) { GeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of GeneratorBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + 14.5.1 Static Semantics: Early Errors + + AsyncGeneratorMethod : async * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncGeneratorBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + AsyncGeneratorDeclaration : async function * BindingIdentifier ( FormalParameters ) { AsyncGeneratorBody } + AsyncGeneratorDeclaration : async function * ( FormalParameters ) { AsyncGeneratorBody } + AsyncGeneratorExpression : async function * BindingIdentifier ( FormalParameters ) { AsyncGeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncGeneratorBody is true and + IsSimpleParameterList of FormalParameters is false. + + 14.7.1 Static Semantics: Early Errors + + AsyncMethod : async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncFunctionBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + AsyncFunctionDeclaration : async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody } + AsyncFunctionDeclaration : async function ( FormalParameters ) { AsyncFunctionBody } + AsyncFunctionExpression : async function ( FormalParameters ) { AsyncFunctionBody } + AsyncFunctionExpression : async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncFunctionBody is true and + IsSimpleParameterList of FormalParameters is false. + + 14.8.1 Static Semantics: Early Errors + + AsyncArrowFunction : CoverCallExpressionAndAsyncArrowHead => AsyncConciseBody + + - It is a Syntax Error if ContainsUseStrict of AsyncConciseBody is true and + IsSimpleParameterList of CoverCallExpressionAndAsyncArrowHead is false. + +---*/ +$DONOTEVALUATE(); + +class C { + method({property}) { + "use strict"; + } +} diff --git a/js/src/tests/test262/language/statements/class/method/params-trailing-comma-multiple.js b/js/src/tests/test262/language/statements/class/method/params-trailing-comma-multiple.js new file mode 100644 index 0000000000..06f47ab0e4 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/method/params-trailing-comma-multiple.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/params-trailing-comma-multiple.case +// - src/function-forms/default/cls-decl-meth.template +/*--- +description: A trailing comma should not increase the respective length, using multiple parameters (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Trailing comma in the parameters list + + 14.1 Function Definitions + + FormalParameters[Yield, Await] : FormalParameterList[?Yield, ?Await] , +---*/ + +var callCount = 0; +class C { + method(a, b,) { + assert.sameValue(a, 42); + assert.sameValue(b, 39); + callCount = callCount + 1; + } +} + +C.prototype.method(42, 39, 1); + +// Stores a reference `ref` for case evaluation +var ref = C.prototype.method; + +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +assert.sameValue(ref.length, 2, 'length is properly set'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/method/params-trailing-comma-single.js b/js/src/tests/test262/language/statements/class/method/params-trailing-comma-single.js new file mode 100644 index 0000000000..1b264c609c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/method/params-trailing-comma-single.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/function-forms/params-trailing-comma-single.case +// - src/function-forms/default/cls-decl-meth.template +/*--- +description: A trailing comma should not increase the respective length, using a single parameter (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +flags: [generated] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Trailing comma in the parameters list + + 14.1 Function Definitions + + FormalParameters[Yield, Await] : FormalParameterList[?Yield, ?Await] , +---*/ + +var callCount = 0; +class C { + method(a,) { + assert.sameValue(a, 42); + callCount = callCount + 1; + } +} + +C.prototype.method(42, 39); + +// Stores a reference `ref` for case evaluation +var ref = C.prototype.method; + +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +assert.sameValue(ref.length, 1, 'length is properly set'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/method/rest-param-strict-body.js b/js/src/tests/test262/language/statements/class/method/rest-param-strict-body.js new file mode 100644 index 0000000000..0a6215c24c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/method/rest-param-strict-body.js @@ -0,0 +1,154 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/function-forms/rest-param-strict-body.case +// - src/function-forms/syntax/cls-decl-meth.template +/*--- +description: RestParameter and Use Strict Directive are not allowed to coexist for the same function. (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +features: [rest-parameters] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.13 Static Semantics: IsSimpleParameterList + + FormalParameters : FormalParameterList , FunctionRestParameter + + 1. Return false. + + 14.1.2 Static Semantics: Early Errors + + FunctionDeclaration : function BindingIdentifier ( FormalParameters ) { FunctionBody } + FunctionDeclaration : function ( FormalParameters ) { FunctionBody } + FunctionExpression : function BindingIdentifier ( FormalParameters ) { FunctionBody } + + - It is a Syntax Error if ContainsUseStrict of FunctionBody is true and + IsSimpleParameterList of FormalParameters is false. + + 14.2.1 Static Semantics: Early Errors + + ArrowFunction : ArrowParameters => ConciseBody + + - It is a Syntax Error if ContainsUseStrict of ConciseBody is true and + IsSimpleParameterList of ArrowParameters is false. + + 14.3.1 Static Semantics: Early Errors + + MethodDefinition : PropertyName ( UniqueFormalParameters ) { FunctionBody } + + - It is a Syntax Error if ContainsUseStrict of FunctionBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + MethodDefinition : set PropertyName ( PropertySetParameterList ) { FunctionBody } + + - It is a Syntax Error if ContainsUseStrict of FunctionBody is true and + IsSimpleParameterList of PropertySetParameterList is false. + + 14.4.1 Static Semantics: Early Errors + + GeneratorMethod : * PropertyName ( UniqueFormalParameters ) { GeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of GeneratorBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + GeneratorDeclaration : function * BindingIdentifier ( FormalParameters ) { GeneratorBody } + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + GeneratorExpression : function * BindingIdentifier ( FormalParameters ) { GeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of GeneratorBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + 14.5.1 Static Semantics: Early Errors + + AsyncGeneratorMethod : async * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncGeneratorBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + AsyncGeneratorDeclaration : async function * BindingIdentifier ( FormalParameters ) { AsyncGeneratorBody } + AsyncGeneratorDeclaration : async function * ( FormalParameters ) { AsyncGeneratorBody } + AsyncGeneratorExpression : async function * BindingIdentifier ( FormalParameters ) { AsyncGeneratorBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncGeneratorBody is true and + IsSimpleParameterList of FormalParameters is false. + + 14.7.1 Static Semantics: Early Errors + + AsyncMethod : async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncFunctionBody is true and + IsSimpleParameterList of UniqueFormalParameters is false. + + AsyncFunctionDeclaration : async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody } + AsyncFunctionDeclaration : async function ( FormalParameters ) { AsyncFunctionBody } + AsyncFunctionExpression : async function ( FormalParameters ) { AsyncFunctionBody } + AsyncFunctionExpression : async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody } + + - It is a Syntax Error if ContainsUseStrict of AsyncFunctionBody is true and + IsSimpleParameterList of FormalParameters is false. + + 14.8.1 Static Semantics: Early Errors + + AsyncArrowFunction : CoverCallExpressionAndAsyncArrowHead => AsyncConciseBody + + - It is a Syntax Error if ContainsUseStrict of AsyncConciseBody is true and + IsSimpleParameterList of CoverCallExpressionAndAsyncArrowHead is false. + +---*/ +$DONOTEVALUATE(); + +class C { + method(a,...rest) { + "use strict"; + } +} diff --git a/js/src/tests/test262/language/statements/class/method/rest-params-trailing-comma-early-error.js b/js/src/tests/test262/language/statements/class/method/rest-params-trailing-comma-early-error.js new file mode 100644 index 0000000000..68072feed6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/method/rest-params-trailing-comma-early-error.js @@ -0,0 +1,79 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/function-forms/rest-params-trailing-comma-early-error.case +// - src/function-forms/syntax/cls-decl-meth.template +/*--- +description: It's a syntax error if a FunctionRestParameter is followed by a trailing comma (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Trailing comma in the parameters list + + 14.1 Function Definitions + + FormalParameters[Yield, Await] : + [empty] + FunctionRestParameter[?Yield, ?Await] + FormalParameterList[?Yield, ?Await] + FormalParameterList[?Yield, ?Await] , + FormalParameterList[?Yield, ?Await] , FunctionRestParameter[?Yield, ?Await] +---*/ +$DONOTEVALUATE(); + +class C { + method(...a,) { + + } +} diff --git a/js/src/tests/test262/language/statements/class/method/shell.js b/js/src/tests/test262/language/statements/class/method/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/name-binding/basic.js b/js/src/tests/test262/language/statements/class/name-binding/basic.js new file mode 100644 index 0000000000..cdee07ecc5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/name-binding/basic.js @@ -0,0 +1,38 @@ +// Copyright (C) 2014 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.5 +description: > + class name binding +---*/ +var C2; +class C { + constructor() { + C2 = C; + } + m() { + C2 = C; + } + get x() { + C2 = C; + } + set x(_) { + C2 = C; + } +} +new C(); +assert.sameValue(C, C2, "The value of `C` is `C2`"); + +C2 = undefined; +new C().m(); +assert.sameValue(C, C2, "The value of `C` is `C2`"); + +C2 = undefined; +new C().x; +assert.sameValue(C, C2, "The value of `C` is `C2`"); + +C2 = undefined; +new C().x = 1; +assert.sameValue(C, C2, "The value of `C` is `C2`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/name-binding/browser.js b/js/src/tests/test262/language/statements/class/name-binding/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/name-binding/const.js b/js/src/tests/test262/language/statements/class/name-binding/const.js new file mode 100644 index 0000000000..326ac008a3 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/name-binding/const.js @@ -0,0 +1,33 @@ +// Copyright (C) 2014 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.5 +description: > + class name binding const +---*/ +assert.throws(TypeError, function() { + class C { constructor() { C = 42; } }; new C(); +}); +assert.throws(TypeError, function() { + new (class C { constructor() { C = 42; } }) +}); +assert.throws(TypeError, function() { + class C { m() { C = 42; } }; new C().m() +}); +assert.throws(TypeError, function() { + new (class C { m() { C = 42; } }).m() +}); +assert.throws(TypeError, function() { + class C { get x() { C = 42; } }; new C().x +}); +assert.throws(TypeError, function() { + (new (class C { get x() { C = 42; } })).x +}); +assert.throws(TypeError, function() { + class C { set x(_) { C = 42; } }; new C().x = 15; +}); +assert.throws(TypeError, function() { + (new (class C { set x(_) { C = 42; } })).x = 15; +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/name-binding/expression.js b/js/src/tests/test262/language/statements/class/name-binding/expression.js new file mode 100644 index 0000000000..26a584e479 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/name-binding/expression.js @@ -0,0 +1,43 @@ +// Copyright (C) 2014 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.5 +description: > + class name binding expression +---*/ +var Cc; +var Cm; +var Cgx; +var Csx; +var Cv = class C { + constructor() { + assert.sameValue(C, Cv, "The value of `C` is `Cv`, inside `constructor()`"); + Cc = C; + } + m() { + assert.sameValue(C, Cv, "The value of `C` is `Cv`, inside `m()`"); + Cm = C; + } + get x() { + assert.sameValue(C, Cv, "The value of `C` is `Cv`, inside `get x()`"); + Cgx = C; + } + set x(_) { + assert.sameValue(C, Cv, "The value of `C` is `Cv`, inside `set x()`"); + Csx = C; + } +}; + +new Cv(); +assert.sameValue(Cc, Cv, "The value of `Cc` is `Cv`, after executing `new Cv();`"); + +new Cv().m(); +assert.sameValue(Cm, Cv, "The value of `Cm` is `Cv`, after executing `new Cv().m();`"); + +new Cv().x; +assert.sameValue(Cgx, Cv, "The value of `Cgx` is `Cv`, after executing `new Cv().x;`"); + +new Cv().x = 1; +assert.sameValue(Csx, Cv, "The value of `Csx` is `Cv`, after executing `new Cv().x = 1;`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/name-binding/in-extends-expression-assigned.js b/js/src/tests/test262/language/statements/class/name-binding/in-extends-expression-assigned.js new file mode 100644 index 0000000000..eb0b9818f6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/name-binding/in-extends-expression-assigned.js @@ -0,0 +1,12 @@ +// Copyright (C) 2014 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.5 +description: > + class name binding in extends expression, assigned +---*/ +assert.throws(ReferenceError, function() { + var x = (class x extends x {}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/name-binding/in-extends-expression-grouped.js b/js/src/tests/test262/language/statements/class/name-binding/in-extends-expression-grouped.js new file mode 100644 index 0000000000..c4259d8ae4 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/name-binding/in-extends-expression-grouped.js @@ -0,0 +1,13 @@ +// Copyright (C) 2014 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.5 +description: > + class name binding in extends expression, grouped +---*/ + +assert.throws(ReferenceError, function() { + (class x extends x {}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/name-binding/in-extends-expression.js b/js/src/tests/test262/language/statements/class/name-binding/in-extends-expression.js new file mode 100644 index 0000000000..cd586bc04b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/name-binding/in-extends-expression.js @@ -0,0 +1,12 @@ +// Copyright (C) 2014 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.5 +description: > + class name binding in extends expression +---*/ +assert.throws(ReferenceError, function() { + class x extends x {} +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/name-binding/shell.js b/js/src/tests/test262/language/statements/class/name-binding/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/name.js b/js/src/tests/test262/language/statements/class/name.js new file mode 100644 index 0000000000..a426556179 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/name.js @@ -0,0 +1,23 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 14.5.15 +description: Assignment of function `name` attribute +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + [...] + 6. If hasNameProperty is false, then perform SetFunctionName(value, + className). +includes: [propertyHelper.js] +---*/ + +class Test262 {} + +assert.sameValue(Test262.name, 'Test262'); +verifyNotEnumerable(Test262, 'name'); +verifyNotWritable(Test262, 'name'); +verifyConfigurable(Test262, 'name'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/params-dflt-gen-meth-args-unmapped.js b/js/src/tests/test262/language/statements/class/params-dflt-gen-meth-args-unmapped.js new file mode 100644 index 0000000000..ca91616981 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/params-dflt-gen-meth-args-unmapped.js @@ -0,0 +1,106 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Referencing the arguments object from a default parameter (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [generators, default-parameters] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. +---*/ + +var callCount = 0; +class C { + *method(x, _ = 0) { + assert.sameValue(x, undefined, 'parameter binding value (initial)'); + assert.sameValue( + arguments[0], undefined, 'arguments property value (initial)' + ); + + arguments[0] = 1; + + assert.sameValue( + x, undefined, 'parameter binding value (after arguments modification)' + ); + assert.sameValue( + arguments[0], 1, 'arguments property value (after arguments modification)' + ); + + x = 2; + + assert.sameValue( + x, 2, 'parameter binding value (after parameter binding modification)' + ); + assert.sameValue( + arguments[0], + 1, + 'arguments property value (after parameter binding modification)' + ); + callCount = callCount + 1; + } +} + +C.prototype.method().next(); + +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/params-dflt-gen-meth-ref-arguments.js b/js/src/tests/test262/language/statements/class/params-dflt-gen-meth-ref-arguments.js new file mode 100644 index 0000000000..36f27467df --- /dev/null +++ b/js/src/tests/test262/language/statements/class/params-dflt-gen-meth-ref-arguments.js @@ -0,0 +1,85 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Referencing the arguments object from a default parameter (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [generators, default-parameters] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. +---*/ + +var callCount = 0; +class C { + *method(x = arguments[2], y = arguments[3], z) { + assert.sameValue(x, 'third', 'first parameter'); + assert.sameValue(y, 'fourth', 'second parameter'); + assert.sameValue(z, 'third', 'third parameter'); + callCount = callCount + 1; + } +} + +C.prototype.method(undefined, undefined, 'third', 'fourth').next(); + +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/params-dflt-gen-meth-static-args-unmapped.js b/js/src/tests/test262/language/statements/class/params-dflt-gen-meth-static-args-unmapped.js new file mode 100644 index 0000000000..fde66a0534 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/params-dflt-gen-meth-static-args-unmapped.js @@ -0,0 +1,106 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Referencing the arguments object from a default parameter (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [generators, default-parameters] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. +---*/ + +var callCount = 0; +class C { + static *method(x, _ = 0) { + assert.sameValue(x, undefined, 'parameter binding value (initial)'); + assert.sameValue( + arguments[0], undefined, 'arguments property value (initial)' + ); + + arguments[0] = 1; + + assert.sameValue( + x, undefined, 'parameter binding value (after arguments modification)' + ); + assert.sameValue( + arguments[0], 1, 'arguments property value (after arguments modification)' + ); + + x = 2; + + assert.sameValue( + x, 2, 'parameter binding value (after parameter binding modification)' + ); + assert.sameValue( + arguments[0], + 1, + 'arguments property value (after parameter binding modification)' + ); + callCount = callCount + 1; + } +} + +C.method().next(); + +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/params-dflt-gen-meth-static-ref-arguments.js b/js/src/tests/test262/language/statements/class/params-dflt-gen-meth-static-ref-arguments.js new file mode 100644 index 0000000000..8cf52d1a56 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/params-dflt-gen-meth-static-ref-arguments.js @@ -0,0 +1,85 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Referencing the arguments object from a default parameter (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [generators, default-parameters] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. +---*/ + +var callCount = 0; +class C { + static *method(x = arguments[2], y = arguments[3], z) { + assert.sameValue(x, 'third', 'first parameter'); + assert.sameValue(y, 'fourth', 'second parameter'); + assert.sameValue(z, 'third', 'third parameter'); + callCount = callCount + 1; + } +} + +C.method(undefined, undefined, 'third', 'fourth').next(); + +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/params-dflt-meth-args-unmapped.js b/js/src/tests/test262/language/statements/class/params-dflt-meth-args-unmapped.js new file mode 100644 index 0000000000..e38673c6b5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/params-dflt-meth-args-unmapped.js @@ -0,0 +1,104 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Referencing the arguments object from a default parameter (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [default-parameters] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. +---*/ + +var callCount = 0; +class C { + method(x, _ = 0) { + assert.sameValue(x, undefined, 'parameter binding value (initial)'); + assert.sameValue( + arguments[0], undefined, 'arguments property value (initial)' + ); + + arguments[0] = 1; + + assert.sameValue( + x, undefined, 'parameter binding value (after arguments modification)' + ); + assert.sameValue( + arguments[0], 1, 'arguments property value (after arguments modification)' + ); + + x = 2; + + assert.sameValue( + x, 2, 'parameter binding value (after parameter binding modification)' + ); + assert.sameValue( + arguments[0], + 1, + 'arguments property value (after parameter binding modification)' + ); + callCount = callCount + 1; + } +} + +C.prototype.method(); + +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/params-dflt-meth-ref-arguments.js b/js/src/tests/test262/language/statements/class/params-dflt-meth-ref-arguments.js new file mode 100644 index 0000000000..ce6906e22c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/params-dflt-meth-ref-arguments.js @@ -0,0 +1,83 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Referencing the arguments object from a default parameter (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [default-parameters] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. +---*/ + +var callCount = 0; +class C { + method(x = arguments[2], y = arguments[3], z) { + assert.sameValue(x, 'third', 'first parameter'); + assert.sameValue(y, 'fourth', 'second parameter'); + assert.sameValue(z, 'third', 'third parameter'); + callCount = callCount + 1; + } +} + +C.prototype.method(undefined, undefined, 'third', 'fourth'); + +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/params-dflt-meth-static-args-unmapped.js b/js/src/tests/test262/language/statements/class/params-dflt-meth-static-args-unmapped.js new file mode 100644 index 0000000000..5765b8ef0f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/params-dflt-meth-static-args-unmapped.js @@ -0,0 +1,104 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Referencing the arguments object from a default parameter (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [default-parameters] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. +---*/ + +var callCount = 0; +class C { + static method(x, _ = 0) { + assert.sameValue(x, undefined, 'parameter binding value (initial)'); + assert.sameValue( + arguments[0], undefined, 'arguments property value (initial)' + ); + + arguments[0] = 1; + + assert.sameValue( + x, undefined, 'parameter binding value (after arguments modification)' + ); + assert.sameValue( + arguments[0], 1, 'arguments property value (after arguments modification)' + ); + + x = 2; + + assert.sameValue( + x, 2, 'parameter binding value (after parameter binding modification)' + ); + assert.sameValue( + arguments[0], + 1, + 'arguments property value (after parameter binding modification)' + ); + callCount = callCount + 1; + } +} + +C.method(); + +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/params-dflt-meth-static-ref-arguments.js b/js/src/tests/test262/language/statements/class/params-dflt-meth-static-ref-arguments.js new file mode 100644 index 0000000000..fc107fd2e6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/params-dflt-meth-static-ref-arguments.js @@ -0,0 +1,83 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Referencing the arguments object from a default parameter (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [default-parameters] +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. +---*/ + +var callCount = 0; +class C { + static method(x = arguments[2], y = arguments[3], z) { + assert.sameValue(x, 'third', 'first parameter'); + assert.sameValue(y, 'fourth', 'second parameter'); + assert.sameValue(z, 'third', 'third parameter'); + callCount = callCount + 1; + } +} + +C.method(undefined, undefined, 'third', 'fourth'); + +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/poisoned-underscore-proto.js b/js/src/tests/test262/language/statements/class/poisoned-underscore-proto.js new file mode 100644 index 0000000000..5f71e08af1 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/poisoned-underscore-proto.js @@ -0,0 +1,30 @@ +// Copyright (C) 2019 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: prod-ClassDeclaration +description: > + ClassDeclaration should directly set [[Prototype]] internal slot. +info: | + ClassDefinitionEvaluation + + [...] + 7. Let proto be ObjectCreate(protoParent). + + ObjectCreate ( proto [ , internalSlotsList ] ) + + [...] + 4. Set obj.[[Prototype]] to proto. +features: [class] +---*/ + +Object.defineProperty(Object.prototype, '__proto__', { + set: function() { + throw new Test262Error('should not be called'); + }, +}); + +class A extends Array {} + +assert.sameValue(new A(1).length, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/private-non-static-getter-static-setter-early-error.js b/js/src/tests/test262/language/statements/class/private-non-static-getter-static-setter-early-error.js new file mode 100644 index 0000000000..7bfce814cd --- /dev/null +++ b/js/src/tests/test262/language/statements/class/private-non-static-getter-static-setter-early-error.js @@ -0,0 +1,20 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2019 Caio Lima (Igalia SL). All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: pending +description: > + It is a Syntax Error if we declare a private instance getter and private static setter +features: [class-static-methods-private, class-methods-private] +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +class C { + get #f() {} + static set #f(v) {} +} + diff --git a/js/src/tests/test262/language/statements/class/private-non-static-setter-static-getter-early-error.js b/js/src/tests/test262/language/statements/class/private-non-static-setter-static-getter-early-error.js new file mode 100644 index 0000000000..3710b7c81f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/private-non-static-setter-static-getter-early-error.js @@ -0,0 +1,20 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2019 Caio Lima (Igalia SL). All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: pending +description: > + It is a Syntax Error if we declare a private instance setter and a static private getter +features: [class-static-methods-private, class-methods-private] +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +class C { + set #f(v) {} + static get #f() {} +} + diff --git a/js/src/tests/test262/language/statements/class/private-static-getter-non-static-setter-early-error.js b/js/src/tests/test262/language/statements/class/private-static-getter-non-static-setter-early-error.js new file mode 100644 index 0000000000..fa3e07f438 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/private-static-getter-non-static-setter-early-error.js @@ -0,0 +1,20 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2019 Caio Lima (Igalia SL). All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: pending +description: > + It is a Syntax Error if we declare a private static getter and a private instance setter +features: [class-static-methods-private, class-methods-private] +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +class C { + static get #f() {} + set #f(v) {} +} + diff --git a/js/src/tests/test262/language/statements/class/private-static-setter-non-static-getter-early-error.js b/js/src/tests/test262/language/statements/class/private-static-setter-non-static-getter-early-error.js new file mode 100644 index 0000000000..970336b31b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/private-static-setter-non-static-getter-early-error.js @@ -0,0 +1,20 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2019 Caio Lima (Igalia SL). All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: pending +description: > + It is a Syntax Error if we declare a static private setter and a private instance getter +features: [class-static-methods-private, class-methods-private] +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +class C { + static set #f(v) {} + get #f() {} +} + diff --git a/js/src/tests/test262/language/statements/class/restricted-properties.js b/js/src/tests/test262/language/statements/class/restricted-properties.js new file mode 100644 index 0000000000..25a9b2db1c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/restricted-properties.js @@ -0,0 +1,62 @@ +// Copyright (C) 2015 Caitlin Potter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + Functions created using ClassDeclaration syntactic form do not have own + properties "caller" or "arguments", but inherit them from + %FunctionPrototype%. +es6id: 16.1 +---*/ + +class BaseClass {} + +assert.sameValue( + BaseClass.hasOwnProperty('caller'), false, 'No "caller" own property' +); +assert.sameValue( + BaseClass.hasOwnProperty('arguments'), false, 'No "arguments" own property' +); + +assert.throws(TypeError, function() { + return BaseClass.caller; +}); + +assert.throws(TypeError, function() { + BaseClass.caller = {}; +}); + +assert.throws(TypeError, function() { + return BaseClass.arguments; +}); + +assert.throws(TypeError, function() { + BaseClass.arguments = {}; +}); + +class SubClass extends BaseClass {} + +assert.sameValue( + SubClass.hasOwnProperty('caller'), false, 'No "caller" own property' +); +assert.sameValue( + SubClass.hasOwnProperty('arguments'), false, 'No "arguments" own property' +); + +assert.throws(TypeError, function() { + return SubClass.caller; +}); + +assert.throws(TypeError, function() { + SubClass.caller = {}; +}); + +assert.throws(TypeError, function() { + return SubClass.arguments; +}); + +assert.throws(TypeError, function() { + SubClass.arguments = {}; +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/scope-gen-meth-paramsbody-var-close.js b/js/src/tests/test262/language/statements/class/scope-gen-meth-paramsbody-var-close.js new file mode 100644 index 0000000000..52f5b6d614 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/scope-gen-meth-paramsbody-var-close.js @@ -0,0 +1,40 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-functiondeclarationinstantiation +description: > + Disposal of variable environment for the function body +info: | + [...] + 26. If hasParameterExpressions is false, then + [...] + 27. Else, + a. NOTE A separate Environment Record is needed to ensure that closures + created by expressions in the formal parameter list do not have + visibility of declarations in the function body. + b. Let varEnv be NewDeclarativeEnvironment(env). + c. Let varEnvRec be varEnv's EnvironmentRecord. + d. Set the VariableEnvironment of calleeContext to varEnv. + e. Let instantiatedVarNames be a new empty List. + [...] +features: [generators] +---*/ + +var probe; + +class C { + // A parameter expression is necessary to trigger the creation of the scope + // under test. + *m(_ = null) { + var x = 'inside'; + probe = function() { return x; }; + } +} +C.prototype.m().next(); + +var x = 'outside'; + +assert.sameValue(probe(), 'inside'); +assert.sameValue(x, 'outside'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/scope-gen-meth-paramsbody-var-open.js b/js/src/tests/test262/language/statements/class/scope-gen-meth-paramsbody-var-open.js new file mode 100644 index 0000000000..1a04446edb --- /dev/null +++ b/js/src/tests/test262/language/statements/class/scope-gen-meth-paramsbody-var-open.js @@ -0,0 +1,38 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-functiondeclarationinstantiation +description: > + Creation of new variable environment for the function body (as distinct from + that for the function's parameters) +info: | + [...] + 26. If hasParameterExpressions is false, then + [...] + 27. Else, + a. NOTE A separate Environment Record is needed to ensure that closures + created by expressions in the formal parameter list do not have + visibility of declarations in the function body. + b. Let varEnv be NewDeclarativeEnvironment(env). + c. Let varEnvRec be varEnv's EnvironmentRecord. + d. Set the VariableEnvironment of calleeContext to varEnv. + e. Let instantiatedVarNames be a new empty List. + [...] +features: [generators] +---*/ + +var x = 'outside'; +var probeParams, probeBody; + +class C { + *m(_ = probeParams = function() { return x; }) { + var x = 'inside'; + probeBody = function() { return x; }; + } +} +C.prototype.m().next(); + +assert.sameValue(probeParams(), 'outside'); +assert.sameValue(probeBody(), 'inside'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/scope-meth-paramsbody-var-close.js b/js/src/tests/test262/language/statements/class/scope-meth-paramsbody-var-close.js new file mode 100644 index 0000000000..e22e47f812 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/scope-meth-paramsbody-var-close.js @@ -0,0 +1,39 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-functiondeclarationinstantiation +description: > + Disposal of variable environment for the function body +info: | + [...] + 26. If hasParameterExpressions is false, then + [...] + 27. Else, + a. NOTE A separate Environment Record is needed to ensure that closures + created by expressions in the formal parameter list do not have + visibility of declarations in the function body. + b. Let varEnv be NewDeclarativeEnvironment(env). + c. Let varEnvRec be varEnv's EnvironmentRecord. + d. Set the VariableEnvironment of calleeContext to varEnv. + e. Let instantiatedVarNames be a new empty List. + [...] +---*/ + +var probe; + +class C { + // A parameter expression is necessary to trigger the creation of the scope + // under test. + m(_ = null) { + var x = 'inside'; + probe = function() { return x; }; + } +} +C.prototype.m(); + +var x = 'outside'; + +assert.sameValue(probe(), 'inside'); +assert.sameValue(x, 'outside'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/scope-meth-paramsbody-var-open.js b/js/src/tests/test262/language/statements/class/scope-meth-paramsbody-var-open.js new file mode 100644 index 0000000000..d66ff74869 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/scope-meth-paramsbody-var-open.js @@ -0,0 +1,37 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-functiondeclarationinstantiation +description: > + Creation of new variable environment for the function body (as distinct from + that for the function's parameters) +info: | + [...] + 26. If hasParameterExpressions is false, then + [...] + 27. Else, + a. NOTE A separate Environment Record is needed to ensure that closures + created by expressions in the formal parameter list do not have + visibility of declarations in the function body. + b. Let varEnv be NewDeclarativeEnvironment(env). + c. Let varEnvRec be varEnv's EnvironmentRecord. + d. Set the VariableEnvironment of calleeContext to varEnv. + e. Let instantiatedVarNames be a new empty List. + [...] +---*/ + +var x = 'outside'; +var probeParams, probeBody; + +class C { + m(_ = probeParams = function() { return x; }) { + var x = 'inside'; + probeBody = function() { return x; }; + } +} +C.prototype.m(); + +assert.sameValue(probeParams(), 'outside'); +assert.sameValue(probeBody(), 'inside'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/scope-name-lex-close.js b/js/src/tests/test262/language/statements/class/scope-name-lex-close.js new file mode 100644 index 0000000000..11fbcdf31e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/scope-name-lex-close.js @@ -0,0 +1,24 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-runtime-semantics-classdefinitionevaluation +description: Removal of lexical environment for class "name" +info: | + [...] + 22. Set the running execution context's LexicalEnvironment to lex. + [...] +---*/ + +class C { + method() { + return C; + } +} + +var cls = C; +assert.sameValue(typeof C, 'function'); +C = null; +assert.sameValue(C, null); +assert.sameValue(cls.prototype.method(), cls, 'from instance method'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/scope-name-lex-open-heritage.js b/js/src/tests/test262/language/statements/class/scope-name-lex-open-heritage.js new file mode 100644 index 0000000000..fb2a809b40 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/scope-name-lex-open-heritage.js @@ -0,0 +1,48 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-runtime-semantics-classdefinitionevaluation +description: > + Creation of new lexical environment for the class "name" (with a heritage) +info: | + 1. Let lex be the LexicalEnvironment of the running execution context. + 2. Let classScope be NewDeclarativeEnvironment(lex). + 3. Let classScopeEnvRec be classScope's EnvironmentRecord. + 4. If className is not undefined, then + a. Perform classScopeEnvRec.CreateImmutableBinding(className, true). + 5. If ClassHeritageopt is not present, then + [...] + 6. Else, + a. Set the running execution context's LexicalEnvironment to classScope. + [...] +---*/ + +var setBefore = function() { C = null; }; +var probeBefore = function() { return C; }; +var probeHeritage, setHeritage; + +class C extends ( + probeHeritage = function() { return C; }, + setHeritage = function() { C = null; } + ) { + method() { + return C; + } +}; + +var cls = probeBefore(); +assert.sameValue(typeof cls, 'function'); +setBefore(); +assert.sameValue(probeBefore(), null); +assert.sameValue(probeHeritage(), cls, 'inner binding is independent'); +assert.throws( + TypeError, setHeritage, 'inner binding rejects modification' +); +assert.sameValue( + typeof probeHeritage(), 'function', 'inner binding is immutable' +); +assert.sameValue( + typeof cls.prototype.method(), 'function', 'from instance method' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/scope-name-lex-open-no-heritage.js b/js/src/tests/test262/language/statements/class/scope-name-lex-open-no-heritage.js new file mode 100644 index 0000000000..6755b167c2 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/scope-name-lex-open-no-heritage.js @@ -0,0 +1,47 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-runtime-semantics-classdefinitionevaluation +description: > + Creation of new lexical environment for the class "name" (without a + heritage) +info: | + 1. Let lex be the LexicalEnvironment of the running execution context. + 2. Let classScope be NewDeclarativeEnvironment(lex). + 3. Let classScopeEnvRec be classScope's EnvironmentRecord. + 4. If className is not undefined, then + a. Perform classScopeEnvRec.CreateImmutableBinding(className, true). + 5. If ClassHeritageopt is not present, then + [...] + 6. Else, + a. Set the running execution context's LexicalEnvironment to classScope. + [...] + 11. Set the running execution context's LexicalEnvironment to classScope. +---*/ + +var probeBefore = function() { return C; }; +var setBefore = function() { C = null; }; + +class C { + probe() { + return C; + } + modify() { + C = null; + } +}; + +var cls = probeBefore(); +assert.sameValue(typeof cls, 'function'); +setBefore(); +assert.sameValue(probeBefore(), null); + +assert.sameValue(cls.prototype.probe(), cls, 'inner binding value'); +assert.throws( + TypeError, cls.prototype.modify, 'inner binding rejects modification' +); +assert.sameValue( + typeof cls.prototype.probe(), 'function', 'inner binding is immutable' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/scope-setter-paramsbody-var-close.js b/js/src/tests/test262/language/statements/class/scope-setter-paramsbody-var-close.js new file mode 100644 index 0000000000..3441207a93 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/scope-setter-paramsbody-var-close.js @@ -0,0 +1,39 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-functiondeclarationinstantiation +description: > + Disposal of variable environment for the function body +info: | + [...] + 26. If hasParameterExpressions is false, then + [...] + 27. Else, + a. NOTE A separate Environment Record is needed to ensure that closures + created by expressions in the formal parameter list do not have + visibility of declarations in the function body. + b. Let varEnv be NewDeclarativeEnvironment(env). + c. Let varEnvRec be varEnv's EnvironmentRecord. + d. Set the VariableEnvironment of calleeContext to varEnv. + e. Let instantiatedVarNames be a new empty List. + [...] +---*/ + +var probe; + +class C { + // A parameter expression is necessary to trigger the creation of the scope + // under test. + set a(_ = null) { + var x = 'inside'; + probe = function() { return x; }; + } +} +C.prototype.a = null; + +var x = 'outside'; + +assert.sameValue(probe(), 'inside'); +assert.sameValue(x, 'outside'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/scope-setter-paramsbody-var-open.js b/js/src/tests/test262/language/statements/class/scope-setter-paramsbody-var-open.js new file mode 100644 index 0000000000..0df927eb66 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/scope-setter-paramsbody-var-open.js @@ -0,0 +1,37 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-functiondeclarationinstantiation +description: > + Creation of new variable environment for the function body (as distinct from + that for the function's parameters) +info: | + [...] + 26. If hasParameterExpressions is false, then + [...] + 27. Else, + a. NOTE A separate Environment Record is needed to ensure that closures + created by expressions in the formal parameter list do not have + visibility of declarations in the function body. + b. Let varEnv be NewDeclarativeEnvironment(env). + c. Let varEnvRec be varEnv's EnvironmentRecord. + d. Set the VariableEnvironment of calleeContext to varEnv. + e. Let instantiatedVarNames be a new empty List. + [...] +---*/ + +var x = 'outside'; +var probeParams, probeBody; + +class C { + set a(_ = probeParams = function() { return x; }) { + var x = 'inside'; + probeBody = function() { return x; }; + } +} +C.prototype.a = undefined; + +assert.sameValue(probeParams(), 'outside'); +assert.sameValue(probeBody(), 'inside'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/scope-static-gen-meth-paramsbody-var-close.js b/js/src/tests/test262/language/statements/class/scope-static-gen-meth-paramsbody-var-close.js new file mode 100644 index 0000000000..13fe98bfcd --- /dev/null +++ b/js/src/tests/test262/language/statements/class/scope-static-gen-meth-paramsbody-var-close.js @@ -0,0 +1,40 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-functiondeclarationinstantiation +description: > + Disposal of variable environment for the function body +info: | + [...] + 26. If hasParameterExpressions is false, then + [...] + 27. Else, + a. NOTE A separate Environment Record is needed to ensure that closures + created by expressions in the formal parameter list do not have + visibility of declarations in the function body. + b. Let varEnv be NewDeclarativeEnvironment(env). + c. Let varEnvRec be varEnv's EnvironmentRecord. + d. Set the VariableEnvironment of calleeContext to varEnv. + e. Let instantiatedVarNames be a new empty List. + [...] +features: [generators] +---*/ + +var probe; + +class C { + // A parameter expression is necessary to trigger the creation of the scope + // under test. + static *m(_ = null) { + var x = 'inside'; + probe = function() { return x; }; + } +} +C.m().next(); + +var x = 'outside'; + +assert.sameValue(probe(), 'inside'); +assert.sameValue(x, 'outside'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/scope-static-gen-meth-paramsbody-var-open.js b/js/src/tests/test262/language/statements/class/scope-static-gen-meth-paramsbody-var-open.js new file mode 100644 index 0000000000..09a890069e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/scope-static-gen-meth-paramsbody-var-open.js @@ -0,0 +1,38 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-functiondeclarationinstantiation +description: > + Creation of new variable environment for the function body (as distinct from + that for the function's parameters) +info: | + [...] + 26. If hasParameterExpressions is false, then + [...] + 27. Else, + a. NOTE A separate Environment Record is needed to ensure that closures + created by expressions in the formal parameter list do not have + visibility of declarations in the function body. + b. Let varEnv be NewDeclarativeEnvironment(env). + c. Let varEnvRec be varEnv's EnvironmentRecord. + d. Set the VariableEnvironment of calleeContext to varEnv. + e. Let instantiatedVarNames be a new empty List. + [...] +features: [generators] +---*/ + +var x = 'outside'; +var probeParams, probeBody; + +class C { + static *m(_ = probeParams = function() { return x; }) { + var x = 'inside'; + probeBody = function() { return x; }; + } +} +C.m().next(); + +assert.sameValue(probeParams(), 'outside'); +assert.sameValue(probeBody(), 'inside'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/scope-static-meth-paramsbody-var-close.js b/js/src/tests/test262/language/statements/class/scope-static-meth-paramsbody-var-close.js new file mode 100644 index 0000000000..cd94ab2977 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/scope-static-meth-paramsbody-var-close.js @@ -0,0 +1,39 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-functiondeclarationinstantiation +description: > + Disposal of variable environment for the function body +info: | + [...] + 26. If hasParameterExpressions is false, then + [...] + 27. Else, + a. NOTE A separate Environment Record is needed to ensure that closures + created by expressions in the formal parameter list do not have + visibility of declarations in the function body. + b. Let varEnv be NewDeclarativeEnvironment(env). + c. Let varEnvRec be varEnv's EnvironmentRecord. + d. Set the VariableEnvironment of calleeContext to varEnv. + e. Let instantiatedVarNames be a new empty List. + [...] +---*/ + +var probe; + +class C { + // A parameter expression is necessary to trigger the creation of the scope + // under test. + static m(_ = null) { + var x = 'inside'; + probe = function() { return x; }; + } +} +C.m(); + +var x = 'outside'; + +assert.sameValue(probe(), 'inside'); +assert.sameValue(x, 'outside'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/scope-static-meth-paramsbody-var-open.js b/js/src/tests/test262/language/statements/class/scope-static-meth-paramsbody-var-open.js new file mode 100644 index 0000000000..024867a196 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/scope-static-meth-paramsbody-var-open.js @@ -0,0 +1,37 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-functiondeclarationinstantiation +description: > + Creation of new variable environment for the function body (as distinct from + that for the function's parameters) +info: | + [...] + 26. If hasParameterExpressions is false, then + [...] + 27. Else, + a. NOTE A separate Environment Record is needed to ensure that closures + created by expressions in the formal parameter list do not have + visibility of declarations in the function body. + b. Let varEnv be NewDeclarativeEnvironment(env). + c. Let varEnvRec be varEnv's EnvironmentRecord. + d. Set the VariableEnvironment of calleeContext to varEnv. + e. Let instantiatedVarNames be a new empty List. + [...] +---*/ + +var x = 'outside'; +var probeParams, probeBody; + +class C { + static m(_ = probeParams = function() { return x; }) { + var x = 'inside'; + probeBody = function() { return x; }; + } +} +C.m(); + +assert.sameValue(probeParams(), 'outside'); +assert.sameValue(probeBody(), 'inside'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/scope-static-setter-paramsbody-var-close.js b/js/src/tests/test262/language/statements/class/scope-static-setter-paramsbody-var-close.js new file mode 100644 index 0000000000..97976c664a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/scope-static-setter-paramsbody-var-close.js @@ -0,0 +1,39 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-functiondeclarationinstantiation +description: > + Disposal of variable environment for the function body +info: | + [...] + 26. If hasParameterExpressions is false, then + [...] + 27. Else, + a. NOTE A separate Environment Record is needed to ensure that closures + created by expressions in the formal parameter list do not have + visibility of declarations in the function body. + b. Let varEnv be NewDeclarativeEnvironment(env). + c. Let varEnvRec be varEnv's EnvironmentRecord. + d. Set the VariableEnvironment of calleeContext to varEnv. + e. Let instantiatedVarNames be a new empty List. + [...] +---*/ + +var probe; + +class C { + // A parameter expression is necessary to trigger the creation of the scope + // under test. + static set a(_ = null) { + var x = 'inside'; + probe = function() { return x; }; + } +} +C.a = null; + +var x = 'outside'; + +assert.sameValue(probe(), 'inside'); +assert.sameValue(x, 'outside'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/scope-static-setter-paramsbody-var-open.js b/js/src/tests/test262/language/statements/class/scope-static-setter-paramsbody-var-open.js new file mode 100644 index 0000000000..5f5975b048 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/scope-static-setter-paramsbody-var-open.js @@ -0,0 +1,37 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-functiondeclarationinstantiation +description: > + Creation of new variable environment for the function body (as distinct from + that for the function's parameters) +info: | + [...] + 26. If hasParameterExpressions is false, then + [...] + 27. Else, + a. NOTE A separate Environment Record is needed to ensure that closures + created by expressions in the formal parameter list do not have + visibility of declarations in the function body. + b. Let varEnv be NewDeclarativeEnvironment(env). + c. Let varEnvRec be varEnv's EnvironmentRecord. + d. Set the VariableEnvironment of calleeContext to varEnv. + e. Let instantiatedVarNames be a new empty List. + [...] +---*/ + +var x = 'outside'; +var probeParams, probeBody; + +class C { + static set a(_ = probeParams = function() { return x; }) { + var x = 'inside'; + probeBody = function() { return x; }; + } +} +C.a = undefined; + +assert.sameValue(probeParams(), 'outside'); +assert.sameValue(probeBody(), 'inside'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/setter-length-dflt.js b/js/src/tests/test262/language/statements/class/setter-length-dflt.js new file mode 100644 index 0000000000..c8099c2415 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/setter-length-dflt.js @@ -0,0 +1,41 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.1.6 +description: > + Default parameters' effect on function length +info: | + Function length is counted by the non initialized parameters in the left. + + 9.2.4 FunctionInitialize (F, kind, ParameterList, Body, Scope) + + [...] + 2. Let len be the ExpectedArgumentCount of ParameterList. + 3. Perform ! DefinePropertyOrThrow(F, "length", PropertyDescriptor{[[Value]]: + len, [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true}). + [...] + + FormalsList : FormalParameter + + 1. If HasInitializer of FormalParameter is true return 0 + 2. Return 1. + + FormalsList : FormalsList , FormalParameter + + 1. Let count be the ExpectedArgumentCount of FormalsList. + 2. If HasInitializer of FormalsList is true or HasInitializer of + FormalParameter is true, return count. + 3. Return count+1. +features: [default-parameters] +includes: [propertyHelper.js] +---*/ + +class C { set m(x = 42) {} } +var set = Object.getOwnPropertyDescriptor(C.prototype, 'm').set; + +assert.sameValue(set.length, 0, 'FormalsList: x = 42'); +verifyNotEnumerable(set, 'length'); +verifyNotWritable(set, 'length'); +verifyConfigurable(set, 'length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/shell.js b/js/src/tests/test262/language/statements/class/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/static-classelementname-abrupt-completion.js b/js/src/tests/test262/language/statements/class/static-classelementname-abrupt-completion.js new file mode 100644 index 0000000000..f18907bedd --- /dev/null +++ b/js/src/tests/test262/language/statements/class/static-classelementname-abrupt-completion.js @@ -0,0 +1,35 @@ +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Class definition should error if evaluation of static ClassElementName errors +esid: runtime-semantics-class-definition-evaluation +info: | + Runtime Semantics: ClassDefinitionEvaluation + ... + 27. For each ClassElement e in order from elements + a. If IsStatic of e is false, then + i. Let fields be the result of performing ClassElementEvaluation + for e with arguments proto and false. + b. Else, + i. Let fields be the result of performing ClassElementEvaluation + for e with arguments F and false. + c. If fields is an abrupt completion, then + i. Set the running execution context's LexicalEnvironment to lex. + ii. Set the running execution context's PrivateNameEnvironment to outerPrivateEnvironment. + iii. Return Completion(status). + +features: [class-static-fields-public] +---*/ + +function f() { + throw new Test262Error(); +} + +assert.throws(Test262Error, function() { + class C { + static [f()] + } +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/static-gen-method-param-dflt-yield.js b/js/src/tests/test262/language/statements/class/static-gen-method-param-dflt-yield.js new file mode 100644 index 0000000000..f9db1da288 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/static-gen-method-param-dflt-yield.js @@ -0,0 +1,28 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-generator-function-definitions +es6id: 14.4 +description: > + YieldExpression cannot be used within the FormalParameters of a generator + function +info: | + GeneratorMethod[Yield]: + + * PropertyName[?Yield] ( StrictFormalParameters[Yield] ) { GeneratorBody } + + YieldExpression cannot be used within the FormalParameters of a generator + function because any expressions that are part of FormalParameters are + evaluated before the resulting generator object is in a resumable state. +features: [generators, default-parameters] +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +class C { + static *g(x = yield) {} +} diff --git a/js/src/tests/test262/language/statements/class/static-init-abrupt.js b/js/src/tests/test262/language/statements/class/static-init-abrupt.js new file mode 100644 index 0000000000..0f94cb1962 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/static-init-abrupt.js @@ -0,0 +1,48 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-class-definitions-static-semantics-early-errors +description: Returns abrupt completion and halts further class body evaluation +info: | + 34. For each element elementRecord of staticElements in List order, do + a. If elementRecord is a ClassFieldDefinition Record, then + [...] + b. Else, + i. Assert: fieldRecord is a ClassStaticBlockDefinition Record. + ii. Let status be the result of performing EvaluateStaticBlock(F, + elementRecord). + d. If status is an abrupt completion, then + i. Set the running execution context's LexicalEnvironment to lex. + ii. Set the running execution context's PrivateEnvironment to + outerPrivateEnvironment. + iii. Return Completion(status). +features: [class-static-fields-public, class-static-block] +---*/ + +var thrown = new Test262Error(); +var caught; +var sameBlock = false; +var subsequentField = false; +var subsequentBlock = false; + +try { + class C { + static { + throw thrown; + sameBlock = true; + } + static x = subsequentField = true; + static { + subsequentBlock = true; + } + } +} catch (error) { + caught = error; +} + +assert.sameValue(caught, thrown); +assert.sameValue(sameBlock, false, 'same block'); +assert.sameValue(subsequentField, false, 'subsequent field'); +assert.sameValue(subsequentBlock, false, 'subsequent block'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/static-init-arguments-functions.js b/js/src/tests/test262/language/statements/class/static-init-arguments-functions.js new file mode 100644 index 0000000000..0473586d1d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/static-init-arguments-functions.js @@ -0,0 +1,42 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-class-definitions-static-semantics-early-errors +description: The identifier `arguments` is not restricted within function forms +info: | + ClassStaticBlockBody : ClassStaticBlockStatementList + + - It is a Syntax Error if ContainsArguments of ClassStaticBlockStatementList + is true. +includes: [compareArray.js] +features: [class-static-block] +---*/ + +var fn, fnParam; +var gen, genParam; +var asyncFn, asyncFnParam; + +class C { + static { + (function({test262 = fnParam = arguments}) { + fn = arguments; + })('function'); + + (function * ({test262 = genParam = arguments}) { + gen = arguments; + })('generator function').next(); + + (async function ({test262 = asyncFnParam = arguments}) { + asyncFn = arguments; + })('async function'); + } +} + +assert.compareArray(['function'], fn, 'body'); +assert.compareArray(['function'], fnParam, 'parameter'); +assert.compareArray(['generator function'], gen, 'body'); +assert.compareArray(['generator function'], genParam, 'parameter'); +assert.compareArray(['async function'], asyncFn, 'body'); +assert.compareArray(['async function'], asyncFnParam, 'parameter'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/static-init-arguments-methods.js b/js/src/tests/test262/language/statements/class/static-init-arguments-methods.js new file mode 100644 index 0000000000..bb4f12c008 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/static-init-arguments-methods.js @@ -0,0 +1,60 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-class-definitions-static-semantics-early-errors +description: The identifier `arguments` is not restricted within method forms +info: | + ClassStaticBlockBody : ClassStaticBlockStatementList + + - It is a Syntax Error if ContainsArguments of ClassStaticBlockStatementList + is true. +includes: [compareArray.js] +features: [class-static-block] +---*/ + +var instance; +var method, methodParam; +var getter; +var setter, setterParam; +var genMethod, genMethodParam; +var asyncMethod, asyncMethodParam; + +class C { + static { + instance = new class { + method({test262 = methodParam = arguments}) { + method = arguments; + } + get accessor() { + getter = arguments; + } + set accessor({test262 = setterParam = arguments}) { + setter = arguments; + } + *gen({test262 = genMethodParam = arguments}) { + genMethod = arguments; + } + async async({test262 = asyncMethodParam = arguments}) { + asyncMethod = arguments; + } + }(); + } +} + +instance.method('method'); +instance.accessor; +instance.accessor = 'setter'; +instance.gen('generator method').next(); +instance.async('async method'); + +assert.compareArray(['method'], method, 'body'); +assert.compareArray(['method'], methodParam, 'parameter'); +assert.compareArray([], getter, 'body'); +assert.compareArray(['setter'], setter, 'body'); +assert.compareArray(['setter'], setterParam, 'parameter'); +assert.compareArray(['generator method'], genMethod, 'body'); +assert.compareArray(['generator method'], genMethodParam, 'parameter'); +assert.compareArray(['async method'], asyncMethod, 'body'); +assert.compareArray(['async method'], asyncMethodParam, 'parameter'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/static-init-await-binding-invalid.js b/js/src/tests/test262/language/statements/class/static-init-await-binding-invalid.js new file mode 100644 index 0000000000..071063276e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/static-init-await-binding-invalid.js @@ -0,0 +1,27 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-class-definitions-static-semantics-early-errors +description: BindingIdentifier may not be `await` within class static blocks +info: | + BindingIdentifier : Identifier + + [...] + - It is a Syntax Error if the code matched by this production is nested, + directly or indirectly (but not crossing function or static initialization + block boundaries), within a ClassStaticBlock and the StringValue of + Identifier is "await". +negative: + phase: parse + type: SyntaxError +features: [class-static-block] +---*/ + +$DONOTEVALUATE(); + +class C { + static { + class await {} + } +} diff --git a/js/src/tests/test262/language/statements/class/static-init-await-binding-valid.js b/js/src/tests/test262/language/statements/class/static-init-await-binding-valid.js new file mode 100644 index 0000000000..caecf44369 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/static-init-await-binding-valid.js @@ -0,0 +1,20 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-class-definitions-static-semantics-early-errors +description: The `await` keyword is interpreted as an identifier within arrow function bodies +info: | + ClassStaticBlockBody : ClassStaticBlockStatementList + + [...] + - It is a Syntax Error if ContainsAwait of ClassStaticBlockStatementList is true. +features: [class-static-block] +---*/ + +class C { + static { + (() => { class await {} }); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/static-init-expr-new-target.js b/js/src/tests/test262/language/statements/class/static-init-expr-new-target.js new file mode 100644 index 0000000000..8753b03bdd --- /dev/null +++ b/js/src/tests/test262/language/statements/class/static-init-expr-new-target.js @@ -0,0 +1,25 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-operations-on-objects +description: The "new.target" value within a static initialization block is undefined +info: | + 2.1.1 EvaluateStaticBlock ( receiver , blockRecord ) + + 1. Assert: Type(receiver) is Object. + 2. Assert: blockRecord is a ClassStaticBlockDefinition Record. + 3. Perform ? Call(blockRecord.[[Body]], receiver). +features: [class-static-block] +---*/ + +var value = null; + +class C { + static { + value = new.target; + } +} + +assert.sameValue(value, undefined); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/static-init-expr-this.js b/js/src/tests/test262/language/statements/class/static-init-expr-this.js new file mode 100644 index 0000000000..b71a935c13 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/static-init-expr-this.js @@ -0,0 +1,25 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-operations-on-objects +description: The "this" value within a static initialization block is the class +info: | + 2.1.1 EvaluateStaticBlock ( receiver , blockRecord ) + + 1. Assert: Type(receiver) is Object. + 2. Assert: blockRecord is a ClassStaticBlockDefinition Record. + 3. Perform ? Call(blockRecord.[[Body]], receiver). +features: [class-static-block] +---*/ + +var value; + +class C { + static { + value = this; + } +} + +assert.sameValue(value, C); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/static-init-invalid-arguments.js b/js/src/tests/test262/language/statements/class/static-init-invalid-arguments.js new file mode 100644 index 0000000000..1b80fe85ff --- /dev/null +++ b/js/src/tests/test262/language/statements/class/static-init-invalid-arguments.js @@ -0,0 +1,24 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-class-definitions-static-semantics-early-errors +description: Block cannot use `arguments` as an identifier +info: | + ClassStaticBlockBody : ClassStaticBlockStatementList + + - It is a Syntax Error if ContainsArguments of ClassStaticBlockStatementList + is true. +negative: + phase: parse + type: SyntaxError +features: [class-static-block] +---*/ + +$DONOTEVALUATE(); + +class C { + static { + (class { [argument\u0073]() {} }); + } +} diff --git a/js/src/tests/test262/language/statements/class/static-init-invalid-await.js b/js/src/tests/test262/language/statements/class/static-init-invalid-await.js new file mode 100644 index 0000000000..87dc665a6e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/static-init-invalid-await.js @@ -0,0 +1,34 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-class-definitions +description: The "Await" parsing context does not apply to the block's statement list +info: | + Syntax + + [...] + + ClassStaticBlockStatementList : + StatementList[~Yield, +Await, ~Return]opt + + ## 15.7.1 Static Semantics: Early Errors + + ClassStaticBlockBody : ClassStaticBlockStatementList + + - It is a Syntax Error if ContainsAwait of ClassStaticBlockStatementList is true. +negative: + phase: parse + type: SyntaxError +features: [class-static-block] +---*/ + +$DONOTEVALUATE(); + +async function f() { + class C { + static { + await 0; + } + } +} diff --git a/js/src/tests/test262/language/statements/class/static-init-invalid-label-dup.js b/js/src/tests/test262/language/statements/class/static-init-invalid-label-dup.js new file mode 100644 index 0000000000..3f8ffe448e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/static-init-invalid-label-dup.js @@ -0,0 +1,25 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-class-definitions-static-semantics-early-errors +description: Block cannot declare duplicate labels +info: | + ClassStaticBlockBody : ClassStaticBlockStatementList + + - It is a Syntax Error if ContainsDuplicateLabels of + ClassStaticBlockStatementList with argument « » is true. +negative: + phase: parse + type: SyntaxError +features: [class-static-block] +---*/ + +$DONOTEVALUATE(); + +class C { + static { + x: x: 0; + } +} + diff --git a/js/src/tests/test262/language/statements/class/static-init-invalid-lex-dup.js b/js/src/tests/test262/language/statements/class/static-init-invalid-lex-dup.js new file mode 100644 index 0000000000..2d750737cd --- /dev/null +++ b/js/src/tests/test262/language/statements/class/static-init-invalid-lex-dup.js @@ -0,0 +1,25 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-class-definitions-static-semantics-early-errors +description: Block cannot declare duplicate lexically-scoped bindings +info: | + ClassStaticBlockBody : ClassStaticBlockStatementList + + - It is a Syntax Error if the LexicallyDeclaredNames of + ClassStaticBlockStatementList contains any duplicate entries. +negative: + phase: parse + type: SyntaxError +features: [class-static-block] +---*/ + +$DONOTEVALUATE(); + +class C { + static { + let x; + let x; + } +} diff --git a/js/src/tests/test262/language/statements/class/static-init-invalid-lex-var.js b/js/src/tests/test262/language/statements/class/static-init-invalid-lex-var.js new file mode 100644 index 0000000000..2aa0e4286b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/static-init-invalid-lex-var.js @@ -0,0 +1,26 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-class-definitions-static-semantics-early-errors +description: Block cannot declare a lexically-scoped binding and function-scoped binding with the same name. +info: | + ClassStaticBlockBody : ClassStaticBlockStatementList + + - It is a Syntax Error if any element of the LexicallyDeclaredNames of + ClassStaticBlockStatementList also occurs in the VarDeclaredNames of + ClassStaticBlockStatementList. +negative: + phase: parse + type: SyntaxError +features: [class-static-block] +---*/ + +$DONOTEVALUATE(); + +class C { + static { + let x; + var x; + } +} diff --git a/js/src/tests/test262/language/statements/class/static-init-invalid-return.js b/js/src/tests/test262/language/statements/class/static-init-invalid-return.js new file mode 100644 index 0000000000..7ee3cbe89b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/static-init-invalid-return.js @@ -0,0 +1,28 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-class-definitions +description: The "Return" parsing context does not apply to the block's statement list +info: | + Syntax + + [...] + + ClassStaticBlockStatementList : + StatementList[~Yield, +Await, ~Return]opt +negative: + phase: parse + type: SyntaxError +features: [class-static-block] +---*/ + +$DONOTEVALUATE(); + +function f() { + class C { + static { + return; + } + } +} diff --git a/js/src/tests/test262/language/statements/class/static-init-invalid-super-call.js b/js/src/tests/test262/language/statements/class/static-init-invalid-super-call.js new file mode 100644 index 0000000000..774bcaf4d6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/static-init-invalid-super-call.js @@ -0,0 +1,23 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-class-definitions-static-semantics-early-errors +description: Block cannot contain SuperCall +info: | + ClassStaticBlock : static { ClassStaticBlockBody } + + - It is a Syntax Error if HasDirectSuper of ClassStaticBlock is true. +negative: + phase: parse + type: SyntaxError +features: [class-static-block] +---*/ + +$DONOTEVALUATE(); + +class C { + static { + super(); + } +} diff --git a/js/src/tests/test262/language/statements/class/static-init-invalid-undefined-break-target.js b/js/src/tests/test262/language/statements/class/static-init-invalid-undefined-break-target.js new file mode 100644 index 0000000000..f5a42e5d0a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/static-init-invalid-undefined-break-target.js @@ -0,0 +1,26 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-class-definitions-static-semantics-early-errors +description: Block cannot reference an undefined `break` target +info: | + ClassStaticBlockBody : ClassStaticBlockStatementList + + - It is a Syntax Error if ContainsUndefinedBreakTarget of + ClassStaticBlockStatementList with argument « » is true. +negative: + phase: parse + type: SyntaxError +features: [class-static-block] +---*/ + +$DONOTEVALUATE(); + +class C { + static { + x: while (false) { + break y; + } + } +} diff --git a/js/src/tests/test262/language/statements/class/static-init-invalid-undefined-continue-target.js b/js/src/tests/test262/language/statements/class/static-init-invalid-undefined-continue-target.js new file mode 100644 index 0000000000..b98dd61045 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/static-init-invalid-undefined-continue-target.js @@ -0,0 +1,26 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-class-definitions-static-semantics-early-errors +description: Block cannot reference an undefined `continue` target +info: | + ClassStaticBlockBody : ClassStaticBlockStatementList + + - It is a Syntax Error if ContainsUndefinedContinueTarget of + ClassStaticBlockStatementList with arguments « » and « » is true. +negative: + phase: parse + type: SyntaxError +features: [class-static-block] +---*/ + +$DONOTEVALUATE(); + +class C { + static { + x: while (false) { + continue y; + } + } +} diff --git a/js/src/tests/test262/language/statements/class/static-init-invalid-yield.js b/js/src/tests/test262/language/statements/class/static-init-invalid-yield.js new file mode 100644 index 0000000000..bd872a1e85 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/static-init-invalid-yield.js @@ -0,0 +1,28 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-class-definitions +description: The "Yield" parsing context does not apply to the block's statement list +info: | + Syntax + + [...] + + ClassStaticBlockStatementList : + StatementList[~Yield, +Await, ~Return]opt +negative: + phase: parse + type: SyntaxError +features: [class-static-block] +---*/ + +$DONOTEVALUATE(); + +function * g() { + class C { + static { + yield; + } + } +} diff --git a/js/src/tests/test262/language/statements/class/static-init-scope-lex-close.js b/js/src/tests/test262/language/statements/class/static-init-scope-lex-close.js new file mode 100644 index 0000000000..e433a49a5f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/static-init-scope-lex-close.js @@ -0,0 +1,29 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-runtime-semantics-classstaticblockdefinitionevaluation +description: Destruction of environment record for variable-scoped bindings +info: | + ClassStaticBlock : static { ClassStaticBlockBody } + + 1. Let lex be the running execution context's LexicalEnvironment. + 2. Let privateScope be the running execution context's PrivateEnvironment. + 3. Let body be OrdinaryFunctionCreate(Method, « », ClassStaticBlockBody, lex, privateScope). +features: [class-static-block] +---*/ + +var test262 = 'outer scope'; +var probe; + +class C { + static { + let test262 = 'first block'; + } + static { + probe = test262; + } +} + +assert.sameValue(probe, 'outer scope'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/static-init-scope-lex-derived.js b/js/src/tests/test262/language/statements/class/static-init-scope-lex-derived.js new file mode 100644 index 0000000000..364583c077 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/static-init-scope-lex-derived.js @@ -0,0 +1,25 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-runtime-semantics-classstaticblockdefinitionevaluation +description: Derivation of environment record for lexically-scoped bindings +info: | + ClassStaticBlock : static { ClassStaticBlockBody } + + 1. Let lex be the running execution context's LexicalEnvironment. + 2. Let privateScope be the running execution context's PrivateEnvironment. + 3. Let body be OrdinaryFunctionCreate(Method, « », ClassStaticBlockBody, lex, privateScope). +features: [class-static-block] +---*/ + +let probe; + +class C { + static { + probe = C; + } +} + +assert.sameValue(probe, C); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/static-init-scope-lex-open.js b/js/src/tests/test262/language/statements/class/static-init-scope-lex-open.js new file mode 100644 index 0000000000..8567ef1cff --- /dev/null +++ b/js/src/tests/test262/language/statements/class/static-init-scope-lex-open.js @@ -0,0 +1,33 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-runtime-semantics-classstaticblockdefinitionevaluation +description: Creation of new environment record for lexically-scoped bindings +info: | + ClassStaticBlock : static { ClassStaticBlockBody } + + 1. Let lex be the running execution context's LexicalEnvironment. + 2. Let privateScope be the running execution context's PrivateEnvironment. + 3. Let body be OrdinaryFunctionCreate(Method, « », ClassStaticBlockBody, lex, privateScope). +features: [class-static-block] +---*/ + +let test262 = 'outer scope'; +let probe1, probe2; + +class C { + static { + let test262 = 'first block'; + probe1 = test262; + } + static { + let test262 = 'second block'; + probe2 = test262; + } +} + +assert.sameValue(test262, 'outer scope'); +assert.sameValue(probe1, 'first block'); +assert.sameValue(probe2, 'second block'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/static-init-scope-private.js b/js/src/tests/test262/language/statements/class/static-init-scope-private.js new file mode 100644 index 0000000000..2718097083 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/static-init-scope-private.js @@ -0,0 +1,27 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-runtime-semantics-classstaticblockdefinitionevaluation +description: Shares environment record for privately-scoped bindings +info: | + ClassStaticBlock : static { ClassStaticBlockBody } + + 1. Let lex be the running execution context's LexicalEnvironment. + 2. Let privateScope be the running execution context's PrivateEnvironment. + 3. Let body be OrdinaryFunctionCreate(Method, « », ClassStaticBlockBody, lex, privateScope). +features: [class-fields-private, class-static-block] +---*/ + +var probe; + +class C { + static #test262 = 'private'; + + static { + probe = C.#test262; + } +} + +assert.sameValue(probe, 'private'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/static-init-scope-var-close.js b/js/src/tests/test262/language/statements/class/static-init-scope-var-close.js new file mode 100644 index 0000000000..f4e9f88a34 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/static-init-scope-var-close.js @@ -0,0 +1,29 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-runtime-semantics-classstaticblockdefinitionevaluation +description: Destruction of environment record for variable-scoped bindings +info: | + ClassStaticBlock : static { ClassStaticBlockBody } + + 1. Let lex be the running execution context's LexicalEnvironment. + 2. Let privateScope be the running execution context's PrivateEnvironment. + 3. Let body be OrdinaryFunctionCreate(Method, « », ClassStaticBlockBody, lex, privateScope). +features: [class-static-block] +---*/ + +var test262 = 'outer scope'; +var probe; + +class C { + static { + var test262 = 'first block'; + } + static { + probe = test262; + } +} + +assert.sameValue(probe, 'outer scope'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/static-init-scope-var-derived.js b/js/src/tests/test262/language/statements/class/static-init-scope-var-derived.js new file mode 100644 index 0000000000..befc4dd9cf --- /dev/null +++ b/js/src/tests/test262/language/statements/class/static-init-scope-var-derived.js @@ -0,0 +1,26 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-runtime-semantics-classstaticblockdefinitionevaluation +description: Derivation of environment record for variable-scoped bindings +info: | + ClassStaticBlock : static { ClassStaticBlockBody } + + 1. Let lex be the running execution context's LexicalEnvironment. + 2. Let privateScope be the running execution context's PrivateEnvironment. + 3. Let body be OrdinaryFunctionCreate(Method, « », ClassStaticBlockBody, lex, privateScope). +features: [class-static-block] +---*/ + +var test262 = 'outer scope'; +var probe; + +class C { + static { + probe = test262; + } +} + +assert.sameValue(probe, 'outer scope'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/static-init-scope-var-open.js b/js/src/tests/test262/language/statements/class/static-init-scope-var-open.js new file mode 100644 index 0000000000..0711446b8a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/static-init-scope-var-open.js @@ -0,0 +1,33 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-runtime-semantics-classstaticblockdefinitionevaluation +description: Creation of new environment record for variable-scoped bindings +info: | + ClassStaticBlock : static { ClassStaticBlockBody } + + 1. Let lex be the running execution context's LexicalEnvironment. + 2. Let privateScope be the running execution context's PrivateEnvironment. + 3. Let body be OrdinaryFunctionCreate(Method, « », ClassStaticBlockBody, lex, privateScope). +features: [class-static-block] +---*/ + +var test262 = 'outer scope'; +var probe1, probe2; + +class C { + static { + var test262 = 'first block'; + probe1 = test262; + } + static { + var test262 = 'second block'; + probe2 = test262; + } +} + +assert.sameValue(test262, 'outer scope'); +assert.sameValue(probe1, 'first block'); +assert.sameValue(probe2, 'second block'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/static-init-sequence.js b/js/src/tests/test262/language/statements/class/static-init-sequence.js new file mode 100644 index 0000000000..f3afe0139e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/static-init-sequence.js @@ -0,0 +1,40 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-runtime-semantics-classelementevaluation +description: Static blocks are evaluated in the order they appear in the source text, interleaved with static fields +info: | + 5.1.14 Runtime Semantics: ClassDefinitionEvaluation + + [...] + 34. For each element elementRecord of staticElements in List order, do + a. If elementRecord is a ClassFieldDefinition Record, then + i. Let status be the result of performing DefineField(F, + elementRecord). + b. Else, + i. Assert: fieldRecord is a ClassStaticBlockDefinition Record. + ii. Let status be the result of performing EvaluateStaticBlock(F, + elementRecord). + [...] +features: [class-static-fields-public, class-static-block] +---*/ + +var sequence = []; + +class C { + static x = sequence.push('first field'); + static { + sequence.push('first block'); + } + static x = sequence.push('second field'); + static { + sequence.push('second block'); + } +} + +assert.sameValue(sequence[0], 'first field'); +assert.sameValue(sequence[1], 'first block'); +assert.sameValue(sequence[2], 'second field'); +assert.sameValue(sequence[3], 'second block'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/static-init-statement-list-optional.js b/js/src/tests/test262/language/statements/class/static-init-statement-list-optional.js new file mode 100644 index 0000000000..21bf888ed7 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/static-init-statement-list-optional.js @@ -0,0 +1,20 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-class-definitions +description: The block's statement list is optional +info: | + Syntax + + [...] + + ClassStaticBlockStatementList : + StatementList[~Yield, +Await, ~Return]opt +features: [class-static-block] +---*/ + +class C { + static {} +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/static-init-super-property.js b/js/src/tests/test262/language/statements/class/static-init-super-property.js new file mode 100644 index 0000000000..1e28eb6753 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/static-init-super-property.js @@ -0,0 +1,26 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-runtime-semantics-classstaticblockdefinitionevaluation +description: The home object for a class static initialization block is the parent class +info: | + ClassStaticBlock : static { ClassStaticBlockBody } + + [...] + 4. Perform MakeMethod(body, homeObject). +features: [class-static-block] +---*/ + +function Parent() {} +Parent.test262 = 'test262'; +var value; + +class C extends Parent { + static { + value = super.test262; + } +} + +assert.sameValue(value, 'test262'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/static-method-gen-non-configurable-err.js b/js/src/tests/test262/language/statements/class/static-method-gen-non-configurable-err.js new file mode 100644 index 0000000000..09b60d1539 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/static-method-gen-non-configurable-err.js @@ -0,0 +1,19 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +description: Failure to define property for static generator method +info: | + [...] + 10. Let desc be the PropertyDescriptor{[[Value]]: closure, [[Writable]]: + true, [[Enumerable]]: enumerable, [[Configurable]]: true}. + 11. Return ? DefinePropertyOrThrow(object, propKey, desc). +features: [generators] +---*/ + +assert.throws(TypeError, function() { + class C { static *['prototype']() {} } +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/static-method-length-dflt.js b/js/src/tests/test262/language/statements/class/static-method-length-dflt.js new file mode 100644 index 0000000000..d8691ebe6d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/static-method-length-dflt.js @@ -0,0 +1,69 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.1.6 +description: > + Default parameters' effect on function length +info: | + Function length is counted by the non initialized parameters in the left. + + 9.2.4 FunctionInitialize (F, kind, ParameterList, Body, Scope) + + [...] + 2. Let len be the ExpectedArgumentCount of ParameterList. + 3. Perform ! DefinePropertyOrThrow(F, "length", PropertyDescriptor{[[Value]]: + len, [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true}). + [...] + + FormalsList : FormalParameter + + 1. If HasInitializer of FormalParameter is true return 0 + 2. Return 1. + + FormalsList : FormalsList , FormalParameter + + 1. Let count be the ExpectedArgumentCount of FormalsList. + 2. If HasInitializer of FormalsList is true or HasInitializer of + FormalParameter is true, return count. + 3. Return count+1. +features: [default-parameters] +includes: [propertyHelper.js] +---*/ + +class C1 { static m(x = 42) {} } + +var m1 = C1.m; + +assert.sameValue(m1.length, 0, 'formalslist: x = 42'); +verifyNotEnumerable(m1, 'length'); +verifyNotWritable(m1, 'length'); +verifyConfigurable(m1, 'length'); + +class C2 { static m(x = 42, y) {} } + +var m2 = C2.m; + +assert.sameValue(m2.length, 0, 'formalslist: x = 42, y'); +verifyNotEnumerable(m2, 'length'); +verifyNotWritable(m2, 'length'); +verifyConfigurable(m2, 'length'); + +class C3 { static m(x, y = 42) {} } + +var m3 = C3.m; + +assert.sameValue(m3.length, 1, 'formalslist: x, y = 42'); +verifyNotEnumerable(m3, 'length'); +verifyNotWritable(m3, 'length'); +verifyConfigurable(m3, 'length'); + +class C4 { static m(x, y = 42, z) {} } + +var m4 = C4.m; + +assert.sameValue(m4.length, 1, 'formalslist: x, y = 42, z'); +verifyNotEnumerable(m4, 'length'); +verifyNotWritable(m4, 'length'); +verifyConfigurable(m4, 'length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/static-method-non-configurable-err.js b/js/src/tests/test262/language/statements/class/static-method-non-configurable-err.js new file mode 100644 index 0000000000..404fa01f47 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/static-method-non-configurable-err.js @@ -0,0 +1,18 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-method-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.3.9 +description: Failure to define property for static method +info: | + [...] + 10. Let desc be the PropertyDescriptor{[[Value]]: closure, [[Writable]]: + true, [[Enumerable]]: enumerable, [[Configurable]]: true}. + 11. Return ? DefinePropertyOrThrow(object, propKey, desc). +---*/ + +assert.throws(TypeError, function() { + class C { static ['prototype']() {} } +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/static-method-param-yield.js b/js/src/tests/test262/language/statements/class/static-method-param-yield.js new file mode 100644 index 0000000000..ce498c7f29 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/static-method-param-yield.js @@ -0,0 +1,23 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-method-definitions +es6id: 14.3 +description: > + YieldExpression cannot be used within the FormalParameters of a class method +info: | + MethodDefinition[Yield] : + + PropertyName[?Yield] ( StrictFormalParameters ) { FunctionBody } +features: [generators, default-parameters] +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +class C { + static m(x = yield) {} +} diff --git a/js/src/tests/test262/language/statements/class/strict-mode/arguments-callee.js b/js/src/tests/test262/language/statements/class/strict-mode/arguments-callee.js new file mode 100644 index 0000000000..f0538aff17 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/strict-mode/arguments-callee.js @@ -0,0 +1,18 @@ +// Copyright (C) 2014 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.5 +description: > + class strict mode +---*/ +var D = class extends function() { + arguments.callee; +} {}; +assert.throws(TypeError, function() { + Object.getPrototypeOf(D).arguments; +}); +assert.throws(TypeError, function() { + new D; +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/strict-mode/browser.js b/js/src/tests/test262/language/statements/class/strict-mode/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/strict-mode/shell.js b/js/src/tests/test262/language/statements/class/strict-mode/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/strict-mode/with.js b/js/src/tests/test262/language/statements/class/strict-mode/with.js new file mode 100644 index 0000000000..064a6cd008 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/strict-mode/with.js @@ -0,0 +1,16 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2014 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.5 +description: > + class strict mode: `with` disallowed +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +class C extends (function B() { with ({}); return B; }()) {} + diff --git a/js/src/tests/test262/language/statements/class/subclass-builtins/browser.js b/js/src/tests/test262/language/statements/class/subclass-builtins/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/subclass-builtins/shell.js b/js/src/tests/test262/language/statements/class/subclass-builtins/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/subclass-builtins/subclass-AggregateError.js b/js/src/tests/test262/language/statements/class/subclass-builtins/subclass-AggregateError.js new file mode 100644 index 0000000000..7f1c35da3f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass-builtins/subclass-AggregateError.js @@ -0,0 +1,17 @@ +// This file was procedurally generated from the following sources: +// - src/subclass-builtins/AggregateError.case +// - src/subclass-builtins/default/statement.template +/*--- +description: new SubAggregateError() instanceof AggregateError (Subclass instanceof Heritage) +features: [AggregateError] +flags: [generated] +---*/ + + +class Subclass extends AggregateError {} + +const sub = new Subclass([]); +assert(sub instanceof Subclass); +assert(sub instanceof AggregateError); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass-builtins/subclass-Array.js b/js/src/tests/test262/language/statements/class/subclass-builtins/subclass-Array.js new file mode 100644 index 0000000000..4da3d445cd --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass-builtins/subclass-Array.js @@ -0,0 +1,16 @@ +// This file was procedurally generated from the following sources: +// - src/subclass-builtins/Array.case +// - src/subclass-builtins/default/statement.template +/*--- +description: new SubArray() instanceof Array (Subclass instanceof Heritage) +flags: [generated] +---*/ + + +class Subclass extends Array {} + +const sub = new Subclass(); +assert(sub instanceof Subclass); +assert(sub instanceof Array); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass-builtins/subclass-ArrayBuffer.js b/js/src/tests/test262/language/statements/class/subclass-builtins/subclass-ArrayBuffer.js new file mode 100644 index 0000000000..7c36fef86e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass-builtins/subclass-ArrayBuffer.js @@ -0,0 +1,17 @@ +// This file was procedurally generated from the following sources: +// - src/subclass-builtins/ArrayBuffer.case +// - src/subclass-builtins/default/statement.template +/*--- +description: new SubArrayBuffer() instanceof ArrayBuffer (Subclass instanceof Heritage) +features: [TypedArray, ArrayBuffer] +flags: [generated] +---*/ + + +class Subclass extends ArrayBuffer {} + +const sub = new Subclass(); +assert(sub instanceof Subclass); +assert(sub instanceof ArrayBuffer); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass-builtins/subclass-BigInt64Array.js b/js/src/tests/test262/language/statements/class/subclass-builtins/subclass-BigInt64Array.js new file mode 100644 index 0000000000..2c348d0750 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass-builtins/subclass-BigInt64Array.js @@ -0,0 +1,17 @@ +// This file was procedurally generated from the following sources: +// - src/subclass-builtins/BigInt64Array.case +// - src/subclass-builtins/default/statement.template +/*--- +description: new SubBigInt64Array() instanceof BigInt64Array (Subclass instanceof Heritage) +features: [TypedArray, BigInt] +flags: [generated] +---*/ + + +class Subclass extends BigInt64Array {} + +const sub = new Subclass(); +assert(sub instanceof Subclass); +assert(sub instanceof BigInt64Array); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass-builtins/subclass-BigUint64Array.js b/js/src/tests/test262/language/statements/class/subclass-builtins/subclass-BigUint64Array.js new file mode 100644 index 0000000000..4167ae674d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass-builtins/subclass-BigUint64Array.js @@ -0,0 +1,17 @@ +// This file was procedurally generated from the following sources: +// - src/subclass-builtins/BigUint64Array.case +// - src/subclass-builtins/default/statement.template +/*--- +description: new SubBigUint64Array() instanceof BigUint64Array (Subclass instanceof Heritage) +features: [TypedArray, BigInt] +flags: [generated] +---*/ + + +class Subclass extends BigUint64Array {} + +const sub = new Subclass(); +assert(sub instanceof Subclass); +assert(sub instanceof BigUint64Array); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass-builtins/subclass-Boolean.js b/js/src/tests/test262/language/statements/class/subclass-builtins/subclass-Boolean.js new file mode 100644 index 0000000000..c54788605e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass-builtins/subclass-Boolean.js @@ -0,0 +1,16 @@ +// This file was procedurally generated from the following sources: +// - src/subclass-builtins/Boolean.case +// - src/subclass-builtins/default/statement.template +/*--- +description: new SubBoolean() instanceof Boolean (Subclass instanceof Heritage) +flags: [generated] +---*/ + + +class Subclass extends Boolean {} + +const sub = new Subclass(); +assert(sub instanceof Subclass); +assert(sub instanceof Boolean); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass-builtins/subclass-DataView.js b/js/src/tests/test262/language/statements/class/subclass-builtins/subclass-DataView.js new file mode 100644 index 0000000000..3f554f75b5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass-builtins/subclass-DataView.js @@ -0,0 +1,17 @@ +// This file was procedurally generated from the following sources: +// - src/subclass-builtins/DataView.case +// - src/subclass-builtins/default/statement.template +/*--- +description: new SubDataView() instanceof DataView (Subclass instanceof Heritage) +features: [TypedArray, DataView] +flags: [generated] +---*/ + + +class Subclass extends DataView {} + +const sub = new Subclass(new ArrayBuffer(1)); +assert(sub instanceof Subclass); +assert(sub instanceof DataView); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass-builtins/subclass-Date.js b/js/src/tests/test262/language/statements/class/subclass-builtins/subclass-Date.js new file mode 100644 index 0000000000..5ef9ae4f1f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass-builtins/subclass-Date.js @@ -0,0 +1,16 @@ +// This file was procedurally generated from the following sources: +// - src/subclass-builtins/Date.case +// - src/subclass-builtins/default/statement.template +/*--- +description: new SubDate() instanceof Date (Subclass instanceof Heritage) +flags: [generated] +---*/ + + +class Subclass extends Date {} + +const sub = new Subclass(); +assert(sub instanceof Subclass); +assert(sub instanceof Date); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass-builtins/subclass-Error.js b/js/src/tests/test262/language/statements/class/subclass-builtins/subclass-Error.js new file mode 100644 index 0000000000..0b1abb0c67 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass-builtins/subclass-Error.js @@ -0,0 +1,16 @@ +// This file was procedurally generated from the following sources: +// - src/subclass-builtins/Error.case +// - src/subclass-builtins/default/statement.template +/*--- +description: new SubError() instanceof Error (Subclass instanceof Heritage) +flags: [generated] +---*/ + + +class Subclass extends Error {} + +const sub = new Subclass(); +assert(sub instanceof Subclass); +assert(sub instanceof Error); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass-builtins/subclass-EvalError.js b/js/src/tests/test262/language/statements/class/subclass-builtins/subclass-EvalError.js new file mode 100644 index 0000000000..bdd98e6ba5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass-builtins/subclass-EvalError.js @@ -0,0 +1,16 @@ +// This file was procedurally generated from the following sources: +// - src/subclass-builtins/EvalError.case +// - src/subclass-builtins/default/statement.template +/*--- +description: new SubEvalError() instanceof EvalError (Subclass instanceof Heritage) +flags: [generated] +---*/ + + +class Subclass extends EvalError {} + +const sub = new Subclass(); +assert(sub instanceof Subclass); +assert(sub instanceof EvalError); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass-builtins/subclass-Float32Array.js b/js/src/tests/test262/language/statements/class/subclass-builtins/subclass-Float32Array.js new file mode 100644 index 0000000000..576c9a5b26 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass-builtins/subclass-Float32Array.js @@ -0,0 +1,17 @@ +// This file was procedurally generated from the following sources: +// - src/subclass-builtins/Float32Array.case +// - src/subclass-builtins/default/statement.template +/*--- +description: new SubFloat32Array() instanceof Float32Array (Subclass instanceof Heritage) +features: [TypedArray, Float32Array] +flags: [generated] +---*/ + + +class Subclass extends Float32Array {} + +const sub = new Subclass(); +assert(sub instanceof Subclass); +assert(sub instanceof Float32Array); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass-builtins/subclass-Float64Array.js b/js/src/tests/test262/language/statements/class/subclass-builtins/subclass-Float64Array.js new file mode 100644 index 0000000000..68b383d543 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass-builtins/subclass-Float64Array.js @@ -0,0 +1,17 @@ +// This file was procedurally generated from the following sources: +// - src/subclass-builtins/Float64Array.case +// - src/subclass-builtins/default/statement.template +/*--- +description: new SubFloat64Array() instanceof Float64Array (Subclass instanceof Heritage) +features: [TypedArray, Float64Array] +flags: [generated] +---*/ + + +class Subclass extends Float64Array {} + +const sub = new Subclass(); +assert(sub instanceof Subclass); +assert(sub instanceof Float64Array); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass-builtins/subclass-Function.js b/js/src/tests/test262/language/statements/class/subclass-builtins/subclass-Function.js new file mode 100644 index 0000000000..1271932e28 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass-builtins/subclass-Function.js @@ -0,0 +1,16 @@ +// This file was procedurally generated from the following sources: +// - src/subclass-builtins/Function.case +// - src/subclass-builtins/default/statement.template +/*--- +description: new SubFunction() instanceof Function (Subclass instanceof Heritage) +flags: [generated] +---*/ + + +class Subclass extends Function {} + +const sub = new Subclass(); +assert(sub instanceof Subclass); +assert(sub instanceof Function); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass-builtins/subclass-Int16Array.js b/js/src/tests/test262/language/statements/class/subclass-builtins/subclass-Int16Array.js new file mode 100644 index 0000000000..b55e8e12d8 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass-builtins/subclass-Int16Array.js @@ -0,0 +1,17 @@ +// This file was procedurally generated from the following sources: +// - src/subclass-builtins/Int16Array.case +// - src/subclass-builtins/default/statement.template +/*--- +description: new SubInt16Array() instanceof Int16Array (Subclass instanceof Heritage) +features: [TypedArray, Int16Array] +flags: [generated] +---*/ + + +class Subclass extends Int16Array {} + +const sub = new Subclass(); +assert(sub instanceof Subclass); +assert(sub instanceof Int16Array); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass-builtins/subclass-Int32Array.js b/js/src/tests/test262/language/statements/class/subclass-builtins/subclass-Int32Array.js new file mode 100644 index 0000000000..8776f9f93d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass-builtins/subclass-Int32Array.js @@ -0,0 +1,17 @@ +// This file was procedurally generated from the following sources: +// - src/subclass-builtins/Int32Array.case +// - src/subclass-builtins/default/statement.template +/*--- +description: new SubInt32Array() instanceof Int32Array (Subclass instanceof Heritage) +features: [TypedArray, Int32Array] +flags: [generated] +---*/ + + +class Subclass extends Int32Array {} + +const sub = new Subclass(); +assert(sub instanceof Subclass); +assert(sub instanceof Int32Array); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass-builtins/subclass-Int8Array.js b/js/src/tests/test262/language/statements/class/subclass-builtins/subclass-Int8Array.js new file mode 100644 index 0000000000..416fa8db5b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass-builtins/subclass-Int8Array.js @@ -0,0 +1,17 @@ +// This file was procedurally generated from the following sources: +// - src/subclass-builtins/Int8Array.case +// - src/subclass-builtins/default/statement.template +/*--- +description: new SubInt8Array() instanceof Int8Array (Subclass instanceof Heritage) +features: [TypedArray, Int8Array] +flags: [generated] +---*/ + + +class Subclass extends Int8Array {} + +const sub = new Subclass(); +assert(sub instanceof Subclass); +assert(sub instanceof Int8Array); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass-builtins/subclass-Map.js b/js/src/tests/test262/language/statements/class/subclass-builtins/subclass-Map.js new file mode 100644 index 0000000000..a47e381092 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass-builtins/subclass-Map.js @@ -0,0 +1,17 @@ +// This file was procedurally generated from the following sources: +// - src/subclass-builtins/Map.case +// - src/subclass-builtins/default/statement.template +/*--- +description: new SubMap() instanceof Map (Subclass instanceof Heritage) +features: [Map] +flags: [generated] +---*/ + + +class Subclass extends Map {} + +const sub = new Subclass(); +assert(sub instanceof Subclass); +assert(sub instanceof Map); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass-builtins/subclass-Number.js b/js/src/tests/test262/language/statements/class/subclass-builtins/subclass-Number.js new file mode 100644 index 0000000000..c1d5057aab --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass-builtins/subclass-Number.js @@ -0,0 +1,16 @@ +// This file was procedurally generated from the following sources: +// - src/subclass-builtins/Number.case +// - src/subclass-builtins/default/statement.template +/*--- +description: new SubNumber() instanceof Number (Subclass instanceof Heritage) +flags: [generated] +---*/ + + +class Subclass extends Number {} + +const sub = new Subclass(); +assert(sub instanceof Subclass); +assert(sub instanceof Number); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass-builtins/subclass-Object.js b/js/src/tests/test262/language/statements/class/subclass-builtins/subclass-Object.js new file mode 100644 index 0000000000..b784f10b87 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass-builtins/subclass-Object.js @@ -0,0 +1,16 @@ +// This file was procedurally generated from the following sources: +// - src/subclass-builtins/Object.case +// - src/subclass-builtins/default/statement.template +/*--- +description: new SubObject() instanceof Object (Subclass instanceof Heritage) +flags: [generated] +---*/ + + +class Subclass extends Object {} + +const sub = new Subclass(); +assert(sub instanceof Subclass); +assert(sub instanceof Object); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass-builtins/subclass-Promise.js b/js/src/tests/test262/language/statements/class/subclass-builtins/subclass-Promise.js new file mode 100644 index 0000000000..3f74cc8625 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass-builtins/subclass-Promise.js @@ -0,0 +1,17 @@ +// This file was procedurally generated from the following sources: +// - src/subclass-builtins/Promise.case +// - src/subclass-builtins/default/statement.template +/*--- +description: new SubPromise() instanceof Promise (Subclass instanceof Heritage) +features: [Promise] +flags: [generated] +---*/ + + +class Subclass extends Promise {} + +const sub = new Subclass(() => {}); +assert(sub instanceof Subclass); +assert(sub instanceof Promise); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass-builtins/subclass-RangeError.js b/js/src/tests/test262/language/statements/class/subclass-builtins/subclass-RangeError.js new file mode 100644 index 0000000000..1c6693bcad --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass-builtins/subclass-RangeError.js @@ -0,0 +1,16 @@ +// This file was procedurally generated from the following sources: +// - src/subclass-builtins/RangeError.case +// - src/subclass-builtins/default/statement.template +/*--- +description: new SubRangeError() instanceof RangeError (Subclass instanceof Heritage) +flags: [generated] +---*/ + + +class Subclass extends RangeError {} + +const sub = new Subclass(); +assert(sub instanceof Subclass); +assert(sub instanceof RangeError); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass-builtins/subclass-ReferenceError.js b/js/src/tests/test262/language/statements/class/subclass-builtins/subclass-ReferenceError.js new file mode 100644 index 0000000000..05613c49ec --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass-builtins/subclass-ReferenceError.js @@ -0,0 +1,16 @@ +// This file was procedurally generated from the following sources: +// - src/subclass-builtins/ReferenceError.case +// - src/subclass-builtins/default/statement.template +/*--- +description: new SubReferenceError() instanceof ReferenceError (Subclass instanceof Heritage) +flags: [generated] +---*/ + + +class Subclass extends ReferenceError {} + +const sub = new Subclass(); +assert(sub instanceof Subclass); +assert(sub instanceof ReferenceError); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass-builtins/subclass-RegExp.js b/js/src/tests/test262/language/statements/class/subclass-builtins/subclass-RegExp.js new file mode 100644 index 0000000000..f1e8dc9869 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass-builtins/subclass-RegExp.js @@ -0,0 +1,16 @@ +// This file was procedurally generated from the following sources: +// - src/subclass-builtins/RegExp.case +// - src/subclass-builtins/default/statement.template +/*--- +description: new SubRegExp() instanceof RegExp (Subclass instanceof Heritage) +flags: [generated] +---*/ + + +class Subclass extends RegExp {} + +const sub = new Subclass(); +assert(sub instanceof Subclass); +assert(sub instanceof RegExp); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass-builtins/subclass-Set.js b/js/src/tests/test262/language/statements/class/subclass-builtins/subclass-Set.js new file mode 100644 index 0000000000..0724548e7d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass-builtins/subclass-Set.js @@ -0,0 +1,17 @@ +// This file was procedurally generated from the following sources: +// - src/subclass-builtins/Set.case +// - src/subclass-builtins/default/statement.template +/*--- +description: new SubSet() instanceof Set (Subclass instanceof Heritage) +features: [Set] +flags: [generated] +---*/ + + +class Subclass extends Set {} + +const sub = new Subclass(); +assert(sub instanceof Subclass); +assert(sub instanceof Set); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass-builtins/subclass-SharedArrayBuffer.js b/js/src/tests/test262/language/statements/class/subclass-builtins/subclass-SharedArrayBuffer.js new file mode 100644 index 0000000000..240412e689 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass-builtins/subclass-SharedArrayBuffer.js @@ -0,0 +1,18 @@ +// |reftest| skip-if(!this.hasOwnProperty('SharedArrayBuffer')) -- SharedArrayBuffer is not enabled unconditionally +// This file was procedurally generated from the following sources: +// - src/subclass-builtins/SharedArrayBuffer.case +// - src/subclass-builtins/default/statement.template +/*--- +description: new SubSharedArrayBuffer() instanceof SharedArrayBuffer (Subclass instanceof Heritage) +features: [SharedArrayBuffer] +flags: [generated] +---*/ + + +class Subclass extends SharedArrayBuffer {} + +const sub = new Subclass(); +assert(sub instanceof Subclass); +assert(sub instanceof SharedArrayBuffer); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass-builtins/subclass-String.js b/js/src/tests/test262/language/statements/class/subclass-builtins/subclass-String.js new file mode 100644 index 0000000000..8884f5bacc --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass-builtins/subclass-String.js @@ -0,0 +1,16 @@ +// This file was procedurally generated from the following sources: +// - src/subclass-builtins/String.case +// - src/subclass-builtins/default/statement.template +/*--- +description: new SubString() instanceof String (Subclass instanceof Heritage) +flags: [generated] +---*/ + + +class Subclass extends String {} + +const sub = new Subclass(); +assert(sub instanceof Subclass); +assert(sub instanceof String); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass-builtins/subclass-SyntaxError.js b/js/src/tests/test262/language/statements/class/subclass-builtins/subclass-SyntaxError.js new file mode 100644 index 0000000000..b865e826f1 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass-builtins/subclass-SyntaxError.js @@ -0,0 +1,16 @@ +// This file was procedurally generated from the following sources: +// - src/subclass-builtins/SyntaxError.case +// - src/subclass-builtins/default/statement.template +/*--- +description: new SubSyntaxError() instanceof SyntaxError (Subclass instanceof Heritage) +flags: [generated] +---*/ + + +class Subclass extends SyntaxError {} + +const sub = new Subclass(); +assert(sub instanceof Subclass); +assert(sub instanceof SyntaxError); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass-builtins/subclass-TypeError.js b/js/src/tests/test262/language/statements/class/subclass-builtins/subclass-TypeError.js new file mode 100644 index 0000000000..20f2b916c2 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass-builtins/subclass-TypeError.js @@ -0,0 +1,16 @@ +// This file was procedurally generated from the following sources: +// - src/subclass-builtins/TypeError.case +// - src/subclass-builtins/default/statement.template +/*--- +description: new SubTypeError() instanceof TypeError (Subclass instanceof Heritage) +flags: [generated] +---*/ + + +class Subclass extends TypeError {} + +const sub = new Subclass(); +assert(sub instanceof Subclass); +assert(sub instanceof TypeError); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass-builtins/subclass-URIError.js b/js/src/tests/test262/language/statements/class/subclass-builtins/subclass-URIError.js new file mode 100644 index 0000000000..2dfd7fae49 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass-builtins/subclass-URIError.js @@ -0,0 +1,16 @@ +// This file was procedurally generated from the following sources: +// - src/subclass-builtins/URIError.case +// - src/subclass-builtins/default/statement.template +/*--- +description: new SubURIError() instanceof URIError (Subclass instanceof Heritage) +flags: [generated] +---*/ + + +class Subclass extends URIError {} + +const sub = new Subclass(); +assert(sub instanceof Subclass); +assert(sub instanceof URIError); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass-builtins/subclass-Uint16Array.js b/js/src/tests/test262/language/statements/class/subclass-builtins/subclass-Uint16Array.js new file mode 100644 index 0000000000..11ef8aace7 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass-builtins/subclass-Uint16Array.js @@ -0,0 +1,17 @@ +// This file was procedurally generated from the following sources: +// - src/subclass-builtins/Uint16Array.case +// - src/subclass-builtins/default/statement.template +/*--- +description: new SubUint16Array() instanceof Uint16Array (Subclass instanceof Heritage) +features: [TypedArray, Uint16Array] +flags: [generated] +---*/ + + +class Subclass extends Uint16Array {} + +const sub = new Subclass(); +assert(sub instanceof Subclass); +assert(sub instanceof Uint16Array); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass-builtins/subclass-Uint32Array.js b/js/src/tests/test262/language/statements/class/subclass-builtins/subclass-Uint32Array.js new file mode 100644 index 0000000000..f349a0f3f8 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass-builtins/subclass-Uint32Array.js @@ -0,0 +1,17 @@ +// This file was procedurally generated from the following sources: +// - src/subclass-builtins/Uint32Array.case +// - src/subclass-builtins/default/statement.template +/*--- +description: new SubUint32Array() instanceof Uint32Array (Subclass instanceof Heritage) +features: [TypedArray, Uint32Array] +flags: [generated] +---*/ + + +class Subclass extends Uint32Array {} + +const sub = new Subclass(); +assert(sub instanceof Subclass); +assert(sub instanceof Uint32Array); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass-builtins/subclass-Uint8Array.js b/js/src/tests/test262/language/statements/class/subclass-builtins/subclass-Uint8Array.js new file mode 100644 index 0000000000..e542c6d412 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass-builtins/subclass-Uint8Array.js @@ -0,0 +1,17 @@ +// This file was procedurally generated from the following sources: +// - src/subclass-builtins/Uint8Array.case +// - src/subclass-builtins/default/statement.template +/*--- +description: new SubUint8Array() instanceof Uint8Array (Subclass instanceof Heritage) +features: [TypedArray, Uint8Array] +flags: [generated] +---*/ + + +class Subclass extends Uint8Array {} + +const sub = new Subclass(); +assert(sub instanceof Subclass); +assert(sub instanceof Uint8Array); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass-builtins/subclass-Uint8ClampedArray.js b/js/src/tests/test262/language/statements/class/subclass-builtins/subclass-Uint8ClampedArray.js new file mode 100644 index 0000000000..e45f89dbdb --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass-builtins/subclass-Uint8ClampedArray.js @@ -0,0 +1,17 @@ +// This file was procedurally generated from the following sources: +// - src/subclass-builtins/Uint8ClampedArray.case +// - src/subclass-builtins/default/statement.template +/*--- +description: new SubUint8ClampedArray() instanceof Uint8ClampedArray (Subclass instanceof Heritage) +features: [TypedArray, Uint8ClampedArray] +flags: [generated] +---*/ + + +class Subclass extends Uint8ClampedArray {} + +const sub = new Subclass(); +assert(sub instanceof Subclass); +assert(sub instanceof Uint8ClampedArray); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass-builtins/subclass-WeakMap.js b/js/src/tests/test262/language/statements/class/subclass-builtins/subclass-WeakMap.js new file mode 100644 index 0000000000..3e6b8ccf31 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass-builtins/subclass-WeakMap.js @@ -0,0 +1,17 @@ +// This file was procedurally generated from the following sources: +// - src/subclass-builtins/WeakMap.case +// - src/subclass-builtins/default/statement.template +/*--- +description: new SubWeakMap() instanceof WeakMap (Subclass instanceof Heritage) +features: [WeakMap] +flags: [generated] +---*/ + + +class Subclass extends WeakMap {} + +const sub = new Subclass(); +assert(sub instanceof Subclass); +assert(sub instanceof WeakMap); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass-builtins/subclass-WeakRef.js b/js/src/tests/test262/language/statements/class/subclass-builtins/subclass-WeakRef.js new file mode 100644 index 0000000000..fd97648922 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass-builtins/subclass-WeakRef.js @@ -0,0 +1,18 @@ +// |reftest| skip-if(!this.hasOwnProperty('WeakRef')) -- WeakRef is not enabled unconditionally +// This file was procedurally generated from the following sources: +// - src/subclass-builtins/WeakRef.case +// - src/subclass-builtins/default/statement.template +/*--- +description: new SubWeakRef() instanceof WeakRef (Subclass instanceof Heritage) +features: [WeakRef] +flags: [generated] +---*/ + + +class Subclass extends WeakRef {} + +const sub = new Subclass({}); +assert(sub instanceof Subclass); +assert(sub instanceof WeakRef); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass-builtins/subclass-WeakSet.js b/js/src/tests/test262/language/statements/class/subclass-builtins/subclass-WeakSet.js new file mode 100644 index 0000000000..969c54ced4 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass-builtins/subclass-WeakSet.js @@ -0,0 +1,17 @@ +// This file was procedurally generated from the following sources: +// - src/subclass-builtins/WeakSet.case +// - src/subclass-builtins/default/statement.template +/*--- +description: new SubWeakSet() instanceof WeakSet (Subclass instanceof Heritage) +features: [WeakSet] +flags: [generated] +---*/ + + +class Subclass extends WeakSet {} + +const sub = new Subclass(); +assert(sub instanceof Subclass); +assert(sub instanceof WeakSet); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass/binding.js b/js/src/tests/test262/language/statements/class/subclass/binding.js new file mode 100644 index 0000000000..cd22c23d35 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass/binding.js @@ -0,0 +1,54 @@ +// Copyright (C) 2014 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.5 +description: > + class subclass binding +---*/ +class Base { + constructor(x, y) { + this.x = x; + this.y = y; + } +} + +var obj = {}; +class Subclass extends Base { + constructor(x, y) { + super(x,y); + assert.sameValue(this !== obj, true, "The result of `this !== obj` is `true`"); + } +} + +var f = Subclass.bind(obj); +assert.throws(TypeError, function () { f(1, 2); }); +var s = new f(1, 2); +assert.sameValue(s.x, 1, "The value of `s.x` is `1`"); +assert.sameValue(s.y, 2, "The value of `s.y` is `2`"); +assert.sameValue( + Object.getPrototypeOf(s), + Subclass.prototype, + "`Object.getPrototypeOf(s)` returns `Subclass.prototype`" +); + +var s1 = new f(1); +assert.sameValue(s1.x, 1, "The value of `s1.x` is `1`"); +assert.sameValue(s1.y, undefined, "The value of `s1.y` is `undefined`"); +assert.sameValue( + Object.getPrototypeOf(s1), + Subclass.prototype, + "`Object.getPrototypeOf(s1)` returns `Subclass.prototype`" +); + +var g = Subclass.bind(obj, 1); +assert.throws(TypeError, function () { g(8); }); +var s2 = new g(8); +assert.sameValue(s2.x, 1, "The value of `s2.x` is `1`"); +assert.sameValue(s2.y, 8, "The value of `s2.y` is `8`"); +assert.sameValue( + Object.getPrototypeOf(s), + Subclass.prototype, + "`Object.getPrototypeOf(s)` returns `Subclass.prototype`" +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass/browser.js b/js/src/tests/test262/language/statements/class/subclass/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Array/browser.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Array/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Array/contructor-calls-super-multiple-arguments.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Array/contructor-calls-super-multiple-arguments.js new file mode 100644 index 0000000000..e1d285b914 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Array/contructor-calls-super-multiple-arguments.js @@ -0,0 +1,28 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 22.1.1 +description: > + Constructor calling super() with 2+ arguments creates an Array object +info: | + 22.1.1 The Array Constructor + + The Array constructor is designed to be subclassable. It may be used as the + value of an extends clause of a class definition. Subclass constructors that + intend to inherit the exotic Array behaviour must include a super call to the + Array constructor to initialize subclass instances that are exotic Array + objects. +includes: [compareArray.js] +---*/ + +class Sub extends Array { + constructor(a, b) { + super(a, b); + } +} + +var sub = new Sub(42, 'foo'); + +assert.compareArray(sub, [42, 'foo']); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Array/contructor-calls-super-single-argument.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Array/contructor-calls-super-single-argument.js new file mode 100644 index 0000000000..9311d7f278 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Array/contructor-calls-super-single-argument.js @@ -0,0 +1,27 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 22.1.1 +description: > + Constructor calling super() with a single argument creates an Array object +info: | + 22.1.1 The Array Constructor + + The Array constructor is designed to be subclassable. It may be used as the + value of an extends clause of a class definition. Subclass constructors that + intend to inherit the exotic Array behaviour must include a super call to the + Array constructor to initialize subclass instances that are exotic Array + objects. +---*/ + +class Sub extends Array { + constructor(a) { + super(a); + } +} + +var sub = new Sub(42); + +assert.sameValue(sub.length, 42); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Array/length.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Array/length.js new file mode 100644 index 0000000000..e19bc322a6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Array/length.js @@ -0,0 +1,38 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 22.1.4.1 +description: > + Instances has the own property length +info: | + 22.1.4.1 length + + The length property of an Array instance is a data property whose value is + always numerically greater than the name of every configurable own property + whose name is an array index. + + The length property initially has the attributes { [[Writable]]: true, + [[Enumerable]]: false, [[Configurable]]: false }. +---*/ + +class Ar extends Array {} + +var arr = new Ar('foo', 'bar'); + +assert.sameValue(arr[0], 'foo'); +assert.sameValue(arr[1], 'bar'); + +var arrDesc = Object.getOwnPropertyDescriptor(arr, 'length'); + +assert.sameValue(arrDesc.writable, true); +assert.sameValue(arrDesc.enumerable, false); +assert.sameValue(arrDesc.configurable, false); + +assert.sameValue(arr[1], 'bar'); + +arr.length = 1; + +assert.sameValue(arr[0], 'foo'); +assert.sameValue(arr[1], undefined); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Array/regular-subclassing.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Array/regular-subclassing.js new file mode 100644 index 0000000000..3b5df29719 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Array/regular-subclassing.js @@ -0,0 +1,35 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 22.1.1 +description: Subclassing Array +info: | + 22.1.1 The Array Constructor + + The Array constructor is designed to be subclassable. It may be used as the + value of an extends clause of a class definition. (...) +includes: [compareArray.js] +---*/ + +class Sub extends Array {} + +var a1 = new Sub(42, 'foo'); + +assert.sameValue(a1.length, 2); +assert.sameValue(a1[0], 42); +assert.sameValue(a1[1], 'foo'); + +a1.push(true); +assert.sameValue(a1.length, 3, 'Array#push updates the length property'); +assert.sameValue(a1[0], 42); +assert.sameValue(a1[1], 'foo'); +assert.sameValue(a1[2], true, 'Adds new item'); + +var a2 = new Sub(7); +assert.sameValue(a2.length, 7); + +var a3 = new Sub(); +assert.compareArray(a3, []); +assert.sameValue(a3.length, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Array/shell.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Array/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Array/super-must-be-called.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Array/super-must-be-called.js new file mode 100644 index 0000000000..134c3a7702 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Array/super-must-be-called.js @@ -0,0 +1,34 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 22.1.1 +description: Super need to be called to initialize internals +info: | + 22.1.1 The Array Constructor + + ... + + The Array constructor is designed to be subclassable. It may be used as the + value of an extends clause of a class definition. Subclass constructors that + intend to inherit the exotic Array behaviour must include a super call to the + Array constructor to initialize subclass instances that are exotic Array + objects. +---*/ + +class A extends Array { + constructor() {} +} + +assert.throws(ReferenceError, function() { + new A(); +}); + +class A2 extends Array { + constructor() { + super(); + } +} + +new A2(); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/ArrayBuffer/browser.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/ArrayBuffer/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/ArrayBuffer/regular-subclassing.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/ArrayBuffer/regular-subclassing.js new file mode 100644 index 0000000000..d2b319173a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/ArrayBuffer/regular-subclassing.js @@ -0,0 +1,28 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 24.1.2 +description: Subclassing the ArrayBuffer object +info: | + 24.1.2 The ArrayBuffer Constructor + + ... + + The ArrayBuffer constructor is designed to be subclassable. It may be used as + the value of an extends clause of a class definition. Subclass constructors + that intend to inherit the specified ArrayBuffer behaviour must include a + super call to the ArrayBuffer constructor to create and initialize subclass + instances with the internal state necessary to support the + ArrayBuffer.prototype built-in methods. +---*/ + +class AB extends ArrayBuffer {} + +var ab = new AB(4); + +var sliced = ab.slice(0, 1); + +assert(sliced instanceof AB); +assert(sliced instanceof ArrayBuffer); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/ArrayBuffer/shell.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/ArrayBuffer/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/ArrayBuffer/super-must-be-called.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/ArrayBuffer/super-must-be-called.js new file mode 100644 index 0000000000..232c344cee --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/ArrayBuffer/super-must-be-called.js @@ -0,0 +1,35 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 24.1.2 +description: Super need to be called to initialize internals +info: | + 24.1.2 The ArrayBuffer Constructor + + ... + + The ArrayBuffer constructor is designed to be subclassable. It may be used as + the value of an extends clause of a class definition. Subclass constructors + that intend to inherit the specified ArrayBuffer behaviour must include a + super call to the ArrayBuffer constructor to create and initialize subclass + instances with the internal state necessary to support the + ArrayBuffer.prototype built-in methods. +---*/ + +class AB1 extends ArrayBuffer { + constructor() {} +} + +assert.throws(ReferenceError, function() { + new AB1(1); +}); + +class AB2 extends ArrayBuffer { + constructor(length) { + super(length); + } +} + +new AB2(1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Boolean/browser.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Boolean/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Boolean/regular-subclassing.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Boolean/regular-subclassing.js new file mode 100644 index 0000000000..e296c1d4e3 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Boolean/regular-subclassing.js @@ -0,0 +1,25 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 19.3.1 +description: Subclassing Function +info: | + 19.3.1 The Boolean Constructor + + The Boolean constructor is designed to be subclassable. It may be used as the + value of an extends clause of a class definition. + ... +---*/ + +class Bln extends Boolean {} + +var b1 = new Bln(1); + +assert.notSameValue(b1, true, 'b1 is an Boolean object'); +assert.sameValue(b1.valueOf(), true); + +var b2 = new Bln(0); +assert.notSameValue(b2, false, 'bln is an Boolean object'); +assert.sameValue(b2.valueOf(), false); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Boolean/shell.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Boolean/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Boolean/super-must-be-called.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Boolean/super-must-be-called.js new file mode 100644 index 0000000000..fde940702f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Boolean/super-must-be-called.js @@ -0,0 +1,33 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 19.3.1 +description: Super need to be called to initialize Boolean internals +info: | + 19.3.1 The Boolean Constructor + + ... + Subclass constructors that intend to inherit the specified Boolean behaviour + must include a super call to the Boolean constructor to create and initialize + the subclass instance with a [[BooleanData]] internal slot. +---*/ + +class Bln extends Boolean { + constructor() {} +} + +// Boolean internals are not initialized +assert.throws(ReferenceError, function() { + new Bln(1); +}); + +class Bln2 extends Boolean { + constructor() { + super(); + } +} + +var b = new Bln2(1); +assert(b instanceof Boolean); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/DataView/browser.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/DataView/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/DataView/regular-subclassing.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/DataView/regular-subclassing.js new file mode 100644 index 0000000000..fe91d32a2b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/DataView/regular-subclassing.js @@ -0,0 +1,30 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 24.2.2 +description: Subclassing the DataView object +info: | + 24.2.2 The DataView Constructor + + ... + + The DataView constructor is designed to be subclassable. It may be used as the + value of an extends clause of a class definition. Subclass constructors that + intend to inherit the specified DataView behaviour must include a super call + to the DataView constructor to create and initialize subclass instances with + the internal state necessary to support the DataView.prototype built-in + methods. +---*/ + +class DV extends DataView {} + +var buffer = new ArrayBuffer(1); + +var dv = new DV(buffer); +assert.sameValue(dv.buffer, buffer); + +assert.throws(TypeError, function() { + new DV(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/DataView/shell.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/DataView/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/DataView/super-must-be-called.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/DataView/super-must-be-called.js new file mode 100644 index 0000000000..9693b9a205 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/DataView/super-must-be-called.js @@ -0,0 +1,37 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 24.2.2 +description: Super need to be called to initialize internals +info: | + 24.2.2 The DataView Constructor + + ... + + The DataView constructor is designed to be subclassable. It may be used as the + value of an extends clause of a class definition. Subclass constructors that + intend to inherit the specified DataView behaviour must include a super call + to the DataView constructor to create and initialize subclass instances with + the internal state necessary to support the DataView.prototype built-in + methods. +---*/ + +class DV1 extends DataView { + constructor() {} +} + +var buffer = new ArrayBuffer(1); + +assert.throws(ReferenceError, function() { + new DV1(buffer); +}); + +class DV2 extends DataView { + constructor(length) { + super(length); + } +} + +new DV2(buffer); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Date/browser.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Date/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Date/regular-subclassing.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Date/regular-subclassing.js new file mode 100644 index 0000000000..41619f26b4 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Date/regular-subclassing.js @@ -0,0 +1,39 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 20.3.2 +description: Subclassing the String object +info: | + 20.3.2 The Date Constructor + + ... + + The Date constructor is a single function whose behaviour is overloaded based + upon the number and types of its arguments. + + The Date constructor is designed to be subclassable. It may be used as the + value of an extends clause of a class definition. Subclass constructors that + intend to inherit the specified Date behaviour must include a super call to + the Date constructor to create and initialize the subclass instance with a + [[DateValue]] internal slot. +---*/ + +class D extends Date {} + +var d1 = new D(1859, '10', 24, 11); +assert.sameValue(d1.getFullYear(), 1859); +assert.sameValue(d1.getMonth(), 10); +assert.sameValue(d1.getDate(), 24); + +var d2 = new D(-3474558000000); +assert.sameValue(d2.getUTCFullYear(), 1859); +assert.sameValue(d2.getUTCMonth(), 10); +assert.sameValue(d2.getUTCDate(), 24); + +var d3 = new D(); +var d4 = new Date(); +assert.sameValue(d3.getFullYear(), d4.getFullYear()); +assert.sameValue(d3.getMonth(), d4.getMonth()); +assert.sameValue(d3.getDate(), d4.getDate()); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Date/shell.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Date/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Date/super-must-be-called.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Date/super-must-be-called.js new file mode 100644 index 0000000000..8099ac871f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Date/super-must-be-called.js @@ -0,0 +1,37 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 20.3.2 +description: Super need to be called to initialize internals +info: | + 20.3.2 The Date Constructor + + ... + + The Date constructor is a single function whose behaviour is overloaded based + upon the number and types of its arguments. + + The Date constructor is designed to be subclassable. It may be used as the + value of an extends clause of a class definition. Subclass constructors that + intend to inherit the specified Date behaviour must include a super call to + the Date constructor to create and initialize the subclass instance with a + [[DateValue]] internal slot. +---*/ + +class D extends Date { + constructor() {} +} + +assert.throws(ReferenceError, function() { + new D(); +}); + +class D2 extends Date { + constructor() { + super(); + } +} + +new D2(); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Error/browser.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Error/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Error/message-property-assignment.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Error/message-property-assignment.js new file mode 100644 index 0000000000..afa9b7e924 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Error/message-property-assignment.js @@ -0,0 +1,38 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 19.5.1.1 +description: > + A new instance has the message property if created with a parameter +info: | + 19.5.1.1 Error ( message ) + + ... + 4. If message is not undefined, then + a. Let msg be ToString(message). + b. ReturnIfAbrupt(msg). + c. Let msgDesc be the PropertyDescriptor{[[Value]]: msg, [[Writable]]: true, + [[Enumerable]]: false, [[Configurable]]: true}. + d. Let status be DefinePropertyOrThrow(O, "message", msgDesc). + ... +includes: [propertyHelper.js] + +---*/ + +class Err extends Error {} + +Err.prototype.message = 'custom-error'; + +var err1 = new Err('foo 42'); +assert.sameValue(err1.message, 'foo 42'); +assert(err1.hasOwnProperty('message')); + +verifyWritable(err1, 'message'); +verifyNotEnumerable(err1, 'message'); +verifyConfigurable(err1, 'message'); + +var err2 = new Err(); +assert.sameValue(err2.hasOwnProperty('message'), false); +assert.sameValue(err2.message, 'custom-error'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Error/regular-subclassing.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Error/regular-subclassing.js new file mode 100644 index 0000000000..d34c85cb3c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Error/regular-subclassing.js @@ -0,0 +1,24 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 19.5.1 +description: Subclassing the Error object +info: | + 19.5.1 The Error Constructor + + ... + The Error constructor is designed to be subclassable. It may be used as the + alue of an extends clause of a class definition. Subclass constructors that + intend to inherit the specified Error behaviour must include a super call to + the Error constructor to create and initialize subclass instances with a + [[ErrorData]] internal slot. +---*/ + +class CustomError extends Error {} + +var err = new CustomError('foo 42'); + +assert.sameValue(err.message, 'foo 42'); +assert.sameValue(err.name, 'Error'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Error/shell.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Error/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Error/super-must-be-called.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Error/super-must-be-called.js new file mode 100644 index 0000000000..8d7dcae53e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Error/super-must-be-called.js @@ -0,0 +1,25 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 19.5.1 +description: Super need to be called to initialize internals +info: | + 19.5.1 The Error Constructor + + ... + The Error constructor is designed to be subclassable. It may be used as the + alue of an extends clause of a class definition. Subclass constructors that + intend to inherit the specified Error behaviour must include a super call to + the Error constructor to create and initialize subclass instances with a + [[ErrorData]] internal slot. +---*/ + +class CustomError extends Error { + constructor() {} +} + +assert.throws(ReferenceError, function() { + new CustomError('foo'); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Function/browser.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Function/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Function/instance-length.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Function/instance-length.js new file mode 100644 index 0000000000..d14cd344d4 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Function/instance-length.js @@ -0,0 +1,29 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 19.2.4.1 +description: Subclassed Function instances has length and name properties +info: | + 19.2.4.1 length + + The value of the length property is an integer that indicates the typical + number of arguments expected by the function. However, the language permits + the function to be invoked with some other number of arguments. The behaviour + of a function when invoked on a number of arguments other than the number + specified by its length property depends on the function. This property has + the attributes { [[Writable]]: false, [[Enumerable]]: false, + [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +class Fn extends Function {} + +var fn = new Fn('a', 'b', 'return a + b'); + +assert.sameValue(fn.length, 2); + +verifyNotEnumerable(fn, 'length'); +verifyNotWritable(fn, 'length'); +verifyConfigurable(fn, 'length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Function/instance-name.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Function/instance-name.js new file mode 100644 index 0000000000..6648909da4 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Function/instance-name.js @@ -0,0 +1,41 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 19.2.4.2 +description: Subclassed Function instances has length and name properties +info: | + 19.2.4.2 name + + The value of the name property is an String that is descriptive of the + function. The name has no semantic significance but is typically a variable or + property name that is used to refer to the function at its point of definition + in ECMAScript code. This property has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. + + Anonymous functions objects that do not have a contextual name associated with + them by this specification do not have a name own property but inherit the + name property of %FunctionPrototype%. + + 19.2.1.1.1 RuntimeSemantics: CreateDynamicFunction(constructor, newTarget, + kind, args) + + ... + 29. Perform SetFunctionName(F, "anonymous"). + ... +includes: [propertyHelper.js] +---*/ + +class Fn extends Function {} + +var fn = new Fn('a', 'b', 'return a + b'); + +assert.sameValue( + fn.name, 'anonymous', + 'Dynamic Functions are called anonymous' +); + +verifyNotEnumerable(fn, 'name'); +verifyNotWritable(fn, 'name'); +verifyConfigurable(fn, 'name'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Function/regular-subclassing.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Function/regular-subclassing.js new file mode 100644 index 0000000000..d68fb28206 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Function/regular-subclassing.js @@ -0,0 +1,22 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 19.2.1 +description: Subclassing Function +info: | + 19.2.1 The Function Constructor + + ... + + The Function constructor is designed to be subclassable. It may be used as the + value of an extends clause of a class definition. + ... +---*/ + +class Fn extends Function {} + +var fn = new Fn('a', 'return a * 2'); + +assert.sameValue(fn(42), 84); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Function/shell.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Function/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Function/super-must-be-called.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Function/super-must-be-called.js new file mode 100644 index 0000000000..9d8fc30c0c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Function/super-must-be-called.js @@ -0,0 +1,37 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 19.2.1 +description: > + super must be called to initialize Function internal slots +info: | + 19.2.1 The Function Constructor + + ... + + The Function constructor is designed to be subclassable. It may be used as the + value of an extends clause of a class definition. Subclass constructors that + intend to inherit the specified Function behaviour must include a super call + to the Function constructor to create and initialize a subclass instances with + the internal slots necessary for built-in function behaviour. + ... +---*/ + +class Fn extends Function { + constructor() {} +} + +assert.throws(ReferenceError, function() { + new Fn(); +}); + +class Fn2 extends Function { + constructor() { + super(); + } +} + +var fn = new Fn2(); +assert(fn instanceof Function); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/GeneratorFunction/browser.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/GeneratorFunction/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/GeneratorFunction/instance-length.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/GeneratorFunction/instance-length.js new file mode 100644 index 0000000000..f5d17fe131 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/GeneratorFunction/instance-length.js @@ -0,0 +1,33 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 25.2.4.1 +description: > + Subclassed GeneratorFunction instances `length` property +info: | + 25.2.4.1 length + + The value of the length property is an integer that indicates the typical + number of arguments expected by the GeneratorFunction. However, the language + permits the function to be invoked with some other number of arguments. The + behaviour of a GeneratorFunction when invoked on a number of arguments other + than the number specified by its length property depends on the function. + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, + [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +var GeneratorFunction = Object.getPrototypeOf(function* () {}).constructor; + +class GFn extends GeneratorFunction {} + +var gfn = new GFn('a', 'b', 'return a + b'); + +assert.sameValue(gfn.length, 2); + +verifyNotEnumerable(gfn, 'length'); +verifyNotWritable(gfn, 'length'); +verifyConfigurable(gfn, 'length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/GeneratorFunction/instance-name.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/GeneratorFunction/instance-name.js new file mode 100644 index 0000000000..69be80c2e4 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/GeneratorFunction/instance-name.js @@ -0,0 +1,48 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 25.2.4.2 +description: Subclassed GeneratorFunction instances `name` property +info: | + 25.2.4.2 name + + The specification for the name property of Function instances given in + 19.2.4.2 also applies to GeneratorFunction instances. + + 19.2.4.2 name + + The value of the name property is an String that is descriptive of the + function. The name has no semantic significance but is typically a variable or + property name that is used to refer to the function at its point of definition + in ECMAScript code. This property has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. + + Anonymous functions objects that do not have a contextual name associated with + them by this specification do not have a name own property but inherit the + name property of %FunctionPrototype%. + + 19.2.1.1.1 RuntimeSemantics: CreateDynamicFunction(constructor, newTarget, + kind, args) + + ... + 29. Perform SetFunctionName(F, "anonymous"). + ... +includes: [propertyHelper.js] +---*/ + +var GeneratorFunction = Object.getPrototypeOf(function* () {}).constructor; + +class GFn extends GeneratorFunction {} + +var gfn = new GFn('a', 'b', 'return a + b'); + +assert.sameValue( + gfn.name, 'anonymous', + 'Dynamic Functions are called anonymous' +); + +verifyNotEnumerable(gfn, 'name'); +verifyNotWritable(gfn, 'name'); +verifyConfigurable(gfn, 'name'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/GeneratorFunction/instance-prototype.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/GeneratorFunction/instance-prototype.js new file mode 100644 index 0000000000..3b4029adcd --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/GeneratorFunction/instance-prototype.js @@ -0,0 +1,40 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 25.2.4.3 +description: > + Subclassed GeneratorFunction instances `prototype` property +info: | + 25.2.4.3 prototype + + Whenever a GeneratorFunction instance is created another ordinary object is + also created and is the initial value of the generator function’s prototype + property. The value of the prototype property is used to initialize the + [[Prototype]] internal slot of a newly created Generator object when the + generator function object is invoked using either [[Call]] or [[Construct]]. + + This property has the attributes { [[Writable]]: true, [[Enumerable]]: false, + [[Configurable]]: false }. +includes: [propertyHelper.js] +---*/ + +var GeneratorFunction = Object.getPrototypeOf(function* () {}).constructor; + +class GFn extends GeneratorFunction {} + +var gfn = new GFn(';'); + +assert.sameValue( + Object.keys(gfn.prototype).length, 0, + 'prototype is a new ordinary object' +); +assert.sameValue( + gfn.prototype.hasOwnProperty('constructor'), false, + 'prototype has no constructor reference' +); + +verifyNotEnumerable(gfn, 'prototype'); +verifyWritable(gfn, 'prototype'); +verifyNotConfigurable(gfn, 'prototype'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/GeneratorFunction/regular-subclassing.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/GeneratorFunction/regular-subclassing.js new file mode 100644 index 0000000000..55a8c2ded5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/GeneratorFunction/regular-subclassing.js @@ -0,0 +1,31 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 25.2.1 +description: Subclassing GeneratorFunction +info: | + 25.2.1 The GeneratorFunction Constructor + + ... + + GeneratorFunction is designed to be subclassable. It may be used as the value + of an extends clause of a class definition. Subclass constructors that intend + to inherit the specified GeneratorFunction behaviour must include a super call + to the GeneratorFunction constructor to create and initialize subclass + instances with the internal slots necessary for built-in GeneratorFunction + behaviour. + ... +---*/ + +var GeneratorFunction = Object.getPrototypeOf(function* () {}).constructor; + +class Gfn extends GeneratorFunction {} + +var gfn = new Gfn('a', 'yield a; yield a * 2;'); + +var iter = gfn(42); + +assert.sameValue(iter.next().value, 42); +assert.sameValue(iter.next().value, 84); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/GeneratorFunction/shell.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/GeneratorFunction/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/GeneratorFunction/super-must-be-called.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/GeneratorFunction/super-must-be-called.js new file mode 100644 index 0000000000..6d3aa6004d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/GeneratorFunction/super-must-be-called.js @@ -0,0 +1,40 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 25.2.1 +description: > + super must be called to initialize GeneratorFunction internal slots +info: | + 25.2.1 The GeneratorFunction Constructor + + ... + + GeneratorFunction is designed to be subclassable. It may be used as the value + of an extends clause of a class definition. Subclass constructors that intend + to inherit the specified GeneratorFunction behaviour must include a super call + to the GeneratorFunction constructor to create and initialize subclass + instances with the internal slots necessary for built-in GeneratorFunction + behaviour. + ... +---*/ + +var GeneratorFunction = Object.getPrototypeOf(function* () {}).constructor; + +class GFn1 extends GeneratorFunction { + constructor() {} +} + +assert.throws(ReferenceError, function() { + new GFn1(); +}); + +class GFn2 extends GeneratorFunction { + constructor() { + super(); + } +} + +var fn = new GFn2(); +assert(fn instanceof GeneratorFunction); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Map/browser.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Map/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Map/regular-subclassing.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Map/regular-subclassing.js new file mode 100644 index 0000000000..755b2b1faa --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Map/regular-subclassing.js @@ -0,0 +1,28 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 23.1.1 +description: Subclassing the Map object +info: | + 23.1.1 The Map Constructor + + ... + + The Map constructor is designed to be subclassable. It may be used as the + value in an extends clause of a class definition. Subclass constructors that + intend to inherit the specified Map behaviour must include a super call to the + Map constructor to create and initialize the subclass instance with the + internal state necessary to support the Map.prototype built-in methods. +---*/ + +class M extends Map {} + +var map = new M([{ 'foo': 'bar' }]); + +assert.sameValue(map.size, 1); + +map.set('bar', 'baz'); + +assert.sameValue(map.size, 2); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Map/shell.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Map/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Map/super-must-be-called.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Map/super-must-be-called.js new file mode 100644 index 0000000000..23d3e8dbf8 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Map/super-must-be-called.js @@ -0,0 +1,34 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 23.1.1 +description: Super need to be called to initialize internals +info: | + 23.1.1 The Map Constructor + + ... + + The Map constructor is designed to be subclassable. It may be used as the + value in an extends clause of a class definition. Subclass constructors that + intend to inherit the specified Map behaviour must include a super call to the + Map constructor to create and initialize the subclass instance with the + internal state necessary to support the Map.prototype built-in methods. +---*/ + +class M1 extends Map { + constructor() {} +} + +assert.throws(ReferenceError, function() { + new M1(); +}); + +class M2 extends Map { + constructor() { + super(); + } +} + +new M2(); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/NativeError/EvalError-message.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/NativeError/EvalError-message.js new file mode 100644 index 0000000000..6d911069bf --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/NativeError/EvalError-message.js @@ -0,0 +1,37 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 19.5.6.1.1 +description: > + A new instance has the message property if created with a parameter +info: | + 19.5.6.1.1 NativeError ( message ) + + ... + 4. If message is not undefined, then + a. Let msg be ToString(message). + b. Let msgDesc be the PropertyDescriptor{[[Value]]: msg, [[Writable]]: true, + [[Enumerable]]: false, [[Configurable]]: true}. + c. Let status be DefinePropertyOrThrow(O, "message", msgDesc). + ... +includes: [propertyHelper.js] + +---*/ + +class Err extends EvalError {} + +Err.prototype.message = 'custom-eval-error'; + +var err1 = new Err('foo 42'); +assert.sameValue(err1.message, 'foo 42'); +assert(err1.hasOwnProperty('message')); + +verifyWritable(err1, 'message'); +verifyNotEnumerable(err1, 'message'); +verifyConfigurable(err1, 'message'); + +var err2 = new Err(); +assert.sameValue(err2.hasOwnProperty('message'), false); +assert.sameValue(err2.message, 'custom-eval-error'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/NativeError/EvalError-name.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/NativeError/EvalError-name.js new file mode 100644 index 0000000000..9f4c87eeb5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/NativeError/EvalError-name.js @@ -0,0 +1,20 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 19.5.6.1.1 +description: > + The name property on a new instance +info: | + 19.5.6.3.3 NativeError.prototype.name + + The initial value of the name property of the prototype for a given + NativeError constructor is a string consisting of the name of the constructor + (the name used instead of NativeError). +---*/ + +class Err extends EvalError {} + +var err1 = new Err(); +assert.sameValue(err1.name, 'EvalError'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/NativeError/EvalError-super.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/NativeError/EvalError-super.js new file mode 100644 index 0000000000..3e7055bcc0 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/NativeError/EvalError-super.js @@ -0,0 +1,25 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 19.5.6.1 +description: Super need to be called to initialize internals +info: | + 19.5.6.1 NativeError Constructors + + ... + Each NativeError constructor is designed to be subclassable. It may be used as + the value of an extends clause of a class definition. Subclass constructors + that intend to inherit the specified NativeError behaviour must include a + super call to the NativeError constructor to create and initialize subclass + instances with a [[ErrorData]] internal slot. +---*/ + +class CustomError extends EvalError { + constructor() {} +} + +assert.throws(ReferenceError, function() { + new CustomError(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/NativeError/RangeError-message.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/NativeError/RangeError-message.js new file mode 100644 index 0000000000..28931bfcd5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/NativeError/RangeError-message.js @@ -0,0 +1,37 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 19.5.6.1.1 +description: > + A new instance has the message property if created with a parameter +info: | + 19.5.6.1.1 NativeError ( message ) + + ... + 4. If message is not undefined, then + a. Let msg be ToString(message). + b. Let msgDesc be the PropertyDescriptor{[[Value]]: msg, [[Writable]]: true, + [[Enumerable]]: false, [[Configurable]]: true}. + c. Let status be DefinePropertyOrThrow(O, "message", msgDesc). + ... +includes: [propertyHelper.js] + +---*/ + +class Err extends RangeError {} + +Err.prototype.message = 'custom-range-error'; + +var err1 = new Err('foo 42'); +assert.sameValue(err1.message, 'foo 42'); +assert(err1.hasOwnProperty('message')); + +verifyWritable(err1, 'message'); +verifyNotEnumerable(err1, 'message'); +verifyConfigurable(err1, 'message'); + +var err2 = new Err(); +assert.sameValue(err2.hasOwnProperty('message'), false); +assert.sameValue(err2.message, 'custom-range-error'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/NativeError/RangeError-name.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/NativeError/RangeError-name.js new file mode 100644 index 0000000000..49a05b2ab0 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/NativeError/RangeError-name.js @@ -0,0 +1,20 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 19.5.6.1.1 +description: > + The name property on a new instance +info: | + 19.5.6.3.3 NativeError.prototype.name + + The initial value of the name property of the prototype for a given + NativeError constructor is a string consisting of the name of the constructor + (the name used instead of NativeError). +---*/ + +class Err extends RangeError {} + +var err1 = new Err(); +assert.sameValue(err1.name, 'RangeError'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/NativeError/RangeError-super.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/NativeError/RangeError-super.js new file mode 100644 index 0000000000..af5a17d16e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/NativeError/RangeError-super.js @@ -0,0 +1,25 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 19.5.6.1 +description: Super need to be called to initialize internals +info: | + 19.5.6.1 NativeError Constructors + + ... + Each NativeError constructor is designed to be subclassable. It may be used as + the value of an extends clause of a class definition. Subclass constructors + that intend to inherit the specified NativeError behaviour must include a + super call to the NativeError constructor to create and initialize subclass + instances with a [[ErrorData]] internal slot. +---*/ + +class CustomError extends RangeError { + constructor() {} +} + +assert.throws(ReferenceError, function() { + new CustomError(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/NativeError/ReferenceError-message.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/NativeError/ReferenceError-message.js new file mode 100644 index 0000000000..cb5626c984 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/NativeError/ReferenceError-message.js @@ -0,0 +1,37 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 19.5.6.1.1 +description: > + A new instance has the message property if created with a parameter +info: | + 19.5.6.1.1 NativeError ( message ) + + ... + 4. If message is not undefined, then + a. Let msg be ToString(message). + b. Let msgDesc be the PropertyDescriptor{[[Value]]: msg, [[Writable]]: true, + [[Enumerable]]: false, [[Configurable]]: true}. + c. Let status be DefinePropertyOrThrow(O, "message", msgDesc). + ... +includes: [propertyHelper.js] + +---*/ + +class Err extends ReferenceError {} + +Err.prototype.message = 'custom-reference-error'; + +var err1 = new Err('foo 42'); +assert.sameValue(err1.message, 'foo 42'); +assert(err1.hasOwnProperty('message')); + +verifyWritable(err1, 'message'); +verifyNotEnumerable(err1, 'message'); +verifyConfigurable(err1, 'message'); + +var err2 = new Err(); +assert.sameValue(err2.hasOwnProperty('message'), false); +assert.sameValue(err2.message, 'custom-reference-error'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/NativeError/ReferenceError-name.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/NativeError/ReferenceError-name.js new file mode 100644 index 0000000000..8898f2e7b5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/NativeError/ReferenceError-name.js @@ -0,0 +1,20 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 19.5.6.1.1 +description: > + The name property on a new instance +info: | + 19.5.6.3.3 NativeError.prototype.name + + The initial value of the name property of the prototype for a given + NativeError constructor is a string consisting of the name of the constructor + (the name used instead of NativeError). +---*/ + +class Err extends ReferenceError {} + +var err1 = new Err(); +assert.sameValue(err1.name, 'ReferenceError'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/NativeError/ReferenceError-super.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/NativeError/ReferenceError-super.js new file mode 100644 index 0000000000..b8517e4e25 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/NativeError/ReferenceError-super.js @@ -0,0 +1,25 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 19.5.6.1 +description: Super need to be called to initialize internals +info: | + 19.5.6.1 NativeError Constructors + + ... + Each NativeError constructor is designed to be subclassable. It may be used as + the value of an extends clause of a class definition. Subclass constructors + that intend to inherit the specified NativeError behaviour must include a + super call to the NativeError constructor to create and initialize subclass + instances with a [[ErrorData]] internal slot. +---*/ + +class CustomError extends ReferenceError { + constructor() {} +} + +assert.throws(ReferenceError, function() { + new CustomError(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/NativeError/SyntaxError-message.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/NativeError/SyntaxError-message.js new file mode 100644 index 0000000000..c5460959d6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/NativeError/SyntaxError-message.js @@ -0,0 +1,37 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 19.5.6.1.1 +description: > + A new instance has the message property if created with a parameter +info: | + 19.5.6.1.1 NativeError ( message ) + + ... + 4. If message is not undefined, then + a. Let msg be ToString(message). + b. Let msgDesc be the PropertyDescriptor{[[Value]]: msg, [[Writable]]: true, + [[Enumerable]]: false, [[Configurable]]: true}. + c. Let status be DefinePropertyOrThrow(O, "message", msgDesc). + ... +includes: [propertyHelper.js] + +---*/ + +class Err extends SyntaxError {} + +Err.prototype.message = 'custom-syntax-error'; + +var err1 = new Err('foo 42'); +assert.sameValue(err1.message, 'foo 42'); +assert(err1.hasOwnProperty('message')); + +verifyWritable(err1, 'message'); +verifyNotEnumerable(err1, 'message'); +verifyConfigurable(err1, 'message'); + +var err2 = new Err(); +assert.sameValue(err2.hasOwnProperty('message'), false); +assert.sameValue(err2.message, 'custom-syntax-error'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/NativeError/SyntaxError-name.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/NativeError/SyntaxError-name.js new file mode 100644 index 0000000000..19719c503c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/NativeError/SyntaxError-name.js @@ -0,0 +1,20 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 19.5.6.1.1 +description: > + The name property on a new instance +info: | + 19.5.6.3.3 NativeError.prototype.name + + The initial value of the name property of the prototype for a given + NativeError constructor is a string consisting of the name of the constructor + (the name used instead of NativeError). +---*/ + +class Err extends SyntaxError {} + +var err1 = new Err(); +assert.sameValue(err1.name, 'SyntaxError'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/NativeError/SyntaxError-super.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/NativeError/SyntaxError-super.js new file mode 100644 index 0000000000..00c4865cab --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/NativeError/SyntaxError-super.js @@ -0,0 +1,25 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 19.5.6.1 +description: Super need to be called to initialize internals +info: | + 19.5.6.1 NativeError Constructors + + ... + Each NativeError constructor is designed to be subclassable. It may be used as + the value of an extends clause of a class definition. Subclass constructors + that intend to inherit the specified NativeError behaviour must include a + super call to the NativeError constructor to create and initialize subclass + instances with a [[ErrorData]] internal slot. +---*/ + +class CustomError extends SyntaxError { + constructor() {} +} + +assert.throws(ReferenceError, function() { + new CustomError(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/NativeError/TypeError-message.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/NativeError/TypeError-message.js new file mode 100644 index 0000000000..855e3ad1a4 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/NativeError/TypeError-message.js @@ -0,0 +1,37 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 19.5.6.1.1 +description: > + A new instance has the message property if created with a parameter +info: | + 19.5.6.1.1 NativeError ( message ) + + ... + 4. If message is not undefined, then + a. Let msg be ToString(message). + b. Let msgDesc be the PropertyDescriptor{[[Value]]: msg, [[Writable]]: true, + [[Enumerable]]: false, [[Configurable]]: true}. + c. Let status be DefinePropertyOrThrow(O, "message", msgDesc). + ... +includes: [propertyHelper.js] + +---*/ + +class Err extends TypeError {} + +Err.prototype.message = 'custom-type-error'; + +var err1 = new Err('foo 42'); +assert.sameValue(err1.message, 'foo 42'); +assert(err1.hasOwnProperty('message')); + +verifyWritable(err1, 'message'); +verifyNotEnumerable(err1, 'message'); +verifyConfigurable(err1, 'message'); + +var err2 = new Err(); +assert.sameValue(err2.hasOwnProperty('message'), false); +assert.sameValue(err2.message, 'custom-type-error'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/NativeError/TypeError-name.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/NativeError/TypeError-name.js new file mode 100644 index 0000000000..ca1cb0995a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/NativeError/TypeError-name.js @@ -0,0 +1,20 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 19.5.6.1.1 +description: > + The name property on a new instance +info: | + 19.5.6.3.3 NativeError.prototype.name + + The initial value of the name property of the prototype for a given + NativeError constructor is a string consisting of the name of the constructor + (the name used instead of NativeError). +---*/ + +class Err extends TypeError {} + +var err1 = new Err(); +assert.sameValue(err1.name, 'TypeError'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/NativeError/TypeError-super.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/NativeError/TypeError-super.js new file mode 100644 index 0000000000..80fcbf935a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/NativeError/TypeError-super.js @@ -0,0 +1,25 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 19.5.6.1 +description: Super need to be called to initialize internals +info: | + 19.5.6.1 NativeError Constructors + + ... + Each NativeError constructor is designed to be subclassable. It may be used as + the value of an extends clause of a class definition. Subclass constructors + that intend to inherit the specified NativeError behaviour must include a + super call to the NativeError constructor to create and initialize subclass + instances with a [[ErrorData]] internal slot. +---*/ + +class CustomError extends TypeError { + constructor() {} +} + +assert.throws(ReferenceError, function() { + new CustomError(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/NativeError/URIError-message.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/NativeError/URIError-message.js new file mode 100644 index 0000000000..1131b75185 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/NativeError/URIError-message.js @@ -0,0 +1,37 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 19.5.6.1.1 +description: > + A new instance has the message property if created with a parameter +info: | + 19.5.6.1.1 NativeError ( message ) + + ... + 4. If message is not undefined, then + a. Let msg be ToString(message). + b. Let msgDesc be the PropertyDescriptor{[[Value]]: msg, [[Writable]]: true, + [[Enumerable]]: false, [[Configurable]]: true}. + c. Let status be DefinePropertyOrThrow(O, "message", msgDesc). + ... +includes: [propertyHelper.js] + +---*/ + +class Err extends URIError {} + +Err.prototype.message = 'custom-uri-error'; + +var err1 = new Err('foo 42'); +assert.sameValue(err1.message, 'foo 42'); +assert(err1.hasOwnProperty('message')); + +verifyWritable(err1, 'message'); +verifyNotEnumerable(err1, 'message'); +verifyConfigurable(err1, 'message'); + +var err2 = new Err(); +assert.sameValue(err2.hasOwnProperty('message'), false); +assert.sameValue(err2.message, 'custom-uri-error'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/NativeError/URIError-name.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/NativeError/URIError-name.js new file mode 100644 index 0000000000..83d8d8f5e8 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/NativeError/URIError-name.js @@ -0,0 +1,20 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 19.5.6.1.1 +description: > + The name property on a new instance +info: | + 19.5.6.3.3 NativeError.prototype.name + + The initial value of the name property of the prototype for a given + NativeError constructor is a string consisting of the name of the constructor + (the name used instead of NativeError). +---*/ + +class Err extends URIError {} + +var err1 = new Err(); +assert.sameValue(err1.name, 'URIError'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/NativeError/URIError-super.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/NativeError/URIError-super.js new file mode 100644 index 0000000000..3714a11749 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/NativeError/URIError-super.js @@ -0,0 +1,25 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 19.5.6.1 +description: Super need to be called to initialize internals +info: | + 19.5.6.1 NativeError Constructors + + ... + Each NativeError constructor is designed to be subclassable. It may be used as + the value of an extends clause of a class definition. Subclass constructors + that intend to inherit the specified NativeError behaviour must include a + super call to the NativeError constructor to create and initialize subclass + instances with a [[ErrorData]] internal slot. +---*/ + +class CustomError extends URIError { + constructor() {} +} + +assert.throws(ReferenceError, function() { + new CustomError(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/NativeError/browser.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/NativeError/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/NativeError/shell.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/NativeError/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Number/browser.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Number/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Number/regular-subclassing.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Number/regular-subclassing.js new file mode 100644 index 0000000000..f5764f046f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Number/regular-subclassing.js @@ -0,0 +1,25 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 20.1.1 +description: Subclassing the Number object +info: | + 20.1.1 The Number Constructor + + ... + + The Number constructor is designed to be subclassable. It may be used as the + value of an extends clause of a class definition. Subclass constructors that + intend to inherit the specified Number behaviour must include a super call to + the Number constructor to create and initialize the subclass instance with a + [[NumberData]] internal slot. +---*/ + +class N extends Number {} + +var n = new N(42); + +assert.sameValue(n.toFixed(2), '42.00'); +assert.sameValue(n.toExponential(2), '4.20e+1'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Number/shell.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Number/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Number/super-must-be-called.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Number/super-must-be-called.js new file mode 100644 index 0000000000..fb37ca829c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Number/super-must-be-called.js @@ -0,0 +1,34 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 20.1.1 +description: Super need to be called to initialize internals +info: | + 20.1.1 The Number Constructor + + ... + + The Number constructor is designed to be subclassable. It may be used as the + value of an extends clause of a class definition. Subclass constructors that + intend to inherit the specified Number behaviour must include a super call to + the Number constructor to create and initialize the subclass instance with a + [[NumberData]] internal slot. +---*/ + +class N extends Number { + constructor() {} +} + +assert.throws(ReferenceError, function() { + new N(); +}); + +class N2 extends Number { + constructor() { + super(); + } +} + +new N2(); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Object/browser.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Object/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Object/constructor-return-undefined-throws.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Object/constructor-return-undefined-throws.js new file mode 100644 index 0000000000..ddf4ec4795 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Object/constructor-return-undefined-throws.js @@ -0,0 +1,47 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 9.2.2 +description: Throws a ReferenceError if constructor result is undefined +info: | + 9.2.2 [[Construct]] ( argumentsList, newTarget) + + ... + 11. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + ... + 13. If result.[[type]] is return, then + a. If Type(result.[[value]]) is Object, return + NormalCompletion(result.[[value]]). + ... + c. If result.[[value]] is not undefined, throw a TypeError exception. + ... + 15. Return envRec.GetThisBinding(). + + 8.1.1.3.4 GetThisBinding () + + ... + 3. If envRec.[[thisBindingStatus]] is "uninitialized", throw a ReferenceError + exception. + ... + +---*/ + +class Obj extends Object { + constructor() { + return undefined; + } +} + +class Obj2 extends Object { + constructor() {} +} + +assert.throws(ReferenceError, function() { + new Obj(); +}); + +assert.throws(ReferenceError, function() { + new Obj2(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Object/constructor-returns-non-object.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Object/constructor-returns-non-object.js new file mode 100644 index 0000000000..6f266cc1e7 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Object/constructor-returns-non-object.js @@ -0,0 +1,42 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 9.2.2 +description: The Type of the return value must be an Object +info: | + 9.2.2 [[Construct]] ( argumentsList, newTarget) + + ... + 11. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + ... + 13. If result.[[type]] is return, then + a. If Type(result.[[value]]) is Object, return + NormalCompletion(result.[[value]]). + ... + c. If result.[[value]] is not undefined, throw a TypeError exception. + ... + + 6.1.7.2 Object Internal Methods and Internal Slots + + ... + If any specified use of an internal method of an exotic object is not + supported by an implementation, that usage must throw a TypeError exception + when attempted. + + 6.1.7.3 Invariants of the Essential Internal Methods + + [[Construct]] ( ) + - The Type of the return value must be Object. +---*/ + +class Obj extends Object { + constructor() { + return 42; + } +} + +assert.throws(TypeError, function() { + var obj = new Obj(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Object/regular-subclassing.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Object/regular-subclassing.js new file mode 100644 index 0000000000..59b6afd6a3 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Object/regular-subclassing.js @@ -0,0 +1,22 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 19.1.1 +description: Subclassing Object +info: | + 19.1.1 The Object Constructor + + The Object constructor is designed to be subclassable. It may be used as the + value of an extends clause of a class definition. +---*/ + +class Obj extends Object {} + +var obj = new Obj(); + +assert.notSameValue( + Object.getPrototypeOf(obj), Object.prototype, + 'returns the class prototype' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Object/replacing-prototype.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Object/replacing-prototype.js new file mode 100644 index 0000000000..dd6e7d5635 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Object/replacing-prototype.js @@ -0,0 +1,23 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 19.1.1 +description: Subclassing Object replacing a prototype method +info: | + 19.1.1 The Object Constructor + + The Object constructor is designed to be subclassable. It may be used as the + value of an extends clause of a class definition. +---*/ + +class Obj extends Object { + valueOf() { + return 42; + } +} + +var obj = new Obj(); + +assert.sameValue(obj.valueOf(), 42, 'Replaces prototype'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Object/shell.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Object/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Promise/browser.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Promise/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Promise/regular-subclassing.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Promise/regular-subclassing.js new file mode 100644 index 0000000000..397e452cf0 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Promise/regular-subclassing.js @@ -0,0 +1,38 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 25.4.3 +description: Subclassing the Promise object +info: | + 25.4.3 The Promise Constructor + + ... + + The Promise constructor is designed to be subclassable. It may be used as the + value in an extends clause of a class definition. Subclass constructors that + intend to inherit the specified Promise behaviour must include a super call + to the Promise constructor to create and initialize the subclass instance with + the internal state necessary to support the Promise and Promise.prototype + built-in methods. +---*/ + +class Prom extends Promise {} + +assert.throws(TypeError, function() { + new Prom(); +}); + +var calledExecutor = false; +var executorArguments; + +var prom1 = new Prom(function() { + calledExecutor = true; + executorArguments = arguments; +}); + +assert(calledExecutor); +assert.sameValue(executorArguments.length, 2); +assert.sameValue(typeof executorArguments[0], "function"); +assert.sameValue(typeof executorArguments[1], "function"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Promise/shell.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Promise/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Promise/super-must-be-called.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Promise/super-must-be-called.js new file mode 100644 index 0000000000..8ed2fb3f63 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Promise/super-must-be-called.js @@ -0,0 +1,35 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 25.4.3 +description: Super need to be called to initialize internals +info: | + 25.4.3 The Promise Constructor + + ... + + The Promise constructor is designed to be subclassable. It may be used as the + value in an extends clause of a class definition. Subclass constructors that + intend to inherit the specified Promise behaviour must include a super call + to the Promise constructor to create and initialize the subclass instance with + the internal state necessary to support the Promise and Promise.prototype + built-in methods. +---*/ + +class Prom1 extends Promise { + constructor() {} +} + +assert.throws(ReferenceError, function() { + new Prom1(); +}); + +class Prom2 extends Promise { + constructor(exec) { + super(exec); + } +} + +new Prom2(function() {}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Proxy/browser.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Proxy/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Proxy/no-prototype-throws.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Proxy/no-prototype-throws.js new file mode 100644 index 0000000000..c61848395c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Proxy/no-prototype-throws.js @@ -0,0 +1,34 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.5.14 +description: The Proxy Object is not subclasseable without a prototype +info: | + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 5. If ClassHeritageopt is not present, then + ... + 6. Else + ... + e. If superclass is null, then + ... + f. Else if IsConstructor(superclass) is false, throw a TypeError exception. + g. Else + ... + ii. Let protoParent be Get(superclass, "prototype"). + iii. ReturnIfAbrupt(protoParent). + iv. If Type(protoParent) is neither Object nor Null, throw a TypeError exception. + + 26.2.1 The Proxy Constructor + + The Proxy constructor is the %Proxy% intrinsic object and the initial value of + the Proxy property of the global object. When called as a constructor it + creates and initializes a new proxy exotic object. Proxy is not intended to be + called as a function and will throw an exception when called in that manner. +---*/ + +assert.throws(TypeError, function() { + class P extends Proxy {} +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Proxy/shell.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Proxy/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/RegExp/browser.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/RegExp/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/RegExp/lastIndex.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/RegExp/lastIndex.js new file mode 100644 index 0000000000..bf0726227b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/RegExp/lastIndex.js @@ -0,0 +1,28 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.2.6.1 +description: Instances has the own property lastIndex +info: | + 21.2.6.1 lastIndex + + The value of the lastIndex property specifies the String index at which to + start the next match. It is coerced to an integer when used (see 21.2.5.2.2). + This property shall have the attributes { [[Writable]]: true, [[Enumerable]]: + false, [[Configurable]]: false }. +includes: [propertyHelper.js] +---*/ + +class RE extends RegExp {} + +var re = new RE('39?'); + +re.exec('TC39'); + +assert.sameValue(re.lastIndex, 0); + +verifyWritable(re, 'lastIndex'); +verifyNotEnumerable(re, 'lastIndex'); +verifyNotConfigurable(re, 'lastIndex'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/RegExp/regular-subclassing.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/RegExp/regular-subclassing.js new file mode 100644 index 0000000000..3dab8a3ee6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/RegExp/regular-subclassing.js @@ -0,0 +1,25 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.2.3 +description: Subclassing the RegExp object +info: | + 21.2.3 The RegExp Constructor + + ... + + The RegExp constructor is designed to be subclassable. It may be used as the + value of an extends clause of a class definition. Subclass constructors that + intend to inherit the specified RegExp behaviour must include a super call to + the RegExp constructor to create and initialize subclass instances with the + necessary internal slots. +---*/ + +class RE extends RegExp {} + +var re = new RE(39); + +assert.sameValue(re.test('TC39'), true); +assert.sameValue(re.test('42'), false); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/RegExp/shell.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/RegExp/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/RegExp/super-must-be-called.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/RegExp/super-must-be-called.js new file mode 100644 index 0000000000..8d617a15ee --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/RegExp/super-must-be-called.js @@ -0,0 +1,34 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.2.3 +description: Super need to be called to initialize internals +info: | + 21.2.3 The RegExp Constructor + + ... + + The RegExp constructor is designed to be subclassable. It may be used as the + value of an extends clause of a class definition. Subclass constructors that + intend to inherit the specified RegExp behaviour must include a super call to + the RegExp constructor to create and initialize subclass instances with the + necessary internal slots. +---*/ + +class RE1 extends RegExp { + constructor() {} +} + +assert.throws(ReferenceError, function() { + new RE1(); +}); + +class RE2 extends RegExp { + constructor() { + super(); + } +} + +new RE2(); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Set/browser.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Set/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Set/regular-subclassing.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Set/regular-subclassing.js new file mode 100644 index 0000000000..43a92d8a69 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Set/regular-subclassing.js @@ -0,0 +1,28 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 23.2.1 +description: Subclassing the Set object +info: | + 23.2.1 The Set Constructor + + ... + + The Set constructor is designed to be subclassable. It may be used as the + value in an extends clause of a class definition. Subclass constructors that + intend to inherit the specified Set behaviour must include a super call to the + Set constructor to create and initialize the subclass instance with the + internal state necessary to support the Set.prototype built-in methods. +---*/ + +class S extends Set {} + +var set = new S([{}, {}]); + +assert.sameValue(set.size, 2); + +set.add({}); + +assert.sameValue(set.size, 3); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Set/shell.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Set/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Set/super-must-be-called.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Set/super-must-be-called.js new file mode 100644 index 0000000000..1b5e23cd08 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Set/super-must-be-called.js @@ -0,0 +1,34 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 23.2.1 +description: Super need to be called to initialize internals +info: | + 23.2.1 The Set Constructor + + ... + + The Set constructor is designed to be subclassable. It may be used as the + value in an extends clause of a class definition. Subclass constructors that + intend to inherit the specified Set behaviour must include a super call to the + Set constructor to create and initialize the subclass instance with the + internal state necessary to support the Set.prototype built-in methods. +---*/ + +class S1 extends Set { + constructor() {} +} + +assert.throws(ReferenceError, function() { + new S1(); +}); + +class S2 extends Set { + constructor() { + super(); + } +} + +new S2(); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/String/browser.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/String/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/String/length.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/String/length.js new file mode 100644 index 0000000000..0d1f33ef7f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/String/length.js @@ -0,0 +1,32 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.4 +description: Instances has the own property length +info: | + 21.1.4 Properties of String Instances + + ... + + String instances have a length property, and a set of enumerable properties + with integer indexed names. +includes: [propertyHelper.js] +---*/ + +class S extends String {} + +var s1 = new S(); +assert.sameValue(s1.length, 0); + +verifyNotWritable(s1, 'length'); +verifyNotEnumerable(s1, 'length'); +verifyNotConfigurable(s1, 'length'); + +var s2 = new S('test262'); +assert.sameValue(s2.length, 7); + +verifyNotWritable(s2, 'length'); +verifyNotEnumerable(s2, 'length'); +verifyNotConfigurable(s2, 'length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/String/regular-subclassing.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/String/regular-subclassing.js new file mode 100644 index 0000000000..b5c2ac34be --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/String/regular-subclassing.js @@ -0,0 +1,24 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.1 +description: Subclassing the String object +info: | + 21.1.1 The String Constructor + + ... + The String constructor is designed to be subclassable. It may be used as the + value of an extends clause of a class definition. Subclass constructors that + intend to inherit the specified String behaviour must include a super call to + the String constructor to create and initialize the subclass instance with a + [[StringData]] internal slot. +---*/ + +class S extends String {} + +var s = new S(' test262 '); + +assert.sameValue(s.trim(), 'test262'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/String/shell.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/String/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/String/super-must-be-called.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/String/super-must-be-called.js new file mode 100644 index 0000000000..0c247e62db --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/String/super-must-be-called.js @@ -0,0 +1,33 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.1 +description: Super need to be called to initialize internals +info: | + 21.1.1 The String Constructor + + ... + The String constructor is designed to be subclassable. It may be used as the + value of an extends clause of a class definition. Subclass constructors that + intend to inherit the specified String behaviour must include a super call to + the String constructor to create and initialize the subclass instance with a + [[StringData]] internal slot. +---*/ + +class S1 extends String { + constructor() {} +} + +assert.throws(ReferenceError, function() { + new S1(); +}); + +class S2 extends String { + constructor() { + super(); + } +} + +new S2(); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Symbol/browser.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Symbol/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Symbol/new-symbol-with-super-throws.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Symbol/new-symbol-with-super-throws.js new file mode 100644 index 0000000000..70cdae8717 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Symbol/new-symbol-with-super-throws.js @@ -0,0 +1,38 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 19.4.1 +description: Symbol subclass called with the new operator throws on super() +info: | + 19.4.1 The Symbol Constructor + + ... + The Symbol constructor is not intended to be used with the new operator or to + be subclassed. It may be used as the value of an extends clause of a class + definition but a super call to the Symbol constructor will cause an exception. + + 19.4.1.1 Symbol ( [ description ] ) + + ... + 1. If NewTarget is not undefined, throw a TypeError exception. +features: [Symbol] +---*/ + +class S1 extends Symbol {} + +assert.throws(TypeError, function() { + new S1(); +}); + +class S2 extends Symbol { + constructor() { + super(); + } +} + +assert.throws(TypeError, function() { + new S2(); +}); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Symbol/shell.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Symbol/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Symbol/symbol-valid-as-extends-value.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Symbol/symbol-valid-as-extends-value.js new file mode 100644 index 0000000000..2ba5f953e2 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Symbol/symbol-valid-as-extends-value.js @@ -0,0 +1,19 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 19.4.1 +description: Symbol can be used as the value of an extends +info: | + 19.4.1 The Symbol Constructor + + ... + The Symbol constructor is not intended to be used with the new operator or to + be subclassed. It may be used as the value of an extends clause of a class + definition but a super call to the Symbol constructor will cause an exception. + ... +features: [Symbol] +---*/ + +class S extends Symbol {} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/TypedArray/browser.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/TypedArray/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/TypedArray/regular-subclassing.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/TypedArray/regular-subclassing.js new file mode 100644 index 0000000000..abc83cdf31 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/TypedArray/regular-subclassing.js @@ -0,0 +1,37 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 22.2.4 +description: Subclassing TypedArrays +info: | + 22.2.4 The TypedArray Constructors + + ... + + The TypedArray constructors are designed to be subclassable. They may be used + as the value of an extends clause of a class definition. Subclass constructors + that intend to inherit the specified TypedArray behaviour must include a super + call to the TypedArray constructor to create and initialize the subclass + instance with the internal state necessary to support the + %TypedArray%.prototype built-in methods. +---*/ + +[ + Int8Array, + Uint8Array, + Uint8ClampedArray, + Int16Array, + Uint16Array, + Int32Array, + Uint32Array, + Float32Array, + Float64Array +].forEach(function(Constructor) { + class Typed extends Constructor {} + + var arr = new Typed(2); + + assert.sameValue(arr.length, 2); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/TypedArray/shell.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/TypedArray/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/TypedArray/super-must-be-called.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/TypedArray/super-must-be-called.js new file mode 100644 index 0000000000..5a8ae56122 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/TypedArray/super-must-be-called.js @@ -0,0 +1,47 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 22.2.4 +description: Super need to be called to initialize internals +info: | + 22.2.4 The TypedArray Constructors + + ... + + The TypedArray constructors are designed to be subclassable. They may be used + as the value of an extends clause of a class definition. Subclass constructors + that intend to inherit the specified TypedArray behaviour must include a super + call to the TypedArray constructor to create and initialize the subclass + instance with the internal state necessary to support the + %TypedArray%.prototype built-in methods. +---*/ + +[ + Int8Array, + Uint8Array, + Uint8ClampedArray, + Int16Array, + Uint16Array, + Int32Array, + Uint32Array, + Float32Array, + Float64Array +].forEach(function(Constructor) { + class Typed extends Constructor { + constructor() {} + } + + assert.throws(ReferenceError, function() { + new Typed(); + }); + + class TypedWithSuper extends Constructor { + constructor() { + super(); + } + } + + new TypedWithSuper(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/WeakMap/browser.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/WeakMap/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/WeakMap/regular-subclassing.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/WeakMap/regular-subclassing.js new file mode 100644 index 0000000000..04e2258258 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/WeakMap/regular-subclassing.js @@ -0,0 +1,31 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 23.3.1 +description: Subclassing the WeakMap object +info: | + 23.3.1 The WeakMap Constructor + + ... + + The WeakMap constructor is designed to be subclassable. It may be used as the + value in an extends clause of a class definition. Subclass constructors that + intend to inherit the specified WeakMap behaviour must include a super call to + the WeakMap constructor to create and initialize the subclass instance with + the internal state necessary to support the WeakMap.prototype built-in + methods. +features: [WeakMap] +---*/ + +class WM extends WeakMap {} + +var map = new WM(); +var obj = {}; + +assert.sameValue(map.has(obj), false); + +map.set(obj, 42); +assert.sameValue(map.has(obj), true); +assert.sameValue(map.get(obj), 42); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/WeakMap/shell.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/WeakMap/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/WeakMap/super-must-be-called.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/WeakMap/super-must-be-called.js new file mode 100644 index 0000000000..ae4c4acf2c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/WeakMap/super-must-be-called.js @@ -0,0 +1,36 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 23.3.1 +description: Super need to be called to initialize internals +info: | + 23.3.1 The WeakMap Constructor + + ... + + The WeakMap constructor is designed to be subclassable. It may be used as the + value in an extends clause of a class definition. Subclass constructors that + intend to inherit the specified WeakMap behaviour must include a super call to + the WeakMap constructor to create and initialize the subclass instance with + the internal state necessary to support the WeakMap.prototype built-in + methods. +features: [WeakMap] +---*/ + +class M1 extends WeakMap { + constructor() {} +} + +assert.throws(ReferenceError, function() { + new M1(); +}); + +class M2 extends WeakMap { + constructor() { + super(); + } +} + +new M2(); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/WeakSet/browser.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/WeakSet/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/WeakSet/regular-subclassing.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/WeakSet/regular-subclassing.js new file mode 100644 index 0000000000..9f8aa73318 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/WeakSet/regular-subclassing.js @@ -0,0 +1,30 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 23.4.1 +description: Subclassing the WeakSet object +info: | + 23.4.1 The WeakSet Constructor + + ... + + The WeakSet constructor is designed to be subclassable. It may be used as the + value in an extends clause of a class definition. Subclass constructors that + intend to inherit the specified WeakSet behaviour must include a super call to + the WeakSet constructor to create and initialize the subclass instance with + the internal state necessary to support the WeakSet.prototype built-in + methods. +features: [WeakSet] +---*/ + +class WS extends WeakSet {} + +var set = new WS(); +var obj = {}; + +assert.sameValue(set.has(obj), false); + +set.add(obj); +assert.sameValue(set.has(obj), true); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/WeakSet/shell.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/WeakSet/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/WeakSet/super-must-be-called.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/WeakSet/super-must-be-called.js new file mode 100644 index 0000000000..473bbf7c5e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/WeakSet/super-must-be-called.js @@ -0,0 +1,36 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 23.4.1 +description: Super need to be called to initialize internals +info: | + 23.4.1 The WeakSet Constructor + + ... + + The WeakSet constructor is designed to be subclassable. It may be used as the + value in an extends clause of a class definition. Subclass constructors that + intend to inherit the specified WeakSet behaviour must include a super call to + the WeakSet constructor to create and initialize the subclass instance with + the internal state necessary to support the WeakSet.prototype built-in + methods. +features: [WeakSet] +---*/ + +class WS1 extends WeakSet { + constructor() {} +} + +assert.throws(ReferenceError, function() { + new WS1(); +}); + +class WS2 extends WeakSet { + constructor() { + super(); + } +} + +new WS2(); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/browser.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/shell.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/subclass/builtins.js b/js/src/tests/test262/language/statements/class/subclass/builtins.js new file mode 100644 index 0000000000..dc95f7827a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass/builtins.js @@ -0,0 +1,32 @@ +// Copyright (C) 2014 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.5 +description: > + class sublclassing builtins +---*/ +class ExtendedUint8Array extends Uint8Array { + constructor() { + super(10); + this[0] = 255; + this[1] = 0xFFA; + } +} + +var eua = new ExtendedUint8Array(); +assert.sameValue(eua.length, 10, "The value of `eua.length` is `10`"); +assert.sameValue(eua.byteLength, 10, "The value of `eua.byteLength` is `10`"); +assert.sameValue(eua[0], 0xFF, "The value of `eua[0]` is `0xFF`"); +assert.sameValue(eua[1], 0xFA, "The value of `eua[1]` is `0xFA`"); +assert.sameValue( + Object.getPrototypeOf(eua), + ExtendedUint8Array.prototype, + "`Object.getPrototypeOf(eua)` returns `ExtendedUint8Array.prototype`" +); +assert.sameValue( + Object.prototype.toString.call(eua), + "[object Uint8Array]", + "`Object.prototype.toString.call(eua)` returns `\"[object Uint8Array]\"`" +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass/class-definition-evaluation-empty-constructor-heritage-present.js b/js/src/tests/test262/language/statements/class/subclass/class-definition-evaluation-empty-constructor-heritage-present.js new file mode 100644 index 0000000000..2039140be5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass/class-definition-evaluation-empty-constructor-heritage-present.js @@ -0,0 +1,37 @@ +// Copyright (C) 2014 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.5.14 +description: > + 10. If constructor is empty, then, + a. If ClassHeritageopt is present, then + i. Let constructor be the result of parsing the String "constructor(... args){ super (...args);}" using the syntactic grammar with the goal symbol MethodDefinition. +---*/ +var args; + +class A { + constructor() { + args = arguments; + } +} + +class B extends A { + /* + The missing constructor is created by the runtime: + + constructor(...args) { + super(...args); + } + + */ +} + +new B(0, 1, 2); + + +assert.sameValue(args[0], 0); +assert.sameValue(args[1], 1); +assert.sameValue(args[2], 2); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass/class-definition-null-proto-contains-return-override.js b/js/src/tests/test262/language/statements/class/subclass/class-definition-null-proto-contains-return-override.js new file mode 100644 index 0000000000..5fc6aa0c29 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass/class-definition-null-proto-contains-return-override.js @@ -0,0 +1,35 @@ +// Copyright (C) 2014 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-runtime-semantics-classdefinitionevaluation +es6id: 14.5.14 +description: > + The constructor of a null-extending class can contain an explicit return value. +info: | + Runtime Semantics: ClassDefinitionEvaluation + + [...] + 15. If ClassHeritageopt is present, then set F's [[ConstructorKind]] internal slot to "derived". + [...] + + 9.2.2 [[Construct]] + + [...] + 13. If result.[[Type]] is return, then + a. If Type(result.[[Value]]) is Object, return NormalCompletion(result.[[Value]]). + [...] +---*/ +var obj; + +class Foo extends null { + constructor() { + return obj = {}; + } +} + +var f = new Foo(); + +assert.sameValue(f, obj); +assert.sameValue(Object.getPrototypeOf(f), Object.prototype); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass/class-definition-null-proto-missing-return-override.js b/js/src/tests/test262/language/statements/class/subclass/class-definition-null-proto-missing-return-override.js new file mode 100644 index 0000000000..efdb8d3299 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass/class-definition-null-proto-missing-return-override.js @@ -0,0 +1,41 @@ +// Copyright (C) 2014 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-runtime-semantics-classdefinitionevaluation +description: > + The `this` value of a null-extending class isn't automatically initialized, + which makes it necessary to have an explicit return value in the constructor. +info: | + Runtime Semantics: ClassDefinitionEvaluation + + [...] + 5. If ClassHeritageopt is not present, then + [...] + 6. Else, + [...] + b. Let superclass be the result of evaluating ClassHeritage. + [...] + 15. If ClassHeritageopt is present, then set F's [[ConstructorKind]] internal slot to "derived". + [...] + + 9.2.2 [[Construct]] + + [...] + 15. Return ? envRec.GetThisBinding(). + + 8.1.1.3.4 GetThisBinding ( ) + [...] + 3. If envRec.[[ThisBindingStatus]] is "uninitialized", throw a ReferenceError exception. + [...] +---*/ + +class Foo extends null { + constructor() { + } +} + +assert.throws(ReferenceError, function() { + new C(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass/class-definition-null-proto-super.js b/js/src/tests/test262/language/statements/class/subclass/class-definition-null-proto-super.js new file mode 100644 index 0000000000..5270bb8c72 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass/class-definition-null-proto-super.js @@ -0,0 +1,54 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-runtime-semantics-classdefinitionevaluation +description: > + Attempting to call `super()` in a null-extending class throws a TypeError, + because %FunctionPrototype% cannot be called as constructor function. +info: | + Runtime Semantics: ClassDefinitionEvaluation + + [...] + 5. If ClassHeritageopt is not present, then + [...] + 6. Else, + [...] + b. Let superclass be the result of evaluating ClassHeritage. + [...] + e. If superclass is null, then + [...] + ii. Let constructorParent be the intrinsic object %FunctionPrototype%. + [...] + 15. Let constructorInfo be the result of performing DefineMethod for constructor with arguments proto and constructorParent as the optional functionPrototype argument. + [...] + + 12.3.5.1 Runtime Semantics: Evaluation + + SuperCall : super Arguments + + [...] + 3. Let func be ! GetSuperConstructor(). + 4. Let argList be ? ArgumentListEvaluation of Arguments. + 5. If IsConstructor(func) is false, throw a TypeError exception. + [...] +---*/ + +var unreachable = 0; +var reachable = 0; + +class C extends null { + constructor() { + reachable += 1; + super(); + unreachable += 1; + } +} + +assert.throws(TypeError, function() { + new C(); +}); + +assert.sameValue(reachable, 1); +assert.sameValue(unreachable, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass/class-definition-null-proto-this.js b/js/src/tests/test262/language/statements/class/subclass/class-definition-null-proto-this.js new file mode 100644 index 0000000000..e4d4b6a917 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass/class-definition-null-proto-this.js @@ -0,0 +1,41 @@ +// Copyright (C) 2014 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-runtime-semantics-classdefinitionevaluation +description: > + The `this` value of a null-extending class isn't automatically initialized +info: | + Runtime Semantics: ClassDefinitionEvaluation + + [...] + 15. If ClassHeritageopt is present, then set F's [[ConstructorKind]] internal slot to "derived". + [...] + + 12.2.2.1 Runtime Semantics: Evaluation + PrimaryExpression : this + 1. Return ? ResolveThisBinding( ). + + 8.3.4 ResolveThisBinding ( ) + [...] + 2. Return ? envRec.GetThisBinding(). + + 8.1.1.3.4 GetThisBinding ( ) + [...] + 3. If envRec.[[ThisBindingStatus]] is "uninitialized", throw a ReferenceError exception. + [...] +---*/ + +class C extends null { + constructor() { + // Use an arrow function to access the `this` binding of the class constructor. + assert.throws(ReferenceError, () => { + this; + }); + } +} + +assert.throws(ReferenceError, function() { + new C(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass/class-definition-null-proto.js b/js/src/tests/test262/language/statements/class/subclass/class-definition-null-proto.js new file mode 100644 index 0000000000..da766ba6ff --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass/class-definition-null-proto.js @@ -0,0 +1,31 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-runtime-semantics-classdefinitionevaluation +es6id: 14.5.14 +description: > + The prototype of a null-extending class is %FunctionPrototype%, the prototype of + its "prototype" property is `null`. +info: | + Runtime Semantics: ClassDefinitionEvaluation + + [...] + 5. If ClassHeritageopt is not present, then + [...] + 6. Else, + [...] + b. Let superclass be the result of evaluating ClassHeritage. + [...] + e. If superclass is null, then + i. Let protoParent be null. + ii. Let constructorParent be the intrinsic object %FunctionPrototype%. + [...] +---*/ + +class Foo extends null {} + +assert.sameValue(Object.getPrototypeOf(Foo.prototype), null); +assert.sameValue(Object.getPrototypeOf(Foo.prototype.constructor), Function.prototype); +assert.sameValue(Foo, Foo.prototype.constructor); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass/class-definition-parent-proto-null.js b/js/src/tests/test262/language/statements/class/subclass/class-definition-parent-proto-null.js new file mode 100644 index 0000000000..951b569c66 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass/class-definition-parent-proto-null.js @@ -0,0 +1,26 @@ +// Copyright (C) 2016 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-runtime-semantics-classdefinitionevaluation +description: A class which extends a constructor with null .prototype is a derived class. +---*/ + +var invoked = false; +var instance, savedArg; + +function A(arg) { + invoked = true; + savedArg = arg; + this.prop = 0; +} +A.prototype = null; + +class C extends A {} + +instance = new C(1); + +assert.sameValue(invoked, true); +assert.sameValue(savedArg, 1); +assert.sameValue(instance.prop, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass/default-constructor-2.js b/js/src/tests/test262/language/statements/class/subclass/default-constructor-2.js new file mode 100644 index 0000000000..e5a984401d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass/default-constructor-2.js @@ -0,0 +1,65 @@ +// Copyright (C) 2014 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.5 +description: > + class default constructor 2 +---*/ +class Base1 { } +assert.throws(TypeError, function() { Base1(); }); + +class Subclass1 extends Base1 { } + +assert.throws(TypeError, function() { Subclass1(); }); + +var s1 = new Subclass1(); +assert.sameValue( + Subclass1.prototype, + Object.getPrototypeOf(s1), + "The value of `Subclass1.prototype` is `Object.getPrototypeOf(s1)`, after executing `var s1 = new Subclass1();`" +); + +class Base2 { + constructor(x, y) { + this.x = x; + this.y = y; + } +} + +class Subclass2 extends Base2 {}; + +var s2 = new Subclass2(1, 2); + +assert.sameValue( + Subclass2.prototype, + Object.getPrototypeOf(s2), + "The value of `Subclass2.prototype` is `Object.getPrototypeOf(s2)`, after executing `var s2 = new Subclass2(1, 2);`" +); +assert.sameValue(s2.x, 1, "The value of `s2.x` is `1`"); +assert.sameValue(s2.y, 2, "The value of `s2.y` is `2`"); + +var f = Subclass2.bind({}, 3, 4); +var s2prime = new f(); +assert.sameValue( + Subclass2.prototype, + Object.getPrototypeOf(s2prime), + "The value of `Subclass2.prototype` is `Object.getPrototypeOf(s2prime)`" +); +assert.sameValue(s2prime.x, 3, "The value of `s2prime.x` is `3`"); +assert.sameValue(s2prime.y, 4, "The value of `s2prime.y` is `4`"); + + +var obj = {}; +class Base3 { + constructor() { + return obj; + } +} + +class Subclass3 extends Base3 {}; + +var s3 = new Subclass3(); +assert.sameValue(s3, obj, "The value of `s3` is `obj`"); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass/default-constructor-spread-override.js b/js/src/tests/test262/language/statements/class/subclass/default-constructor-spread-override.js new file mode 100644 index 0000000000..72d76c00a6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass/default-constructor-spread-override.js @@ -0,0 +1,27 @@ +// Copyright (C) 2016 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-runtime-semantics-classdefinitionevaluation +description: > + Default class constructor does not use argument evaluation. +features: [Symbol.iterator] +---*/ + +Array.prototype[Symbol.iterator] = function() { + throw new Test262Error('@@iterator invoked'); +}; + +class Base { + constructor(value) { + this.value = value; + } +} + +class Derived extends Base {} + +const instance = new Derived(5); + +assert.sameValue(instance.value, 5); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass/default-constructor.js b/js/src/tests/test262/language/statements/class/subclass/default-constructor.js new file mode 100644 index 0000000000..5976b13a8b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass/default-constructor.js @@ -0,0 +1,22 @@ +// Copyright (C) 2014 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.5 +description: > + class default constructor +---*/ +var calls = 0; +class Base { + constructor() { + calls++; + } +} +class Derived extends Base {} +var object = new Derived(); +assert.sameValue(calls, 1, "The value of `calls` is `1`"); + +calls = 0; +assert.throws(TypeError, function() { Derived(); }); +assert.sameValue(calls, 0, "The value of `calls` is `0`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass/derived-class-return-override-catch-finally-arrow.js b/js/src/tests/test262/language/statements/class/subclass/derived-class-return-override-catch-finally-arrow.js new file mode 100644 index 0000000000..f2bebd31f5 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass/derived-class-return-override-catch-finally-arrow.js @@ -0,0 +1,29 @@ +// Copyright (C) 2021 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-ecmascript-function-objects-construct-argumentslist-newtarget +description: > + `super()` in finally block is executed before checking for missing `super()` + call when `return` is in a catch block. The `super()` call is performed + through an arrow function. +---*/ + +class C extends class {} { + constructor() { + var f = () => super(); + + try { + throw null; + } catch(e) { + return; + } finally { + f(); + } + } +} + +var o = new C(); +assert.sameValue(typeof o, "object"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass/derived-class-return-override-catch-finally.js b/js/src/tests/test262/language/statements/class/subclass/derived-class-return-override-catch-finally.js new file mode 100644 index 0000000000..e296a4642b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass/derived-class-return-override-catch-finally.js @@ -0,0 +1,26 @@ +// Copyright (C) 2021 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-ecmascript-function-objects-construct-argumentslist-newtarget +description: > + `super()` in finally block is executed before checking for missing `super()` + call when `return` is in a catch block. +---*/ + +class C extends class {} { + constructor() { + try { + throw null; + } catch(e) { + return; + } finally { + super(); + } + } +} + +var o = new C(); +assert.sameValue(typeof o, "object"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass/derived-class-return-override-catch-super-arrow.js b/js/src/tests/test262/language/statements/class/subclass/derived-class-return-override-catch-super-arrow.js new file mode 100644 index 0000000000..d7f4a4ef1c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass/derived-class-return-override-catch-super-arrow.js @@ -0,0 +1,27 @@ +// Copyright (C) 2021 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-ecmascript-function-objects-construct-argumentslist-newtarget +description: > + TypeError from `return 0` is not catchable with `super` called in catch block + from an arrow function. +---*/ + +class C extends class {} { + constructor() { + var f = () => super(); + + try { + return 0; + } catch(e) { + f(); + } + } +} + +assert.throws(TypeError, function() { + new C(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass/derived-class-return-override-catch-super.js b/js/src/tests/test262/language/statements/class/subclass/derived-class-return-override-catch-super.js new file mode 100644 index 0000000000..6497f86914 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass/derived-class-return-override-catch-super.js @@ -0,0 +1,24 @@ +// Copyright (C) 2021 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-ecmascript-function-objects-construct-argumentslist-newtarget +description: > + TypeError from `return 0` is not catchable with `super` in catch block. +---*/ + +class C extends class {} { + constructor() { + try { + return 0; + } catch(e) { + super(); + } + } +} + +assert.throws(TypeError, function() { + new C(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass/derived-class-return-override-catch.js b/js/src/tests/test262/language/statements/class/subclass/derived-class-return-override-catch.js new file mode 100644 index 0000000000..253cc850e8 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass/derived-class-return-override-catch.js @@ -0,0 +1,26 @@ +// Copyright (C) 2021 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-ecmascript-function-objects-construct-argumentslist-newtarget +description: > + TypeError from `return 0` is not catchable. +---*/ + +class C extends class {} { + constructor() { + super(); + + try { + return 0; + } catch(e) { + return; + } + } +} + +assert.throws(TypeError, function() { + new C(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass/derived-class-return-override-finally-super-arrow.js b/js/src/tests/test262/language/statements/class/subclass/derived-class-return-override-finally-super-arrow.js new file mode 100644 index 0000000000..b0b7246055 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass/derived-class-return-override-finally-super-arrow.js @@ -0,0 +1,27 @@ +// Copyright (C) 2021 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-ecmascript-function-objects-construct-argumentslist-newtarget +description: > + `super()` in finally block is executed before checking for missing `super()` + call when `return` is in a try block. The `super()` call is performed + through an arrow function. +---*/ + +class C extends class {} { + constructor() { + var f = () => super(); + + try { + return; + } finally { + f(); + } + } +} + +var o = new C(); +assert.sameValue(typeof o, "object"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass/derived-class-return-override-finally-super.js b/js/src/tests/test262/language/statements/class/subclass/derived-class-return-override-finally-super.js new file mode 100644 index 0000000000..5b7f585b62 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass/derived-class-return-override-finally-super.js @@ -0,0 +1,24 @@ +// Copyright (C) 2021 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-ecmascript-function-objects-construct-argumentslist-newtarget +description: > + `super()` in finally block is executed before checking for missing `super()` + call when `return` is in a try block. +---*/ + +class C extends class {} { + constructor() { + try { + return; + } finally { + super(); + } + } +} + +var o = new C(); +assert.sameValue(typeof o, "object"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass/derived-class-return-override-for-of-arrow.js b/js/src/tests/test262/language/statements/class/subclass/derived-class-return-override-for-of-arrow.js new file mode 100644 index 0000000000..020dcbb6d8 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass/derived-class-return-override-for-of-arrow.js @@ -0,0 +1,40 @@ +// Copyright (C) 2021 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-ecmascript-function-objects-construct-argumentslist-newtarget +description: > + ReferenceError when returning from a derived class constructor without calling + `super()` is thrown after the function body has been left, so an iterator + return handler can still call `super()`. +---*/ + +var iter = { + [Symbol.iterator]() { + return this; + }, + next() { + return {done: false}; + }, + return() { + // Calls |super()|. + this.f(); + + return {done: true}; + }, +}; + +class C extends class {} { + constructor() { + iter.f = () => super(); + + for (var k of iter) { + return; + } + } +} + +var o = new C(); +assert.sameValue(typeof o, "object"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass/derived-class-return-override-for-of.js b/js/src/tests/test262/language/statements/class/subclass/derived-class-return-override-for-of.js new file mode 100644 index 0000000000..c0bc4e153d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass/derived-class-return-override-for-of.js @@ -0,0 +1,39 @@ +// Copyright (C) 2021 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-ecmascript-function-objects-construct-argumentslist-newtarget +description: > + TypeError from `return 0` is thrown after the function body has been left, so + an error thrown from an iterator has precedence. +---*/ + +var error = new Test262Error(); + +var iter = { + [Symbol.iterator]() { + return this; + }, + next() { + return {done: false}; + }, + return() { + throw error; + }, +}; + +class C extends class {} { + constructor() { + super(); + + for (var k of iter) { + return 0; + } + } +} + +assert.throws(Test262Error, function() { + new C(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass/derived-class-return-override-with-boolean.js b/js/src/tests/test262/language/statements/class/subclass/derived-class-return-override-with-boolean.js new file mode 100644 index 0000000000..5e62e661da --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass/derived-class-return-override-with-boolean.js @@ -0,0 +1,32 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 9.2.2 +description: > + [[Construct]] ( argumentsList, newTarget) + + ... + 13. If result.[[type]] is return, then + ... + c. If result.[[value]] is not undefined, throw a TypeError exception. + ... + + `return true;` + +---*/ +class Base { + constructor() {} +} +class Derived extends Base { + constructor() { + super(); + + return true; + } +} + +assert.throws(TypeError, function() { + new Derived(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass/derived-class-return-override-with-empty.js b/js/src/tests/test262/language/statements/class/subclass/derived-class-return-override-with-empty.js new file mode 100644 index 0000000000..28bb88ecee --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass/derived-class-return-override-with-empty.js @@ -0,0 +1,42 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 9.2.2 +description: > + [[Construct]] ( argumentsList, newTarget) + + ... + 13. If result.[[type]] is return, then + ... + c. If result.[[value]] is not undefined, ... + 14. Else, ReturnIfAbrupt(result). + 15. Return envRec.GetThisBinding(). + + `return (empty);` Should be the same as `return undefined;` +---*/ +var calls = 0; +class Base { + constructor() { + this.prop = 1; + calls++; + } +} +class Derived extends Base { + constructor() { + super(); + + return; + } +} + +var object = new Derived(); + +// super is called +assert.sameValue(calls, 1, "The value of `calls` is `1`, because `super()`"); + +// undefined was returned +assert.sameValue(object.prop, 1); +assert.sameValue(object instanceof Derived, true); +assert.sameValue(object instanceof Base, true); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass/derived-class-return-override-with-null.js b/js/src/tests/test262/language/statements/class/subclass/derived-class-return-override-with-null.js new file mode 100644 index 0000000000..9d1c0660d0 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass/derived-class-return-override-with-null.js @@ -0,0 +1,32 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 9.2.2 +description: > + [[Construct]] ( argumentsList, newTarget) + + ... + 13. If result.[[type]] is return, then + ... + c. If result.[[value]] is not undefined, throw a TypeError exception. + ... + + `return null;` + +---*/ +class Base { + constructor() {} +} +class Derived extends Base { + constructor() { + super(); + + return null; + } +} + +assert.throws(TypeError, function() { + new Derived(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass/derived-class-return-override-with-number.js b/js/src/tests/test262/language/statements/class/subclass/derived-class-return-override-with-number.js new file mode 100644 index 0000000000..7dbb94394f --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass/derived-class-return-override-with-number.js @@ -0,0 +1,32 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 9.2.2 +description: > + [[Construct]] ( argumentsList, newTarget) + + ... + 13. If result.[[type]] is return, then + ... + c. If result.[[value]] is not undefined, throw a TypeError exception. + ... + + `return 0;` + +---*/ +class Base { + constructor() {} +} +class Derived extends Base { + constructor() { + super(); + + return 0; + } +} + +assert.throws(TypeError, function() { + new Derived(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass/derived-class-return-override-with-object.js b/js/src/tests/test262/language/statements/class/subclass/derived-class-return-override-with-object.js new file mode 100644 index 0000000000..a1581be078 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass/derived-class-return-override-with-object.js @@ -0,0 +1,42 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 9.2.2 +description: > + [[Construct]] ( argumentsList, newTarget) + + ... + 13. If result.[[type]] is return, then + a. If Type(result.[[value]]) is Object, return NormalCompletion(result.[[value]]). + ... + ... + + `return {};` + +---*/ +var calls = 0; +class Base { + constructor() { + this.prop = 1; + calls++; + } +} +class Derived extends Base { + constructor() { + super(); + + return {}; + } +} + +var object = new Derived(); + +// super is called +assert.sameValue(calls, 1, "The value of `calls` is `1`, because `super()`"); + +// But the this object was discarded. +assert.sameValue(typeof object.prop, "undefined"); +assert.sameValue(object instanceof Derived, false); +assert.sameValue(object instanceof Base, false); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass/derived-class-return-override-with-string.js b/js/src/tests/test262/language/statements/class/subclass/derived-class-return-override-with-string.js new file mode 100644 index 0000000000..c670fae177 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass/derived-class-return-override-with-string.js @@ -0,0 +1,32 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 9.2.2 +description: > + [[Construct]] ( argumentsList, newTarget) + + ... + 13. If result.[[type]] is return, then + ... + c. If result.[[value]] is not undefined, throw a TypeError exception. + ... + + `return "";` + +---*/ +class Base { + constructor() {} +} +class Derived extends Base { + constructor() { + super(); + + return ""; + } +} + +assert.throws(TypeError, function() { + new Derived(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass/derived-class-return-override-with-symbol.js b/js/src/tests/test262/language/statements/class/subclass/derived-class-return-override-with-symbol.js new file mode 100644 index 0000000000..d4b3315212 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass/derived-class-return-override-with-symbol.js @@ -0,0 +1,33 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 9.2.2 +description: > + [[Construct]] ( argumentsList, newTarget) + + ... + 13. If result.[[type]] is return, then + ... + c. If result.[[value]] is not undefined, throw a TypeError exception. + ... + + `return Symbol();` + +features: [Symbol] +---*/ +class Base { + constructor() {} +} +class Derived extends Base { + constructor() { + super(); + + return Symbol(); + } +} + +assert.throws(TypeError, function() { + new Derived(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass/derived-class-return-override-with-this.js b/js/src/tests/test262/language/statements/class/subclass/derived-class-return-override-with-this.js new file mode 100644 index 0000000000..49cf683e04 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass/derived-class-return-override-with-this.js @@ -0,0 +1,43 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 9.2.2 +description: > + [[Construct]] ( argumentsList, newTarget) + + ... + 13. If result.[[type]] is return, then + ... + b. If kind is "base", return NormalCompletion(thisArgument). + ... + ... + + `return this;` + +---*/ +var calls = 0; +class Base { + constructor() { + this.prop = 1; + calls++; + } +} +class Derived extends Base { + constructor() { + super(); + + return this; + } +} + +var object = new Derived(); + +// super is called +assert.sameValue(calls, 1, "The value of `calls` is `1`, because `super()`"); + +// The this object was returned. +assert.sameValue(object.prop, 1); +assert.sameValue(object instanceof Derived, true); +assert.sameValue(object instanceof Base, true); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass/derived-class-return-override-with-undefined.js b/js/src/tests/test262/language/statements/class/subclass/derived-class-return-override-with-undefined.js new file mode 100644 index 0000000000..882889c9b1 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass/derived-class-return-override-with-undefined.js @@ -0,0 +1,43 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 9.2.2 +description: > + [[Construct]] ( argumentsList, newTarget) + + ... + 13. If result.[[type]] is return, then + ... + c. If result.[[value]] is not undefined, ... + 14. Else, ReturnIfAbrupt(result). + 15. Return envRec.GetThisBinding(). + + `return undefined;` + +---*/ +var calls = 0; +class Base { + constructor() { + this.prop = 1; + calls++; + } +} +class Derived extends Base { + constructor() { + super(); + + return undefined; + } +} + +var object = new Derived(); + +// super is called +assert.sameValue(calls, 1, "The value of `calls` is `1`, because `super()`"); + +// undefined was returned +assert.sameValue(object.prop, 1); +assert.sameValue(object instanceof Derived, true); +assert.sameValue(object instanceof Base, true); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass/shell.js b/js/src/tests/test262/language/statements/class/subclass/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/subclass/superclass-arrow-function.js b/js/src/tests/test262/language/statements/class/subclass/superclass-arrow-function.js new file mode 100644 index 0000000000..be59091134 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass/superclass-arrow-function.js @@ -0,0 +1,53 @@ +// Copyright (C) 2020 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-runtime-semantics-classdefinitionevaluation +description: > + IsConstructor check is performed before "prototype" lookup. + Arrow functions are not constructors (MakeConstructor is not called on them). +info: | + ClassDefinitionEvaluation + + [...] + 5. Else, + [...] + d. Let superclass be ? GetValue(superclassRef). + e. If superclass is null, then + [...] + f. Else if IsConstructor(superclass) is false, throw a TypeError exception. +features: [arrow-function, class, Proxy] +---*/ + +var fn = () => {}; +Object.defineProperty(fn, "prototype", { + get: function() { + throw new Test262Error("`superclass.prototype` is unreachable"); + }, +}); + +assert.throws(TypeError, function() { + class A extends fn {} +}); + +var bound = (() => {}).bind(); +Object.defineProperty(bound, "prototype", { + get: function() { + throw new Test262Error("`superclass.prototype` is unreachable"); + }, +}); + +assert.throws(TypeError, function() { + class C extends bound {} +}); + +var proxy = new Proxy(() => {}, { + get: function() { + throw new Test262Error("`superclass.prototype` is unreachable"); + }, +}); + +assert.throws(TypeError, function() { + class C extends proxy {} +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass/superclass-async-function.js b/js/src/tests/test262/language/statements/class/subclass/superclass-async-function.js new file mode 100644 index 0000000000..b9e71515ac --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass/superclass-async-function.js @@ -0,0 +1,53 @@ +// Copyright (C) 2020 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-runtime-semantics-classdefinitionevaluation +description: > + IsConstructor check is performed before "prototype" lookup. + Async functions are not constructors (MakeConstructor is not called on them). +info: | + ClassDefinitionEvaluation + + [...] + 5. Else, + [...] + d. Let superclass be ? GetValue(superclassRef). + e. If superclass is null, then + [...] + f. Else if IsConstructor(superclass) is false, throw a TypeError exception. +features: [async-functions, class, Proxy] +---*/ + +async function fn() {} +Object.defineProperty(fn, "prototype", { + get: function() { + throw new Test262Error("`superclass.prototype` is unreachable"); + }, +}); + +assert.throws(TypeError, function() { + class A extends fn {} +}); + +var bound = (async function() {}).bind(); +Object.defineProperty(bound, "prototype", { + get: function() { + throw new Test262Error("`superclass.prototype` is unreachable"); + }, +}); + +assert.throws(TypeError, function() { + class C extends bound {} +}); + +var proxy = new Proxy(async function() {}, { + get: function() { + throw new Test262Error("`superclass.prototype` is unreachable"); + }, +}); + +assert.throws(TypeError, function() { + class C extends proxy {} +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass/superclass-async-generator-function.js b/js/src/tests/test262/language/statements/class/subclass/superclass-async-generator-function.js new file mode 100644 index 0000000000..d77acb6c90 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass/superclass-async-generator-function.js @@ -0,0 +1,44 @@ +// Copyright (C) 2020 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-runtime-semantics-classdefinitionevaluation +description: > + IsConstructor check is performed before "prototype" lookup. + Async generator functions are not constructors (MakeConstructor is not called on them). +info: | + ClassDefinitionEvaluation + + [...] + 5. Else, + [...] + d. Let superclass be ? GetValue(superclassRef). + e. If superclass is null, then + [...] + f. Else if IsConstructor(superclass) is false, throw a TypeError exception. +features: [async-iteration, class, Proxy] +---*/ + +async function* fn() {} + +assert.throws(TypeError, function() { + class A extends fn {} +}); + +var bound = (async function* () {}).bind(); +Object.defineProperty(bound, "prototype", { + get: function() { + throw new Test262Error("`superclass.prototype` is unreachable"); + }, +}); + +assert.throws(TypeError, function() { + class C extends bound {} +}); + +var proxy = new Proxy(async function* () {}, {}); + +assert.throws(TypeError, function() { + class C extends proxy {} +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass/superclass-bound-function.js b/js/src/tests/test262/language/statements/class/subclass/superclass-bound-function.js new file mode 100644 index 0000000000..2f95cc1ccf --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass/superclass-bound-function.js @@ -0,0 +1,27 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-runtime-semantics-classdefinitionevaluation +description: SuperClass may be a bound function object +info: | + ClassDefinitionEvaluation + + [...] + 5. Else, + [...] + f. Else if IsConstructor(superclass) is false, throw a TypeError exception. + g. Else, + i. Let protoParent be ? Get(superclass, "prototype"). + ii. If Type(protoParent) is neither Object nor Null, throw a TypeError exception. + iii. Let constructorParent be superclass. +features: [class] +---*/ + +var bound = function() {}.bind(); +bound.prototype = {}; + +class C extends bound {} + +assert.sameValue(Object.getPrototypeOf(new C()), C.prototype); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass/superclass-generator-function.js b/js/src/tests/test262/language/statements/class/subclass/superclass-generator-function.js new file mode 100644 index 0000000000..c49a6be82a --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass/superclass-generator-function.js @@ -0,0 +1,44 @@ +// Copyright (C) 2014 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-runtime-semantics-classdefinitionevaluation +description: > + IsConstructor check is performed before "prototype" lookup. + Generator functions are not constructors (MakeConstructor is not called on them). +info: | + ClassDefinitionEvaluation + + [...] + 5. Else, + [...] + d. Let superclass be ? GetValue(superclassRef). + e. If superclass is null, then + [...] + f. Else if IsConstructor(superclass) is false, throw a TypeError exception. +features: [generators, class, Proxy] +---*/ + +function* fn() {} + +assert.throws(TypeError, function() { + class A extends fn {} +}); + +var bound = (function* () {}).bind(); +Object.defineProperty(bound, "prototype", { + get: function() { + throw new Test262Error("`superclass.prototype` is unreachable"); + }, +}); + +assert.throws(TypeError, function() { + class C extends bound {} +}); + +var proxy = new Proxy(function* () {}, {}); + +assert.throws(TypeError, function() { + class C extends proxy {} +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass/superclass-prototype-setter-constructor.js b/js/src/tests/test262/language/statements/class/subclass/superclass-prototype-setter-constructor.js new file mode 100644 index 0000000000..04f3f34ced --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass/superclass-prototype-setter-constructor.js @@ -0,0 +1,20 @@ +// Copyright (C) 2014 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.5 +description: > + superclass setter "constructor" override +---*/ +function Base() {} + +Base.prototype = { + set constructor(_) { + throw new Test262Error("`Base.prototype.constructor` is unreachable."); + } +}; + +class C extends Base {} + +new C(); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass/superclass-prototype-setter-method-override.js b/js/src/tests/test262/language/statements/class/subclass/superclass-prototype-setter-method-override.js new file mode 100644 index 0000000000..f137ad2140 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass/superclass-prototype-setter-method-override.js @@ -0,0 +1,24 @@ +// Copyright (C) 2014 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.5 +description: > + superclass prototype override +---*/ +function Base() {} + +Base.prototype = { + set m(_) { + throw new Test262Error("`Base.prototype.m` is unreachable."); + } +}; + +class C extends Base { + m() { + return 1; + } +} + +assert.sameValue(new C().m(), 1, "`new C().m()` returns `1`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/subclass/superclass-static-method-override.js b/js/src/tests/test262/language/statements/class/subclass/superclass-static-method-override.js new file mode 100644 index 0000000000..bd3d17d807 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass/superclass-static-method-override.js @@ -0,0 +1,23 @@ +// Copyright (C) 2014 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.5 +description: > + Static method override +---*/ +function Base() {} +Object.defineProperty(Base, 'staticM', { + set: function() { + throw new Test262Error("`Base.staticM` is unreachable."); + } +}); + +class C extends Base { + static staticM() { + return 1; + } +} + +assert.sameValue(C.staticM(), 1, "`C.staticM()` returns `1`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/super/browser.js b/js/src/tests/test262/language/statements/class/super/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/super/in-constructor-superproperty-evaluation.js b/js/src/tests/test262/language/statements/class/super/in-constructor-superproperty-evaluation.js new file mode 100644 index 0000000000..43ef9d6bc2 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/super/in-constructor-superproperty-evaluation.js @@ -0,0 +1,19 @@ +// Copyright (C) 2018 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-makesuperpropertyreference +description: > + SuperProperty evaluation order: super() thisBinding initialization must occur first. +---*/ +class Derived extends Object { + constructor() { + super[super()]; + throw new Test262Error(); + } +} + +assert.throws(ReferenceError, function() { + new Derived(); +}, '`super[super()]` via `new Derived()` throws a ReferenceError'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/super/in-constructor.js b/js/src/tests/test262/language/statements/class/super/in-constructor.js new file mode 100644 index 0000000000..e635c94ed4 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/super/in-constructor.js @@ -0,0 +1,23 @@ +// Copyright (C) 2014 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-makesuperpropertyreference +description: > + class super in constructor +---*/ +var calls = 0; +class B {} +B.prototype.x = 42; + +class C extends B { + constructor() { + super(); + calls++; + assert.sameValue(super.x, 42, "The value of `super.x` is `42`"); + } +} + +new C; +assert.sameValue(calls, 1, "The value of `calls` is `1`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/super/in-getter.js b/js/src/tests/test262/language/statements/class/super/in-getter.js new file mode 100644 index 0000000000..b8be37b2a3 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/super/in-getter.js @@ -0,0 +1,24 @@ +// Copyright (C) 2014 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-makesuperpropertyreference +description: > + class super in getter +---*/ +class B { + method() { + return 1; + } + get x() { + return 2; + } +} +class C extends B { + get y() { + assert.sameValue(super.x, 2, "The value of `super.x` is `2`"); + return super.method(); + } +} +assert.sameValue(new C().y, 1, "The value of `new C().y` is `1`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/super/in-methods.js b/js/src/tests/test262/language/statements/class/super/in-methods.js new file mode 100644 index 0000000000..90d2e08c66 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/super/in-methods.js @@ -0,0 +1,24 @@ +// Copyright (C) 2014 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-makesuperpropertyreference +description: > + class super in methods +---*/ +class B { + method() { + return 1; + } + get x() { + return 2; + } +} +class C extends B { + method() { + assert.sameValue(super.x, 2, "The value of `super.x` is `2`"); + return super.method(); + } +} +assert.sameValue(new C().method(), 1, "`new C().method()` returns `1`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/super/in-setter.js b/js/src/tests/test262/language/statements/class/super/in-setter.js new file mode 100644 index 0000000000..52cade7f64 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/super/in-setter.js @@ -0,0 +1,25 @@ +// Copyright (C) 2014 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-makesuperpropertyreference +description: > + class super in setter +---*/ +class B { + method() { + return 1; + } + get x() { + return 2; + } +} +class C extends B { + set y(v) { + assert.sameValue(v, 3, "The value of `v` is `3`"); + assert.sameValue(super.x, 2, "The value of `super.x` is `2`"); + assert.sameValue(super.method(), 1, "`super.method()` returns `1`"); + } +} +assert.sameValue(new C().y = 3, 3, "`new C().y = 3` is `3`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/super/in-static-getter.js b/js/src/tests/test262/language/statements/class/super/in-static-getter.js new file mode 100644 index 0000000000..edff783e68 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/super/in-static-getter.js @@ -0,0 +1,24 @@ +// Copyright (C) 2014 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-makesuperpropertyreference +description: > + class super in static getter +---*/ +class B { + static method() { + return 1; + } + static get x() { + return 2; + } +} +class C extends B { + static get x() { + assert.sameValue(super.x, 2, "The value of `super.x` is `2`"); + return super.method(); + } +} +assert.sameValue(C.x, 1, "The value of `C.x` is `1`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/super/in-static-methods.js b/js/src/tests/test262/language/statements/class/super/in-static-methods.js new file mode 100644 index 0000000000..1d6808e0a2 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/super/in-static-methods.js @@ -0,0 +1,24 @@ +// Copyright (C) 2014 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-makesuperpropertyreference +description: > + class super in static methods +---*/ +class B { + static method() { + return 1; + } + static get x() { + return 2; + } +} +class C extends B { + static method() { + assert.sameValue(super.x, 2, "The value of `super.x` is `2`"); + return super.method(); + } +} +assert.sameValue(C.method(), 1, "`C.method()` returns `1`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/super/in-static-setter.js b/js/src/tests/test262/language/statements/class/super/in-static-setter.js new file mode 100644 index 0000000000..e870d302a6 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/super/in-static-setter.js @@ -0,0 +1,25 @@ +// Copyright (C) 2014 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-makesuperpropertyreference +description: > + class super in static setter +---*/ +class B { + static method() { + return 1; + } + static get x() { + return 2; + } +} +class C extends B { + static set x(v) { + assert.sameValue(v, 3, "The value of `v` is `3`"); + assert.sameValue(super.x, 2, "The value of `super.x` is `2`"); + assert.sameValue(super.method(), 1, "`super.method()` returns `1`"); + } +} +assert.sameValue(C.x = 3, 3, "`C.x = 3` is `3`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/super/shell.js b/js/src/tests/test262/language/statements/class/super/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/syntax/browser.js b/js/src/tests/test262/language/statements/class/syntax/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/syntax/class-body-has-direct-super-class-heritage.js b/js/src/tests/test262/language/statements/class/syntax/class-body-has-direct-super-class-heritage.js new file mode 100644 index 0000000000..4c8a3a1499 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/syntax/class-body-has-direct-super-class-heritage.js @@ -0,0 +1,25 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.5.1 +description: > + The opposite of: + + ClassTail : ClassHeritageopt { ClassBody } + + It is a Syntax Error if ClassHeritage is not present and the following algorithm evaluates to true: + 1. Let constructor be ConstructorMethod of ClassBody. + 2. If constructor is empty, return false. + 3. Return HasDirectSuper of constructor. +---*/ +class A {} +class B extends A { + constructor() { + super(); + } +} + + +assert.sameValue(typeof B, "function"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/syntax/class-body-method-definition-super-property.js b/js/src/tests/test262/language/statements/class/syntax/class-body-method-definition-super-property.js new file mode 100644 index 0000000000..0d98925d67 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/syntax/class-body-method-definition-super-property.js @@ -0,0 +1,25 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.5.1 +description: > + No restrictions on SuperProperty +---*/ +class A { + constructor() { + super.toString(); + } + dontDoThis() { + super.makeBugs = 1; + } +} + + +assert.sameValue(typeof A, "function"); + +var a = new A(); + +a.dontDoThis(); +assert.sameValue(a.makeBugs, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/syntax/class-declaration-binding-identifier-class-element-list.js b/js/src/tests/test262/language/statements/class/syntax/class-declaration-binding-identifier-class-element-list.js new file mode 100644 index 0000000000..bebea48ef1 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/syntax/class-declaration-binding-identifier-class-element-list.js @@ -0,0 +1,37 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.5 +description: > + ClassDeclaration: + class BindingIdentifier ClassTail + + ClassTail: + ... { ClassBodyopt } + + ClassBody[Yield] : + ClassElementList[?Yield] + + + ClassElementList[Yield] : + ClassElement[?Yield] + ClassElementList[?Yield] ClassElement[?Yield] + + ClassElement[Yield] : + MethodDefinition[?Yield] + static MethodDefinition[?Yield] + ; + + +---*/ +class A { + method() {} + static method() {} + ; +} + +assert.sameValue(typeof A, "function"); +assert.sameValue(typeof A.prototype.method, "function"); +assert.sameValue(typeof A.method, "function"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/syntax/class-declaration-computed-method-definition.js b/js/src/tests/test262/language/statements/class/syntax/class-declaration-computed-method-definition.js new file mode 100644 index 0000000000..01baa0e028 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/syntax/class-declaration-computed-method-definition.js @@ -0,0 +1,32 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.5 +description: > + ClassDeclaration: + class BindingIdentifier ClassTail + + ClassTail: + ... { ClassBodyopt } + + ClassBody[Yield] : + ClassElementList[?Yield] + + + ClassElementList[Yield] : + ClassElement[?Yield] + ClassElementList[?Yield] ClassElement[?Yield] + + ClassElement[Yield] : + MethodDefinition[?Yield] + ... + +---*/ +class A { + [1]() {} +} + +assert.sameValue(typeof A, "function"); +assert.sameValue(typeof A.prototype[1], "function"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/syntax/class-declaration-computed-method-generator-definition.js b/js/src/tests/test262/language/statements/class/syntax/class-declaration-computed-method-generator-definition.js new file mode 100644 index 0000000000..1f209a0777 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/syntax/class-declaration-computed-method-generator-definition.js @@ -0,0 +1,32 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.5 +description: > + ClassDeclaration: + class BindingIdentifier ClassTail + + ClassTail: + ... { ClassBodyopt } + + ClassBody[Yield] : + ClassElementList[?Yield] + + + ClassElementList[Yield] : + ClassElement[?Yield] + ClassElementList[?Yield] ClassElement[?Yield] + + ClassElement[Yield] : + MethodDefinition[?Yield] + ... + +---*/ +class A { + *[1]() {} +} + +assert.sameValue(typeof A, "function"); +assert.sameValue(typeof A.prototype[1], "function"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/syntax/class-declaration-heritage-identifier-reference-class-element-list.js b/js/src/tests/test262/language/statements/class/syntax/class-declaration-heritage-identifier-reference-class-element-list.js new file mode 100644 index 0000000000..ddfca89cc9 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/syntax/class-declaration-heritage-identifier-reference-class-element-list.js @@ -0,0 +1,56 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.5 +description: > + ClassHeritage[Yield] : + extends LeftHandSideExpression[?Yield] + + LeftHandSideExpression : + NewExpression + ... + + NewExpression : + MemberExpression + ... + + MemberExpression : + PrimaryExpression + ... + + PrimaryExpression : + IdentifierReference + ... + + ClassDeclaration: + class BindingIdentifier ClassTail + + ClassTail: + ... { ClassBodyopt } + + ClassBody[Yield] : + ClassElementList[?Yield] + + + ClassElementList[Yield] : + ClassElement[?Yield] + ClassElementList[?Yield] ClassElement[?Yield] + + ClassElement[Yield] : + MethodDefinition[?Yield] + static MethodDefinition[?Yield] + ; + +---*/ +class A {} +class B extends A { + method() {} + static method() {} + ; +} + +assert.sameValue(typeof B, "function"); +assert.sameValue(typeof B.prototype.method, "function"); +assert.sameValue(typeof B.method, "function"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/syntax/class-expression-binding-identifier-opt-class-element-list.js b/js/src/tests/test262/language/statements/class/syntax/class-expression-binding-identifier-opt-class-element-list.js new file mode 100644 index 0000000000..a0822488c1 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/syntax/class-expression-binding-identifier-opt-class-element-list.js @@ -0,0 +1,41 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.5 +description: > + ClassExpression[Yield,GeneratorParameter] : + class BindingIdentifier[?Yield]opt ClassTail[?Yield,?GeneratorParameter] + + ClassDeclaration: + class BindingIdentifier ClassTail + + ClassTail: + ... { ClassBodyopt } + + ClassBody[Yield] : + ClassElementList[?Yield] + + + ClassElementList[Yield] : + ClassElement[?Yield] + ClassElementList[?Yield] ClassElement[?Yield] + + ClassElement[Yield] : + MethodDefinition[?Yield] + static MethodDefinition[?Yield] + ; + +---*/ +var A = class B { + method() {} + static method() {} + ; +} + +assert.sameValue(typeof A, "function"); +assert.sameValue(typeof A.prototype.method, "function"); +assert.sameValue(typeof A.method, "function"); + +assert.sameValue(typeof B, "undefined"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/syntax/class-expression-heritage-identifier-reference.js b/js/src/tests/test262/language/statements/class/syntax/class-expression-heritage-identifier-reference.js new file mode 100644 index 0000000000..56c9faaa93 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/syntax/class-expression-heritage-identifier-reference.js @@ -0,0 +1,18 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.5 +description: > + ClassExpression[Yield,GeneratorParameter] : + class BindingIdentifier[?Yield]opt ClassTail[?Yield,?GeneratorParameter] + + ClassTail[Yield,GeneratorParameter] : + [~GeneratorParameter] ClassHeritage[?Yield]opt { ClassBody[?Yield]opt } + [+GeneratorParameter] ClassHeritageopt { ClassBodyopt } +---*/ +class A {} +var B = class extends A {} + +assert.sameValue(typeof B, "function"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/syntax/class-expression.js b/js/src/tests/test262/language/statements/class/syntax/class-expression.js new file mode 100644 index 0000000000..eb3207be4d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/syntax/class-expression.js @@ -0,0 +1,12 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.5 +description: > + ClassExpression +---*/ +var A = class {} + +assert.sameValue(typeof A, "function"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/syntax/class-method-propname-constructor.js b/js/src/tests/test262/language/statements/class/syntax/class-method-propname-constructor.js new file mode 100644 index 0000000000..36688dd52e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/syntax/class-method-propname-constructor.js @@ -0,0 +1,19 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.5.1 +description: > + The opposite of: + + ClassBody : ClassElementList + + It is a Syntax Error if PrototypePropertyNameList of ClassElementList contains more than one occurrence of "constructor". +---*/ +class A { + constructor() {} +} + +assert.sameValue(typeof A, "function"); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/syntax/early-errors/browser.js b/js/src/tests/test262/language/statements/class/syntax/early-errors/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/syntax/early-errors/class-definition-evaluation-block-duplicate-binding.js b/js/src/tests/test262/language/statements/class/syntax/early-errors/class-definition-evaluation-block-duplicate-binding.js new file mode 100644 index 0000000000..2217ee010e --- /dev/null +++ b/js/src/tests/test262/language/statements/class/syntax/early-errors/class-definition-evaluation-block-duplicate-binding.js @@ -0,0 +1,19 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 13.1.1 +description: > + Block : { StatementList } + + It is a Syntax Error if the LexicallyDeclaredNames of StatementList contains any duplicate entries. +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); +{ + class A {} + class A {} +} diff --git a/js/src/tests/test262/language/statements/class/syntax/early-errors/class-definition-evaluation-scriptbody-duplicate-binding.js b/js/src/tests/test262/language/statements/class/syntax/early-errors/class-definition-evaluation-scriptbody-duplicate-binding.js new file mode 100644 index 0000000000..fa9fe2dbba --- /dev/null +++ b/js/src/tests/test262/language/statements/class/syntax/early-errors/class-definition-evaluation-scriptbody-duplicate-binding.js @@ -0,0 +1,17 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 15.1.1 +description: > + ScriptBody : StatementList + + It is a Syntax Error if the LexicallyDeclaredNames of StatementList contains any duplicate entries. +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); +class A {} +class A {} diff --git a/js/src/tests/test262/language/statements/class/syntax/early-errors/shell.js b/js/src/tests/test262/language/statements/class/syntax/early-errors/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/statements/class/syntax/escaped-static.js b/js/src/tests/test262/language/statements/class/syntax/escaped-static.js new file mode 100644 index 0000000000..8c22111e0d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/syntax/escaped-static.js @@ -0,0 +1,26 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-grammar-notation +description: > + The `static` contextual keyword must not contain Unicode escape sequences. +info: | + Terminal symbols are shown + in fixed width font, both in the productions of the grammars and throughout this + specification whenever the text directly refers to such a terminal symbol. These + are to appear in a script exactly as written. All terminal symbol code points + specified in this way are to be understood as the appropriate Unicode code points + from the Basic Latin range, as opposed to any similar-looking code points from + other Unicode ranges. +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +class C { + st\u0061tic m() {} +} diff --git a/js/src/tests/test262/language/statements/class/syntax/shell.js b/js/src/tests/test262/language/statements/class/syntax/shell.js new file mode 100644 index 0000000000..e69de29bb2 -- cgit v1.2.3